粒子

The basic particle system provides a simple particle generator and basic effectors. The API is defined in c4d_particleobject.h .

Particle modifiers are based on ObjectData and must implement ObjectData::ModifyParticles() . Within such a modifier changes are done through the BaseParticle structure.

// This example creates a particle emitter, a Field Force object and a linear field. // The linear field is referenced in the Field Force object; the Field Force object // is referenced in the particle emitter.

// make emitter

BaseObject * const emitter = BaseObject::Alloc ( Oparticle ); if (emitter == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );
ParticleObject * const particleEmitter = static_cast< ParticleObject * > (emitter); doc-> InsertObject (particleEmitter, nullptr , nullptr );

// make field force BaseObject * const fieldForce = BaseObject::Alloc ( Ofieldforce ); if (fieldForce == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); doc-> InsertObject (fieldForce, nullptr , nullptr );

// make field BaseObject * const linearField = BaseObject::Alloc ( Flinear ); if (linearField == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); doc-> InsertObject (linearField, fieldForce, nullptr );

// link field force in emitter MAXON_SCOPE { emitter-> SetParameter ( PARTICLEOBJECT_MODE , PARTICLEOBJECT_MODE_INCLUDE , DESCFLAGS_SET::NONE ); GeData data( CUSTOMDATATYPE_INEXCLUDE_LIST , DEFAULTVALUE ); CustomDataType * const customData = data. GetCustomDataType ( CUSTOMDATATYPE_INEXCLUDE_LIST ); InExcludeData * const inExData = static_cast< InExcludeData * > (customData); if (inExData == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );

// insert object into list inExData-> InsertObject (fieldForce, 1); // set parameter particleEmitter-> SetParameter ( PARTICLEOBJECT_INCLUDE , data, DESCFLAGS_SET::NONE ); }

// make layer in Field force MAXON_SCOPE { const DescID fieldsID { ID_FIELDFORCE_FIELDLIST }; GeData effectorData; if (fieldForce-> GetParameter (fieldsID, effectorData, DESCFLAGS_GET::NONE ) == false ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); CustomDataType * const customData = effectorData. GetCustomDataType ( CUSTOMDATATYPE_FIELDLIST ); FieldList * const fieldList = static_cast< FieldList * > (customData); if (fieldList == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );

// use field layer FieldLayer * const layer = FieldLayer::Alloc ( FLfield ); if (layer == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); layer-> SetLinkedObject (linearField);

// enable layer and set direction layer-> SetChannelFlag ( FIELDLAYER_CHANNELFLAG::ENABLE , true ); layer-> SetChannelFlag ( FIELDLAYER_CHANNELFLAG::DIRECTION , true );

// insert fieldList-> InsertLayer (layer, nullptr , nullptr ) iferr_return ;

// set data fieldForce-> SetParameter (fieldsID, effectorData, DESCFLAGS_SET::NONE );

// set strength fieldForce-> SetParameter ( ID_FIELDFORCE_STRENGTH , 20.0, DESCFLAGS_SET::NONE ); }

FieldLayer
定义: c4d_fielddata.h:1151
FieldLayer::SetLinkedObject
Bool SetLinkedObject(const FieldLayerLink &link)
定义: c4d_fielddata.h:1321
BaseDocument::InsertObject
void InsertObject(BaseObject *op, BaseObject *parent, BaseObject *pred, Bool checknames=false)
BaseObject
定义: c4d_baseobject.h:224
DescID
定义: lib_description.h:327
FLfield
static const Int32 FLfield
FieldLayer Field object based layer.
定义: c4d_fielddata.h:83
CUSTOMDATATYPE_FIELDLIST
#define CUSTOMDATATYPE_FIELDLIST
定义: customgui_field.h:26
ID_FIELDFORCE_FIELDLIST
@ ID_FIELDFORCE_FIELDLIST
定义: ofieldforce.h:6
Ofieldforce
#define Ofieldforce
定义: ge_prepass.h:1036
iferr_return
#define iferr_return
定义: resultbase.h:1434
PARTICLEOBJECT_MODE_INCLUDE
@ PARTICLEOBJECT_MODE_INCLUDE
定义: oparticle.h:35
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
FIELDLAYER_CHANNELFLAG::ENABLE
@ ENABLE
The layer is enabled and being sampled.
DESCFLAGS_SET::NONE
@ NONE
None.
CUSTOMDATATYPE_INEXCLUDE_LIST
#define CUSTOMDATATYPE_INEXCLUDE_LIST
InExclude custom data type ID.
定义: customgui_inexclude.h:25
InExcludeData
InExclude custom data type (CUSTOMDATATYPE_INEXCLUDE_LIST).
定义: customgui_inexclude.h:111
PARTICLEOBJECT_MODE
@ PARTICLEOBJECT_MODE
定义: oparticle.h:33
Oparticle
#define Oparticle
Particle emitter - ParticleObject.
定义: ge_prepass.h:984
C4DAtom::SetParameter
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
InExcludeData::InsertObject
Bool InsertObject(BaseList2D *pObject, Int32 lFlags)
PARTICLEOBJECT_INCLUDE
@ PARTICLEOBJECT_INCLUDE
定义: oparticle.h:34
FIELDLAYER_CHANNELFLAG::DIRECTION
@ DIRECTION
Direction sampling is enabled for this layer.
FieldList
Field custom GUI (CUSTOMDATATYPE_FIELDLIST) for the Field list data.
定义: customgui_field.h:58
GeData
定义: c4d_gedata.h:82
DEFAULTVALUE
@ DEFAULTVALUE
Dummy value for the default value GeData constructor.
定义: c4d_gedata.h:65
CustomDataType
Base class for custom data types.
定义: c4d_customdatatype.h:50
BaseObject::Alloc
static BaseObject * Alloc(Int32 type)
ParticleObject
定义: c4d_particleobject.h:70
DESCFLAGS_GET::NONE
@ NONE
None.
GeData::GetCustomDataType
CustomDataType * GetCustomDataType(Int32 datatype) const
定义: c4d_gedata.h:507
FieldList::InsertLayer
maxon::Result< void > InsertLayer(FieldLayer *layer, FieldLayer *parent=nullptr, FieldLayer *prev=nullptr)
FieldLayer::SetChannelFlag
void SetChannelFlag(FIELDLAYER_CHANNELFLAG flag, Bool state=true)
定义: c4d_fielddata.h:1249
C4DAtom::GetParameter
Bool GetParameter(const DescID &id, GeData &t_data, DESCFLAGS_GET flags)
MAXON_SCOPE
#define MAXON_SCOPE
定义: apibase.h:2645
ID_FIELDFORCE_STRENGTH
@ ID_FIELDFORCE_STRENGTH
定义: ofieldforce.h:7
Flinear
static const Int32 Flinear
Linear shaped field.
定义: c4d_fielddata.h:45
FieldLayer::Alloc
static FieldLayer * Alloc(Int32 type)
定义: c4d_fielddata.h:1328

Copyright  © 2014-2025 乐数软件    

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