PDA

View Full Version : Particle Flow looping using Find Target


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 ( )

Piflik
09-10-2009, 10:44 AM
First, try formating your script, so it is easier to read...
Second, I need to look at your Flow to be able to say anything...
Third, you can tell us what you are trying to achieve. Maybe there is another way...

All I can say right now is, that you script doesn't seem to do anything useful in your situation. You need to write the Position of the Particles into the particles Vector Channel.
The Integer Channel is for the use with multiple Targets.

Try the following script instead:

on ChannelsUsed pCont do
(
pCont.usePosition = true
pCont.useVector = true
)

on Init pCont do ()

on Proceed pCont do
(
count = pCont.NumPArticles()

for i in 1 to count do
(
pCont.ParticleIndex = i
pCont.ParticleVector = pCont.ParticlePosition
)
)

on Release pCont do ()

Then in the Find Target Test you choose 'by Script Vector' in the 'Point' dropdown list. (Again, Script Integer is to choose between multiple target objects, hence it is in the 'Object' dropdown list)

yangin0
09-10-2009, 03:43 PM
I tried out putting your script in and it started working!
I don't know how to read the script so didn't really understand what first script did.

I'm sending the particle out to a target>go back to original position to make looping animation
The problem I am having now are;
-particles get close to where they started but not exactly to the same point

so instead of going back to frame 0, I try lengthen the animation and particle life, and sending old particles back to the first event, but
-particles doesn't seem to react same to the following event second time

I'm gonna study it more later and see if I can get it working exactly as I want...may ask more questions about this
Thank you very much for your help.

ps. how do I format the code? It kept collapsing on me
Is there a way to post the max file?

CGTalk Moderation
09-10-2009, 03:43 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.