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

This example generates the surface figure that consists of gear

// This example generates the surface figure that consists of gear
#include <CoreAPI.h>
//@config: Debug
class GearPrim:public BaseClass {
public:
GearPrim() {
Radius = 50;
Depth = 0.1;
Sharpness = 0.5;
Height = 100;
Order = 16;
}
float Radius;
float Depth;
float Sharpness;
float Height;
int Order;
// this is class registration, look dialogs example
SERIALIZE() {
FSLIDER(Radius, "%Radius", 10, 100, 50, false);
FSLIDER(Depth, "%Depth", 0.1, 1, 0.1, false);
FSLIDER(Sharpness, "%Sharpness", 0.1, 1, 0.5, false);
FSLIDER(Height, "%Height", 20, 200.0, 100, false);
SLIDER(Order, "%Order", 8, 32, 16, false);
}
void build() {
auto current = coat::Scene::sculptRoot().addChild("Gear"+coat::str::ToString(voxId));
auto volume = current.Volume();
volume.toSurface();
coat::gear gear;
gear.height(Height)
.radiusTop(Radius)
.radiusBottom(Radius)
.depth(Depth)
.sharpness(Sharpness)
.order(Order)
.details(0.2)
.add(volume);
}
};
EXPORT
int main() {
// get to sculpt room
coat::ui::toRoom("Sculpt");
GearPrim gearPrim;
// load settings if exist
gearPrim.ReadFromFile("data/Temp/gear.json");
if(dlg.ok().cancel().params(&gearPrim).show() == 1) {// ok pressed, buttons start from 1
// save settings
gearPrim.WriteToFile("data/Temp/gear.json");
// build the figure
gearPrim.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
int childCount() const
returns the child elements count
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:3388
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()
pass the function/lambda that will be called when the button will be pressed. The button index (start...
The gear.
Definition CorePrimAPI.h:1262
gear & sharpness(const float &sharp)
set the sharpness value.
gear & order(const int &nteeth)
set the number of teeth in gear.
prim & details(const float det_level)
set the detail level
T & Obj()
Get the primitive object reference.
Definition CorePrimAPI.h:264
void add(Volume &v)
add the prim into scene
static void toRoom(const char *name)
switch to the room