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:

updateParticles particleSystem

Forces a particle update at the specified time.

numParticles()

Returns the number of particles.

numParticlesGenerated()

Returns the number of generated particles.

setEveryStepUpdateScriptLine script

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

setEveryStepUpdateScriptFile fileName

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

setFinalStepUpdateScriptLine script

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

setFinalStepUpdateScriptFile fileName

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

getUpdateTime()

Returns the current update time.

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.

getParticleID particleIndex

Returns the particle ID of the indexed particle.

hasParticleID 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.

getParticleGroup particleIndex

Returns the particle group node of the indexed particle.

getParticleIndex particleBornIndex

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

getParticleAge particleIndex

Returns the particle Age of the indexed particle.

getParticleAgeByID particleID

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

setParticleAge particleIndex

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

setParticleAgeByID particleID

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

getParticleLifeSpan particleIndex

Returns the life span time of the specified indexed particle.

getParticleLifeSpanByID particleID

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

setParticleLifeSpan particleIndex

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

setParticleLifeSpanByID particleID

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

getParticleGroupTime particleIndex

Returns the Group Time of the indexed particle.

getParticleGroupTimeByID particleID

Returns the Group Time of the particle specified by ID.

setParticleGroupTime particleIndex

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

setParticleGroupTimeByID particleID

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

getParticlePosition particleIndex

Returns the position of the indexed particle.

getParticlePositionByID particleID

Returns the position of the particle specified by ID.

setParticlePosition particleIndex position

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

setParticlePositionByID particleID position

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

getParticleSpeed particleIndex

Returns the speed of the indexed particle as Point3 value.

getParticleSpeedByID particleID

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

setParticleSpeed particleIndex speed

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

setParticleSpeedByID particleID speed

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

getParticleOrientation particleIndex

Returns the orientation of the indexed particle as Point3 value.

getParticleOrientationByID particleID

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

setParticleOrientation particleIndex orientation

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

setParticleOrientationByID particleID orientation

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

getParticleSpin particleIndex

Returns the Spin of the indexed particle as angleAxis value.

getParticleSpinByID particleID

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

setParticleSpin particleIndex spin

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

setParticleSpinByID particleID spin

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

getParticleScale particleIndex

Returns the size of the indexed particle as Float value.

getParticleScaleByID particleID

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

setParticleScale particleIndex scale

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

setParticleScaleByID particleID scale

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

getParticleScaleXYZ particleIndex

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

getParticleScaleXYZByID particleID

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

setParticleScaleXYZ particleIndex scaleXYZ

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

setParticleScaleXYZByID particleID scaleXYZ

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

getParticleTM particleIndex

Returns the Transformation Matrix of the inexed particle.

getParticleTMByID particleID

Returns the Transformation Matrix of the particle specified by ID.

setParticleTM particleIndex TM

Sets the Transformation Matrix of the indexed particle.

setParticleTMByID particleID TM

Sets the Transformation Matrix of the particle specified by ID.

getParticleSelected particleIndex

Returns the selected state of the indexed particle.

getParticleSelectedByID particleID

Returns the selected state of the particle specified by ID.

setParticleSelected particleIndex selected

Sets the selected state of the indexed particle.

setParticleSelectedByID particleID selected

Sets the selected state of the particle specified by ID.

getParticleShape particleIndex

Returns the shape of the indexed particle as mesh value.

getParticleShapeByID particleID

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

setParticleShape particleIndex shape

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

setParticleShapeByID particleID shape

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

setShapeForAllParticles 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