PDA

View Full Version : Spin by Age script operator for pflow?


avolution
01-21-2009, 01:02 PM
For the life of me, I can not figure out how to create a script where the
spin rate increases as the particle age increases.

Here is the script so far, it shows via display script that all the
particle spin rate increased per frame, but not per particle age.

Any help is most appreciated!

-- This is a script that can be used to set up particle spin
--
-- Created: 4-17-2006
-- Last Updated:
--
-- Author : Oleg Bayborodin
-- Version: 3ds max 6.0
--********************************************************************
-- MODIFY THIS AT YOUR OWN RISK

on ChannelsUsed pCont do
(
pCont.useOrientation=true
pCont.useSpin = true
--pCont.useVector=true
pCont.useFloat=true
)

on Init pCont do ()

on Proceed pCont do
(
count = pCont.NumParticles()
for i in 1 to count do
(
CurAge=pCont.particleAge
pCont.particleIndex = i
sp = pCont.particleSpin
sp.angle = 360.0*(CurAge/75.0)/4800
sp.axis = [1, 0, 0]
pCont.particleSpin = sp
--pCont.particleVector=sp.axis
pCont.particleFloat=sp.angle
)
)

on Release pCont do ()

Piflik
01-21-2009, 01:15 PM
Maybe

pCont.useAge = true

in the "ChannelsUsed" part.

DaveWortley
01-21-2009, 03:48 PM
Yes as Piflik says you're missing the useAge = true, then it will work.

D

avolution
01-21-2009, 04:55 PM
That was an oversite from the script I copy/pasted.
My scripts that don't work have the useAge=true.

You see if you set up multiple birthed boxes, use the script to spin them
yes the spin rate increased with time; but the seperate boxes still have the
same spin rate on each frame.


This was the script I should have included

on ChannelsUsed pCont do
(
pCont.useOrientation=true
pCont.useSpin = true
pCont.useAge = true
)

on Init pCont do ()

on Proceed pCont do
(
count = pCont.NumParticles()
for i in 1 to count do
(



CurAge=pCont.particleAge
pCont.particleIndex = i
sp = pCont.particleSpin
sp.angle = (180.0/4800)*((CurAge+1)/75.0)
sp.axis = [1, 0, 0]
pCont.particleSpin = sp
-- print Sp

)
)

on Release pCont do ()





Yes as Piflik says you're missing the useAge = true, then it will work.

D

Piflik
01-21-2009, 05:10 PM
I think you have to swap these two lines to get the CurAge Variable get the correct Age value:

CurAge=pCont.particleAge
pCont.particleIndex = i

But I'm not entirely sure, since I don't script too much.

Bobo
01-21-2009, 05:30 PM
Mark, it actually appears to be working here.
I created 10 particles over 100 frames (and just swapped the particleIndex line to be the first thing in the loop to be perfect) and the boxes accelerate their spin rate as they are getting older. Not sure what the problem is, can you explain or post a quicktime?

Piflik
01-21-2009, 05:38 PM
No wonder it worked...you followed my advice :D

avolution
01-21-2009, 07:33 PM
When I swap the lines as indicated it works.

Thanks for your help
Question: why is the order of the lines so important
they are both inside the for i in 1 to count loop?

Mark, it actually appears to be working here.
I created 10 particles over 100 frames (and just swapped the particleIndex line to be the first thing in the loop to be perfect) and the boxes accelerate their spin rate as they are getting older. Not sure what the problem is, can you explain or post a quicktime?

Piflik
01-21-2009, 07:35 PM
All functions like pCont.ParticleAge or pCont.ParticleSpin need to know, on which particle they are applied. That does the particleIndex = i and since the lines are run through sequencially, that line has to be before anything else. (methinks :D)

avolution
01-21-2009, 08:37 PM
See I am learning from the masters already!
Thanks


All functions like pCont.ParticleAge or pCont.ParticleSpin need to know, on which particle they are applied. That does the particleIndex = i and since the lines are run through sequencially, that line has to be before anything else. (methinks :D)

Piflik
01-21-2009, 08:46 PM
I wouldn't consider myself "Master" im just a humble Disciple. Bobo is the Master. :bowdown: :bowdown: :bowdown:

Bobo
01-21-2009, 10:30 PM
I wouldn't consider myself "Master" im just a humble Disciple. Bobo is the Master. :bowdown: :bowdown: :bowdown:

You did well, young padawan!

CGTalk Moderation
01-21-2009, 10:30 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.