Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Animation (https://simplymaya.com/forum/forumdisplay.php?f=14)
-   -   Constant Rotation (https://simplymaya.com/forum/showthread.php?t=27211)

diggersworld 12-08-2007 09:35 AM

Constant Rotation
 
Hey I been using Maya for a while now, but have never really gone into the animation side of it, not to keen on rigging, setting up weights and all that jazz.

Anyway, I would like to know if there's a way that you can take an object and make it rotate on its own central pivot, without having to key it every so many frames.

E.g. A fan turning round continuously in a clock wise, or anti-clockwise direction.

Thanks in advance for anyone who comments.

happymat27 12-08-2007 10:13 AM

hello there diggersworld,

there's a simple sollution to your question and it's cycle with offset your animation curves. Basically all you need to do is key the start and end frame of your rotation...........

Say you wanted a fan to rotate 5 times a second @25fps, you'd key frame 1 then rotate it 360 degrees and key frame 5 (5x5=25).

Next, with the rotating object selected, open up the graph editor (Window > Animation Editors > Graph Editor), you'll see the animation curve as a straight line (if you can't just hit the 'a' key).

The default for an animation curve's infinity setting is constant, this means that before the first and after the final key the curve is at a constant value, go to the view menu in the graph editor and hit infinity to see this. All you need to do is change the post infinity setting to Cycle with Offset (Curves > Post Infinity > Cycle with Offset) and your object will rotate forever.

I hope my rambling helps,

Mat.

diggersworld 12-08-2007 10:16 AM

cool, i'll give it a wurl... de dum tish... lol

diggersworld 12-08-2007 10:24 AM

Yeah that works, cheers for your help.

diggersworld 12-08-2007 10:54 AM

Okay sticking with this topic but taking it further... is there a way that i can make a controller so that i can control the speed at which it rotates....

i.e. like on a stationary hover craft, the fans may rotate slowly but not enough to push it along, but when accelerated (rotated faster) it begins to move.

So in other words, a controller that alters the Rotations of the object.

Xander-0 12-08-2007 08:17 PM

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.

diggersworld 12-08-2007 09:28 PM

Cool, thanks...
I'll give it a go.

diggersworld 12-08-2007 09:44 PM

K... having a bit of trouble...

How do I make sure that the new attribute I'm adding is a double?

Also, I carried on assuming is was, and got this error when trying to add the expression:

Error: Attribute already controlled by an expression, keyframe, or other connection: fan.rotateZ

diggersworld 12-08-2007 09:48 PM

Oh no... tried it again, and got it working this time... Hurray!!

Cool thanks man... I'll try the controller now, but it'd no biggy if that don't work.

mirek03 12-08-2007 10:00 PM

Matt, you have been pushing that graoh editor lately :) can you think of an easier way to control the speed.., I was thinking set driven key.., but its been so long since Ive used it??

happymat27 12-08-2007 10:19 PM

Awwww, I just made a little tutorial to show how to do this and Xander-O beat me to the explanation!

Mirek: The graph editor is a really simple visualisation of your animation. Setting the infinity curve to cycle with offset is the easiest way answer the first part of diggersworld's query. Using the graph editor to deal with the second query, it's possible to control the speed manually but it's not possible to control the value of a key through SDK's.

Top explanation Xander :beer:

Take it easy,

Mat.

mirek03 13-08-2007 12:34 PM

ummm yes great explanation.., and.., I do know what a graph editor is.., just wondered if there was more than one way to skin a cat by influence rather than expression but I guess I was wrong.., :)

Xander-0 14-08-2007 05:21 PM

ehh.... thanks, I guess.

I really had to get into how to write control expressions when I was figuring out how to do tank treads and a bunch of other stuff (like expanding joints).

mirek03 14-08-2007 06:10 PM

now that would be interesting.., how DO you do tank treads, is there a tut, I have a script but Id ig to know how it is done.., maybe ill look over what you wrote again and dissect it.

Xander-0 15-08-2007 04:00 PM

1 Attachment(s)
ummm... the problem is I know how to control them, but I don't have a good way to set them up yet (another one of my many projects is to write the scripts for a setup).

I have some old notes that I made for myself for creating the treads - mostly, it gives the equations and what each piece is, but it doesn't tell much about setup. (because, of course, I knew it) urgh. Anyways, maybe this helps?

I know there are scripts out there that both setup and control creation of tank treads, but they always struck me as problematic in two ways - 1) there usually weren't many choices you could make during creation about things, and 2) control options were also rather limited. Mostly I set this up so I'd have a manual control of the treads, instead of only a entered value.


All times are GMT. The time now is 08:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018