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
{
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
}
// 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
}
@ DEFAULTVALUE
Dummy value for the default value GeData constructor.
Definition: c4d_gedata.h:65
Definition: c4d_baseobject.h:225
static BaseObject * Alloc(Int32 type)
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
Bool GetParameter(const DescID &id, GeData &t_data, DESCFLAGS_GET flags)
Definition: lib_description.h:330
Definition: c4d_fielddata.h:1148
Bool SetLinkedObject(const FieldLayerLink &link)
Definition: c4d_fielddata.h:1317
void SetChannelFlag(FIELDLAYER_CHANNELFLAG flag, Bool state=true)
Definition: c4d_fielddata.h:1245
static FieldLayer * Alloc(Int32 type)
Definition: c4d_fielddata.h:1324
Field custom GUI (CUSTOMDATATYPE_FIELDLIST) for the Field list data.
Definition: customgui_field.h:59
maxon::Result< void > InsertLayer(FieldLayer *layer, FieldLayer *parent=nullptr, FieldLayer *prev=nullptr)
Definition: c4d_gedata.h:83
CustomDataType * GetCustomDataType(Int32 datatype) const
Definition: c4d_gedata.h:507
InExclude custom data type (CUSTOMDATATYPE_INEXCLUDE_LIST).
Definition: customgui_inexclude.h:115
Bool InsertObject(BaseList2D *pObject, Int32 lFlags)
Definition: c4d_particleobject.h:71
#define CUSTOMDATATYPE_FIELDLIST
Definition: customgui_field.h:26
#define CUSTOMDATATYPE_INEXCLUDE_LIST
InExclude custom data type ID.
Definition: customgui_inexclude.h:25
#define MAXON_SCOPE
Definition: apibase.h:2841
@ DIRECTION
Direction sampling is enabled for this layer.
@ ENABLE
The layer is enabled and being sampled.
static const Int32 FLfield
FieldLayer Field object based layer.
Definition: c4d_fielddata.h:79
static const Int32 Flinear
Linear shaped field.
Definition: c4d_fielddata.h:43
#define Ofieldforce
Particle field force
Definition: ge_prepass.h:1095
#define Oparticle
Particle emitter - ParticleObject.
Definition: ge_prepass.h:1043
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
@ ID_FIELDFORCE_FIELDLIST
Definition: ofieldforce.h:6
@ ID_FIELDFORCE_STRENGTH
Definition: ofieldforce.h:7
@ PARTICLEOBJECT_MODE_INCLUDE
Definition: oparticle.h:35
@ PARTICLEOBJECT_MODE
Definition: oparticle.h:33
@ PARTICLEOBJECT_INCLUDE
Definition: oparticle.h:34
const char * doc
Definition: pyerrors.h:226
#define iferr_return
Definition: resultbase.h:1519
Base class for custom data types.
Definition: c4d_customdatatype.h:51