PDA

View Full Version : Particles to follow vertices



Saxcore
12-23-2009, 08:04 AM
Hi everyone!

I've looked far and wide for the answer to this one, however do point me in the right direction if this is covered somewhere and I've completely missed it.

Essentially I'm going to be animating a mesh in Maya. This mesh is then imported into Realflow as SD. I then want a particle to follow each of the vertices of the mesh when the mesh moves around (the mesh is not used in the simulation in any way, other than for it's vertex positions); naturally this is going to require some scripting. So far I've written the script that initialises this procedure, so that an emitter creates one particle at each and every vertex of a mesh. The trouble I'm now having is getting the particles to update their positions to move to the new position that their corresponding vertex has moved to, each frame.

To make this a little bit more tricky, the particles that are following the object are "dumb" particles until they collide with another object. When they collide, they are "moved" to a second emitter that is of the "liquid" type (particles are moved in the sense that they are deleted from one emitter, and an identical particle is created in another emitter). Particles in this emitter no longer follow their allocated vertex, and become fully dynamic (and thus fall to the ground, splash around, etc). So far, this bit of the script is working. However, the particles don't follow their mesh each frame (i.e. they remain perfectly in the shape that the object was in a frame 0, until another object moves into them, which then makes them "transfer" to the second emitter, fully dynamic).

The algorithm I'm using at the moment to update the dumb particle's positions each frame (to follow the object) uses the particle's ID; looping through all particles remaining in the dumb emitter, I can get a position to move to by finding it's corresponding vertex in a vertex list. To work out which vertex in this list to follow, I'm using the particle's ID (casting it as an int) as the element to access. (there is DEFINITELY a better way to explain this bit :) )

..Urgh. Not only this is proving incredibly hard to explain, but it is sounding a lot more complicated than it actually is! I could post the onSimulationStep() function definition if it would help?

Basically, I'm wondering if there is a good way to link the position of a particle to the position of a vertex of an object. I'm sure it can be done, as I've actually had one particle following the "last" vertex at some points in the development history of this script!

Anyway, thanks for reading! ..and thanks in advance for any help.

Sam.