Notifications
Clear all

[Closed] How to achieve the effect like Path Constrain using MAXScript?

Thanks for your reply during the busy work!

But I’m cofused at this place:
cir = (2*pi)*Obj.radius

What does Obj.radius mean?
I guess that it’s the radius of the object’s trajectory,but there’s no such property for a node as far as I know.

And using your method the object always rotates for a plus number,but sometimes it may rotate for a negative degree like -70.
So how do we get that the angle of its rotation is a plus number or a negative one?

O man, hahahaha, I completely messed this one up:) So sorry man, I posted a completely wrong part of what I wanted to show. This is for the wheel rotation, not for the actual object rotation. Sorry about that. So here goes my second attempt:)

if currenttime != 0f then --I prefer to have the rotation neutral at frame 0
     (
     YVec = normalize (Cnt.pos - (at time (currenttime-1) Cnt.pos)) --get normalize
     ZVec = [0,0,1] --this is needed for a temporary up vector calculation
     XVec = cross YVec Zvec --cross product of Y and Z gives us X
     ZVec = cross XVec YVec --cross product of X and Y gives the orthogonal Z
     tm = (matrix3 XVec YVec ZVec Obj.pos) -- this is our objects transform
     tm.rotationpart --get the rotational part
     )
     else
     (
     quat 0 0 0 1
     )
 What I gave you was basically another part of having a car set-up, which would be the wheel rotation. Once again sorry:blush: shame on me! Anyways, this should do it for you:thumbsup:

EDIT: In fact, lemme attach the max file so that you can see it in action! (Its in Max 2k8 format)

Thank you!

I’m learning your method which looks very cool.

I got it, man!
The Vector Cross Product is very cool!
And I’ve also understood the meaning of Matrix3!
Thank you!

:applause: Good stuff dude! Glad I could help. Once you finish the rig, you should post it to show the results:) And yea, 3D math is quite a lot of fun! Just need to get into it.

1 Reply
(@jausn)
Joined: 11 months ago

Posts: 0

I suppose it would take quite a long time to finish my car rigging because this is just beginning,but I’ll show it here when I get it done.
:lightbulb :lightbulb

It is not a problem, but rather expected. As the script evaluates with every event, including time scrubbing, the script is set to evaluate the same things, meaning going to the frame before the one you are on, getting the rotation there, and rotating more from it. But if you actually animate the root moving backwards, the wheel will rotate backwards as well. So unless there is some reason for needing the backwards time scrubbing for the rig, you have nothing to worry about. Or you can bake the animation. That will give you the solid fixed rotation on the wheels. But I don’t really see why you’d need it, as you are very unlikely going to need the backward time.

Also, if you notice in the script, there is the if statement for frame 0f. This makes sure that if you do playback the animation, you always start rotating from zero.

Hope this answers your concern

You got that right.
When finished the animation we started rendering which is almost always a frame-by-frame and forward process so this is not an issue.
Thank you for your answer!

I think we could simplify your script a litte bit like this:
Obj.RotVal.Rot += dist/obj.radius – this is a radian value

‘Cause you can see your script:
cir = (2*pi)Obj.radius
ang = dist/cir
Obj.RotVal.Rot += degtorad(360
ang)

And degtorad(360ang) equal to:
degtorad(360
ang) = 2piang = 2pidist/2piObj.radius = dist/obj.radius

Anything wrong with me?

Yup, seems like you are right. I just did this in a way I was thinking, but as I’m quite often blind to some simpler solutions at first, I never saw that before:) Thanks for showing me this:)

Page 2 / 2