PDA

View Full Version : animating a rolling wheel


Riptyde
02-28-2003, 09:21 PM
Hey all,

I want to animate a wheel rolling, and I'n not sure what is the easiest or best way to do it.

The one way is to animate the rotate atribute and calculate how far it would roll based on the circumference.

The other way I was thinking, and this I am not sure of because I'm still quite a novis to Maya, is to use one of the dynamics tools in a way that as the wheel is moved forward (or backward) it would rotate automatically. Is this way even possible? I'd like to try it if it is even if it might not be the best way. It would be something to learn dynamics with.

If you have ideas, please let me know

Thank you

Riptyde

mark_wilkins
02-28-2003, 09:38 PM
You can do this with solid body dynamics, but it's a highly inefficient way to do it.

(Problems include: you can't really put the surfaces exactly in contact on frame 1, so the wheel will bounce and you'll need some run-up time to control the simulation; you won't be able to control the wheel's motion exactly; the scene's heaviness will be absurd for the simplicity of what you're doing; and you'll probably need to spend some time tweaking with friction settings to get the right result.)

-- Mark

dmcgrath
03-01-2003, 01:46 AM
So a wheel is usually attached to something. You can use a set driven key set up that will work forever. You only have to move an object (car or whatever) and have that drive the rotation of the wheel. Just make it look good, it doesn't have to be perfect.

What you want to do is to set a Driver up first, lets say it is a car.
Now, make "Car" the Driver.
And "Wheel" the Driven.
Make it something like when the car moves forward in Z (lets say 10 cm.) then the wheel will rotate 360 degrees. in X.

When it looks right to you, then go to the Graph Editor and select the "Wheel" rotateX curve. Make it Infinite in the menu at the top of the GE. Then go to curves (i think it's curves) and go to Pre Infinity, Cycle. And then Post-Infinity, Cycle. Piece of cake. Only two keyframes, and you never have to mess with it again.

Try it and let me know if it works.

mikefeil
03-01-2003, 01:53 AM
im very interested in this too...surely there is some script that calculates the rotatation of a wheel based on the distance it has come from the last frame.

gas
03-01-2003, 02:07 AM
yeah, a equation of some sort, like the wheels "radius times pii" or something..
-someone probably remember this from school..

but/and while we at it, It would be nice to be able to include a "driver-bar" that one can make (0)/1 and get the nice "backspin" effekt "quickrenerably" when dessired, mayby adding another "layer" semivisible "wheel" that could fake up the moblur..

I think I have seen a site out here that was full of "clever tricks", I think I found the "IKrotate_delay.mel" that made "whisping" a dogs tail so easy =)
Anyone having the link to that one or some other similar.. Yeah I know highend have a lot of them mels but this site had like 15-20 only but real timesavers when "not complete control" is whished for and included example and playblast...

I will follow this thread and see... / VI@GAS

mark_wilkins
03-01-2003, 04:16 AM
OK, here's the expression:

If $speed contains the speed at which the wheel's rotating

wheel.rotateY = $speed * (360 / 6.2830) * time;

-- Mark

dmcgrath
03-01-2003, 07:13 AM
I'm telling you guys. You don't need an expression for this. Expressions are eval./time anyway. The SDK is the easiest and fastest way to go for a wheel that you want to work and not have to think about.

mark_wilkins
03-01-2003, 08:13 AM
Sorry, didn't mean to dispute that driven keys are a perfectly viable solution. However, he wants an expression, I give him an expression!

Of course a better one would be:

wheel.ry = (wheel.tx / (6.2830 * $radius)) * 360;


assuming it's rolling in the local X direction. Note, if you want it to turn, group it and rotate the parent transform.


-- Mark

mikefeil
03-01-2003, 11:30 AM
i really need to read up on how to do this expression stuff...evertyime i try to put this in in the expression editor..and link my cylinder object to translate x i get
// Error: "$radius" is an undeclared variable. //


.hrmm..

noob i am

Mighè
03-01-2003, 12:10 PM
There is a MEL script in Maya 4.5 (not sure in earlier versions) called MAKEROLL, you can find it in the MEL reference with F1: this script put an expression on the object (not only wheels) and when you translate you achieve a rolling effect, very nice.
Try it, i think that is useful

dmcgrath
03-01-2003, 05:56 PM
Sorry Mark, I also wasn't trying to slam expressions :beer: , but I assumed Riptyde was looking for a simple solution for a wheel attached to a car. Your second expression would definately solve the problem, I think.

Iso, the reason you have an error message is because you never told maya what your radius of the wheel was. If it's 4 units across then the radius is 2. Mark's $radius variable is assuming that you have already declaired the variable. You can just replace the $radius with a number. Or write this above it.

float $radius = 2;

wheel.ry = (wheel.tx / (6.2830 * $radius)) * 360;


Here it is in action

Riptyde
03-01-2003, 08:25 PM
Thanks for the reply's guys. I wasn't expecting so many. The sdk is probably the best way, but for the sake of learning I think I wil try 'em all.

Riptyde.

mark_wilkins
03-01-2003, 10:35 PM
Oops! I was a little under the weather when I last posted so I didn't deal with the $radius issue. Sorry!

Also, my trick of grouping the wheel will force you to do things differently, because if you move the wheel under the group for its linear motion then rotating the group will no longer rotate the wheel around its pivot. Again, I was under the weather. :D

-- Mark

mikefeil
03-02-2003, 01:26 AM
thanx dmcgrath


I will have to learn some mel looks like its not that hard to learn...thanx once again

lostpencil
03-03-2003, 01:59 AM
Well.. you could always check out this online tutorial to see the step by step details on how to make it all work:

http://www.cgtalk.com/showthread.php?s=&threadid=47140

:)

mark_wilkins
03-03-2003, 02:24 AM
Very nice.

Was this tutorial inspired by our discussion? :)

-- Mark

lostpencil
03-03-2003, 02:45 AM
Hey Master Mark! Thanks! Yep, it sure was. I had a version of the rotating wheel for a Lightwave character I'm using for some commercials:

http://www.lostpencil.com/images2/roland.jpg

(not the best shot, but it's part of an animation - here the silhouette is weak)

And seeing the question asked, I made the wheel work with Maya. By the way, thanks for a great book on Mel scripting!

mark_wilkins
03-03-2003, 02:48 AM
I was just thinking you'd turned it around (haha!) awfully fast after this question was posted!

-- Mark

lostpencil
03-03-2003, 02:55 AM
Ooo... good pun. Thanks, it went fairly quickly without much 'spinning of the wheels' :eek: ! I hope it helps people see the value of knowing a bit of math and some scripting.

mikefeil
03-03-2003, 08:14 AM
hey great stuff man...I have been praying that someone would do this :)

one little questions...what would u do to create a quick rotation...so it rotates more in a set distance....ill probably figure this out when I look at the script...but I suck at maths..so might aswell ask if I dont get it

cheers once again :bounce:

edit:: here is a little animation i did(below and just for one wheel, which will be parented to its body in the next ermmm 5 mins) based on your expression :)

http://users.bigpond.net.au/iso/.avi

thanx once again

mikefeil
03-03-2003, 10:05 AM
I cant seem to be able to get the tyre to contrain to the body right...i always have problems with constrains and I can never understand them cause im a noob...

could anyone help me out with contraining 4 tyres to a little lego racer so it can move like with the box hehe....

DOWNLOAD SCENE (tyre and mainbody [locators already set] )
http://users.bigpond.net.au/iso/scenes.zip

Riptyde
03-03-2003, 03:09 PM
Lostpencil... Thanks for the tut, I'll check it out today. You also thanked mark for the mel scripting book, what was that book?

Thanks again guys!

Riptyde

lostpencil
03-03-2003, 03:24 PM
Hey Riptyde,

You are welcome! I hope you like it. The book by Mark is Mel Scripting for Maya Animators (http://www.amazon.com/exec/obidos/tg/detail/-/1558608419/qid=1046707127/sr=8-1/ref=sr_8_1/102-1902227-7733763?v=glance&s=books&n=507846)

Hi Isometrix,

The trick was to make sure there are no keyframes on the 'tyre'. Also, I oriented the body of the car along Z (just to make sure my 'flip' wheel rotation logic didn't break). Then I made sure the wheel in the tyre file was centered and transformations were frozen at the origin. Then I imported the wheel into the body file. Selected the locator, then the wheel control, and point and orient constrained the wheel to the locator. I also had to tweak the oldx and oldy globals as per the tutorial online. Here is your cool lego racer with it's wheels attached:

http://www.lostpencil.com/temp/scenes.zip

Hope that helped!

dmcgrath
03-03-2003, 09:44 PM
I know that Lostpencil has probably solved the problem, but here is my lengthy text explaination for SDK. Iso.

I looked at the file and found that as soon as you parent the tire to the body, the expressions won't work anymore. That is because you are now moving a different node in the translation.
If you hook the tire up to the locators, just use a simple point constraint.
And it's not centered very well, so the tire wobbles a lot. you'll have to go back and spin the tire and see what I mean. Just move the rotates for the top node around until it straightens back up, and then freeze transormations. (You'll have to delete your animation keys and break connections to the expression)

Now put it on the car, and use a set driven key. (It'll be easier for this). Make a locator for the car, move it somewhere where you can get at it very easily, like above the model. Freeze Trans on it, then parent the car under. You have to parent the wheels under the car, not that locator, so they will orient with the car correctly.

The tire is almost 2 units in height, so the set driven key is easily done.
Make the car locator the driver, and the wheel group the driven.
Key the correct Trans value on the loc. and the correct rot value on the wheel at zero. then move the Locator forward or backward 2 units in the channel box, and rotate the wheel group + or - 360 degrees in the channel box and key those values together.

Lastly, select the wheel group, go to the graph editor and select the rotate value you have keyed. In the menu go to view/Infinity, and then go find the Pre Infinity/cycle and Post Infinity/cycle
and check them both.

Now go back to your scene and see if when you move the locator, does the wheel turn. If it doesn't than I either missed a step or you did.

Good luck, take your time and you'll learn a lot.

mark_wilkins
03-03-2003, 09:53 PM
You just have to do the parenting before you write your expression, and take the parenting into account!! :D

It's not that tricky, but I don't have the time to put together a nice tutorial. Perhaps LostPencil can get on it!? :beer:

-- Mark

lostpencil
03-03-2003, 10:11 PM
Hey Guys! It works great with point and orient constraining. I was actually playing around with the lego racer and it was neat... spinning the car rotated all the wheels properly. Kinda fun.

As for another tutorial... :surprised I think I'd be going around in circles... :eek:

Riptyde
03-04-2003, 01:17 PM
I played around with the sdk stuff and this is what I came up with.

First of all I wanted to play with motion paths as well and attached the body to the motion path. Then I set up a seperate SDK for the wheel by creating a seperate driver object. This objet moved the same distance as the circumference of the wheel. I believe it was 12.5 units (for what I was using). So for every 12.5 units the tire would rotate 360 degrees. I then used dmcgrath's example of pre-infinity and post-infinity cycles to have the wheel roll continually. Then I greated a heiarchy between the body object (the one attached to the motion path) and the wheel with the wheel as the child. Than all I had to do was animate the driver object for the same number of frames and same length as the motion path. It worked great!

I think this all makes sence.


I have the file in the 4.5PLE format if anybody is interested.

Thanks for the great info and suggestions.

Riptyde

MayaMagic
03-20-2003, 03:42 PM
DMCgrath~

I am modeling and animating the delorean form back to the future. I like your idea on setting driven keys as opposed to creating an expression. I was wondeirng if you could go a little more in depth on how i would make the wheels rotate with the movement of the car along a motion path... thank you for your help.

MagicMaya

YankyBJeans
03-20-2003, 04:33 PM
i understand the set driven key idea and i like that better since its easier for intermediate maya users, especially those of us who have never dabbled in any scripting. However, the sdk is for constant motion right (360 degrees over 10 cm is constant)? what would you do if you wanted to have control over the wheel's speed independant of the distance that the car moves? say for example you needed the car to speed up or slow down.

Yanky

CGTalk Moderation
01-14-2006, 01:00 PM
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.