#include <c4d_particles.h>

The master system is the main Thinking Particles engine class. There can only be one master system per document. This is the easiest way to get it:
Private Member Functions | |
| TP_MasterSystem () | |
| ~TP_MasterSystem () | |
Particle/Particles | |
| Int32 | AllocParticle () | 
| Int32 | AllocParticles (Int32 num, Int32 *ids) | 
| void | FreeParticle (Int32 pid) | 
| void | FreeAllParticles () | 
| Int32 | NumParticles () const | 
Particle Group | |
| TP_PGroup * | AllocParticleGroup () | 
| void | FreeParticleGroup (TP_PGroup *&group) | 
| Bool | SetPGroupHierarchy (TP_PGroup *parent, TP_PGroup *group, TP_InsertMode mode) | 
| Int32 | GetParticleGroups (TP_PGroup *ingroup, TP_PGroupArray *gtab, TP_GetPGroupMode mode, Bool subgroups=true) | 
| Int32 | GetParticleGroups (const TP_PGroup *ingroup, maxon::BaseArray< const TP_PGroup * > *gtab, TP_GetPGroupMode mode, Bool subgroups=true) const | 
| Int32 | GetGroupParticleCount (TP_PGroup *ingroup, Bool subgroups=true) | 
| BaseObject * | GetVirtualObjects (TP_PGroup *ingroup, Bool inRender=true, Bool subgroups=true, const HierarchyHelp *hh=nullptr) | 
| BaseContainer * | GetGroupInfo (TP_PGroup *group) | 
| TP_PGroup * | GetGroupFromInfo (BaseContainer *info) | 
| Bool | UpdateGroup (TP_PGroup *group, const BaseTime &timeDelta) | 
Particle Information/Bits | |
| Bool | Alive (Int32 pid) const | 
| Bool | IsBorn (Int32 pid) const | 
| Bool | IsDie (Int32 pid) const | 
| Bool | EntersGroup (Int32 pid) const | 
| TP_PGroup * | Group (Int32 pid) | 
| Vector | Position (Int32 pid) const | 
| Vector | Velocity (Int32 pid) const | 
| Float | Mass (Int32 pid) const | 
| TP_Spin | Spin (Int32 pid) const | 
| Float | Size (Int32 pid) const | 
| Vector | Scale (Int32 pid) const | 
| BaseTime | Age (Int32 pid) const | 
| BaseTime | Life (Int32 pid) const | 
| Matrix | Alignment (Int32 pid) const | 
| Int32 | Randomseed (Int32 pid) const | 
| TP_PShapePtr | Shape (Int32 pid) const | 
| Matrix | Transform (Int32 pid) const | 
| UInt16 | Flags (Int32 pid) const | 
| Float | DTFactor (Int32 pid) const | 
Set Particle Information/Bits | |
| void | SetPosition (Int32 pid, const Vector &p) | 
| void | SetVelocity (Int32 pid, const Vector &p) | 
| void | SetMass (Int32 pid, Float mass) | 
| void | SetSpin (Int32 pid, const TP_Spin &spin) | 
| void | SetAge (Int32 pid, const BaseTime &age) | 
| void | SetLife (Int32 pid, const BaseTime &life) | 
| void | SetGroup (Int32 pid, TP_PGroup *group) | 
| void | SetSize (Int32 pid, Float size) | 
| void | SetScale (Int32 pid, const Vector &scale) | 
| void | SetAlignment (Int32 pid, const Matrix &align) | 
| void | SetRandomseed (Int32 pid, Int32 seed) | 
| void | SetShape (Int32 pid, const TP_PShapePtr &shape, Bool deleteold=true) | 
| void | SetCollision (Int32 pid, Int32 collision) | 
| void | SetDTFactor (Int32 pid, Float dt) | 
Particle Data Channels | |
| Bool | AddDataChannel (GvDataID type, const maxon::String &str) | 
| Bool | RemoveDataChannel (Int32 chan) | 
| Int32 | NumDataChannels () | 
| GvDataID | DataChannelType (Int32 chan) | 
| String | DataChannelName (Int32 chan) | 
| Int32 | DataChannelUniqueID (Int32 chan) | 
| Int32 | DataChannelID (Int32 unique_id) | 
| Bool | SetData (Int32 pid, Int32 chan, void *data, GvValueID type) | 
| Bool | GetData (Int32 pid, Int32 chan, void *data, GvValueID type) | 
| Bool | SetDataFromPort (Int32 pid, Int32 chan, GvPort *p, GvRun *r) | 
| Bool | SetDataToPort (Int32 pid, Int32 chan, GvPort *p, GvRun *r) | 
| BaseContainer * | GetDataChannelInfo (Int32 chan) | 
| Int32 | GetDataChannelFromInfo (BaseContainer *info) | 
Callbacks | |
| void | Reg_FreeParticle_CB (TP_FreeParticle_CB *cb) | 
| void | UReg_FreeParticle_CB (TP_FreeParticle_CB *cb) | 
| void | Reg_DeletePShape_CB (TP_FreePShape_CB *cb) | 
| void | UReg_DeletePShape_CB (TP_FreePShape_CB *cb) | 
Operator Link Table | |
| Int32 | GetOperatorID (GvNode *op) | 
| GvOperatorData * | GetOperator (Int32 id) | 
Dirty | |
| UInt32 | GetDirty () const | 
| void | SetDirty () | 
Collision | |
| Bool | CheckCollision (Int32 collision, Int32 pid, Float t, Vector &pos, Vector &vel, TP_Spin &spin, Float dt, Float &ct) | 
Particle Shape | |
| TP_PShapePtr | GetShapeClone (const TP_PShapePtr &shape, Int32 pid, COPYFLAGS flags, AliasTrans *trn) | 
| TP_PShapePtr | GetShape (const TP_PShapePtr &shape, Int32 pid, Int32 owner_id) | 
| BaseObject * | GetShapeVirtualObjects (const TP_PShapePtr &shape, Int32 pid, BaseDocument *doc, const HierarchyHelp *hh) | 
| Float | GetShapeScale (const TP_PShapePtr &shape, Int32 pid) | 
| void | FreeShape (TP_PShapePtr &shape, Int32 pid) | 
Collider Cache | |
| GeColliderCache * | ColliderCache (Int32 pid) | 
Color Property | |
| Vector32 | Color (Int32 pid) | 
| void | SetColor (Int32 pid, const Vector32 &color) | 
      
  | 
  private | 
      
  | 
  private | 
| Int32 AllocParticle | ( | ) | 
Allocates a particle.
Allocates num particles and stores their particles IDs in the ids array.
| [in] | num | The number of particles to allocate. | 
| [out] | ids | An array of num Int32 elements. Filled with the allocated particle IDs. The caller owns the pointed array. | 
| void FreeParticle | ( | Int32 | pid | ) | 
Frees a particle.
| [in] | pid | The particle ID of the particle to free: 0 <= pid < NumParticles() | 
| void FreeAllParticles | ( | ) | 
Frees all particles.
| Int32 NumParticles | ( | ) | const | 
Retrieves the number of allocated particles. All particles IDs are less than this value.
| TP_PGroup* AllocParticleGroup | ( | ) | 
Allocates a new particle group. Must be freed with FreeParticleGroup(), or inserted into the list with SetPGroupHierarchy().
| void FreeParticleGroup | ( | TP_PGroup *& | group | ) | 
Frees a particle group, removing it from the list.
| [in,out] | group | The group to free. Set to nullptr afterwards. | 
| Bool SetPGroupHierarchy | ( | TP_PGroup * | parent, | 
| TP_PGroup * | group, | ||
| TP_InsertMode | mode | ||
| ) | 
Performs a hierarchy action on a particle group.
| [in] | parent | The parent parameter. The caller owns the pointed TP_PGroup. | 
| [in] | group | The group to act on. The caller owns the pointed TP_PGroup. | 
| [in] | mode | The hierarchy action: TP_InsertMode | 
| Int32 GetParticleGroups | ( | TP_PGroup * | ingroup, | 
| TP_PGroupArray * | gtab, | ||
| TP_GetPGroupMode | mode, | ||
| Bool | subgroups = true  | 
        ||
| ) | 
Returns the particle groups in ingroup, specified by mode, into the gtab list.
Example: 
| [in] | ingroup | The in-group parameter. The caller owns the pointed TP_PGroup. | 
| [out] | gtab | The specified groups are added to this list. The caller owns the pointed TP_PGroup. | 
| [in] | mode | The mode: TP_GetPGroupMode | 
| [in] | subgroups | If true sub-groups are included. | 
| Int32 GetParticleGroups | ( | const TP_PGroup * | ingroup, | 
| maxon::BaseArray< const TP_PGroup * > * | gtab, | ||
| TP_GetPGroupMode | mode, | ||
| Bool | subgroups = true  | 
        ||
| ) | const | 
Calculates the number of particles in ingroup.
| [in] | ingroup | The in-group parameter. The caller owns the pointed TP_PGroup. | 
| [in] | subgroups | If true sub-groups are included. | 
| BaseObject* GetVirtualObjects | ( | TP_PGroup * | ingroup, | 
| Bool | inRender = true,  | 
        ||
| Bool | subgroups = true,  | 
        ||
| const HierarchyHelp * | hh = nullptr  | 
        ||
| ) | 
Creates the virtual object hierarchy for a particle group, i.e. an object group containing all particles. Used by the ParticleGeometry object.
| [in] | ingroup | The in-group parameter. The caller owns the pointed TP_PGroup. | 
| [in] | inRender | true if this is for rendering, otherwise the objects are built for the editor view. | 
| [in] | subgroups | If true sub-groups are included. | 
| [in] | hh | The hierarchy helper for the virtual object generation. The caller owns the pointed HierarchyHelp. | 
| BaseContainer* GetGroupInfo | ( | TP_PGroup * | group | ) | 
Retrieves the group information for a group.
| [in] | group | The group to get the information for. The caller owns the pointed TP_PGroup. | 
| TP_PGroup* GetGroupFromInfo | ( | BaseContainer * | info | ) | 
Retrieves a group from the information in info.
| [in] | info | The group information to search for. The caller owns the pointed TP_PGroupInfo. | 
Updates a group at a given time difference since the last update. Use a default timeDelta of 0 to update at the current time.
| [in] | group | The group to update. The caller owns the pointed TP_PGroup. | 
| [in] | timeDelta | The time difference since the last update. | 
Retrieves the alive bit of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Retrieves the is-born bit of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Retrieves the is-die bit of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Retrieves the enters-group bit of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Retrieves the group of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Retrieves the position of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Retrieves the velocity of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Retrieves the mass of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Retrieves the spin of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Retrieves the size of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Retrieves the scale of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Retrieves the age of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Retrieves the lifetime of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Retrieves the alignment matrix of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Retrieves the random seed of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| TP_PShapePtr Shape | ( | Int32 | pid | ) | const | 
Retrieves the shape of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Retrieves the transformation matrix of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Retrieves the flags of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Retrieves the delta time factor of a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Sets the position for a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | p | The new particle position. | 
Sets the velocity for a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | p | The new particle velocity. | 
Sets the mass for a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | mass | The new particle mass. | 
Sets the spin for a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | spin | The new particle spin. | 
Sets the age for a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | age | The new particle age. | 
Sets the lifetime for a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | life | The new particle lifetime. | 
Inserts a particle into another group.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | group | The group to place the particle in. The pointed group must belong to this master system. | 
Sets the size for a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | size | The new particle size. | 
Sets the scale for a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | scale | The new particle scale. | 
Sets the alignment matrix for a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | align | The new particle alignment matrix. | 
Sets the random seed for a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | seed | The new particle random seed. | 
| void SetShape | ( | Int32 | pid, | 
| const TP_PShapePtr & | shape, | ||
| Bool | deleteold = true  | 
        ||
| ) | 
Sets the shape for a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | shape | The new particle shape. TP_PShapeI::owner_id should be set to GetOperatorID() for the node responsible for the shape handling. This node should be prepared to provide a TP_PShapeInterface via the TP_MSG_GET_PSHAPEINTERFACE message.  | 
| [in] | deleteold | If true the old shape is deleted. | 
Sets the collision handling information for a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | collision | The collision ID. This is the GetOperatorID() for the node responsible for the collision handling. This node should be prepared to provide a TP_CollisionInterface via the TP_MSG_GET_COLLISIONINTERFACE message.  | 
Sets the delta time factor for a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | dt | The new particle delta time factor. | 
| Bool AddDataChannel | ( | GvDataID | type, | 
| const maxon::String & | str | ||
| ) | 
Adds a data channel.
| [in] | type | The channel data type: GvDataID | 
| [in] | str | The channel name. | 
Removes a data channel.
| [in] | chan | The channel index: 0 <= chan < NumDataChannels() | 
| Int32 NumDataChannels | ( | ) | 
Retrieves the data channel count.
Retrieves the data type of a data channel.
| [in] | chan | The channel index: 0 <= chan < NumDataChannels() | 
Retrieves the name of a data channel.
| [in] | chan | The channel index: 0 <= chan < NumDataChannels() | 
Retrieves a unique ID for a data channel that is independent of its index.
| [in] | chan | The channel index: 0 <= chan < NumDataChannels() | 
Retrieves the index of a data channel from its unique ID.
| [in] | unique_id | The unique channel ID. | 
Sets the data channel for a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | chan | The channel index: 0 <= chan < NumDataChannels() | 
| [in] | data | The data to set. Points to GV data. The layout of the pointed data is determined by type. | 
| [in] | type | Determines the type of data. | 
Retrieves the data channel for a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | chan | The channel index: 0 <= chan < NumDataChannels() | 
| [out] | data | Filled with the retrieved data. Points to GV data. The layout of the pointed data is determined by type. | 
| [in] | type | Determines the type of data. | 
Sets the data channel for a particle, getting the data from a GV port.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | chan | The channel index: 0 <= chan < NumDataChannels() | 
| [in] | p | The port with the data to set. The caller owns the pointed GvPort. | 
| [in] | r | The run helper. The caller owns the pointed GvRun. | 
Retrieves the data channel for a particle, storing the data in a GV port.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | chan | The channel index: 0 <= chan < NumDataChannels() | 
| [out] | p | The retrieved data is set in this port. The caller owns the pointed GvPort. | 
| [in] | r | The run helper. The caller owns the pointed GvRun. | 
| BaseContainer* GetDataChannelInfo | ( | Int32 | chan | ) | 
Retrieves the channel information for a data channel.
| Int32 GetDataChannelFromInfo | ( | BaseContainer * | info | ) | 
Retrieves a data channel index from the information in info.
| [in] | info | The information to search for. The caller owns the pointed TP_DataChannelInfo. | 
| void Reg_FreeParticle_CB | ( | TP_FreeParticle_CB * | cb | ) | 
Registers a free-particle callback.
| [in] | cb | The callback to register. | 
| void UReg_FreeParticle_CB | ( | TP_FreeParticle_CB * | cb | ) | 
Unregisters a free-particle callback.
| [in] | cb | The callback to unregister. | 
| void Reg_DeletePShape_CB | ( | TP_FreePShape_CB * | cb | ) | 
Registers a delete-shape callback.
| [in] | cb | The callback to register. | 
| void UReg_DeletePShape_CB | ( | TP_FreePShape_CB * | cb | ) | 
Unregisters a delete-shape callback.
| [in] | cb | The callback to unregister. | 
Retrieves an ID for op that can later be used with GetOperator() to get op back.
| [in] | op | A node. The caller owns the pointed node. | 
| GvOperatorData* GetOperator | ( | Int32 | id | ) | 
Retrieves the operator for an ID previously acquired with GetOperatorID().
| [in] | id | The operator ID, as returned by GetOperatorID(). | 
| UInt32 GetDirty | ( | ) | const | 
A dirty counter for the master system. This can be used to see if anything has changed. Use SetDirty() to increment the counter.
| void SetDirty | ( | ) | 
Increments the dirty counter, i.e. tells anyone using GetDirty() that something has changed.
| Bool CheckCollision | ( | Int32 | collision, | 
| Int32 | pid, | ||
| Float | t, | ||
| Vector & | pos, | ||
| Vector & | vel, | ||
| TP_Spin & | spin, | ||
| Float | dt, | ||
| Float & | ct | ||
| ) | 
Finds the node responsible for collision, the one that called SetCollision(), and tells it to evaluate the passed collision parameters.
| [in] | collision | The collision ID. This is GetOperatorID() for the node responsible for the collision. | 
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | t | Time to evaluate the collision at. Collisions are detected between t - dt and t. | 
| [in] | pos | Assigned the new position of the object if there is a collision. | 
| [out] | vel | Assigned the new velocity of the object if there is a collision. | 
| [out] | spin | Assigned the new spin of the object if there is a collision. | 
| [in] | dt | The time since the last evaluation, i.e. the time to look backwards for collisions. | 
| [in] | ct | The collision time, if there was a collision. This is generally less than t. | 
| TP_PShapePtr GetShapeClone | ( | const TP_PShapePtr & | shape, | 
| Int32 | pid, | ||
| COPYFLAGS | flags, | ||
| AliasTrans * | trn | ||
| ) | 
Finds the node responsible for shape, as specified by TP_PShapeI::owner_id, and tells it to return a clone of shape.
| [in] | shape | The particle shape. The caller owns the pointed shape. | 
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | flags | The flags: COPYFLAGS | 
| [in] | trn | An alias translator for the operation. Can be nullptr. The caller owns the pointed AliasTrans. | 
| TP_PShapePtr GetShape | ( | const TP_PShapePtr & | shape, | 
| Int32 | pid, | ||
| Int32 | owner_id | ||
| ) | 
Finds the node responsible for shape, as specified by TP_PShapeI::owner_id, and tells it to return the shape associated with shape. (Normally this is the same object.)
| [in] | shape | The particle shape. The caller owns the pointed shape. | 
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | owner_id | The owner ID. | 
| BaseObject* GetShapeVirtualObjects | ( | const TP_PShapePtr & | shape, | 
| Int32 | pid, | ||
| BaseDocument * | doc, | ||
| const HierarchyHelp * | hh | ||
| ) | 
Finds the node responsible for shape, as specified by TP_PShapeI::owner_id, and tells it to return a BaseObject shape for shape.
| [in] | shape | The particle shape. The caller owns the pointed shape. | 
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | doc | The current document. The caller owns the pointed BaseDocument. | 
| [in] | hh | A hierarchy helper for the operation. The caller owns the pointed HierarchyHelp. | 
| Float GetShapeScale | ( | const TP_PShapePtr & | shape, | 
| Int32 | pid | ||
| ) | 
Finds the node responsible for shape, as specified by TP_PShapeI::owner_id, and tells it to return the scale of shape.
| [in] | shape | The particle shape. The caller owns the pointed shape. | 
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| void FreeShape | ( | TP_PShapePtr & | shape, | 
| Int32 | pid | ||
| ) | 
Finds the node responsible for shape, as specified by TP_PShapeI::owner_id, and tells it to free shape.
| [in] | shape | The particle shape. The caller owns the pointed shape. | 
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| GeColliderCache* ColliderCache | ( | Int32 | pid | ) | 
Retrieves a collider cache for the shape associated with a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Retrieves the color for a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
Sets the color for a particle.
| [in] | pid | The particle ID: 0 <= pid < NumParticles() | 
| [in] | color | The particle color. |