Animated object => get orientation

Animated object => get orientation

Anonymous
Not applicable
1,295 Views
4 Replies
Message 1 of 5

Animated object => get orientation

Anonymous
Not applicable
Hello,

I have a maxscript problem and I need help to find the solution : I give you
a sample max file and a script that illustrates what I want to do.

In the 3dsmax file, you have 3 meshs with animations : the first is a box, the
second a cylinder and the third one is a teapot.
My problem deals with the use of the Link_Constraint controler. Cylinder is
first linked to world and at frame 20 it is linked to the box. The teapot is
linked to the cylinder at frame 70. They all have pos and orientation keys.

I use the testScript.ms to get position and orientation of each of them. The
problem is that the teapot informations the maxscript gives me are not the
good ones. I want orienation in universe coordinates and I do not get them.

To test the problem :
1. Open Max file in 3dsmax9 and go to frame 85
2. Select the world coordinate system
3. Select the teapot and right click on the rotation tool to see rotation
values => gives you (-1,424;173.079,-37
876) => these values seems to be the
right ones.
4. Run the maxscript => Gives you horrible values :
(178.576,6.92052,142.124)

The question is : how to get the correct values of orientation with the
maxscript way ? Do we have to transform the matrix back to get World
coordinates?
The problem does not seem to occur on the position track.

Hope it's clear. 🙂
Thank you for the anwers.
Stephane.

39_Pk3qlZupYFuZ9smfCq4Y.zip

0 Likes
1,296 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
It looks like your are trying to get the world coordinates from the transform matrix of the object... but once an object is parented it's transform matrix is relative to the parented object... the rotation as well... I'm not in front of max right now but if you want to get the world orientation you should look for a function in the help file that gets you the world orientation instead of the rotation part from the transform matrix, cause obviously that's not relative to the world once parented.

-Johan
0 Likes
Message 3 of 5

Anonymous
Not applicable
That is exactly the aim of my question.
How do you get the world coordinates of the object in maxscript?
All I found, seems to be relative cordinates (at least for the rotations).

Any help wolud be welcome...
0 Likes
Message 4 of 5

Anonymous
Not applicable


obj = selection
in coordsys world obj.transform.rotation as eulerangles



I also wrote a function to get the parentnode of linkconstrainted object



fn getParent_from_linkconstraint obj =
(
obj_controller = obj.controller
if (classof obj_controller) == Link_Constraint then
(
numTrgts = obj_controller.getNumTargets()
time_arr = for i in 1 to numTrgts collect obj_controller.getFrameNo i
ct = currenttime as integer / ticksPerFrame

notFound = true
for i in numTrgts to 1 by -1 while notFound do
(
if time_arr <= ct then
(
notFound = false
parent_node = obj_controller.getNode i
if parent_node != undefined then
return parent_node
else
return undefined
)
)
)
)
obj = selection
p = getParent_from_linkconstraint obj



It could probably be optimised a bit more... but it seems to work

Goodluck!
-Johan
0 Likes
Message 5 of 5

Anonymous
Not applicable
Can you tell me what seems to work ? The fact that you retrieve the parent ?
I had already tested the first code you give and it does not give me the correct angles ?

I'm trying to get coordinates in parents coordinates :

objParent = $Cylindre01
eul = in coordsys objParent s.transform.rotation as eulerangles


but il gives me always the same result that does not seem to be the right one!
0 Likes