Search code examples
rotationmaxscript

Getting position & rotation in parent space


I have few bones.

Bone001:

enter image description here

Bone002:

enter image description here

The are aligned in the same direction. Bone001 has an rotation (in both World and Parent space). Bone002 has the same rotation as Bone001 in World space and it's rotation in Parent space (Boone001) is 0.

I want to get the position and rotation of Bone002 in Parent space (which should be 0).

I have tried (according to official documentation):

--each and every returns the same World space pos (as $Bone002.transform.pos)
(in coordsys parent $Bone002.transform.pos)
(in coordsys local $Bone002.transform.pos)
(in coordsys $Bone001 $Bone002.transform.pos)
$Bone002.transform.pos *= inverse $Bone002.transform

But each and every of them returns the Bone002 World space position (and not the Parent space one). Same for rotation.


Solution

  • You were close with the last one, to get transformation in another object's space, multiply by the inverse of that object's transform. Here, that would be:

    obj.transform.pos * inverse obj.parent.transform