About
A VoronoiFracture object represents a Voronoi Fracture MoGraph generator. The class provides safe access to the point sources referenced, owned and used by the generator. It is defined in the lib_voronoifracture.h
header file.
VoronoiFracture* const fractureObject = VoronoiFracture::Alloc();
if (fractureObject == nullptr)
doc->InsertObject(fractureObject,
nullptr,
nullptr);
BaseTag* const rigidBodyTag = BaseTag::Alloc(180000102);
if (rigidBodyTag == nullptr)
fractureObject->InsertTag(rigidBodyTag);
BaseObject*
const sphere = BaseObject::Alloc(
Osphere);
if (sphere == nullptr)
doc->InsertObject(sphere, fractureObject,
nullptr);
BaseObject*
const pointGenerator = fractureObject->AddPointGenerator(pointCreatorType,
NOTOK,
nullptr);
if (pointGenerator == nullptr)
NONE
Definition: asset_browser.h:1
#define NOTOK
Definition: ge_sys_math.h:258
#define MSG_MENUPREPARE
Allows tags, objects, shaders etc. to do some setup work when called from the menu....
Definition: c4d_baselist.h:417
#define Osphere
Sphere.
Definition: ge_prepass.h:1119
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:69
#define ConstDescID(...)
Definition: lib_description.h:592
maxon::Int32 Int32
Definition: ge_sys_math.h:51
@ ID_POINTCREATOR_CREATEDPOINTAMOUNT
Definition: opointcreator_panel.h:25
@ ID_POINTCREATOR_CREATORTYPE_DISTRIBUTION
Definition: opointcreator_panel.h:7
const char * doc
Definition: pyerrors.h:226
Access
A VoronoiFracture object can be accessed like any other object.
BaseObject*
const obj =
doc->GetActiveObject();
if (
obj !=
nullptr &&
obj->IsInstanceOf(1036557))
{
VoronoiFracture*
const voronoiFracture =
static_cast<VoronoiFracture*
>(
obj);
const Int32 srcCnt = voronoiFracture->GetSourcesCount();
const String srcCntStr = String::IntToString(srcCnt);
}
PyObject * obj
Definition: complexobject.h:60
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
Allocation/Deallocation
VoronoiFracture objects are created with the usual tools:
- VoronoiFracture::Alloc(): Creates a new VoronoiFracture object.
- VoronoiFracture::Free(): Deletes the given VoronoiFracture object.
BaseObject*
const activeObject =
doc->GetActiveObject();
if (activeObject == nullptr)
VoronoiFracture* const fracture = VoronoiFracture::Alloc();
if (fracture == nullptr)
doc->InsertObject(fracture,
nullptr,
nullptr);
activeObject->Remove();
doc->InsertObject(activeObject, fracture,
nullptr);
Parameters
The IDs of the standard parameters of a VoronoiFracture object are defined in the omograph_fracturevoronoi.h
header file.
- Note
- The list of point sources must only be edited through the dedicated functions of the VoronoiFracture class (see below).
Sources
Both scene objects and dedicated point generator objects can be used to define the position of Voronoi points inside the mesh volume. The following functions allow to add, remove and edit these point sources. The type ID of point generator objects is Ovoronoipointgenerator.
Access Sources
The VoronoiFracture class provides functions to access the object and generator sources referenced in the "Sources" parameter.
- VoronoiFracture::GetSourcesCount(): Returns the number of sources.
- VoronoiFracture::GetSource(): Returns the source at the given index.
- VoronoiFracture::GetSourceByType(): Returns the source of the given type.
const Int32 srcCnt = voronoiFracture->GetSourcesCount();
{
BaseObject*
const source = voronoiFracture->GetSource(
i);
const String sourceName =
source->GetName();
}
Py_ssize_t i
Definition: abstract.h:645
const Py_UNICODE * source
Definition: unicodeobject.h:54
Remove Sources
The VoronoiFracture class also provides functions to safely remove objects and generators from the "Sources" parameter.
- VoronoiFracture::RemoveSource(): Removes the source with the given index, a point generator is also deleted.
- VoronoiFracture::ClearSources(): Clears the "Sources" parameter and deletes all point generators.
{
voronoiFracture->RemoveSource(
index);
}
Py_ssize_t * index
Definition: abstract.h:374
#define Ovoronoipointgenerator
Voronoi Fracture internal Point generator.
Definition: ge_prepass.h:1169
Add Sources
Using the VoronoiFracture functions it is safe to add new sources and generators to the "Sources" parameter.
- VoronoiFracture::AddPointGenerator(): Creates and adds a new point generator of the given type. Valid types are:
Point generators are represented by dedicated BaseObject elements that are owned by the VoronoiFracture object. To configure such a point generator one can simply edit the parameters of the corresponding BaseObject. The parameter IDs of these parameters are defined in opointcreator_panel.h
.
BaseObject*
const shaderSource = voronoiFracture->AddPointGenerator(shaderGenerator,
Xnoise);
if (shaderSource == nullptr)
#define Xnoise
Noise.
Definition: ge_prepass.h:1367
@ ID_POINTCREATOR_CREATORTYPE_SHADER
Definition: opointcreator_panel.h:8
@ ID_POINTCREATOR_SHADERSAMPLEAMOUNT
Definition: opointcreator_panel.h:43
The VoronoiFracture object can also use external objects as sources of points:
- VoronoiFracture::AddSceneObject(): Adds the given BaseObject to the "Sources" list.
- VoronoiFracture::GetSourceSettingsContainerForIndex(): Returns the BaseContainer with the settings for the given source object index.
- VoronoiFracture::GetSourceSettingsContainerForObject(): Returns the BaseContainer with the settings for the given source object.
The IDs for these settings are defined in tfracturevoronoi.h
.
BaseObject*
const cube = BaseObject::Alloc(
Ocube);
if (cube == nullptr)
doc->InsertObject(cube,
nullptr,
nullptr);
voronoiFracture->AddSceneObject(cube);
BaseContainer* const settings = voronoiFracture->GetSourceSettingsContainerForObject(cube);
if (settings == nullptr)
#define Ocube
Cube.
Definition: ge_prepass.h:1118
@ ID_FRACTURETAG_POINTCREATIONTYPE
Definition: tfracturevoronoi.h:15
@ ID_FRACTURETAG_POLYS
Definition: tfracturevoronoi.h:18
Further Reading