Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Tracing and tracking specific particles produces interesting results, especially when they become meshed later or when a particular object is applied. With this method it is possible to create trails from selected particles and display them either with the help of objects or new particles.

 

Name

ParticleTracker .rfs

Type

Simulation Events

Description

The script records the position data from one or more particles and makes them visible with the help of new particles or "Null" objects. Particles are shifted to a new emitter, "Nulls" are added at the end of the simulation and automatically grouped. 

...

Code Block
themeEclipse
languagepython
linenumberstrue
# FramesPost

emitter    = scene.getEmitterget_PB_Emitter("Square01")
tracker    = scene.getEmitterget_PB_Emitter("Tracker")
idList     = [1,56,145,354,508,722,1032,1195,1482,1648,2000]
nullVec    = Vector.new(0,0,0)
e_particle = emitter.getFirstParticle()

while (e_particle):
    currentId = e_particle.getId()

    if (currentId in idList):
        pos = e_particle.getPosition()
        tracker.addParticle(pos, nullVec)
        e_particle = e_particle.getNextParticle()

t_particle = tracker.getFirstParticle()

while (t_particle):
    t_particle.freeze()
    t_particle = t_particle.getNextParticle()

...

This does not look very sophisticated, but in fact it is! Imagine several simulations with a different group name each time. With this short version you do not have to keep track of the group’s name, because everything is directly stored with the variable. That is very convenient for lots of objects and important when you rename the "Nulls" – which happens in the next step. Before you can add the "Nulls" it is necessary to create a new name for each item. The naming pattern should contain leading 0 characters to allow easy and correct sorting:

Tracker0001 -> Tracker0010 -> Tracker0100 -> Tracker1000+

This kind of naming can be done with a counter and few simple if-conditions which are already familiar from the first example “Placing Object”:

...

This construction allows you to specify your own “file padding”. The str(variable) instruction is used to mix a given string with the content of variables. This does not work with vectors, because they are stored in a hexadecimal format, but here only simple scalars are used. Finally a few basic operations are done to rescale and dye the "Null" nodes and add them to the group. This should be basic stuff now, except adding the new items to the appropriate group. Another new feature that is introduced here is to prevent the "Null" nodes from being exported to disk. Although that is more important for a script version where the "Nulls" are created during the simulation process, it is still worth showing you how to manipulate "Export Central" with Python. The notation is:

...