VoronoiFracture Manual

内容表

关于

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.

// This example creates a Voronoi Fracture object, // adds an input Sphere object, a Rigid Body tag and a point generator.

// create Voronoi Fracture object VoronoiFracture * const fractureObject = VoronoiFracture::Alloc (); if (fractureObject == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );

doc-> InsertObject (fractureObject, nullptr , nullptr );

// add a Rigid Body tag (ID 180000102) BaseTag * const rigidBodyTag = BaseTag::Alloc (180000102); if (rigidBodyTag == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );

fractureObject-> InsertTag (rigidBodyTag); rigidBodyTag-> 消息 ( MSG_MENUPREPARE );

// add sphere as input object BaseObject * const sphere = BaseObject::Alloc ( Osphere ); if (sphere == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); doc-> InsertObject (sphere, fractureObject, nullptr );

// add point source const Int32 pointCreatorType = ID_POINTCREATOR_CREATORTYPE_DISTRIBUTION ; BaseObject * const pointGenerator = fractureObject-> AddPointGenerator (pointCreatorType, NOTOK , nullptr ); if (pointGenerator == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );

// configure point generator pointGenerator-> SetParameter ( ID_POINTCREATOR_CREATEDPOINTAMOUNT , 10, DESCFLAGS_SET::NONE );

Access

A VoronoiFracture object can be accessed like any other object.

// This example accesses the currently selected // Voronoi Fracture object to print the number // of used sources. BaseObject * const obj = doc-> GetActiveObject ();

// check if the active object is a Voronoi Fracture object (ID 1036557) if (obj != nullptr && obj-> IsInstanceOf (1036557)) { VoronoiFracture * const voronoiFracture = static_cast< VoronoiFracture * > (obj);

// get source count const Int32 srcCnt = voronoiFracture-> GetSourcesCount ();

// print source count const String srcCntStr = String::IntToString (srcCnt); ApplicationOutput (voronoiFracture-> GetName () + " uses " + srcCntStr + " sources." ); }

Allocation/Deallocation

VoronoiFracture objects are created with the usual tools:

// This example creates a Voronoi Fracture object as the new // parent object of the currently active object.

// get active object BaseObject * const activeObject = doc-> GetActiveObject (); if (activeObject == nullptr ) return maxon::IllegalArgumentError( MAXON_SOURCE_LOCATION );

// create voronoi fracture VoronoiFracture * const fracture = VoronoiFracture::Alloc (); if (fracture == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );

// insert voronoi fracture doc-> InsertObject (fracture, nullptr , nullptr );

// insert active object under the fracture object activeObject-> 移除 (); doc-> InsertObject (activeObject, fracture, nullptr );

参数

The IDs of the standard parameters of a VoronoiFracture object are defined in the omograph_fracturevoronoi.h header file.

注意
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.

// This example loops through all point sources of the given // Voronoi Fracture object and prints their names.

// get source count const Int32 srcCnt = voronoiFracture-> GetSourcesCount ();

// loop through all sources for ( Int32 i = 0; i < srcCnt; ++i) { // get source BaseObject * const source = voronoiFracture-> GetSource (i); if (source == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );

// print source name const String sourceName = source-> GetName (); ApplicationOutput ( "Source: " + sourceName); }

Remove Sources

The VoronoiFracture class also provides functions to safely remove objects and generators from the "Sources" parameter.

// This example removes all point generator sources from the // given Voronoi Fracture object. Int32 index = NOTOK ;

// loop through all point generators until no point generator is found anymore while (voronoiFracture-> GetSourceByType ( Ovoronoipointgenerator , NOTOK , &index)) { voronoiFracture-> RemoveSource (index); }

Add Sources

使用 VoronoiFracture functions it is safe to add new sources and generators to the "Sources" parameter.

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 .

// This example adds a shader generator source to the given // Voronoi Fracture object and adds a shader. const Int32 shaderGenerator = ID_POINTCREATOR_CREATORTYPE_SHADER ; BaseObject * const shaderSource = voronoiFracture-> AddPointGenerator (shaderGenerator, Xnoise ); if (shaderSource == nullptr ) return maxon::UnknownError( MAXON_SOURCE_LOCATION );

// configure generator shaderSource-> SetParameter ( ID_POINTCREATOR_SHADERSAMPLEAMOUNT , 500, DESCFLAGS_SET::NONE );

The VoronoiFracture object can also use external objects as sources of points:

The IDs for these settings are defined in tfracturevoronoi.h .

// This example creates a new cube and uses it // as a point source in the given VoronoiFracture object. BaseObject * const cube = BaseObject::Alloc ( Ocube ); if (cube == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); doc-> InsertObject (cube, nullptr , nullptr );

// use as source object voronoiFracture-> AddSceneObject (cube); BaseContainer * const settings = voronoiFracture-> GetSourceSettingsContainerForObject (cube); if (settings == nullptr ) return maxon::UnknownError( MAXON_SOURCE_LOCATION ); settings-> SetInt32 ( ID_FRACTURETAG_POINTCREATIONTYPE , ID_FRACTURETAG_POLYS );

延伸阅读

BaseTag::Alloc
static BaseTag * Alloc(Int32 type)
VoronoiFracture::AddPointGenerator
BaseObject * AddPointGenerator(const Int32 type, const Int32 shaderType=NOTOK, Int32 *const index=nullptr)
BaseDocument::InsertObject
void InsertObject(BaseObject *op, BaseObject *parent, BaseObject *pred, Bool checknames=false)
VoronoiFracture::Alloc
static VoronoiFracture * Alloc()
BaseObject
定义: c4d_baseobject.h:224
BaseContainer::SetInt32
void SetInt32(Int32 id, Int32 l)
定义: c4d_basecontainer.h:505
Ovoronoipointgenerator
#define Ovoronoipointgenerator
Voronoi Fracture internal Point generator.
定义: ge_prepass.h:1090
ID_POINTCREATOR_CREATORTYPE_SHADER
@ ID_POINTCREATOR_CREATORTYPE_SHADER
定义: opointcreator_panel.h:8
BaseTag
定义: c4d_basetag.h:46
Ocube
#define Ocube
Cube.
定义: ge_prepass.h:1040
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
ID_POINTCREATOR_CREATEDPOINTAMOUNT
@ ID_POINTCREATOR_CREATEDPOINTAMOUNT
定义: opointcreator_panel.h:25
DESCFLAGS_SET::NONE
@ NONE
None.
Xnoise
#define Xnoise
Noise.
定义: ge_prepass.h:1200
Osphere
#define Osphere
Sphere.
定义: ge_prepass.h:1041
String
定义: c4d_string.h:38
VoronoiFracture::GetSourceByType
BaseObject * GetSourceByType(const Int32 type, const Int32 startIndex=NOTOK, Int32 *const index=nullptr)
String::IntToString
static String IntToString(Int32 v)
定义: c4d_string.h:495
C4DAtom::SetParameter
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
VoronoiFracture::GetSourcesCount
Int32 GetSourcesCount()
ID_FRACTURETAG_POINTCREATIONTYPE
@ ID_FRACTURETAG_POINTCREATIONTYPE
定义: tfracturevoronoi.h:15
MSG_MENUPREPARE
#define MSG_MENUPREPARE
Allows tags, objects, shaders etc. to do some setup work when called from the menu....
定义: c4d_baselist.h:384
NOTOK
#define NOTOK
定义: ge_sys_math.h:265
VoronoiFracture
定义: lib_voronoifracture.h:25
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
ApplicationOutput
#define ApplicationOutput(formatString,...)
定义: debugdiagnostics.h:207
C4DAtom::Message
Bool Message(Int32 type, void *data=nullptr)
定义: c4d_baselist.h:1394
ID_FRACTURETAG_POLYS
@ ID_FRACTURETAG_POLYS
定义: tfracturevoronoi.h:18
GeListNode::Remove
void Remove()
定义: c4d_baselist.h:1854
ID_POINTCREATOR_CREATORTYPE_DISTRIBUTION
@ ID_POINTCREATOR_CREATORTYPE_DISTRIBUTION
定义: opointcreator_panel.h:7
ID_POINTCREATOR_SHADERSAMPLEAMOUNT
@ ID_POINTCREATOR_SHADERSAMPLEAMOUNT
定义: opointcreator_panel.h:44
VoronoiFracture::GetSource
BaseObject * GetSource(const Int32 index)
BaseObject::Alloc
static BaseObject * Alloc(Int32 type)
VoronoiFracture::AddSceneObject
Bool AddSceneObject(BaseObject *object, Int32 *const index=nullptr)
VoronoiFracture::RemoveSource
Bool RemoveSource(const Int32 index)
BaseDocument::GetActiveObject
BaseObject * GetActiveObject(void)
C4DAtom::IsInstanceOf
Bool IsInstanceOf(Int32 id) const
定义: c4d_baselist.h:1373
BaseList2D::GetName
String GetName() const
定义: c4d_baselist.h:2318
BaseObject::InsertTag
void InsertTag(BaseTag *tp, BaseTag *pred=nullptr)
BaseContainer
定义: c4d_basecontainer.h:46
VoronoiFracture::GetSourceSettingsContainerForObject
BaseContainer * GetSourceSettingsContainerForObject(BaseObject *object)

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1