Dynamic Car Rig

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 07 July 2005   #1
Dynamic Car Rig

Hi guys,

After looking at the dynamic Ferrari Car posted here:
http://forums.cgsociety.org/showthread.php?t=194356

by roni, i wanted to make something similar for my own animation. I am actually using a Ferrari Modena as well =D.

Below i have cut-and-pasted the script that i have written with reference to Roni's, and, after editing the Syntax errors in it via the script editor, it does not seem to work as it should in maya.

I used just one tire to test the script, and keyframed the 1st and 500th frame to different translate keys. Frame one being (0,0,0) and frame 500 being about (90, 0, 80), in format (x,y,z).

I plugged in the script, and saw that the wheel, while rotating at about the speed that it should be, rotated on the wrong axis, and looked like it was flipping head over heels instead of being tire-like.

Here is the script:

Note: if a word has "<>" around it, that means that it will be replaced with the name/value of real thing once they are created.

float $transX = <leftwheelname>.translateX;
 float $transZ = <leftwheelname>.translateZ;
 float $tls = 'currentTime-q' - 1;
 float $lsx = 'getAttr -time $tls <leftwheelname>.translateX';
 float $lsz = 'getAttr -time $tls <leftwheelname>.translateZ';
 float $relx = $transX - $lsx;
 float $relZ = $transZ - $lsz;
 float $hyp = sqrt(($relx*$relx) + ($relz*$relz));
 float $wheelaim = asind($relx/$hyp);
 
 //Scripting various rotation of the wheel.
 //Required: An (empty) node named "CarVars"
 
 //Turning wheels to correspond to aim of car.
 
 if (carvars.backwards == 0)
 	{
 	if ($relx <= 0 && $relz > 0 || $relx > 0 && $relz > 0)
 		{
 		<leftwheelname>.rotateY = 90 - $wheelaim;
 		}
 	else
 		{
 		<leftwheelname>.rotateY = 90 + $wheelaim;
 		}
 	}
 else
 	{
 	if (carvars.backwards == 1)
 		{
 		if ($relx <= 0 $$ relz > 0 || $relx > 0 && $relz > 0)
 			{
 			<leftwheelname>.rotateY = -90 - $wheelaim;
 		else
 			{
 			<leftwheelname>.rotateY = -90 + $wheelaim;
 			}
 		}
 	}
 
 //Turning wheels to correspond to their rotation as they spin on the ground.
 
 if (carvars.backwards == 0)
 	{
 	<leftwheelname>.rotateX = <leftwheelname>.rotateX + $hyp*360/(2*3.14159*<wheelradius>);
 	}
 else
 	{
 	if (carvars.backwards == 1)
 		{
 		<leftwheelname>.rotateX = <leftwheelname>.rotateX - $hyp*360(2*3.14159*<wheelradius>);
 		}
 	}
 
 <leftwheelname>.rotateX = <leftwheelname>.rotateX;
 



The carvars.backwards attribute specifies if the car is moving backwards or forwards (i.e. if it is in drive or in reverse).

I would be happy and gracious beyond belief if somebody could help me with this. This is one of my first lengthy MEL/expression projects, and I really do not want it to become a nightmare =D.

Thanks greatly in advance to any replies.
-Andy
 
Old 07 July 2005   #2
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:34 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.