PDA

View Full Version : pflow script operator oddity


Haamu
02-04-2006, 01:28 AM
I am trying to create sort of particle trajectory using script operator in pflow. The script adds knots to existing spline shape.

on ChannelsUsed pCont do
(
pCont.useposition = true

)

on Init pCont do
(

)

on Proceed pCont do
(
pCont.particleIndex = 1
addknot $line 1 #corner #curve pcont.particleposition
updateshape $line
)

on Release pCont do
(

)
Now the weird thing is that at first it was working fine and i had some other functionalities there but when i started adding more complex stuff it started acting up. It is supposed to create only one knot per frame but instead it randomly creates 3 to 5 knots. If i run the anim frame by frame it works fine but when i actually play the anim it gets messed. it worked at first but now it doesn't and i'm totally confused :curious:. I guess i could -not add- new knots when there already is one in that place but how can i check that? Mainly, how can I check the position of the very last knot? I can't find any function for that :shrug:

question 2:
while editing the script operator it quite randomly while typing pops up an error message saying something like "there is an error in the script" and then jumps to the area where the error is supposed to be...while the error is actually the unfinished thing i'm just typing. It happens even when the script or whole pflow is disabled.Is there any way to disable this feature? It's kinda annoying.

Haamu
02-04-2006, 12:39 PM
Well reading the last knot was obvious enough (numknots and getknotpoint), it was 4 am so didn't think clearly :). However, not adding knots didn't quite work for some reason but deleting extra ones after creation did. Earlier, I noticed that sometimes when I open/close the script editor, select different object or save the scene, the knots jump to their correct positions, which could mean that the correct positions are stored but presented incorrectly (that isn't anyway visible in the script above but the correct version deletes knot accordingly to produce trail like effect and the trail is much shorter when created incorrectly). Also, when I exit the scene, max crashes so there is definitely something wrong here.

Haamu
02-06-2006, 03:01 PM
Took a while but I got it working. Here is the final script if someone is interested. It's still bit flawed but does its job for now.
on ChannelsUsed pCont do

(

pCont.usePosition = true

)



on Init pCont do

(
h=$trail
)



on Proceed pCont do

(
p = pCont.NumParticles()
if h==undefined then h=$trail
for i = 1 to p do
(
pCont.particleIndex = i
if (numsplines h) < i then addnewspline h
if numknots h i == 0 then
(
addknot h i #corner #curve pcont.particleposition
addknot h i #corner #curve pcont.particleposition
)
addknot h i #corner #curve pcont.particleposition
a=numknots h i
if getknotpoint h i a == getknotpoint h i (a-1) then deleteknot h i a
if numknots h i > 10 then
(deleteknot h i 1)

)--end for
updateshape h
)



on Release pCont do ( )


Just noticed that on init h variable should be global...that could explain few odd error :). The script simply creates a trail after a particle. Did a quick test too. Quite neat effect indeed and renders very fast compared to simply creating trail of particles, though I had to use mesher to get it update in renderer.
http://koti.mbnet.fi/sinko/host/trail2.avi
I still quite puzzled why it works differently when run step by step. I also noticed that it stops working if I rename the script operator. ehm, and why does it lag one frame behind the true particle position.

CGTalk Moderation
02-06-2006, 03:01 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.