Interface: particleObjectExt

The particleObjectExt Interface is exposed in Particle Flow Source Classes.

Properties:

.particleIndex : index : Read|Write|Validated by Range: 1 to 100000000

Get/Set the current particle index.

.particleID : index : Read|Write|Validated by Range: 1 to 100000000

Get/Set the current particle ID.

.particleAge : time : Read|Write|Validated by Range: 0f to 625000f

Get/Set the current particle Age.

.particleGroupTime : time : Read|Write|Validated by Range: 0f to 625000f

Get/Set the current particle Group Time.

.particlePosition : point3 : Read|Write

Get/Set the current particle position.

.particleSpeed : point3 : Read|Write

Get/Set the current particle speed.

.particleOrientation : point3 : Read|Write

Get/Set the current particle orientation.

.particleSpin : angleAxis : Read|Write

Get/Set the current particle spin.

.particleScale : float : Read|Write|Validated by Range: 0.0 to 1e+009

Get/Set the size of the current particle.

.particleScaleXYZ : point3 : Read|Write

Get/Set the Scale of the current particle as Point3 value.

.particleTM : matrix3 : Read|Write

Get/Set the Transformation Matrix of the current particle.

.particleSelected : bool : Read|Write

Get/Set the Selected state of the current particle

.particleShape : mesh : Read|Write

Get/Set the current particle’s mesh.

Examples and Results:

--Create a default PF Source in the Scene from the Create Tab.

--Get the Source by name to test the Interface Properties:

pf = $'PF Source 01'

$PF_Source:PF Source 01 @ [2.536594,-48.031052,0.000000]

--Get the curren particle's index

pf.particleIndex

1

--Change the particle index. Any subsequent

--properties will be from particle 2

pf.particleIndex = 2

2

--Check to make sure it worked...

pf.particleIndex

2

--Get the Particle ID of particle 2

pf.particleID

0

--Get the Particle Age on frame 0

--This is a newborn particle, age is 0!

pf.particleAge

0f

--Now change the scene time to frame 10...

sliderTime = 10

10

--...and get the Age again –

--10 frames later, the Age is 9.7 frames!

pf.particleAge

9.7f

--Check whether particle 2 is selected

--No, it is not

pf.particleSelected

false

--Change to Modify panel

max modify mode

OK

--Change to Particle sub-object level

subObjectLevel = 1

1

--Select Particle 2 - one particle

--should turn red in the viewport

pf.particleSelected = true

true

--Get the particle position

pf.particlePosition

[12.1301,-40.7149,-96.9697]

--You can change it -

--The Particle should move there...

pf.particlePosition = [10.0,-10.0,-40.0]

[10,-10,-40]

--Get the Speed of particle 2

pf.particleSpeed

[0,0,-0.0625]

--Get the Orientation of particle 2

pf.particleOrientation

[-2.75317,-1.18547,-0.402363]

--Get the Spin of particle 2

pf.particleSpin

(angleAxis 0 [1,0,0])

--Get the size of the particle

pf.particleScale

16.3299

--Get the Scale of the particle

pf.particleScaleXYZ

[1,1,1]

--Get the complete TM of the particle

pf.particleTM

(matrix3 [0.345842,-0.147184,0.926677] [-0.0394943,-0.989029,-0.142347] [0.937461,0.0126313,-0.34786] [12.1301,-40.7149,-96.9697])

--Get the Shape as TriMesh.

msh = pf.particleShape

TriMesh

--Take a look at the number of vertices

msh.numverts

4

--...and the number of faces

msh.numfaces

4

--Why not take a look at the actual TriMesh?

--Create a new empty Editable Mesh

new_mesh = Editable_mesh()

$Editable_Mesh:Object01 @ [0.000000,0.000000,0.000000]

--Assign the shape snapshot to the mesh

new_mesh.mesh = msh

TriMesh

--And finally update all caches of the Emesh to see the result:

update new_mesh

OK

 

 

Methods:

<void>updateParticles <node>particleSystem <time>time

Forces a particle update at the specified time.

<integer>numParticles()

Returns the number of particles.

<integer>numParticlesGenerated()

Returns the number of generated particles.

<void>setEveryStepUpdateScriptLine <string>script

Sets the script string to be executed on every update step.

<void>setEveryStepUpdateScriptFile <filename>fileName

Sets the script file to be executed on every update step.

<void>setFinalStepUpdateScriptLine <string>script

Sets the script string to be executed at the final update step.

<void>setFinalStepUpdateScriptFile <filename>fileName

Sets the script file to be executed at the final update step.

<time>getUpdateTime()

Returns the current update time.

<void>getUpdateInterval <&time>timeStart <&time>timeEnd

timeStart is In and Out parameter

timeEnd is In and Out parameter

Returns the update interval in the two by-reference variables.

<index>getParticleID <index>particleIndex

Returns the particle ID of the indexed particle.

<bool>hasParticleID <index>particleBornIndex <&index>particleIndex

particleIndex is In and Out parameter

Returns true if a particle with the specified particle birth ID exists. Returns the actual particle index in the specified by-reference variable.

<node>getParticleGroup <index>particleIndex

Returns the particle group node of the indexed particle.

<index>getParticleIndex <index>particleBornIndex

Returns the particle index of the particle with the specified birth index.

<time>getParticleAge <index>particleIndex

Returns the particle Age of the indexed particle.

<time>getParticleAgeByID <index>particleID

Returns the particle Age of the particle specified by particle ID.

<void>setParticleAge <index>particleIndex <time>age

Sets the particle age of the specified indexed particle to the specified age value.

<void>setParticleAgeByID <index>particleID <time>age

Sets the particle age of the particle specified by ID to the specified age value.

<time>getParticleLifeSpan <index>particleIndex

Returns the life span time of the specified indexed particle.

<time>getParticleLifeSpanByID <index>particleID

Returns the life span time of the particle specified by ID.

<void>setParticleLifeSpan <index>particleIndex <time>lifeSpan

Sets the life span time of the indexed particle to the specified lifeSpan value.

<void>setParticleLifeSpanByID <index>particleID <time>lifeSpan

Sets the life span time of the particle specified by ID to the specified lifeSpan value.

<time>getParticleGroupTime <index>particleIndex

Returns the Group Time of the indexed particle.

<time>getParticleGroupTimeByID <index>particleID

Returns the Group Time of the particle specified by ID.

<void>setParticleGroupTime <index>particleIndex <time>age

Sets the Group Time of the indexed particle to the specified age value.

<void>setParticleGroupTimeByID <index>particleID <time>age

Sets the Group Time of the particle specified by ID to the specified age value.

<point3>getParticlePosition <index>particleIndex

Returns the position of the indexed particle.

<point3>getParticlePositionByID <index>particleID

Returns the position of the particle specified by ID.

<void>setParticlePosition <index>particleIndex <point3>position

Sets the position of the indexed particle to the specified Point3 value.

<void>setParticlePositionByID <index>particleID <point3>position

Sets the position of the particle specified by ID to the specified Point3 value.

<point3>getParticleSpeed <index>particleIndex

Returns the speed of the indexed particle as Point3 value.

<point3>getParticleSpeedByID <index>particleID

Returns the speed of the particle specified by ID as Point3 value.

<void>setParticleSpeed <index>particleIndex <point3>speed

Sets the speed of the indexed particle to the specified Point3 value.

<void>setParticleSpeedByID <index>particleID <point3>speed

Sets the speed of the particle specified by ID to the specified Point3 value.

<point3>getParticleOrientation <index>particleIndex

Returns the orientation of the indexed particle as Point3 value.

<point3>getParticleOrientationByID <index>particleID

Returns the orientation of the particle specified by ID as Point3 value.

<void>setParticleOrientation <index>particleIndex <point3>orientation

Sets the orientation of the indexed particle to the specified Point3 value.

<void>setParticleOrientationByID <index>particleID <point3>orientation

Sets the orientation of the particle specified by ID to the specified Point3 value.

<angleAxis>getParticleSpin <index>particleIndex

Returns the Spin of the indexed particle as angleAxis value.

<angleAxis>getParticleSpinByID <index>particleID

Returns the Spin of the particle specified by ID as angleAxis value.

<void>setParticleSpin <index>particleIndex <angleAxis>spin

Sets the Spin of the indexed particle to the specified AngleAxis value.

<void>setParticleSpinByID <index>particleID <angleAxis>spin

Sets the Spin of the particle specified by ID to the specified angleAxis value.

<float>getParticleScale <index>particleIndex

Returns the size of the indexed particle as Float value.

<float>getParticleScaleByID <index>particleID

Returns the size of the particle specified by ID as Float value.

<void>setParticleScale <index>particleIndex <float>scale

Sets the size of the indexed particle to the specified Float value.

<void>setParticleScaleByID <index>particleID <float>scale

Sets the size of the particle specified by ID to the specified Float value.

<point3>getParticleScaleXYZ <index>particleIndex

Returns the Scale of the indexed particle as a Point3 value.

<point3>getParticleScaleXYZByID <index>particleID

Returns the Scale of the particle specified by ID as a Point3 value.

<void>setParticleScaleXYZ <index>particleIndex <point3>scaleXYZ

Sets the Scale of the indexed particle to the specified Point3 value.

<void>setParticleScaleXYZByID <index>particleID <point3>scaleXYZ

Sets the Scale of the particle specified by ID to the specified Point3 value.

<matrix3>getParticleTM <index>particleIndex

Returns the Transformation Matrix of the inexed particle.

<matrix3>getParticleTMByID <index>particleID

Returns the Transformation Matrix of the particle specified by ID.

<void>setParticleTM <index>particleIndex <matrix3>TM

Sets the Transformation Matrix of the indexed particle.

<void>setParticleTMByID <index>particleID <matrix3>TM

Sets the Transformation Matrix of the particle specified by ID.

<bool>getParticleSelected <index>particleIndex

Returns the selected state of the indexed particle.

<bool>getParticleSelectedByID <index>particleID

Returns the selected state of the particle specified by ID.

<void>setParticleSelected <index>particleIndex <bool>selected

Sets the selected state of the indexed particle.

<void>setParticleSelectedByID <index>particleID <bool>selected

Sets the selected state of the particle specified by ID.

<mesh>getParticleShape <index>particleIndex

Returns the shape of the indexed particle as mesh value.

<mesh>getParticleShapeByID <index>particleID

Returns the shape of the particle specified by ID as mesh value.

<void>setParticleShape <index>particleIndex <mesh>shape

Sets the shape of the indexed particle to the specified mesh value.

<void>setParticleShapeByID <index>particleID <mesh>shape

Sets the shape of the particle specified by ID to the specified mesh value.

<void>setShapeForAllParticles <mesh>shape

Sets the shape of all particles to the specified mesh value.

 

Examples and Results:

--Create a new Particle Flow Source in the Viewport,

--then get it by name from the scene

pf = $'PF Source 01'

$PF_Source:PF Source 01 @ [2.536594,-48.031052,0.000000]

--Set the scene time to frame 10

sliderTime = 10

10

--Update the particles at time 10

pf.updateParticles pf 10f

OK

--Get total number of particles at current time

pf.numParticles()

34

--Get the total number of particles generated up to the current time

pf.numParticlesGenerated()

34

--Get the particles update time

pf.getUpdateTime()

10f

--Initialize two user variables to 0

ts = te = 0

0

--Set scene time to frame 10

sliderTime = 10f

10f

--Get the update interval into the variables passed by reference

pf.getUpdateInterval &ts &te

OK

--Check the start time

ts

9f

--Check the end time

te

10f

pf.getParticleID 34 --Get the particle ID of the 34th particle

34

--Try to get the 35th particle.

--There are only 34 particles, so ID is 0

pf.getParticleID 35

0

--Initialize a variable to pass by reference

idx = 0

0

--Check if there is particle with ID 34 –

--Yes, there is one

pf.hasParticleID 34 &idx

true

--and its index is 34

idx

34

--Check the same about particle ID 35 –

--no, there is none

pf.hasParticleID 35 &idx

false

--Get the Particle Group node

pf.getParticleGroup 2

$Particle_Group:PF Source 01->Event 01 @ [0.000000,0.000000,0.000000]

--Get the index of particle 34

pf.getParticleIndex 34

34

--Get the index of particle 35

--No such particle ID, index is 0

pf.getParticleIndex 35

0

--Get the particle age of particle 2

pf.getParticleAge 2

9.7f

--Get the particle age of particle ID 2 –

--It is the same particle!

pf.getParticleAgeByID 2

9.7f

--Get the particle age of particle 34

--It was born later, age is smaller

pf.getParticleAge 34

9f

--Set age of particle 2 to 5 frames

pf.setParticleAge 2 5f

OK

--Check to see if it worked - It did!

pf.getParticleAge 2

5f

--Get the life span of particle 2

--Who wants to live forever? This one!

pf.getParticleLifeSpan 2

1.34218e+007f

--Change the life span of particle 2

pf.setParticleLifeSpan 2 10f

OK

--Check again – it changed!

pf.getParticleLifeSpan 2

10f

--Get the Group Time of Particle 2

pf.getParticleGroupTime 2

0f

–-Set the Particle Group Time to 10

pf.setParticleGroupTime 2 10f

OK

--Get the time again – it was set!

pf.getParticleGroupTime 2

10f

--Let’s change the mesh of particle 2 to a Geosphere

gs = (geosphere radius:5).mesh

TriMesh

--Change the Display to Geometry

pf.Event_01.Display_01.Type = 6

6

--Set the particle mesh

--One particle should become a Geosphere!

pf.setParticleShape 2 gs

OK

--Get the mesh of a teapot

tp = (teapot radius:5).mesh

TriMesh

--and assign to all particles – they should turn into teapots!

--IT’S TEA TIME!

pf.setShapeForAllParticles tp

OK

This Interface is available in:

PF_Source : GeometryClass

ParticleGroup : GeometryClass

 

See also

Particle Flow Interfaces