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

This example generates the surface figure that consists of spiral

// This example generates the surface figure that consists of spiral
#include <CoreAPI.h>
//@config: Debug
class SpiralPrim:public BaseClass {
public:
SpiralPrim() {
Radius = 50;
ProfileRadius = 10;
Step = 40;
Turns = 8;
height = 10;
width = 10;
}
float Radius;
float ProfileRadius;
float Step;
float height;
float width;
int Turns;
coat::SpiralProfile ProfileType;
// this is class registration, look dialogs example
SERIALIZE() {
Enumerator* E = ENUM.Get("PROFILETYPE");
if (E->GetAmount() == 0) {
E->Add("circle");
E->Add("rectangle");
}
REG_DROPLIST(ProfileType,"ProfileType","PROFILETYPE");
FSLIDER(Radius, "%Radius", 10, 100, 20, false);
FSLIDER(Step, "%Step", 5, 40, 8, false);
SLIDER(Turns, "%Turns", 1, 10);
DELIMITER;
if (ProfileType == coat::SpiralProfile::RECTANGLE) {
FSLIDER(width, "%Profile Width", 5, 30, 10, false);
FSLIDER(height, "%Profile Height", 5, 30, 10, false);
} else {
FSLIDER(ProfileRadius, "%ProfileRadius", 2, 40, 20, false);
}
}
void build() {
auto current = coat::Scene::sculptRoot().addChild("Spiral"+coat::str::ToString(voxId));
auto volume = current.Volume();
volume.toSurface();
coat::spiral spiral;
spiral.radius(Radius)
.step(Step)
.turns(Turns)
.profile_type(ProfileType)
.profile_radius(ProfileRadius)
.profile_rect(width,height)
.details(0.5)
.add(volume);
}
};
EXPORT
int main() {
// get to sculpt room
coat::ui::toRoom("Sculpt");
SpiralPrim spiralPrim;
// load settings if exist
spiralPrim.ReadFromFile("data/Temp/spiral.json");
if(dlg.caption("spiral").ok().cancel().params(&spiralPrim).show() == 1) {// ok pressed, buttons start from 1
// save settings
spiralPrim.WriteToFile("data/Temp/spiral.json");
// build the figure
spiralPrim.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
the rich dialog. You may customize it, show your custom parameters and custom buttons.
Definition CoreAPI.h:3593
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...
dialog & caption(const char *id)
pass the caption of the dialog
prim & details(const float det_level)
set the detail level
void add(Volume &v)
add the prim into scene
The spiral.
Definition CorePrimAPI.h:1441
spiral & turns(const int nturns)
set the number of turns.
spiral & profile_rect(const float width, const float height)
set the dimensions for the rectangle profile.
spiral & radius(const float &r)
set the outer radius of the spiral.
spiral & profile_radius(const float &r)
set the profile radius.
spiral & profile_type(const SpiralProfile type)
set the type of profile (circle or rectangle).
spiral & step(const float &vstep)
set the spiral step.
static void toRoom(const char *name)
switch to the room
SpiralProfile
The profile type of the spiral.
Definition CorePrimAPI.h:1431
@ RECTANGLE
rectangle