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

This example generates the surface figure door stop that consists of half-sphere and cylinders

// This example generates the surface figure door stop that consists of half-sphere and cylinders
#include <CoreAPI.h>
using namespace coat;
EXPORT
int main() {
ui::toRoom("Sculpt");
auto scene = Scene::sculptRoot().addChild("Door Stop");
auto volume = scene.Volume();
// turn to surface
volume.toSurface();
mat4 matrix = mat4::Identity;
float _diameter = 200; // half sphere diameter
float _baseheight = 10; // base thickness
float _thickness = 16; // rubber thickness
float _drill = 40; // drill circle diameter
// half sphere
sphere().diameter(_diameter)
.sector_on(true)
.slice_to(180)
.ring_from(90)
.ring_to(0)
.details(0.15)
.add(volume);
// bottom cylinder
cylinder().diameter(_diameter)
.height(_baseheight)
.y(-(_baseheight+0.1))
.fillet(1)
.details(0.2)
.add(volume);
// rubber figure consists of cylinder with sector = 180 degree
matrix *= mat4::RotationX(-90);
.height(_thickness)
.fillet(2)
.transform(matrix)
.z(_thickness)
.details(0.2)
.add(volume);
// drill the circle by the cone
cone().diameter(_drill)
.height(60)
.transform(mat4::RotationX(-180))
.z(_diameter/4)
.y(20)
.details(0.5)
.subtract(volume);
return 0;
};
The cone.
Definition CorePrimAPI.h:1106
cone & diameter(const float &d)
set the value of diameter.
The cylinder.
Definition CorePrimAPI.h:876
cylinder & height(const float &_height)
set the height in the z-axis.
cylinder & diameter(const float &d)
set the diameter.
cylinder & radius(const float &r)
set the radius.
cylinder & sectorAngle(const float &angle)
set the angle for cylinder with sector.
prim & details(const float det_level)
set the detail level
void subtract(Volume &v)
subtract the prim from scene
prim & y(float y)
shift the primitive along the y - axis
prim & fillet(float radius)
set the fillet
prim & z(float z)
shift the primitive along the z - axis
void add(Volume &v)
add the prim into scene
prim & transform(const mat4 &t)
set the transform matrix
The sphere.
Definition CorePrimAPI.h:620
sphere & ring_to(const float &angle)
When sector is on, specifies the angle where the sphere ring ends.
sphere & slice_to(const float &angle)
When sector is on, specifies the angle where the sphere slice ends.
sphere & slice_from(const float &angle)
When sector is on, specifies the angle where the sphere slice begins.
sphere & sector_on(const bool &_switch)
set the flag to create a portion of sphere.
sphere & diameter(const float &d)
set the diameter of the sphere.
sphere & ring_from(const float &angle)
When sector is on, specifies the angle where the sphere ring begins.
The coat namespace used for most 3DCoat API calls except low-level internal structures.
Definition CoreAPI.h:43
comms::cMat4 mat4
4x4 float matrix, see the cMat4
Definition CoreAPI.h:59