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

This example generates the surface figure "olimpic rings" that consists of toruses

//This example generates the surface figure "olimpic rings" that consists of toruses
#include <CoreAPI.h>
#define OUT_RADIUS 50
#define SEC_RADIUS 5
#define N 5
const coat::vec3 cpoints[N] = {coat::vec3(0,0,0),
coat::vec3(2*OUT_RADIUS+OUT_RADIUS/4,0,0),
coat::vec3(4*OUT_RADIUS+OUT_RADIUS/2,0,0),
coat::vec3(OUT_RADIUS+OUT_RADIUS/8,-OUT_RADIUS,0),
coat::vec3(3*OUT_RADIUS+3*OUT_RADIUS/8,-OUT_RADIUS,0)};
//@config: Debug
EXPORT
int main() {
// get to sculpt room
coat::ui::toRoom("Sculpt");
// add new volume
auto current = coat::Scene::sculptRoot().addChild("Olimpic rings");
auto volume = current.Volume();
// turn to surface
volume.toSurface();
float ringRadius = OUT_RADIUS;
float crossSectionRadius = SEC_RADIUS;
float rotate = 90;
coat::torus torus(ringRadius,crossSectionRadius);
// sets rings and slices
torus.rings(16).slices(64);
// get transform matrix
coat::mat4 matrix = torus.transform();
// add figures
for(int i = 0; i < N; i++) {
matrix.SetTranslation(cpoints[i]);
torus.transform(matrix).add(volume);
}
return 0;
}
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 torus.
Definition CorePrimAPI.h:480
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
comms::cMat4 mat4
4x4 float matrix, see the cMat4
Definition CoreAPI.h:59