View Full Version : Controlling force by orientaion

 floopyb10 October 2007, 03:33 AMHi guys, I have used bobos method of controlling force by mass: http://www.scriptspot.com/bobo/mxs5/pflow/ I am doing feathers floating to the ground and was wondering if I can controll the ammount of gravity applied to the feathers based on their orientaion. So when the feather is verticle it recieves full gravity and when its oriented horizontally it recieves none. I know I can get the sma effect by using a path but was just wondering how to do it with scripting. Cheers, Jordan
Bobo
10 October 2007, 05:10 AM
Hi guys,
I have used bobos method of controlling force by mass: http://www.scriptspot.com/bobo/mxs5/pflow/
I am doing feathers floating to the ground and was wondering if I can controll the ammount of gravity applied to the feathers based on their orientaion. So when the feather is verticle it recieves full gravity and when its oriented horizontally it recieves none.
I know I can get the sma effect by using a path but was just wondering how to do it with scripting.
Cheers,

Jordan

This is rather easy.

You can write a script which takes the TM of a particle, extracts one axis out of it (the axis that defines the orientation that allows for maximum influence), calculate the absolute value of the dot product of that vector and the Z axis (or the local Z axis of the gravity spacewarp, if you prefer to have full control), and write the resulting value into the particle float channel. The rest is just like the mass script - let the Force operator be affected by the float channel and you are done!

Even better, since in reality a feather does not get less gravity but more drag due to air resistance, you can create two Force operators - one with a constant Gravity, one with a 100% Drag along X, Y and Z set to use Script Wiring and influenced by the Particle Float channel you scripted. I just tried it and it works nicely:

on ChannelsUsed pCont do
(
pCont.useTM = true
pCont.useFloat = true
)

on Init pCont do ( )

on Proceed pCont do
(
count = pCont.NumParticles()

for i in 1 to count do
(
pCont.particleIndex = i
pCont.particleFloat = abs (dot \$Gravity01.transform.row3 pCont.particleTM.row3)
)
)

on Release pCont do ( )

Note that .row3 means the Z axis of the particle. If you want to use X or Y, use .row1 and .row2 respectively.

The dot product will be 1.0 when the chosen axis is parallel to the gravity and 0.0 when it is perpendicular. Even if pointing in the opposite direction (-1.0), the abs will returns 1.0. So when the chosen axis is parallel to the gravity, the drag will be 100% and the particle will slow down its fall.

floopyb
10 October 2007, 04:49 AM
Thanks Bobo, That worked a treat!

Jordan

floopyb
02 February 2008, 04:57 AM
Just as an addition to the feathers, is there a way that I can add movment to them as they rotate in the direction they are pointing based so they will move side to side?

CGTalk Moderation
02 February 2008, 04:57 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.

1