rotation based on position change

Hi everybody,

I need help developing a rotation script driven by an object translation.
it's similar to the degtorad expressions "degToRad(360*(Ypos/(2*pi*Radius)))" but what I need is a "rotation script" to convert the vector calculated from the object translation into rotation and I'm very bad dealing with rotations in Maxscript.

Thanks in advance
Hani Tiby

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Hani Tiby's picture

Thanks for your useful

Thanks for your useful responds.

lutteral's picture

Rotation of a wheel over an

Rotation of a wheel over an irregular path should be history dependent, I think. I've attached a solution I've found searching for this problem. There's a script controller for the rotation of the wheel, and it adds the successive rotations of the wheel according to the direction and the distance.

M

AttachmentSize
wheel_rig.max 96 KB
Nelson Baietti's picture

All Purpose Car Wheel I'm

All Purpose Car Wheel

I'm working on an "all purpose wheel", and found a book by Cat Woods, Alexander Bicalho and Chris Murray (Max4) that provides a very simple alternative to it, see if it helps (it's a step by step description to make sure it works for you as it worked for me):

• in the front view, create a box ($Box01)
• in the front view, create a cylinder ($Cylinder01)
• put some cap segs on the Cylinder to see it better
• "select and link" the Cylinder to the Box
• animate the box moving from the left to the right on the front viewport

• select the cylinder
• open the tab "Motion"
• on the "Assign Controller" window, open "Rotation", "Z Rotation"
• click on the button "Assign Controller"
• choose "Float Expression"

• on "Create Variables", type "Radius", select "Scalar" and click "Create"
• on the List "Scalars" below, choose the variable you've created and click on the button "Assign to Controller"
• Search into: "Objects", "Box01", "Cylinder01", "Object(Cylinder)", select "Radius" and click "OK"

• on "Create Variables", type "Car", select "Vector" and click "Create"
• on the List "Vectors" below, choose the variable you've created and click on the button "Assign to Controller"
• Search into: "Objects", "Box01", "Transform", select "Position: Position XYZ" and click "OK"

• on the field "Expression" to the right, substitute the default "0" for the following expression:

Car.x/Radius*-1

• press the "Evaluate" button
• move the time slider and check the rotation of the wheel
• the -1 on the expression should work due to the way the objects where created, but if it rotates backwards for you, eliminate that part of the script

--

I'm sure that there's as a lot of different ways to achieve the same result, this is just one of them

I'm still working in others aspects of this thing to achieve my goal, but maybe, this might help you too as it's helping me.

Good luck!

- Nelson Baietti

sam_o_sa20's picture

Thank you

Worked perfectly for me

sam_o_sa20's picture

Thank you

Worked perfectly for me

grosmongol's picture

Hello, im a student in 3d

Hello,

im a student in 3d animation in canada and found your explanation very usefull. It work flawlessly with a simple mouvement on the box so i decide to tried and apply it to my first school assignement, a train rolling in circle on a track.

Keep in mind that i dont NEED the wheel to follow the track, i just want them to roll as the train move along.

I follow everything and first found my first bug : My wheel were Tube instead of Cylinder and i had Radius 1 and Radius 2.

So i change my wheel to a Cylinder. and got the Radius.

Alas! it didnt work.

When i click Evaluate the a rotation on screen but that it. No others rotation on the wheel as i move the time bar.

So i am Asking a few question if you dont mind :

1. Can it be that the movement in circle confuse the expression which would want to work only in straight line ?

2. Could it be that my Path Constraint wich animate my train confuse the expression ?

Any input would be appreciate, im learning !

ty

nick

onitreb's picture

It worked great, kind

It worked great, kind of...until my vehicle turned around and moved in the opposite direction and the wheel started to spin the wrong way.

What the heck?

It looks like car.x is the x position in world space? Because me vehicle is always moving in its own positive-x...

Is there a simple solution? How does one calculate total distance traveled (in x in this case), which is I guess what I want to know to replace the current car.x value.

I hope it doesn't require math, because I'm not good at that.

1acc's picture

I would like to see if

I would like to see if somebody prints a solution or not :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.