3DCoat Core API
The 3DCoat API documentation.
Loading...
Searching...
No Matches
coat::sphere Class Reference

The sphere. More...

#include <CorePrimAPI.h>

Inheritance diagram for coat::sphere:
coat::prim coat::ellipse

Public Types

enum  DivisionMode { DIV_TRIANGLE = 0 , DIV_MERIDIAN = 1 , DIV_CUBE = 2 }
 division modes More...
 

Public Member Functions

 sphere ()
 constructs a new sphere object.
 
 sphere (float radius)
 constructs a new sphere object with radius.
 
 sphere (const vec3 &pos, float radius)
 constructs a new sphere object with position and radius.
 
sphereradius (const float &r)
 set the radius of the sphere.
 
float radius () const
 get the radius of the sphere.
 
spherediameter (const float &d)
 set the diameter of the sphere.
 
float diameter () const
 get the diameter of the sphere.
 
spheresub_division (const int subdiv)
 set the degree for subdivision in the mesh.
 
int sub_division () const
 get the degree of subdivision triangular or cubic division of the sphere.
 
spheresub_div_mode (const sphere::DivisionMode &divmode)
 set the division mode for the mesh.
 
sphere::DivisionMode sub_div_mode () const
 get the division mode for the mesh.
 
sphererings (const int &_rings)
 set the number of rings in the mesh.
 
int rings () const
 get the number of rings in the mesh.
 
sphereslices (const int &_slices)
 set the number of slices in the mesh.
 
int slices () const
 get the number of slices in the mesh.
 
spheresector_on (const bool &_switch)
 set the flag to create a portion of sphere.
 
bool sector_on () const
 get the flag of creating a portion of sphere. Default = false.
 
sphereslice_from (const float &angle)
 When sector is on, specifies the angle where the sphere slice begins.
 
float slice_from () const
 get the angle where the sphere slice begins.
 
sphereslice_to (const float &angle)
 When sector is on, specifies the angle where the sphere slice ends.
 
float slice_to () const
 get the angle where the sphere slice ends.
 
spherering_from (const float &angle)
 When sector is on, specifies the angle where the sphere ring begins.
 
float ring_from () const
 get the angle where the sphere ring begins.
 
spherering_to (const float &angle)
 When sector is on, specifies the angle where the sphere ring ends.
 
float ring_to () const
 get the angle where the sphere ring ends.
 
- Public Member Functions inherited from coat::prim
 prim ()
 constructs a new prim object.
 
str class_name ()
 get the primitive class name.
 
primname (const char *s)
 set the primitive object name.
 
str name () const
 get the primitive object name.
 
void add (Volume &v)
 add the prim into scene
 
void subtract (Volume &v)
 subtract the prim from scene
 
void intersect (Volume &v)
 intersect the prim into scene
 
void merge (Volume &v, const BoolOpType op)
 merge the prim into scene
 
Mesh mesh ()
 get the mesh prim
 
primcolor (DWORD CL)
 assign the color to the primitive (in voxels)
 
primcolor (float r, float g, float b, float a)
 assign the color to the primitive (in voxels)
 
primcolor (float r, float g, float b)
 assign the color to the primitive (in voxels)
 
primcolor (const char *colorid)
 assign the color to the primitive (in voxels)
 
primgloss (float value)
 assign the gloss for the voxel primitive, it will work only if the color already assigned
 
primroughness (float value)
 assign the roughness for the voxel primitive, it will work only if the color already assigned
 
primmetal (float value)
 the metalliclty value for the voxel primitive, it will work only if the color already assigned
 
primopacity (float value)
 assign the opacity of the color over the voxel primitive. The color should be assigned before you assign the opacity, for example p.color("red").opacity(0.5)
 
primdetails (const float det_level)
 set the detail level
 
float details ()
 get the detail level
 
primtransform (const mat4 &t)
 set the transform matrix
 
mat4 transform () const
 get the transform matrix
 
primscale (float scale)
 set the scale
 
primscale (const vec3 &v)
 set the scale
 
vec3 scale () const
 get the scale
 
primtranslate (const vec3 &_pos)
 Set the primitive translation.
 
vec3 translate () const
 get the primitive translation
 
primtranslate (float x, float y, float z)
 Set the primitive translation.
 
primx (float x)
 shift the primitive along the x - axis
 
primy (float y)
 shift the primitive along the y - axis
 
primz (float z)
 shift the primitive along the z - axis
 
primauto_divide (float average_div)
 set the auto devide
 
primstep_divide (float step)
 set the step devide
 
primfillet (float radius)
 set the fillet
 
template<typename T >
T & Obj ()
 Get the primitive object reference.
 
template<typename T >
bool isAs ()
 Check the prim's type.
 
virtual float fillet_relative ()
 calculates a fillet relative value (0..1).
 

Protected Member Functions

virtual cMeshContainer * create_mesh ()
 creates a mesh container for the sphere.
 
virtual void density_subdiv (int &slices, int &rings)
 calculates the density-based subdivisions.
 
- Protected Member Functions inherited from coat::prim
template<class T >
T & to_cast_this ()
 cast this prim to the obj type T
 
void merge_debug (Volume &vol, Mesh &mesh)
 merge the mesh debug into scene
 

Friends

class ellipse
 

Additional Inherited Members

- Static Public Member Functions inherited from coat::prim
static void debug_on (bool isOn=true)
 indicates whether to turn on or off the debug mode.
 
static void debug_clear ()
 clear the debug info for primitive operations
 
static void push_transform (const mat4 &t)
 set the global transform matrix to all primitives
 
static void push_translate (const vec3 &d)
 Set the translation to all primitives.
 
static void push_scale (float scale)
 Set the scale to all primitives.
 
static void push_scale (const vec3 &s)
 Set the scale to all primitives.
 
static void push_details (float details_modulator)
 set the detail level to all primitives
 
static void reset_transform ()
 reset the global transform matrix
 
- Protected Attributes inherited from coat::prim
prim_this
 

Detailed Description

Member Enumeration Documentation

◆ DivisionMode

division modes

Enumerator
DIV_TRIANGLE 

triangle mode

DIV_MERIDIAN 

meridian mode

DIV_CUBE 

cube projection mode

Constructor & Destructor Documentation

◆ sphere() [1/2]

coat::sphere::sphere ( float radius)

constructs a new sphere object with radius.

Parameters
radiussphere radius

◆ sphere() [2/2]

coat::sphere::sphere ( const vec3 & pos,
float radius )

constructs a new sphere object with position and radius.

Parameters
possphere position
radiussphere radius

Member Function Documentation

◆ create_mesh()

virtual cMeshContainer * coat::sphere::create_mesh ( )
protectedvirtual

creates a mesh container for the sphere.

Returns
mesh pointer

Reimplemented from coat::prim.

Reimplemented in coat::ellipse.

◆ density_subdiv()

virtual void coat::sphere::density_subdiv ( int & slices,
int & rings )
protectedvirtual

calculates the density-based subdivisions.

Parameters
slicesthe number of subdivisions around the Z axis
ringsthe number of subdivisions along the Z axis

Reimplemented in coat::ellipse.

◆ diameter() [1/2]

float coat::sphere::diameter ( ) const

get the diameter of the sphere.

Returns
diameter value

◆ diameter() [2/2]

sphere & coat::sphere::diameter ( const float & d)

set the diameter of the sphere.

Parameters
ddiameter.
Returns
sphere reference
Examples
DoorStop.cpp, csg_surface.cpp, csg_voxels.cpp, and cup.cpp.

◆ radius() [1/2]

float coat::sphere::radius ( ) const

get the radius of the sphere.

Returns
radius value

◆ radius() [2/2]

sphere & coat::sphere::radius ( const float & r)

set the radius of the sphere.

Parameters
rradius.
Returns
sphere reference
Examples
spheres.cpp.

◆ ring_from() [1/2]

float coat::sphere::ring_from ( ) const

get the angle where the sphere ring begins.

Returns
the ring begin angle

◆ ring_from() [2/2]

sphere & coat::sphere::ring_from ( const float & angle)

When sector is on, specifies the angle where the sphere ring begins.

Parameters
anglethe angle for sphere ring begin
Returns
sphere reference
Examples
DoorStop.cpp.

◆ ring_to() [1/2]

float coat::sphere::ring_to ( ) const

get the angle where the sphere ring ends.

Returns
the ring end angle

◆ ring_to() [2/2]

sphere & coat::sphere::ring_to ( const float & angle)

When sector is on, specifies the angle where the sphere ring ends.

Parameters
anglethe angle for sphere ring end
Returns
sphere reference
Examples
DoorStop.cpp.

◆ rings() [1/2]

int coat::sphere::rings ( ) const

get the number of rings in the mesh.

Returns
number of rings

◆ rings() [2/2]

sphere & coat::sphere::rings ( const int & _rings)

set the number of rings in the mesh.

Parameters
_ringsnumber of rings.
Returns
sphere reference
Examples
ellipses.cpp, and spheres.cpp.

◆ sector_on() [1/2]

bool coat::sphere::sector_on ( ) const

get the flag of creating a portion of sphere. Default = false.

Returns
the sector switch

◆ sector_on() [2/2]

sphere & coat::sphere::sector_on ( const bool & _switch)

set the flag to create a portion of sphere.

Parameters
_switchthe boolean true/false value
Returns
sphere reference
Examples
DoorStop.cpp.

◆ slice_from() [1/2]

float coat::sphere::slice_from ( ) const

get the angle where the sphere slice begins.

Returns
the slice begin angle

◆ slice_from() [2/2]

sphere & coat::sphere::slice_from ( const float & angle)

When sector is on, specifies the angle where the sphere slice begins.

Parameters
anglethe angle for sphere slice begin
Returns
sphere reference
Examples
DoorStop.cpp.

◆ slice_to() [1/2]

float coat::sphere::slice_to ( ) const

get the angle where the sphere slice ends.

Returns
the slice end angle

◆ slice_to() [2/2]

sphere & coat::sphere::slice_to ( const float & angle)

When sector is on, specifies the angle where the sphere slice ends.

Parameters
anglethe angle for sphere slice end
Returns
sphere reference
Examples
DoorStop.cpp.

◆ slices() [1/2]

int coat::sphere::slices ( ) const

get the number of slices in the mesh.

Returns
number of slices

◆ slices() [2/2]

sphere & coat::sphere::slices ( const int & _slices)

set the number of slices in the mesh.

Parameters
_slicesnumber of slices.
Returns
sphere reference
Examples
ellipses.cpp, and spheres.cpp.

◆ sub_div_mode() [1/2]

sphere::DivisionMode coat::sphere::sub_div_mode ( ) const

get the division mode for the mesh.

Returns
mode of the mesh division

◆ sub_div_mode() [2/2]

sphere & coat::sphere::sub_div_mode ( const sphere::DivisionMode & divmode)

set the division mode for the mesh.

Parameters
divmodemode of the mesh division.
Returns
sphere reference
Examples
ellipses.cpp, and spheres.cpp.

◆ sub_division() [1/2]

int coat::sphere::sub_division ( ) const

get the degree of subdivision triangular or cubic division of the sphere.

Returns
subdivision degree.

◆ sub_division() [2/2]

sphere & coat::sphere::sub_division ( const int subdiv)

set the degree for subdivision in the mesh.

Parameters
subdivsubdivision.
Returns
sphere reference
Examples
ellipses.cpp, and spheres.cpp.

The documentation for this class was generated from the following file: