Particles

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
if (emitter == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
ParticleObject* const particleEmitter = static_cast<ParticleObject*>(emitter);
doc->InsertObject(particleEmitter, nullptr, nullptr);
// make field force
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
{
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
}
// make layer in Field force
{
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
if (layer == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
layer->SetLinkedObject(linearField);
// enable layer and set direction
// insert
fieldList->InsertLayer(layer, nullptr, nullptr) iferr_return;
// set data
fieldForce->SetParameter(fieldsID, effectorData, DESCFLAGS_SET::NONE);
// set strength
}
FieldLayer
Definition: c4d_fielddata.h:1124
FieldLayer::SetLinkedObject
Bool SetLinkedObject(const FieldLayerLink &link)
Definition: c4d_fielddata.h:1294
BaseDocument::InsertObject
void InsertObject(BaseObject *op, BaseObject *parent, BaseObject *pred, Bool checknames=false)
PARTICLEOBJECT_MODE_INCLUDE
@ PARTICLEOBJECT_MODE_INCLUDE
Definition: oparticle.h:35
BaseObject
Definition: c4d_baseobject.h:220
DescID
Definition: lib_description.h:315
FLfield
static const Int32 FLfield
FieldLayer Field object based layer.
Definition: c4d_fielddata.h:79
CUSTOMDATATYPE_FIELDLIST
#define CUSTOMDATATYPE_FIELDLIST
Definition: customgui_field.h:22
Ofieldforce
#define Ofieldforce
Definition: ge_prepass.h:1033
iferr_return
#define iferr_return
Definition: resultbase.h:1434
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
Definition: 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.
Definition: customgui_inexclude.h:21
InExcludeData
InExclude custom data type (CUSTOMDATATYPE_INEXCLUDE_LIST).
Definition: customgui_inexclude.h:107
Oparticle
#define Oparticle
Particle emitter - ParticleObject.
Definition: ge_prepass.h:978
C4DAtom::SetParameter
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
InExcludeData::InsertObject
Bool InsertObject(BaseList2D *pObject, Int32 lFlags)
FIELDLAYER_CHANNELFLAG::DIRECTION
@ DIRECTION
Direction sampling is enabled for this layer.
FieldList
Field custom GUI (CUSTOMDATATYPE_FIELDLIST) for the Field list data.
Definition: customgui_field.h:54
GeData
Definition: c4d_gedata.h:77
PARTICLEOBJECT_INCLUDE
@ PARTICLEOBJECT_INCLUDE
Definition: oparticle.h:34
ID_FIELDFORCE_STRENGTH
@ ID_FIELDFORCE_STRENGTH
Definition: ofieldforce.h:7
DEFAULTVALUE
@ DEFAULTVALUE
Dummy value for the default value GeData constructor.
Definition: c4d_gedata.h:60
CustomDataType
Base class for custom data types.
Definition: c4d_customdatatype.h:46
BaseObject::Alloc
static BaseObject * Alloc(Int32 type)
ParticleObject
Definition: c4d_particleobject.h:66
DESCFLAGS_GET::NONE
@ NONE
None.
PARTICLEOBJECT_MODE
@ PARTICLEOBJECT_MODE
Definition: oparticle.h:33
GeData::GetCustomDataType
CustomDataType * GetCustomDataType(Int32 datatype) const
Definition: c4d_gedata.h:485
FieldList::InsertLayer
maxon::Result< void > InsertLayer(FieldLayer *layer, FieldLayer *parent=nullptr, FieldLayer *prev=nullptr)
FieldLayer::SetChannelFlag
void SetChannelFlag(FIELDLAYER_CHANNELFLAG flag, Bool state=true)
Definition: c4d_fielddata.h:1222
ID_FIELDFORCE_FIELDLIST
@ ID_FIELDFORCE_FIELDLIST
Definition: ofieldforce.h:6
C4DAtom::GetParameter
Bool GetParameter(const DescID &id, GeData &t_data, DESCFLAGS_GET flags)
MAXON_SCOPE
#define MAXON_SCOPE
Definition: apibase.h:2598
Flinear
static const Int32 Flinear
Linear shaped field.
Definition: c4d_fielddata.h:41
FieldLayer::Alloc
static FieldLayer * Alloc(Int32 type)
Definition: c4d_fielddata.h:1301