View Full Version : Propellar rotation
FunkyT 08-07-2006, 05:43 AM I have a vehicle with a propellar, so I have a script that has the rotation of the propellar go up depending on the the frame number. This works fine as long as you never make the propellar slow down. If I do, then instead of adding less and less rotation until it stops, it reverses the rotation until its at 0 again.
In short I need a script that will only add to an attribute over time, but never take away from it after its added. Any ideas?
|
|
isoparmB
08-07-2006, 09:56 AM
This following expression assumes many things. One is that your actual propeller object is named "propeller", and that if spins on its Y axis. It also assumes the propeller has certain custom control attributes:
endTime = determines what frame the propeller will begin to stop spinning.
dieOutRange = determines how many frames the propeller will continue to spin before it finally stops.
rotateFactor = the current frame is multiplied with this factor to get the rotate value on the propeller.
The expression uses a smoothstep function, which has a start, end, and percentile arguement. The function returns a float value between 0 and 1 representing what percent the third argument is relative to the start and end range arguements. For example: smoothstep 0(start) 10(end) 5(percentile) == .5(returnValue). smoothstep 1 5 2 == .25. You can use this function to come up with a smooth descending value to add to and end frame arguement.
It's a nice expression for stopping the propeller, but not for starting it. :] You can modify it a bit to do that too.
float $endFrame = propeller.endTime;
float $dieOutRange = propeller.dieOutRange;
float $currentFrame = frame;
float $smoothstepRange;
if (frame >= $endFrame)
{
$smoothstepRange = `smoothstep $endFrame ($endFrame + $dieOutRange) $currentFrame `;
propeller.rotateY = ($endFrame + ($dieOutRange * $smoothstepRange)) * propeller.rotateFactor;
}
else
{
propeller.rotateY = frame * propeller.rotateFactor;
};
CGTalk Moderation
08-07-2006, 09:56 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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.