getting per particle rotation to stop after collision with floor?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
Old 01 January 2009   #1
getting per particle rotation to stop after collision with floor?

okay so I have a simple particle that emits and bounces onto the ground.
I've setup an extra attribute on the particle - vector PP called rotPP (clever huh)

in the creation expression I have:

particleShape5.rotPP = << rand (0,360), rand (0,360), rand (0,360)>>;

in the runtime BEFORE dynamics I have

particleShape5.rotPP = particleShape5.rotPP + rand (1,4);

now I want to setup a simple script that stops the rotation after colliding with the floor so I added a particle collision event. Then in my particleShape5 a added this expression into the runtime AFTER dynamics..

if (particleShape5.event >= 1)
particleShape5.rotPP = <<0,0,0>>;

prob is that every particle hits the ground then zero's its current rotation out. Is there any way for me to get the rotation that it has when it hits the ground?
Old 01 January 2009   #2
well, perhaps it would be easier only to increment your rotation if the collision hasn't occured yet ?? (an additional if statement in run before dynamics)
additional, when I work with my paticles rotation I tend not to randomize the amout of roatation added, because in most cases you want high speed rotation and low speed rotation of the particles - not particles randomly changing rotation speed (I hope it's understandable in English ) - so normally I create an additional per particle variable like deltaRotation which is generated at creation, and then added every single frame (I also tend to use vectors and sphrand rather then scalars and rand) - in that case you could simply zero the deltaRotation value at collision moment
Old 01 January 2009   #3
wow thanks globus - thats a good basic explanation - the bit you mention about adding the IF statement in the runtime before dynamics bit is kinda useful.

I use the rand function in my vector PP attribute to generate a random xyz rotation value at creation - then I'm simply adding to it in runtime. I like this because each particle is born with a different rotation value.
the rand function in the runtime that I have gives a rotation value that varies the speed of each particle so some particles spin very slowly - others spin fast. theres no variation in the rotation speed with each particle.

the 2nd bit about delta rotation is interesting - do you have a mel example that I could possibly see please? I know I'm asking you to kinda solve my query there and I can kinda see what you are explaining but I dont really know the way about writing it down :/

Last edited by anthonymcgrath : 01 January 2009 at 01:40 PM.
Old 01 January 2009   #4
if you use rand at runtime you will get particles with rotation speed varying from frame to frame which is not always what you want, the difference is:
A)your rand version:
particle is born with rotation (10,20,30) (for example)
frame1: rotation + random rotation -> (10,20,30) + (1,1,1) - which is "slow version"
frame2: rotation + + random rotation-> (11,21,31) + (4,4,4) - which is fast
frame3: (15,25,35) + (2,2,2) -> medium version
f4: fast
f5: slow
and so on and so on
so particle accelerates differently from frame to frame and always goes in the same rotation direction (because of one rand - which gives scalar not vector) only at different speeds beacues it's always positive X positive Y and positive Z rotation, although the starting rotation is random, you get a similar rotation in the end

B) my typical random rotation setup:
additional per particle vector : deltaRotPP
create it's random value at creation: deltaRotPP=sphrand(4); (gives a random vector from <<-4,-4,-4>> to <<4,4,4>> each coordinate separately)
in runtime: rotPP+=deltaRotPP (incrementing our rotation)
in runtime: if collision occurred deltaRotPP=0;

in B) case we get a stable rotation speed in a random (but stable) direction, because each particle is rotated at a constant speed (because direction and rotation increment value is generated at birth by our sphrand expression)

I usually get my deltaRotPP sphrand values controlled by additional parameter so it's easy to change my rotation speed from gui not from script editor

i hope that helped
Old 01 January 2009   #5
groblus thats a great explanation of both methods - thankyou so much!!!

I'm gonna go and try to get that 2nd method working that you explained there
Old 01 January 2009   #6

just tried that sphrand method you put up groblus - WOW! that works a treat - I've got some real nice random rotation and when they collide with the ground the rotation stops at the current xyz rotation it had when it collided!!

thanks once again for this great explanation

okay so I have another query - if I wanted a similar kind of effect on a particle sprite - what would I use - can I use sphrand again?
Old 01 January 2009   #7
Thread automatically closed

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.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 03:10 PM.

Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.