instances rotation alignment to the ground

Become a member of the CGSociety

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

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 05 May 2012   #1
instances rotation alignment to the ground

Hi,

I have faced this problem very often and always found a cheap trick to get the shot done. But I refuse to not know how to do it the fancy way, so here it goes.

Say you have a particle system with instanced geo that has a random rotation but when it collides with the ground plane you want it to align so it lays flat on the ground, so you need to have it rotate from the rotated position at collisionTime into that last position that will have it align to the surface it collided with.

So, I have all the system set up, I am stuck at that last part. Though I have used several options I am stuck at using angleBetween just because I am fairly certain this is the way to go.

Anyone out there that can either help me out or just point me in the direction?

Thanks,
 
Old 05 May 2012   #2
Thumbs up

Did you use expression for the rotation

If not you this expression for the particles

Custom rotaction. Vector
Custom rotation = <<rand(360), cpy 3 time>>;
Now type in runtime dyn
Custom rotation += 1;
create other rand rotation in array with float per particle (add intial state attr)
(In creation) Rand rotation = rand(-1,1);
Runtime


Custom rotation += rand rotation ;

Speed float
Speed = mag(velocity)/30;

Custom rotation += rand rotation *speed;
 
Old 05 May 2012   #3
Well I remember doing this before but forgot how I did it and just spent a good 2-3 hours trying to figure it out and Im sure it wasn't this hard but I did find a solution, wow Im rusty.

I tried doing it with the angleBetween but that requires 2 axis and returns an angle in degrees, the problem is what happens if you have random rotations to start with? I tried unitizing the rotations but the angleBetween command doesnt seem to like anything but whole numbers for axis. It would be good to see this work though. I suck at math.

However I have found a workaround and that is using the hermite function instead. Have a look at it - myRotPP = hermite ( origRot, finalRot, <<0,0,0>>, <<0,0,0>>, linstep(0,highestY,particleYposition));

This rotates your particle from its original random position to your desired angle over the distance it has to fall to ground zero.
__________________
www.jeremyraven.co.nz
Vimeo
 
Old 05 May 2012   #4
Originally Posted by Aikiman: Well I remember doing this before but forgot how I did it and just spent a good 2-3 hours trying to figure it out and Im sure it wasn't this hard but I did find a solution, wow Im rusty.

I tried doing it with the angleBetween but that requires 2 axis and returns an angle in degrees, the problem is what happens if you have random rotations to start with? I tried unitizing the rotations but the angleBetween command doesnt seem to like anything but whole numbers for axis. It would be good to see this work though. I suck at math.

However I have found a workaround and that is using the hermite function instead. Have a look at it - myRotPP = hermite ( origRot, finalRot, <<0,0,0>>, <<0,0,0>>, linstep(0,highestY,particleYposition));

This rotates your particle from its original random position to your desired angle over the distance it has to fall to ground zero.


Thanks Aikiman,
I am out of the office and my scene files are there, will post one with my almost descent result using angleBetween.

I tried the hermite and I get some funky results. I am using the birthPos as the highestY pos. One of the problems is that it automatically snaps on the second frame and the instances just fall flat.
I tried using a locators position or even the collisionTime event to trigger the Hermite but still not getting the result. Most of the time they don't even lay flat on the ground (I am using a cylinder as an instance)

I know it should be easy, but for some reason I am just failing :(

Well, will keep posted when and if I have time to resolve this.

pramod2136, I think what you are trying to give me is just a rotation expression, and in that case I would definetly add a axis with at least 3 different rand floats and use this attr to rotate in x or y or z, and not all at the same time, since that rotation gets funky looking, kinda like a gimbal lock.

Thanks!
__________________
www.berkstein.com
 
Old 05 May 2012   #5
nParticles have the "rotation" parameter that can be used to drive instances.

This is much better than trying to hack rotations from start to 0 as the rotations are more natural. So here is an example and script that accomplishes the "snap to 0" using the angular velocity property to trigger the final behavior (note that this works perfectly even if particles are knocked around gain after coming to a stop)

//define a threshold value for magnitude of angular velocity
$t = 3;

//trigger evaluation on threshold angular velocity while ignoring any still particles
if (mag(nParticleShape1.angularVelocityPP) < $t && angularVelocityPP != <<0,0,0>>){

//use a custom attribute to initialize start rotation only if its 0
if (nParticleShape1.frotPP == <<0,0,0>>){ nParticleShape1.frotPP = nParticleShape1.rotationPP;}

$frot = nParticleShape1.frotPP;
$av = mag(nParticleShape1.angularVelocityPP);

//this will start with 1 and eventually end up as 0
$l = $av/$t;

//using linsteps we define a vector that starts with start rotation and ends up as 0
nParticleShape1.rotationPP = <<linstep($frot.x,0,$l),linstep($frot.y,0,$l),linste p($frot.z,0,$l)>>;
}
Attached Files
File Type: zip stooch_particleRollto0.zip (9.7 KB, 89 views)
__________________
From Russia, with love @ stooch.tv

Last edited by stooch : 05 May 2012 at 07:57 PM.
 
Old 05 May 2012   #6
Originally Posted by stooch: nParticles have the "rotation" parameter that can be used to drive instances. so you dont have to do any fancy scripting anymore. just set your instancer to use this parameter and you are done. (make sure you enable calculate rotation in the nParticleShape)


Thanks, I know this, but I am about to build a rig to be used in maya 2009, some times the new and fancy tools are not available
__________________
www.berkstein.com
 
Old 05 May 2012   #7
Nice one Stooch, very cool. Mine doesnt handle bouncing but it could be adjusted to work with mag(velocity) instead rather than distance.
__________________
www.jeremyraven.co.nz
Vimeo
 
Old 05 May 2012   #8
Thanks guys!

both examples are really helpful. I completely forgot about the angularVelPP attr. And I now see I went completely another direction which would probably never have gotten me where I needed to get to.

stooch, that was what exactly was I looking for.
__________________
www.berkstein.com
 
Old 05 May 2012   #9
Yeah I am pretty confused but I think I have it sussed now. The rotationPP works in degrees whereas the angleBEtween requires 2 vectors based on unit axis but it produces an angle in degrees. AimUpDir and AimDirection for example all work in unit axis also which is why you can rotate an instance using sin and cosine. The prob I still have is that using linstep to rotate the object appears to be ideal for aimUpDir because it goes from 0 -1 but I am still getting a snapping effect rather than the nice interpolation we can get with sin and cosine, that bit doesnt make sense.

Stooch's use of rotationPP resolves all that confusion.
__________________
www.jeremyraven.co.nz
Vimeo
 
Old 05 May 2012   #10
Let me highjack this thread for just a minute =)

Does those setups with the expressions from you Aiki and stooch work if the ground or object that the particles collide with is an uneven geo? will the particles have the correct rotation when they have stopped?
__________________
Voxels for dinner.
_____________
http://esvfx.wordpress.com/ maya vfx blog
 
Old 05 May 2012   #11
Mine wont Stoochs will. Mine is based on Y axis and zero. Stoochs is based on angularVelocityPP.
__________________
www.jeremyraven.co.nz
Vimeo
 
Old 05 May 2012   #12
Ok, cool! thanks guys! This might come in handy! copy and save =)
__________________
Voxels for dinner.
_____________
http://esvfx.wordpress.com/ maya vfx blog
 
Old 05 May 2012   #13
actually my final vector is hard coded to end to <<0,0,0>>

so if the ground is uneven, then this wont really respect the normals, it would be fairly trivial to setup normal orientation though, if anyone wants it i can look into it when i get home.
__________________
From Russia, with love @ stooch.tv
 
Old 02 February 2013   #14
Hey Stooch,

Any chance you can show us how to make them land correctly on an uneven surfaces?

And is it possible to make the pieces slowly rotate flat, rather than snap to position?

I imagine that is a major pain in the arse!

Cheers!
__________________

.

Reel - 3DInk.com
Filmography -IMDB
R&D - VIMEO

*please read- cyanbsl.blogspot.com/*

Last edited by HowardM : 02 February 2013 at 12:55 PM.
 
Old 02 February 2013   #15
In regards to the snap, is this because you haven't declared ParticleShape1.frotPP?
And what was $r for?

Or am I missing something?
__________________

.

Reel - 3DInk.com
Filmography -IMDB
R&D - VIMEO

*please read- cyanbsl.blogspot.com/*

Last edited by HowardM : 02 February 2013 at 05:12 PM.
 
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 07:07 PM.


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