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

This example generates the surface figure that consists of ellipses

// This example generates the surface figure that consists of ellipses
#include <CoreAPI.h>
//@config: Debug
class EllipsesPrim:public BaseClass {
public:
EllipsesPrim() {
Side = coat::vec3(100,40,100);
SubDivisions = 2;
Rings = 12;
Slices = 24;
}
int SubDivisions;
int Rings;
int Slices;
coat::vec3 Side;
// this is class registration, look dialogs example
SERIALIZE() {
Enumerator* E = ENUM.Get("DIVMODE");
if (E->GetAmount() == 0) {
E->Add("triangle");
E->Add("meridian");
E->Add("cube");
}
REG_DROPLIST(DivMode,"DivMode","DIVMODE");
UI_LAYOUT("1 1 1 []");
TEXTMSG2("*Size");
REG_AUTO(Side.x, "$sa");
REG_AUTO(Side.y, "$sb");
REG_AUTO(Side.z, "$sc");
SLIDER(Slices, "Slices", 8, 60);
SLIDER(Rings, "Rings", 6, 60);
}
else if (DivMode == coat::sphere::DivisionMode::DIV_CUBE) {
SLIDER(SubDivisions, "SubDivisions", 2, 20);
}
else {
SLIDER(SubDivisions,"SubDivisions", 1, 10);
}
}
void build() {
auto current = coat::Scene::sculptRoot().addChild("Ellipses"+coat::str::ToString(voxId));
auto volume = current.Volume();
volume.toSurface();
coat::ellipse ellipse;
//settings parameters to the ellipse primitive and add prim to the volume
ellipse.size(Side).sub_div_mode(DivMode).sub_division(SubDivisions).rings(Rings).slices(Slices).add(volume);
ellipse.size(Side/2).translate(coat::vec3(0,3*Side.y,0)).add(volume);
ellipse.size(Side/4).translate(coat::vec3(0,4.5*Side.y,0)).add(volume);
}
};
EXPORT
int main() {
// get to sculpt room
coat::ui::toRoom("Sculpt");
EllipsesPrim ellipses;
// load generator settings if exist
ellipses.ReadFromFile("data/Temp/EllipsesPrim.json");
if(dlg.ok().cancel().params(&ellipses).show() == 1) {// ok pressed, buttons start from 1
// save settings
ellipses.WriteToFile("data/Temp/EllipsesPrim.json");
// build the figure
ellipses.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:3811
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 ellipse.
Definition CorePrimAPI.h:797
ellipse & size(const vec3 &_size)
set the size of the ellipse.
prim & translate(const vec3 &_pos)
Set the primitive translation.
void add(Volume &v)
add the prim into scene
sphere & sub_division(const int subdiv)
set the degree for subdivision in the mesh.
DivisionMode
division modes
Definition CorePrimAPI.h:625
@ DIV_TRIANGLE
triangle mode
Definition CorePrimAPI.h:627
@ DIV_CUBE
cube projection mode
Definition CorePrimAPI.h:631
@ DIV_MERIDIAN
meridian mode
Definition CorePrimAPI.h:629
sphere & slices(const int &_slices)
set the number of slices in the mesh.
sphere & sub_div_mode(const sphere::DivisionMode &divmode)
set the division mode for the mesh.
sphere & rings(const int &_rings)
set the number of rings in the mesh.
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