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

This example generates the surface figure dumb-bell with usage of the debug mode

// This example generates the surface figure dumb-bell with usage of the debug mode
#include <CoreAPI.h>
//@config: Debug
using namespace coat;
EXPORT
int main() {
// get to sculpt room
ui::toRoom("Sculpt");
// add new volume
auto voxId = Scene::sculptRoot().childCount();
auto current = Scene::sculptRoot().addChild("Dumbbell" + str::ToString(voxId));
auto volume = current.Volume();
// debug mode is ON
prim::debug_on(true);
// turn to surface
volume.toSurface();
float _height = 80;
float _radius = 8;
float _rotate = 90;
float _fscale = 4;
float _detail = 0.5;
float _shift_R = _height/2 + _height/8;
float _shift_L = _height/2 - _height/8;
// matrix transform
mat4 matrix = mat4::Scaling(_fscale) * mat4::RotationZ(_rotate) * mat4::RotationX(_rotate);
//add the core figure
cylinder().height(_height)
.radius(_radius)
.transform(matrix)
.translate(vec3(_fscale*_height/2, 0, 0))
.details(_detail)
.name("core")
.add(volume);
//add the first disk
.height(_height/4)
.radius(_radius*3)
.fillet(2)
.transform(matrix)
.translate(vec3(_fscale*_shift_R, 0, 0))
.details(_detail)
.name("disk1")
.add(volume);
//add the second disk
.height(_height/4)
.radius(_radius*3)
.fillet(2)
.transform(matrix)
.translate(vec3(-_fscale*_shift_L, 0, 0))
.details(_detail)
.name("disk2")
.add(volume);
// make the text on the top disk
matrix = mat4::Scaling(_fscale) * mat4::RotationY(-_rotate);
text().font(coat::Font()).string("2 KG").width(2.5*_radius).depth(1)
.transform(matrix).translate(vec3(-_fscale*_shift_R, 0, 0))
.add(volume);
// debug mode is OFF
prim::debug_on(false);
return 0;
}
Definition CorePrimAPI.h:1643
The cylinder.
Definition CorePrimAPI.h:876
cylinder & height(const float &_height)
set the height in the z-axis.
cylinder & radius(const float &r)
set the radius.
The ngon.
Definition CorePrimAPI.h:1347
prim & details(const float det_level)
set the detail level
prim & name(const char *s)
set the primitive object name.
prim & fillet(float radius)
set the fillet
prim & translate(const vec3 &_pos)
Set the primitive translation.
void add(Volume &v)
add the prim into scene
prim & transform(const mat4 &t)
set the transform matrix
text primitive
Definition CorePrimAPI.h:1735
text & font(const Font &f)
set the text font
text & depth(const float &d)
set the text depth in the pixels
text & string(const char *s)
set the text's string.
text & width(const float &w)
set the text width in the pixels
tube & relativeHoleRadius(const float &r)
set the relative value of the hole radius.
The coat namespace used for most 3DCoat API calls except low-level internal structures.
Definition CoreAPI.h:43
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