View Single Post
# 6 12-08-2007 , 08:17 PM
Xander-0's Avatar
Registered User
Join Date: Feb 2005
Location: This Place
Posts: 220
yes, there is.
This is the way I'd set it up (dunno if its the best way, but its how I'd do it)
Oh - and I don't exactly remember all the commands in here, but this is close.

Part one - attribute setup

First, create a new attribute in for your fan blade. Right click on the channel box (where the attributes for translate/rotate/scale are). Click 'add attribute'.
name it something like 'rotation speed'. Make sure its a double, and don't give it any upper or lower bounds (well, if you want your fan to only rotate in one direction, set it to have a minimum of '0').
Then, select the axial attribute that the fan will rotate around (by default, for cylinders, this is the 'y' axis). Right click it, and select 'expressions'. You'll need to add the following command (or something similar);
"fan.rotateY = 360 * fan.rotation_speed * (frame/24);"
(or something like that - I'm a little bit fuzzy about the frame variable at the moment). Anyways, if you set rotation speed to 1, the fan will rotate once in 24 frames (24 or 30 frames is generally standard for movie and tv work).
Now, if you want to, that's all you need to do.

There is a second part, however, that allows you to set up a visual control.

First, you need to do the steps specified above (even some of them aren't strictly necessary with the rest of this setup, its still nice to be able to see the output).

then, you'll need two nurbs curves. actual shape doesn't matter, although I'm going to reccommend two straight lines. stick them into the heriarchy for your controls, just before the fan blade itself. Move them into position near your fan, and make sure to label them (say, fan speed control and control slider).
Freeze their transformations (so that they think they're at (0,0,0)).
geometry constraint the speed control to the slider (or do this, then name them) (this will make it 'stick' to the curve, as seen with motion paths, but here you can still move the other curve.).
Now, normally, your speed control wll have moved (and possibly rotated) itself. for ease of use, you usually want it to be perpendicular to the curve it 'rides' - mess around with the 'tangent' directions until you get this. Then, move it to either one end (if your speed will only be positive) or to roughly the middle (if you can have both positive and negative speeds). Then, freeze the transformations of the speed slider again (so that it again thinks its at zero).

Next, we need to set up an expression to make the control talk to the fan itself. This is also a good way to limit the speed of your fan.

Go back to your fan, select the attribute we created earlier, right click it, and select 'expressions'.
add the following expression (or something similar);
"fan.rotation_speed = 100 *fan_speed_control.translateX;"
(About this statement - I'm assuming a number of things here for the example - 1) your control slider curve is 1 unit long from the '0' point, and you want your fan to rotate at a max of 100 rpf. 2) the way you set up your slider is roughly parallel to the ground plane, and pointing along the x-axis).
click 'add', and you're done!

That's that kind of setup in a nutshell.


Book Wise

https://X4nd5r.deviantart.com