c4d.modules.thinkingparticles.TP_MasterSystem¶
-
class
c4d.modules.thinkingparticles.
TP_MasterSystem
¶ - The master system is the main TP engine class.There can only be one master system per document.You can get it with
BaseDocument.GetParticleSystem()
.
Methods Signatures
Allocates a particle. |
|
Allocates num particles and stores their particles IDs. |
|
Allocates num particles and stores their particles IDs. |
|
Frees all particles. |
|
Allocates a new particle group. |
|
Frees a particle group, removing it from the list. |
|
|
Performs a hierarchy action on a particle group. |
Returns the root group. |
|
|
Returns the particle groups in ingroup, specified by mode. |
|
Calculates the number of particles in the ingroup group. |
Retrieve a list of all particles Id. |
|
Creates the virtual object hierarchy for a particle group, i.e. an object group containing all particles. Used by the ParticleGeometry object. |
|
Retrieves the group information for a group. |
|
Retrieves a group from the information in info. |
|
Updates a group at a given time difference since the last update. |
|
Retrieves the number of allocated particles.
|
|
Retrieves the alive bit of a particle. |
|
Retrieves the is-born bit of a particle. |
|
Retrieves the is-die bit of a particle. |
|
Retrieves the enters-group bit of a particle. |
|
Retrieves the group of a particle. |
|
Retrieves the position of a particle. |
|
Retrieves the velocity of a particle. |
|
Retrieves the mass of a particle. |
|
Retrieves the spin of a particle. |
|
Retrieves the size of a particle. |
|
Retrieves the scale of a particle. |
|
Retrieves the age of a particle. |
|
Retrieves the lifetime of a particle. |
|
Retrieves the alignment matrix of a particle. |
|
Retrieves the random seed of a particle. |
|
Retrieves the transformation matrix of a particle. |
|
Retrieves the transformation matrix of a particle. |
|
Retrieves the delta time factor of a particle. |
|
Retrieves the color of a particle. |
|
Retrieves the delta time factor of a particle. |
|
Sets the velocity for a particle. |
|
Sets the mass for a particle. |
|
Sets the spin for a particle. |
|
Sets the age for a particle. |
|
Sets the age for a particle. |
|
Inserts a particle into another group. |
|
Sets the size for a particle. |
|
Sets the size for a particle. |
|
Sets the alignment matrix for a particle. |
|
Sets the alignment matrix for a particle. |
|
Sets the collision handling information for a particle. |
|
Sets the delta time factor for a particle. |
|
Sets the color for a particle. |
|
Sets the data channel value for a particle: |
|
Sets the data channel value for a particle: |
|
Adds a new data channel. |
|
Removes a data channel. |
|
Retrieves the data channel count. |
|
Retrieves the data type of a data channel. |
|
Retrieves the name of a data channel. |
|
Retrieves a unique ID for a data channel that’s independent of its index. |
|
Retrieves the index of a data channel from its unique ID. |
|
Retrieves an ID for op |
|
A dirty counter for the master system.
|
|
Increments the dirty counter, i.e. tells anyone using |
|
Finds the node responsible for collision, the one that called SetCollision(), |
Inheritance
Parent Class:
Methods Documentation
-
TP_MasterSystem.
AllocParticle
(self)¶ Allocates a particle.
- Return type
int
- Returns
The particle ID of the allocated particle, or NOTOK if the allocation failed.
-
TP_MasterSystem.
AllocParticles
(self, num)¶ Allocates num particles and stores their particles IDs.
Note
The count of allocated particles might be unequal to num due to the limit in the settings Max Particles.Change it to increase the count of allocatable particles.- Parameters
num (int) – The number of particles to allocate.
- Return type
List[int]
- Returns
The list with the allocated particle IDs.
-
TP_MasterSystem.
FreeParticle
(self, pid)¶ Allocates num particles and stores their particles IDs.
Note
Normally this should not be used.Instead you should useSetLife()
with a negative time, so that the particle in question dies immediately.- Parameters
pid (int) – Particle ID of the particle to free. Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.
-
TP_MasterSystem.
FreeAllParticles
(self)¶ Frees all particles.
Note
Normally this should not be used.Instead you should useSetLife()
with a negative time, so that the particle in question dies immediately.
-
TP_MasterSystem.
AllocParticleGroup
(self)¶ Allocates a new particle group.
Warning
Must be freed with
FreeParticleGroup()
, or inserted into the list withSetPGroupHierarchy()
.- Return type
- Returns
The new particle group.
-
TP_MasterSystem.
FreeParticleGroup
(self, group)¶ Frees a particle group, removing it from the list.
- Parameters
group (c4d.modules.thinkingparticles.TP_PGroup) – The group to free.
-
TP_MasterSystem.
SetPGroupHierarchy
(self, parent, group, mode)¶ Performs a hierarchy action on a particle group.
- Parameters
parent (c4d.modules.thinkingparticles.TP_PGroup) – Parent parameter.
group (c4d.modules.thinkingparticles.TP_PGroup) – Group to act on.
mode (int) –
Action:
TP_INSERT_NONE
Not used.
TP_INSERT_UNDERFIRST
Insert group as first child of parent.
TP_INSERT_UNDERLAST
Insert group as last child of parent.
TP_INSERT_BEFORE
Insert group before parent.
TP_INSERT_AFTER
Insert group after parent.
-
TP_MasterSystem.
GetRootGroup
(self)¶ Returns the root group.
- Return type
- Returns
The root group.
-
TP_MasterSystem.
GetParticleGroups
(self, ingroup, mode, subgroups=True)¶ Returns the particle groups in ingroup, specified by mode.
- Parameters
ingroup (c4d.modules.thinkingparticles.TP_PGroup) – In-group parameter.
mode (int) –
Mode:
TP_GETPGROUP_ALL
All groups.
TP_GETPGROUP_WITHPARTICLES
Groups with particles.
TP_GETPGROUP_SELECTED
Selected groups.
subgroups (bool) – If this is True sub groups are included.
- Return type
list of
TP_PGroup
- Returns
The root group.
-
TP_MasterSystem.
GetGroupParticleCount
(self, ingroup, subgroups=True)¶ Calculates the number of particles in the ingroup group.
- Parameters
ingroup (c4d.modules.thinkingparticles.TP_PGroup) – In-group parameter.
subgroups (bool) – If this is True sub groups are included.
- Return type
int
- Returns
The number of particles.
-
TP_MasterSystem.
GetParticles
(self, all=False)¶ Retrieve a list of all particles Id.
- Parameters
all (bool) – If True all particles added, otherwise only alive particle.
- Returns
list(int)
- Return type
A list with all particles ID.
-
TP_MasterSystem.
GetVirtualObjects
(self, ingroup, inRender=True, subgroups=True, hh=None)¶ Creates the virtual object hierarchy for a particle group, i.e. an object group containing all particles. Used by the ParticleGeometry object.
- Parameters
ingroup (c4d.modules.thinkingparticles.TP_PGroup) – In-group parameter.
inRender (bool) – True if this is for rendering, otherwise the objects are built for the editor view.
subgroups (bool) – If this is True sub groups are included.
hh (HierarchyHelp - Not implemented) –
A hierarchy helper for the operation.Usually passed through from a calling function, for example fromObjectData.GetVirtualObjects()
or a Python generator main().
- Return type
- Returns
Virtual object or None if there was an error.
-
TP_MasterSystem.
GetGroupInfo
(self, group)¶ Retrieves the group information for a group.
- Parameters
group (c4d.modules.thinkingparticles.TP_PGroup) – Group to get the information for.
- Return type
- Returns
The group information for the group.
-
TP_MasterSystem.
GetGroupFromInfo
(self, info)¶ Retrieves a group from the information in info.
- Parameters
info (c4d.BaseContainer) – The information to search for.
- Return type
- Returns
The retrieved group or None if no group matched.
-
TP_MasterSystem.
UpdateGroup
(self, group, timeDelta)¶ Updates a group at a given time difference since the last update.
Note
Use a default timeDelta of 0 to update at the current time.
New in version R16.050.
- Parameters
group (c4d.modules.thinkingparticles.TP_PGroup) – The group to update.
timeDelta (c4d.BaseTime) – The time difference since the last update.
- Return type
bool
- Returns
True if the update was done successfully, otherwise False.
-
TP_MasterSystem.
NumParticles
(self)¶ - Retrieves the number of allocated particles.All particles IDs are less than this value.
- Return type
int
- Returns
Number of particles.
-
TP_MasterSystem.
Alive
(self, pid)¶ Retrieves the alive bit of a particle.
- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
bool
- Returns
True if the particle is alive, otherwise False.
-
TP_MasterSystem.
IsBorn
(self, pid)¶ Retrieves the is-born bit of a particle.
- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
bool
- Returns
True if the particle was just born, otherwise False.
-
TP_MasterSystem.
IsDie
(self, pid)¶ Retrieves the is-die bit of a particle.
- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
bool
- Returns
True if the particle just died, otherwise False.
-
TP_MasterSystem.
EntersGroup
(self, pid)¶ Retrieves the enters-group bit of a particle.
- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
bool
- Returns
True if the particle just entered a group, otherwise False.
-
TP_MasterSystem.
Group
(self, pid)¶ Retrieves the group of a particle.
- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
bool
- Returns
The group that the particle currently is in, otherwise None.
-
TP_MasterSystem.
Position
(self, pid)¶ Retrieves the position of a particle.
- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
- Returns
Particle position.
-
TP_MasterSystem.
Velocity
(self, pid)¶ Retrieves the velocity of a particle.
- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
- Returns
Particle velocity.
-
TP_MasterSystem.
Mass
(self, pid)¶ Retrieves the mass of a particle.
- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
float
- Returns
Particle mass.
-
TP_MasterSystem.
Spin
(self, pid)¶ Retrieves the spin of a particle.
- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
float
- Returns
Particle spin.
-
TP_MasterSystem.
Size
(self, pid)¶ Retrieves the size of a particle.
- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
float
- Returns
Particle size.
-
TP_MasterSystem.
Scale
(self, pid)¶ Retrieves the scale of a particle.
- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
- Returns
Particle scale.
-
TP_MasterSystem.
Age
(self, pid)¶ Retrieves the age of a particle.
- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
- Returns
Particle age.
-
TP_MasterSystem.
Life
(self, pid)¶ Retrieves the lifetime of a particle.
- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
- Returns
Particle lifetime.
-
TP_MasterSystem.
Alignment
(self, pid)¶ Retrieves the alignment matrix of a particle.
- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
- Returns
Particle alignment matrix.
-
TP_MasterSystem.
Randomseed
(self, pid)¶ Retrieves the random seed of a particle.
- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
- Returns
Particle random seed.
-
TP_MasterSystem.
Transform
(self, pid)¶ Retrieves the transformation matrix of a particle.
- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
- Returns
Particle transformation matrix.
-
TP_MasterSystem.
Flags
(self, pid)¶ Retrieves the transformation matrix of a particle.
Note
These are private. Use the functions like
Alive()
instead.- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
- Returns
Particle flags.
-
TP_MasterSystem.
DTFactor
(self, pid)¶ Retrieves the delta time factor of a particle.
- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
float
- Returns
Particle flags.
-
TP_MasterSystem.
Color
(self, pid)¶ Retrieves the color of a particle.
New in version R16.038.
- Parameters
pid (int) – Particle ID.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.- Return type
- Returns
Particle color.
-
TP_MasterSystem.
SetPosition
(self, pid, p)¶ Retrieves the delta time factor of a particle.
- Parameters
pid (int) – Particle ID.
p (c4d.Vector) – New particle position.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.
-
TP_MasterSystem.
SetVelocity
(self, pid, p)¶ Sets the velocity for a particle.
- Parameters
pid (int) – Particle ID.
p (c4d.Vector) – New particle velocity.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.
-
TP_MasterSystem.
SetMass
(self, pid, mass)¶ Sets the mass for a particle.
- Parameters
pid (int) – Particle ID.
mass (float) – New particle velocity.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.
-
TP_MasterSystem.
SetSpin
(self, pid, axis, speed)¶ Sets the spin for a particle.
- Parameters
pid (int) – Particle ID.
axis (c4d.Vector) – Rotation axis.
speed (float) – Rotation speed
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.
-
TP_MasterSystem.
SetAge
(self, pid, age)¶ Sets the age for a particle.
- Parameters
pid (int) – Particle ID.
age (c4d.BaseTime) – New particle age.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.
-
TP_MasterSystem.
SetLife
(self, pid, life)¶ Sets the age for a particle.
- Parameters
pid (int) – Particle ID.
life (c4d.BaseTime) – New particle lifetime.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.
-
TP_MasterSystem.
SetGroup
(self, pid, group)¶ Inserts a particle into another group.
- Parameters
pid (int) – Particle ID.
group (c4d.modules.thinkingparticles.TP_PGroup) – The group to place the particle in.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.
-
TP_MasterSystem.
SetSize
(self, pid, size)¶ Sets the size for a particle.
- Parameters
pid (int) – Particle ID.
size (float) – New particle size.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.
-
TP_MasterSystem.
SetScale
(self, pid, scale)¶ Sets the size for a particle.
- Parameters
pid (int) – Particle ID.
scale (c4d.Vector) – New particle scale.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.
-
TP_MasterSystem.
SetAlignment
(self, pid, align)¶ Sets the alignment matrix for a particle.
- Parameters
pid (int) – Particle ID.
align (c4d.Matrix) – New particle alignment matrix.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.
-
TP_MasterSystem.
SetRandomseed
(self, pid, seed)¶ Sets the alignment matrix for a particle.
- Parameters
pid (int) – Particle ID.
seed (int) – New particle random seed.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.
-
TP_MasterSystem.
SetCollision
(self, pid, collision)¶ Sets the collision handling information for a particle.
- Parameters
pid (int) – Particle ID.
collision (int) – Collision ID. This is
GetOperatorID()
for the node responsible for the collision handling.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.
-
TP_MasterSystem.
SetDTFactor
(self, pid, dt)¶ Sets the delta time factor for a particle.
- Parameters
pid (int) – Particle ID.
dt (float) – New particle delta time factor.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.
-
TP_MasterSystem.
SetColor
(self, pid, color)¶ Sets the color for a particle.
New in version R16.038.
- Parameters
pid (int) – Particle ID.
color (c4d.Vector) – New particle color.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.
-
TP_MasterSystem.
SetPData
(self, pid, chan, value)¶ Sets the data channel value for a particle:
pid = 1 chan = 0 ms.SetPData(pid, chan, "Hello World!")
- Parameters
pid (int) – Particle ID.
chan (int) – Channel index.
value (Union[int, float, str, c4d.Vector, c4d.BaseTime, c4d.Matrix, c4d.BaseList2D]) – The new value to set.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.IndexError – If chan is out of range : 0<=chan<
NumDataChannels()
.
- Return type
bool
- Returns
True on success, otherwise False.
-
TP_MasterSystem.
GetPData
(self, pid, chan)¶ Sets the data channel value for a particle:
pid = 1 chan = 0 value = ms.GetPData(pid, chan, "Hello World!")
- Parameters
pid (int) – Particle ID.
chan (int) – Channel index.
- Raises
IndexError – If pid is out of range : 0<=pid<
NumParticles()
.IndexError – If chan is out of range : 0<=chan<
NumDataChannels()
.
- Return type
Any
- Returns
Depends on the type of the channel.
-
TP_MasterSystem.
AddDataChannel
(self, type, str)¶ Adds a new data channel.
- Parameters
type (int) – Channel data type.
str (str) – Channel
- Return type
bool
- Returns
True if successful, otherwise False.
-
TP_MasterSystem.
RemoveDataChannel
(self, chan)¶ Removes a data channel.
- Parameters
chan (int) – Channel index.
- Raises
IndexError – If chan is out of range : 0<=chan<
NumDataChannels()
.- Return type
bool
- Returns
True if successful, otherwise False.
-
TP_MasterSystem.
NumDataChannels
(self)¶ Retrieves the data channel count.
- Return type
int
- Returns
Number of data.
-
TP_MasterSystem.
DataChannelType
(self, chan)¶ Retrieves the data type of a data channel.
- Parameters
chan (int) – Channel index.
- Raises
IndexError – If chan is out of range : 0<=chan<
NumDataChannels()
.- Return type
int
- Returns
Data type of channel chan.
-
TP_MasterSystem.
DataChannelName
(self, chan)¶ Retrieves the name of a data channel.
- Parameters
chan (int) – Channel index.
- Raises
IndexError – If chan is out of range : 0<=chan<
NumDataChannels()
.- Return type
str
- Returns
Number of data.
-
TP_MasterSystem.
DataChannelUniqueID
(self, chan)¶ Retrieves a unique ID for a data channel that’s independent of its index.
- Parameters
chan (int) – Channel index.
- Raises
IndexError – If chan is out of range : 0<=chan<
NumDataChannels()
.- Return type
int
- Returns
Unique ID of channel chan.
-
TP_MasterSystem.
DataChannelID
(self, unique_id)¶ Retrieves the index of a data channel from its unique ID.
- Parameters
unique_id (int) – Channel ID.
- Return type
int
- Returns
Data channel index.
-
TP_MasterSystem.
GetOperatorID
(self, op)¶ Retrieves an ID for op
- Parameters
op (c4d.modules.graphview.GvNode) – A node.
- Return type
int
- Returns
ID for op.
-
TP_MasterSystem.
GetDirty
(self)¶ - A dirty counter for the master system.This can be used to see if anything has changed. Use
SetDirty()
to increment the counter.- Return type
long
- Returns
Dirty counter. Is incremented when something changes in the system.
-
TP_MasterSystem.
SetDirty
(self)¶ Increments the dirty counter, i.e. tells anyone using
GetDirty()
that something has changed.Note
This has to be used whenever an operator affects particle shapes, like the ObjectShape operator does.
-
TP_MasterSystem.
CheckCollision
(self, collision, pid, t, pos, vel, dt)¶ Finds the node responsible for collision, the one that called SetCollision(), and tells it to evaluate the passed collision parameters.
Note
Normally Thinking Particles evaluates this function automatically for registered collisions.
- Parameters
collision (int) – The collision ID. This is GetOperatorID() for the node responsible for the collision.
pid (int) – The particle ID: 0 <= pid < NumParticles()
t (float) –
Time to evaluate the collision at.Collisions are detected between t - dt and t.pos (c4d.Vector) – Assigned the new position of the object if there is a collision.
vel (c4d.Vector) – Assigned the new velocity of the object if there is a collision.
dt (float) – The time since the last evaluation, i.e. the time to look backwards for collisions.
- Return type
tuple(bool, dict(“axis”: c4d.Vector, “speed”: float), float)
- Returns
A tuple filled in this order:
True if there was a collision, otherwise False.
dict with the next entries:
”axis”: Rotation axis.
”speed”: Rotation speed.
The collision time, if there was a collision. This is generally less than t.