View Full Version : pflow script hello world!
HornBerger 01-26-2010, 12:27 PM hey! i just started learning pflow scripting i am in "hello world" phase so forgive me if the question sounds newbish! anyways there's something that keeps bugging me... the pcont.particleEventTime does not take any index as parameter then how does it return the event time of a particle, I mean when its inside the for loop it works correctly and returns the event time of the i'th particle in the loop (right?) but what if i am at frame, say 60 and i wont to know the event age of my, say 204th particle ? do i have to use a loop to do this ?
on Proceed pCont do
(
count = pCont.NumParticles()
-- print pCont.particleEventTime as string -- what does it mean here?
for i in 1 to count do
(
pCont.particleIndex = i
-- print pCont.particleEventTime as string -- what does it mean here?
)
)
any help is appreciated thanks!
|
|
hey! i just started learning pflow scripting i am in "hello world" phase so forgive me if the question sounds newbish! anyways there's something that keeps bugging me... the pcont.particleEventTime does not take any index as parameter then how does it return the event time of a particle, I mean when its inside the for loop it works correctly and returns the event time of the i'th particle in the loop (right?) but what if i am at frame, say 60 and i wont to know the event age of my, say 204th particle ?
pCont is the Particle Container of the Event where the particles live.
The particles inside the Container are indexed from 1 to the number of particles, without gaps.
The pCont.particleSOMEPROPERTY properties reflect the content of the particle's channels.
You can access the property of exactly one particle at a time, based on the current particle set using pCont.particleIndex. In other words, pCont.particleIndex points at the particle you are currently operating on. When the pCont.particleIndex is not set, it might point at no particle at all so the property values returned could be bogus.
To access particle with index 204, all you have to do is set the pCont.particleIndex=204 and then do whatever you want - outside or inside a loop. The For loop in typical Script Operators is there so you can apply some operation on ALL particles (it loops through their indices and sets pCont.particleIndex to 1 to last particle's index), but if your Script Operator is supposed to work with a specific particle, you can remove the loop and just set the index (best by ID, since the index depends on what particles are in and out of the Event) and work with the one particle only. See this example where particle with ID 400 is looked for in the pCont and if it exists, its transform is used to drive a camera. (http://www.scriptspot.com/bobo/mxs5/pflow/pflow__RideTheFlow.htm)
This was about the properties. There are also some methods that let you access (get and set) data using the Particle's ID. These methods are of course not affected by the current pCont.particleIndex pointer and get parameters passed to them to determine what particle to operate on.
Hope this helps.
HornBerger
01-26-2010, 03:53 PM
thanks for the detailed reply Bobo and for the amazing tutorial as well :bowdown:it cleared a few misconceptions i had regarding the structure of the pCont. Also now i understand the difference between the particle ID and the particle index i.e the particle index and particle ID are different entities where the particle ID is alloted once per particle and remains constant throught out the particles life, whereas the index of a particle changes as it moves from event to event that is the reason why i think the camera example uses the rideParticleID instead of the rideParticleIndex ! pretty neat :) earlier i was thinking of pCont as a OOP class therefore the thought about the pcont.particleEventTime () as a member function occured to me anyways its clear now! Thanks once again! i can now contiue my reading of the sample scripts in the maxscript help file ..
Cheers!!!
ps: there is just 1 annoying feature about particle flow i.e the viewport particle % is defaulted to 50% is there a way to default it to a 100%.... using the macro recorder i found this : $'PF Source 01'.Quantity_Viewport = 100 but how do i impletment it for all the pf source created ? is there a callback function associated with the creation of pf souce that could be used to assign this value?
Thanks For your help!
ps: there is just 1 annoying feature about particle flow i.e the viewport particle % is defaulted to 50% is there a way to default it to a 100%.... using the macro recorder i found this : $'PF Source 01'.Quantity_Viewport = 100 but how do i impletment it for all the pf source created ? is there a callback function associated with the creation of pf souce that could be used to assign this value?
*Open a new script.
*Paste the code:
callbacks.removeScripts id:#pflowviewpercent
callbacks.addScript #nodeCreated "try(theNode = callbacks.notificationParam(); if classof theNode == PF_Source do theNode.Quantity_Viewport = 100)catch()" id:#pflowviewpercent
*Press Ctrl+E to evaluate
*Save to disk into the \Scripts\Startup folder to run on each Max start.
HornBerger
01-26-2010, 09:55 PM
Bobo I cannot thank you enough ! the Next autodesk master ! :bowdown:
Bobo I cannot thank you enough ! the Next autodesk master ! :bowdown:
Next? What do you mean Next? :surprised
Glad it worked.
HornBerger
01-27-2010, 06:45 AM
have a look here : http://area.autodesk.com/masters i google'd later and found you had got the 2006 autodesk master award:bowdown:
CGTalk Moderation
01-27-2010, 06:45 AM
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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.