View Full Version : particle rotation to stop based on collision
shan4fx
02-09-2006, 07:50 PM
Hey guys! its me again!!
This time I have a lake with a boat. The lake is a soft body with springs, and turbulance to cause the wavy undulation. Here is my problem...
I have instanced leaves (planes with leaf textures), which have rotationPP, which will collide with the lake surface and cause ripples and then float on the surface. All this works fine. Here is my problem, .. just like real life when the leaves rotate and collide with the lake surface, they get horizontal(almost), STOP ROTATING and float. How do i control this? I'm almost guessing it is a collision event based question but I'm not sure.
Thanks in advance!
sunder
02-10-2006, 09:26 AM
I need to know more about your setup to come up with an ideal solution. Is your soft body NURBS or polygons? Also how do you set your rotationPP?
shan4fx
02-10-2006, 06:47 PM
Hi Sunder,
Thanks for showing interest. The ground plane is a NURBS object. Regarding the rotation of the instanced particles. I created a custom attribute "rotatePP", which basically has a creation expression of values from 0 - 360. Then there is a runtime expression for "rotatePP" which increments the particles rotatePP value by .006 (in mycase) from their current values. I used the following logic for the increment: particleshape.rotatePP += .006; Then from the Instanced object's rotation properties, I set rotation to "rotatePP".
sunder
02-10-2006, 10:22 PM
Good tactic! Instead of making a custom attribute, I'd recommend adding a userVectorPP. This way you can have control over x,y,z instance rotations.
As for stopping the rotation, you could resort to collision checks when using a NURBS object and stop rotational increments. But collisions are registered only once which means the rotation increments can still continue. You'll then need to use a scalarPP attribute as a flag for increasing your rotation.
At this point, I think it becomes too cumbersome to use collisions (which only work for nurbs); so a simple solution would be to instead check for vertical position of the leaf to the lake, which I assume is mostly flat. If it goes below that level, stop rotational increments.
Creation Expression ...
particleShape1.userVector1PP= rand(<<0,0,0>>,<<0,360,0>>);
Runtime Expression ...
//Store current instance rotation vector
vector $rot = particleShape1.userVector1PP;
vector $pos = particleShape1.position;
if ($pos.y < np.translateY+0.1) {
particleShape1.userVector1PP = <<0, $rot.y, 0 >>;
} else {
particleShape1.userVector1PP =
<<$rot.x + 0.006,
$rot.y + 0.006,
$rot.z + 0.006>>;
}
This is sort of functioning, though the leaves tend to snap in place. I'm in a hurry atm, so I'll take another stab at this shortly.
shan4fx
02-11-2006, 11:50 AM
Thanks Sunder.. I'll try this out and tweak it if I can. However I rememberthat with my method I used an If.. else .. statement as well and I got the snapping thing too! They would rotate and then snap all of a sudden...
shan4fx
02-14-2006, 09:57 PM
No luck yet!:( The leaves snap and I feel like I'm running out of options.!!!! Can anyone help me?
sunder
02-15-2006, 10:52 AM
Sorry for the delay. I added some more code to the expression. Instead of setting the value to 0 immediately, I gradually reduce or increase the value to 0. This stops the snapping from what I can see, however, the result still looks very unnatural. I'll see what else I can come up with. Till then, I would recommend animating the leaves as opposed to relying on particle dynamics.