Notifications
Clear all

[Closed] retrieving rotation values > 360

Greeetings

I’m developing a utility in max script, part of which fundamentally requirres the total local (X,Y or Z) rotation of an object. In the curve editor, you can plainly see a value ranging from 0 to lets say 1080 for an object rotating through several revolutions.

I’ve tried several methods to get this data back out, the best I’ve come up with is very convoluted, and history dependant (which is a massive deal breaker for long animations) method. This is due, possibly to my lack of understanding of the transform matrix, or possibly due to the limitations of quats, and euler angles.

I have a CA (absPos), float script, which very successfully calculates the Absolute angle of the requirred axis using a couple conditions based on the following (where source is Node, child of the object being measured) :

((in coordsys gimbal quattoeuler source.parent.transform.rotationpart).z_rotation)

it then converts the Euler +/- 180 to 0 -360, then re-scales the values based on a user specified optional modulous ultimately giving a distance travellled.

Another CA, looks at the above absPos, calculates the difference in the value in time F vs time F-1 to give a speed.

The problem I run into is that in addition to the above, I need to track the total rotational distance travelled over the course of the animation, and display it to the user as a CA.

No matter where i looked i could not find a place max stores values similar to the ones you’d see in the curve editor for a multi-rotational object.

The best i could come up with was to take my initial rotation value, then increment it based on displacement derrived from the speed CA above.

I found i could not reliably do this without a for loop ranging from time 0 to the currentframe. (as the CA gets recalulated for lots of reasons, not just for timeline changes) This makes it history dependant, and very slow (every time opening the curve editor was a nightmare)

So i moved the little for loop into an already existing function running as a timecallback. this way, if the time incremented forward or back exactly one frame, all i had to do was add or subtract the displacement, and only run the for-loop if the user jumped a number of frames ahead. Unfortunately with longer animations, this seems to happen all the time, which means the animation ends up running worse then 1fps at times.

Long story short, I feel broken. Any advice?

Cheers

Mikie

15 Replies

Further to this I bought Bobo’s great Advanced Maxscript DVD… Quite a few good nuggets in there. Chapter 4 contains a scene where there is an angle displayed for a vector which rotates through > 360 degrees. Does anyone have the scene source file, as it is one that did not come on the DVD?

Or, better yet… Hey Bobo, any chance you can tell me how you did that? I might provide a clue to my delema…

Cheers

Mikie

getting the value explicitly from the rotation controller will do what you need:

-- gets the x rotation value at the current time
$.rotation.controller[1].value
-- gets the x rotation value at frame 20
at time 20f $.rotation.controller[1].value

You’re my new hero!

Thanks very much. That Solves a lot of grief I was having. I assume this won’t work if the object’s rotation is coming from a different type of controller? (i.e. the bank of a path constraint) I’ll still have to jump through hoops for that sort of stuff I’m guessing?

PM me if you happen to freelance

Cheers

Mikie

you can use the expose transform helper to extract local and world space positions and rotations from objects that are controlled by constraints (like the path constraint) but i’m not sure if the values will be accessible > 360.

sent you a PM

yah, yea olde expose tms only seem to play <360…

I am digging into the rotation values as well. It is quite painful (at least for me it is)

you can grab the value of a object’s rotation as stated above so long as you remember that it is going to come back to you as a Quaterion Rotation matrix. Which seems to be how Max is storing all of its rotations.

Euler Rotations that are displayed of course only show +/- 180 for their values. But are then converted into Quaterions behind the scene. You can use angleAxis to achieve a rotation of greater than 360 degrees.

When I have been scripting the rotations for objects that are parented I have been doing the following

set coordsys world

To change the objects rotation I use

in coordsys local $.rotation = eulerAngle # # #

equals the degree of rotation in X Y Z

To reset to a zero rotation I can then use

in coordsys gimbal $.rotation = eulerAngle 0 0 0

This reset the rotation of the selected object back to its Zero rotation that is being preserved by the world coordinate system.

I am really unimpressed by Max’s ability to maintain and set rotation values.

Thinking about your specific problem though. What you might do the rotation value in local space everytime it happens and feed that rotation value into an array. Then display the sum of the array in a message or rollout.
basically every key frame rotation would push a number appended to the end of an array. Then do a loop based on how the .count in the array.

Yah, i feel your pain. All it would take is an expose TM that tracked multiple revolutions, and that would jive with how things work in general. quats rock otherwise.

I have script controllers generating speed and acceleration curves for rotation, and i have to jump through all kind of hoops to check for direction of travel for the 0 to 180 or -180 to 0 swap etc. It’s all working at the moment, but if frames get skipped it basically needs to do a history dependent solve, and boy does that suck when you’re on frame one billion.

I am just used to Maya where I have all the rotations exposed in a standardized format (ie all the values match so that if I type in 720 degrees that what shows in all of exposed values. Graph, dope, and channel box) This assine use of one value matrix and swapped for another is just annoying and reaks of poorly written app. I am having to deal with it at the moment. But I am finding that it is not a well written app in a number of ways. It’s mostly simple things that I have been able to do in other apps (not just maya) for over a Decade. Argh!

Max may be a good modeling app, but it is almost more lacking in someways than Lightwave in the animation dept.

We had the option of going with Maya before we went down this road, and sadly, the bank ballances and skills of most of our clients decided on 3ds max… Sigh. In max’s defence though, I have to say that rotation is the only place I’ve really been hung up and resorted to putting stuff into maxscript when it would have been much more eligant in a script controller on a CA. The learning curve for max/maxscript/sdk hasn’t been too bad in general.

Page 1 / 2