PDA

View Full Version : Rotate objectspace


nkls
01-23-2006, 08:51 AM
Hi!

I'm kind of new to mel scripting. Anyway, I'm trying to create a simple "car rig", sliders for steering and so on. The problem I have is when trying to mix the steering control with wheel spinning.

What I'm going to do is an animation with a car moving along a motion path. Along the path, as it turns, I animate the steering by hand via my steering slider. When adding wheel spin it works fine as the car moves straight, but when it turns the wheels starts to rotate incorrect. I figurerd out that this has something to do with objectspace/worldspace rotation. But I don't understand how to write the script to get this right.

Here's the wheelSpin part of my script:

proc wheelSpin() {

//get the starting frame for spinning
int $startFrame= `textFieldGrp -q -text textStart`;
//get the stop frame
int $stopFrame= `textFieldGrp -q -text textStop`;

//counting frames
int $time = ($stopFrame - $startFrame);

//keyframe at startframe
setAttr carWheelFR.rz 0;
setKeyframe -t $startFrame carWheelFR.rz;

//keyframe at stop frame
setAttr carWheelFR.rz ($time * -50);
setKeyframe -t $stopFrame carWheelFR.rz;

}

If anyone understands my problem, please give me some advice!
Thanks in advance.

Buexe
01-23-2006, 09:07 AM
Why don`t you use one node for steering and a child of this node to spin?
I think this way you should get your spinning in the correct object space.
cheers
buexe

nkls
01-23-2006, 09:22 AM
Sorry Buexe, I don't understand what you mean that I should do. Would appreciate a more complete description of what to do!

Thank you anyway for trying to help!

Buexe
01-23-2006, 09:33 AM
Just thought of your problem. Maybe you even only need to adjust your rotation order.

Anyway, to my first suggestion:
1. create a transform node, call it "steerNode"
2. create a transform node, call it "spinNode"
3. parent "spinNode" under "steerNode"
4. parent "steerNode" under your overall car rig ( the node transforming your car in space )
5. set the spinning keyframes on "spinNode"
6. set the steering keyframes on "steerNode"

Now your overall hierarchy should work.
I hope this helps

nkls
01-23-2006, 10:52 AM
Thank you very much! Changing the rotation order was the right thing for me!

I really appreciated your help!

CGTalk Moderation
01-23-2006, 10:52 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.