3DCoat Core API
The 3DCoat API documentation.
Loading...
Searching...
No Matches
HoneyComb.cpp

This example generates the surface figure that consists of honey combs (ngons)

// This example generates the surface figure that consists of honey combs (ngons)
#include <CoreAPI.h>
//@config: Debug
class HoneyComb:public BaseClass {
public:
HoneyComb() {
Radius = 80;
Height = 20;
Fillet = 1;
Size = 1;
}
float Radius;
float Height;
float Fillet;
int Size;
// this is class registration, look dialogs example
SERIALIZE() {
FSLIDER(Radius, "%Radius", 20, 100, 50, false);
FSLIDER(Height, "%Height", 5, 20, 10, false);
FSLIDER(Fillet, "%Fillet", 1, 5, 1, false);
SLIDER(Size, "Size", 1, 10);
}
void build() {
auto current = coat::Scene::sculptRoot().addChild("Honey comb");
auto volume = current.Volume();
float dx=Radius;
float dy=Radius*sqrt(3.0);
volume.toSurface();
ng.height(Height).radiusTop(Radius).radiusBottom(Radius).Obj<coat::ngon>().relativeHoleRadius(0).fillet(Fillet).details(0.2);
for(int i=0;i<Size;i++)
for(int j=i;j<Size;j++)
ng.translate(coat::vec3( (dx+dx/2)*i, 0, dy*i/2 + dy*(Size-1-j))).add(volume);
}
};
EXPORT
int main() {
// get to sculpt room
coat::ui::toRoom("Sculpt");
HoneyComb combs;
// load settings if exist
combs.ReadFromFile("data/Temp/HoneyComb.json");
if(dlg.ok().cancel().params(&combs).show() == 1) {// ok pressed, buttons start from 1
// save settings
combs.WriteToFile("data/Temp/HoneyComb.json");
// build the figure
combs.build();
};
return 0;
}
Use this class for build a class for UI or serialization. see class_reg.h for details about the class...
Definition BaseClass.h:91
SceneElement addChild(const char *name) const
add the child element of the same nature
static SceneElement sculptRoot()
get the root of all sculpt objects
cylinder & radiusBottom(const float &r)
set the bottom radius.
cylinder & height(const float &_height)
set the height in the z-axis.
cylinder & radiusTop(const float &r)
set the top radius.
the rich dialog. You may customize it, show your custom parameters and custom buttons.
Definition CoreAPI.h:3821
dialog & params(BaseClass *params)
The important core feature. BaseClass allows to create the custom controls in the dialog....
dialog & ok()
add Ok button
dialog & cancel()
add Cancel button
int show()
Show the dialog. This is usually the last command in the chain.
The ngon.
Definition CorePrimAPI.h:1347
prim & details(const float det_level)
set the detail level
prim & fillet(float radius)
set the fillet
prim & translate(const vec3 &_pos)
Set the primitive translation.
T & Obj()
Get the primitive object reference.
Definition CorePrimAPI.h:264
static void toRoom(const char *name, bool Force=false)
switch to the room
comms::cVec3 vec3
3D - float vector, see the cVec3
Definition CoreAPI.h:50