PDA

View Full Version : Chunks birth script : how to create chunks every nth frame


reForm
04-30-2008, 12:35 PM
This is my first attempt at scripting particles so please excuse my confusion.

How do I adapt the chunk script (below) so that instead of creating all the particles at frame 0 (t<0), the particles are birthed every nth frame.

I assume I need to change the "if t < 0 do" to something like "for t=0 to numChunks by x" where x is the number of frames I want between each particle being birthed. Or am I, as I suspect, barking up the wrong tree? :)


on ChannelsUsed pCont do
(
pCont.useTime = true --enable the Time channel
pCont.useAge = true
pCont.useTM = true
pCont.useShape = true
)

on Init pCont do
(
global ChunksArray = $parts* as array
)

on Proceed pCont do
(
t = pCont.getTimeStart() as float

if t < 0 do
(
NumChunks = ChunksArray.count

for i = 1 to NumChunks do
(
pCont.AddParticle()
pCont.particleIndex = pCont.NumParticles()
pCont.particleAge = 0
pCont.particleTM = ChunksArray[i].transform
pCont.particleShape = ChunksArray[i].mesh
)
)
)

on Release pCont do
(

)

reForm
04-30-2008, 02:21 PM
Ok, managed to suss it out.



on ChannelsUsed pCont do
(
pCont.useTime = true --enable the Time channel
pCont.useAge = true
pCont.useTM = true
pCont.useShape = true
)

on Init pCont do
(
global ChunksArray = $parts* as array
)

on Proceed pCont do
(
t = pCont.getTimeStart() as float

if t > 0 do
(
NumChunks = ChunksArray.count
tt = ((t/160)+1)
pCont.AddParticle()
pCont.particleIndex = pCont.NumParticles()
pCont.particleAge = 0
pCont.particleTM = ChunksArray[tt].transform
pCont.particleShape = ChunksArray[tt].mesh
--pCont.particleOrientation = [0,0,0]
pCont.particleOrientation += [90,0,0]
)

)

on Release pCont do
(

)

supremepizza
05-02-2008, 09:13 PM
Thanks for posting the code.

Much appreciated.

reForm
05-02-2008, 10:28 PM
Be warned... my code is crap. I think it causes the script to crash when you run out of chunks to create particles from... ie when you scrub the timeline past the birth of the last particle. It works, but not very cleanly.

supremepizza
05-04-2008, 03:54 AM
That's fairly common and I wouldn't worry about if it's a one use deal. If you're going to do alot of this you'll want to bake the particle animation. Then you can scrub to your heart's content.

CGTalk Moderation
05-04-2008, 03:54 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.