3DCoat Core API
The 3DCoat API documentation.
|
The class allows to operate over voxels/surface on the relatively low-level. More...
#include <CoreAPI.h>
Public Member Functions | |
Volume (VoxTreeBranch *tb) | |
Volume (VolumeObject *vo) | |
Volume (const Volume &vol) | |
bool | valid () const |
checks if object is valid | |
bool | isSurface () const |
Check if in surface mode. | |
bool | isVoxelized () const |
Check if in voxel mode. | |
void | toSurface () |
turn to surface mode, the triangles will be tangentially relaxed | |
void | toVoxels () |
turn to voxels, auto-voxelize | |
void | mergeMesh (Mesh &mesh, const mat4 &transform=mat4::Identity, BoolOpType op=BOOL_MERGE) |
merge the mesh into scene | |
void | insertMesh (Mesh &mesh, const mat4 &transform=mat4::Identity) |
insert the mesh into the volume, in case of voxels this is identical to addMesh, in case of surface, mesh will be inserted without booleans | |
void | addMesh (Mesh &mesh, const mat4 &transform=mat4::Identity) |
add the mesh to volume (boolean) | |
void | subtractMesh (Mesh &mesh, const mat4 &transform=mat4::Identity) |
subtract the mesh from volume (boolean) | |
void | intersectWithMesh (Mesh &mesh, const mat4 &transform=mat4::Identity) |
intersect the volume with the mesh (boolean) | |
void | mergeMeshWithTexture (Mesh &mesh, const mat4 &transform=mat4::Identity, BoolOpType op=BOOL_MERGE) |
merge the mesh with facture, the volume polygons will be hidden, just the texture will be shown (like leafs in TreesGenerator) | |
Volume & | makeVoxelFigure (std::function< float(vec3)> densityFunction, const list< vec3 > &growCenters, bool Subtract=false, bool useTempLocation=false, bool overHidden=false, bool useColor=false) |
This function is fast (generally realtime) way to fill the volume with voxels. Voxel Brush Engune completely based on this routine. | |
float | getExactDencity (int x, int y, int z, bool fromBackup, VolumeCache &cache_ref) |
returns the exact voxel density in local space at the exact integer location | |
float | getInterpolatedValue (const vec3 &pos, bool fromBackup) |
returns interolated voxels density | |
void | scanCells (const std::function< void(VolumeCell *vc)> &fn, bool multithreaded=false) |
run through all volume cells | |
void | scanCells (const std::function< void(VolumeCellAttrib *vc)> &fn, bool multithreaded=false) |
run through all volume cells | |
void | scanCells (const std::function< void(VolumeCellAttrib *vc, const tri_DWORD &T)> &fn, bool multithreaded=false) |
run through all volume cells | |
void | scanCells (const std::function< void(VolumeCell *vc, const tri_DWORD &T)> &fn, bool multithreaded=false) |
run through all volume cells | |
void | scanTriangles (const std::function< void(const MCVertex &v1, const MCVertex &v2, const MCVertex &v3)> &fn, bool multithreaded=false) |
run through all triangles | |
void | scanTriangles (const std::function< void(const Vector3D &v1, const Vector3D &v2, const Vector3D &v3)> &fn, bool multithreaded=false) |
run through all triangles | |
int | getPolycount () |
get the volume triangles count | |
float | getVolume () |
get the volume of this object in world coordinates | |
float | getSquare () |
reg the square of this object in world coordinates | |
boundbox | calcLocalSpaceAABB () |
Calculate the Axis - Aligned Bound Box of the object in local space. | |
boundbox | calcWorldSpaceAABB () |
Calculate the Axis - Aligned Bound Box of the object in world space. | |
VoxTreeBranch * | tree () |
returns the low-level object (VoxTreeBranch) for all low-level operations | |
VolumeObject * | vo () |
returns the low-level object (VolumeObject) for all low-level operations | |
VolumeCell * | cell (int cx, int cy, int cz, bool create, bool backup) |
get the cell by cell coordinates, each cell is 8*8*8 | |
VolumeCellAttrib * | attributes (int cx, int cy, int cz, bool create, bool backup) |
get the cell attributes by cell coordinates, each cell is 8*8*8, generally it is kept as VolumeCell::Attr | |
void | dirty (int cx, int cy, int cz) |
mark the cell as dirty. This is required if you | |
void | setOpacity (float Opacity) |
set the volume opacity | |
void | relaxGpu (const vec3 ¢er, float Radius, float degree) |
fast voxel-based relax within the sphere with the gradual falloff. It works only in voxel mode. | |
void | relaxVoxels (int count) |
relax the whole volume, works only for voxels | |
void | relaxSurface (float degree, bool tangent=false, bool keep_sharp_boolean_edges=false) |
relax the object in surface mode | |
void | relaxOpenEdges (int nTimes) |
relax the open edges of the mesh, it is applicable only to the surface mode | |
SceneElement | inScene () |
Get the Volume placement in the scene. | |
void | clear () |
Clear and pass to the Undo queue. | |
void | clearNoUndo () |
Clear quickly, without affecting the Undo queue. | |
void | assignShader (const char *shaderName) |
set the shader for the Volume | |
void | setBoolShaderProperty (const char *property, bool value) |
void | setFloatShaderProperty (const char *property, float value) |
void | setColorShaderProperty (const char *property, DWORD value) |
void | removeFacesByWeight (std::function< float(const vec3 &)> weight) |
Remove all faces where all the function returns the value < 0 for all the vertices over the face. | |
void | closeHoles (int maxSize) |
Close the holes. | |
void | removeUndercuts () |
remove undercuts for the current volume | |
void | basRelief (const vec3 &start_point=vec3::Zero) |
perform the bas-relief for the current volume | |
void | generateMoldingCurves () |
generate the automatic molding curves | |
void | automaticMolding () |
perform the automatic molding | |
void | curveBasedMolding () |
perform the curve-based mold | |
void | subtractWithoutUndecuts () |
subtract the current undercutted object from the preliminary generated molding shapes | |
SceneElement | generateMoldingTest () |
generate the figure that fills the gap between the molding shapes | |
SceneElement | findMoldingTop () |
find the top molding shape (that was previously generated) | |
SceneElement | findMoldingBottom () |
find the bottom molding shape (that was previously generated) | |
SceneElement | findMoldingTest () |
find the test molding test shape (that was previously generated) | |
void | removeMoldingShapes () |
remove all molding intermediate shapes, tests, etc. | |
void | assignLiveBooleans (int operation) |
Apply the live booleans over the sculpt mesh, it is available for voxels only. | |
void | collapseBollTree () |
collapse the boolean tree, it is available for this volume | |
Static Public Member Functions | |
static void | enableVoxelsColoring (bool enable=true) |
enable or disable the voxel-based coloring. It is applied wherever possible - merging models, brushing, creating parametric voxel figures, etc | |
static void | color (DWORD CL) |
set the default color to fill voxels if the voxel coloring enabled | |
static void | color (float r, float g, float b, float a) |
assign the color for the voxel operations | |
static void | color (float r, float g, float b) |
assign the color for the voxel operations | |
static void | color (const char *colorid) |
assign the color for the voxel operations | |
static void | gloss (float value) |
assign the gloss for the voxel operations, it will work only if the color already assigned | |
static void | roughness (float value) |
assign the roughness for the voxel operations, it will work only if the color already assigned | |
static void | metal (float value) |
the metalliclty value for the voxel operations, it will work only if the color already assigned | |
static bool | checkIfMoldingLicenseAvailable () |
check if molding allowed | |
static void | setMoldingParams (const vec3 &direction, float tapering_angle=0, float undercuts_density=1.0f, float decimation_limit_millions=10, bool perform_subtraction=true) |
set the parameters for the molding | |
static void | setAutomaticMoldingBox () |
set the molding bound box to be automatic | |
static void | setMoldingBox (float width, float length, float thickness) |
set the molding bound box to be user-defined, not automatic | |
static void | setMoldingBorder (float width=0) |
set the molding border around the parting line to fade to the plane, if it is zero, the final shape will not fade to plane | |
Protected Attributes | |
VoxTreeBranch * | tb |
VolumeObject * | Obj |
Friends | |
class | SceneElement |
The class allows to operate over voxels/surface on the relatively low-level.
add the mesh to volume (boolean)
mesh | the mesh reference |
transform | the transform applied |
void coat::Volume::assignLiveBooleans | ( | int | operation | ) |
Apply the live booleans over the sculpt mesh, it is available for voxels only.
operation | 0 - stop live booleans, 1 - subtract from the parent, 2 - intersect, 3 - union |
void coat::Volume::assignShader | ( | const char * | shaderName | ) |
set the shader for the Volume
shaderName | the shader name as it is shown in the shader's hint |
VolumeCellAttrib * coat::Volume::attributes | ( | int | cx, |
int | cy, | ||
int | cz, | ||
bool | create, | ||
bool | backup ) |
get the cell attributes by cell coordinates, each cell is 8*8*8, generally it is kept as VolumeCell::Attr
cx | cell x |
cy | cell y |
cz | cell z |
create | pass true if you want to create the cell if it does not exist |
backup | drop the cell to backup (if not already dropped) |
void coat::Volume::basRelief | ( | const vec3 & | start_point = vec3::Zero | ) |
perform the bas-relief for the current volume
start_point | the cut point |
boundbox coat::Volume::calcLocalSpaceAABB | ( | ) |
Calculate the Axis - Aligned Bound Box of the object in local space.
boundbox coat::Volume::calcWorldSpaceAABB | ( | ) |
Calculate the Axis - Aligned Bound Box of the object in world space.
VolumeCell * coat::Volume::cell | ( | int | cx, |
int | cy, | ||
int | cz, | ||
bool | create, | ||
bool | backup ) |
get the cell by cell coordinates, each cell is 8*8*8
cx | cell x |
cy | cell y |
cz | cell z |
create | pass true if you want to create the cell if it does not exist |
backup | drop the cell to backup (if not already dropped) |
|
static |
check if molding allowed
void coat::Volume::closeHoles | ( | int | maxSize | ) |
Close the holes.
maxSize | max hole size (edges over the primeter) |
|
static |
assign the color for the voxel operations
colorid | the color in any suitable form: "RGB", "ARGB", "RRGGBB", "AARRGGBB", "#RGB", "#ARGB", "#RRGGBB", "#AARRGGBB", any web-color common name as "red", "green", "purple", google "webcolors" |
|
static |
assign the color for the voxel operations
r | red value 0..255 |
g | green value 0..255 |
b | blue value 0..255 |
|
static |
assign the color for the voxel operations
r | red value 0..255 |
g | green value 0..255 |
b | blue value 0..255 |
a | alpha value 0..255 |
void coat::Volume::dirty | ( | int | cx, |
int | cy, | ||
int | cz ) |
mark the cell as dirty. This is required if you
cx | |
cy | |
cz |
|
static |
enable or disable the voxel-based coloring. It is applied wherever possible - merging models, brushing, creating parametric voxel figures, etc
enable | true to enable |
SceneElement coat::Volume::findMoldingBottom | ( | ) |
find the bottom molding shape (that was previously generated)
SceneElement coat::Volume::findMoldingTest | ( | ) |
find the test molding test shape (that was previously generated)
SceneElement coat::Volume::findMoldingTop | ( | ) |
find the top molding shape (that was previously generated)
SceneElement coat::Volume::generateMoldingTest | ( | ) |
generate the figure that fills the gap between the molding shapes
float coat::Volume::getExactDencity | ( | int | x, |
int | y, | ||
int | z, | ||
bool | fromBackup, | ||
VolumeCache & | cache_ref ) |
returns the exact voxel density in local space at the exact integer location
x | X-coordinate |
y | Y-coordinate (up) |
z | Z-coordinate |
fromBackup | take the values from the backup (kept before the modifications started) |
cache_ref | define the variable coat::VolumeCache and pass there (in same thread) to speed up access; |
float coat::Volume::getInterpolatedValue | ( | const vec3 & | pos, |
bool | fromBackup ) |
returns interolated voxels density
pos | position in local space |
fromBackup | take from the backup |
int coat::Volume::getPolycount | ( | ) |
get the volume triangles count
float coat::Volume::getSquare | ( | ) |
reg the square of this object in world coordinates
float coat::Volume::getVolume | ( | ) |
get the volume of this object in world coordinates
|
static |
assign the gloss for the voxel operations, it will work only if the color already assigned
value | the [0..1] value of the gloss |
SceneElement coat::Volume::inScene | ( | ) |
Get the Volume placement in the scene.
insert the mesh into the volume, in case of voxels this is identical to addMesh, in case of surface, mesh will be inserted without booleans
mesh | the mesh reference |
transform | the transform applied |
intersect the volume with the mesh (boolean)
mesh | the mesh reference |
transform | the transform applied |
bool coat::Volume::isSurface | ( | ) | const |
Check if in surface mode.
bool coat::Volume::isVoxelized | ( | ) | const |
Check if in voxel mode.
Volume & coat::Volume::makeVoxelFigure | ( | std::function< float(vec3)> | densityFunction, |
const list< vec3 > & | growCenters, | ||
bool | Subtract = false, | ||
bool | useTempLocation = false, | ||
bool | overHidden = false, | ||
bool | useColor = false ) |
This function is fast (generally realtime) way to fill the volume with voxels. Voxel Brush Engune completely based on this routine.
densityFunction | the function should return the value 0..1, where 0 means empty, 1-filled, 0.5 means we are on the surface. Be careful, function should be limited in space. Coordinates passed in volume's local space. |
growCenters | the list of points where function is not zero - that are grow centers |
Subtract | true if you need to subtract, in this case you return value that will be subtracted from the volume |
useTempLocation | if true all your modifications will be applied after you will finish all chnages |
overHidden | if true the function will work as Hide tool (Subtract taken into account) |
useColor | if true the voxel color will be used |
void coat::Volume::mergeMesh | ( | Mesh & | mesh, |
const mat4 & | transform = mat4::Identity, | ||
BoolOpType | op = BOOL_MERGE ) |
merge the mesh into scene
mesh | the Mesh reference |
transform | the transform applied |
op | the type of the merge |
void coat::Volume::mergeMeshWithTexture | ( | Mesh & | mesh, |
const mat4 & | transform = mat4::Identity, | ||
BoolOpType | op = BOOL_MERGE ) |
merge the mesh with facture, the volume polygons will be hidden, just the texture will be shown (like leafs in TreesGenerator)
mesh | the mesh that refers texture |
transform | the transform applied |
op | the boolean operation |
|
static |
the metalliclty value for the voxel operations, it will work only if the color already assigned
value | the [0..1] metal value |
void coat::Volume::relaxGpu | ( | const vec3 & | center, |
float | Radius, | ||
float | degree ) |
fast voxel-based relax within the sphere with the gradual falloff. It works only in voxel mode.
center | the center of |
Radius | the radius of the influence |
degree | the relax degree, < 1 |
void coat::Volume::relaxOpenEdges | ( | int | nTimes | ) |
relax the open edges of the mesh, it is applicable only to the surface mode
nTimes | amount of iterations |
void coat::Volume::relaxSurface | ( | float | degree, |
bool | tangent = false, | ||
bool | keep_sharp_boolean_edges = false ) |
relax the object in surface mode
degree | the degree of smoothing, it may be >1 for the stronger relax |
tangent | use tangent relax |
keep_sharp_boolean_edges | keep the sharp edges appeared due to bolean operations |
void coat::Volume::relaxVoxels | ( | int | count | ) |
relax the whole volume, works only for voxels
count | the count of relax steps |
void coat::Volume::removeFacesByWeight | ( | std::function< float(const vec3 &)> | weight | ) |
Remove all faces where all the function returns the value < 0 for all the vertices over the face.
weight | the function, should return < 0 where you need to remove the whole face, > 0 where you need to keep the face. Coordinate is in global space. |
|
static |
assign the roughness for the voxel operations, it will work only if the color already assigned
value | the [0..1] value of the roughness |
void coat::Volume::scanCells | ( | const std::function< void(VolumeCell *vc)> & | fn, |
bool | multithreaded = false ) |
run through all volume cells
fn | callback/lambda, VolumeCell pointer passed there |
multithreaded | use multi-threading |
void coat::Volume::scanCells | ( | const std::function< void(VolumeCell *vc, const tri_DWORD &T)> & | fn, |
bool | multithreaded = false ) |
run through all volume cells
fn | callback/lambda, VolumeCell pointer and space placement passed there |
multithreaded | use multi-threading |
void coat::Volume::scanCells | ( | const std::function< void(VolumeCellAttrib *vc)> & | fn, |
bool | multithreaded = false ) |
run through all volume cells
fn | callback/lambda, VolumeCellAttrib pointer passed there |
multithreaded | use multi-threading |
void coat::Volume::scanCells | ( | const std::function< void(VolumeCellAttrib *vc, const tri_DWORD &T)> & | fn, |
bool | multithreaded = false ) |
run through all volume cells
fn | callback/lambda, VolumeCellAttrib pointer and space placement passed there |
multithreaded | use multi-threading |
void coat::Volume::scanTriangles | ( | const std::function< void(const MCVertex &v1, const MCVertex &v2, const MCVertex &v3)> & | fn, |
bool | multithreaded = false ) |
run through all triangles
fn | the callback/lambda |
multithreaded | use multi-threading |
void coat::Volume::scanTriangles | ( | const std::function< void(const Vector3D &v1, const Vector3D &v2, const Vector3D &v3)> & | fn, |
bool | multithreaded = false ) |
run through all triangles
fn | the callback/lambda |
multithreaded | use multi-threading |
|
static |
set the molding border around the parting line to fade to the plane, if it is zero, the final shape will not fade to plane
width | the width in mm or other default units |
|
static |
set the molding bound box to be user-defined, not automatic
width | the width of the box |
length | the length of the box |
thickness | the thickness of the box |
|
static |
set the parameters for the molding
direction | the molding direction |
tapering_angle | the tapering angle in degrees |
undercuts_density | the additional density for the undercuts |
decimation_limit_millions | decimate the final shape if it has triangles count more than this value |
perform_subtraction | set false if no need to subtract the molding from the molding shapes |
void coat::Volume::setOpacity | ( | float | Opacity | ) |
set the volume opacity
Opacity | the 0..1 opacity value |
subtract the mesh from volume (boolean)
mesh | the mesh reference |
transform | the transform applied |
VoxTreeBranch * coat::Volume::tree | ( | ) |
returns the low-level object (VoxTreeBranch) for all low-level operations
bool coat::Volume::valid | ( | ) | const |
checks if object is valid
VolumeObject * coat::Volume::vo | ( | ) |
returns the low-level object (VolumeObject) for all low-level operations