yangin0
09-09-2009, 09:04 PM
I read that you can loop the PFlow using Script Operator and Find Target on Max help page. I followed the instruction but having trouble setting it up right. Help?
Tip-In a particle loop, all particles end up at their respective starting positions, enabling seamless repetition of the resulting animation. You can make particle loops with Particle Flow using a Script operator and a Find Target operator. At the start of the loop, the Script operator should read all particle positions and write them into the MXS Vector channel. Then, at the end of the loop, set the Find Target operator to Control by Time, set Timing to Absolute Time, set Time to the end of the loop, and in the Target group, set Point to By Script Vector. Particle Flow will direct particles to the previously cached position at the specified frame.
Following is an example of the script operator that can be used when the Target group > Object > By Script Integer option is active. It assigns the target objects according to particle speed. If the speed is below 1 unit per frame, then the particle is assigned to the first target (index=0). If the speed is higher than 10 units per frame then the particle is assigned to the third target (index=2). All other particles are assigned to the second target (index=1).
Script example is at the end of the post. I am failing to set Target group > Object > By Script Integer option active because object is not active. Object dropdown description says it is only active when multiple objects are set to be target, but I don't have target objects because I'm trying to use initial particle positions at the start of the loop.
Anybody done this before?
on ChannelsUsed pCont do( pCont.useTime = true pCont.useSpeed = true pCont.useInteger = true) on Init pCont do ( ) on Proceed pCont do ( count = pCont.NumParticles() slowSpeed = 1/160.0 fastSpeed = 10/160.0 for i in 1 to count do ( pCont.particleIndex = i if length(pCont.particleSpeed) < slowSpeed then pCont.particleInteger = 0 else ( if (length(pCont.particleSpeed) > fastSpeed) then pCont.particleInteger = 2 else pCont.particleInteger = 1 ) )) on Release pCont do ( )
Tip-In a particle loop, all particles end up at their respective starting positions, enabling seamless repetition of the resulting animation. You can make particle loops with Particle Flow using a Script operator and a Find Target operator. At the start of the loop, the Script operator should read all particle positions and write them into the MXS Vector channel. Then, at the end of the loop, set the Find Target operator to Control by Time, set Timing to Absolute Time, set Time to the end of the loop, and in the Target group, set Point to By Script Vector. Particle Flow will direct particles to the previously cached position at the specified frame.
Following is an example of the script operator that can be used when the Target group > Object > By Script Integer option is active. It assigns the target objects according to particle speed. If the speed is below 1 unit per frame, then the particle is assigned to the first target (index=0). If the speed is higher than 10 units per frame then the particle is assigned to the third target (index=2). All other particles are assigned to the second target (index=1).
Script example is at the end of the post. I am failing to set Target group > Object > By Script Integer option active because object is not active. Object dropdown description says it is only active when multiple objects are set to be target, but I don't have target objects because I'm trying to use initial particle positions at the start of the loop.
Anybody done this before?
on ChannelsUsed pCont do( pCont.useTime = true pCont.useSpeed = true pCont.useInteger = true) on Init pCont do ( ) on Proceed pCont do ( count = pCont.NumParticles() slowSpeed = 1/160.0 fastSpeed = 10/160.0 for i in 1 to count do ( pCont.particleIndex = i if length(pCont.particleSpeed) < slowSpeed then pCont.particleInteger = 0 else ( if (length(pCont.particleSpeed) > fastSpeed) then pCont.particleInteger = 2 else pCont.particleInteger = 1 ) )) on Release pCont do ( )
