Particles

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

  • ParticleObject represents the simple particle emitter, which holds particles. The ID is Oparticle.
  • Particle represents a particle stored inside the ParticleObject.

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
{
InExcludeData* const inExData = data.GetCustomDataTypeWritable<InExcludeData>();
if (inExData == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
// insert object into list
inExData->InsertObject(fieldForce, 1);
// set parameter
particleEmitter->SetParameter(ConstDescID(DescLevel(PARTICLEOBJECT_INCLUDE)), data, DESCFLAGS_SET::NONE);
}
// make layer in Field force
{
const DescID fieldsID = ConstDescID(DescLevel(ID_FIELDFORCE_FIELDLIST));
GeData effectorData;
if (fieldForce->GetParameter(fieldsID, effectorData, DESCFLAGS_GET::NONE) == false)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
FieldList* const fieldList = effectorData.GetCustomDataTypeWritable<FieldList>();
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(ConstDescID(DescLevel(ID_FIELDFORCE_STRENGTH)), 20.0, DESCFLAGS_SET::NONE);
}
NONE
Definition: asset_browser.h:1
#define CUSTOMDATATYPE_INEXCLUDE_LIST
InExclude custom data type ID.
Definition: customgui_inexclude.h:24
DIRECTION
Sample the velocity at the current point.
Definition: ge_prepass.h:1
#define MAXON_SCOPE
Definition: apibase.h:2891
static const Int32 FLfield
FieldLayer Field object based layer.
Definition: c4d_fielddata.h:77
static const Int32 Flinear
Linear shaped field.
Definition: c4d_fielddata.h:41
#define Ofieldforce
Particle field force
Definition: ge_prepass.h:1104
#define Oparticle
Particle emitter - ParticleObject.
Definition: ge_prepass.h:1052
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:69
#define ConstDescID(...)
Definition: lib_description.h:592
@ DEFAULTVALUE
Dummy value for the default value GeData constructor.
Definition: c4d_gedata.h:64
@ 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
ENABLE
The layer is enabled and being sampled.
Definition: operatingsystem.h:1
const char * doc
Definition: pyerrors.h:226
#define iferr_return
Definition: resultbase.h:1531