3

Related to this: apply non-hierarchial transforms to hierarchial skeleton?

If an object is attached to another one and you need to set its position, rotation and scale in global space, what do you do to get the local versions of these values, knowing the same values for the "parent" object?

(in the other thread I can do matrix.decompose() to get these values from a matrix)

Community
  • 1
  • 1

1 Answers1

7

Just multiply the object's world transform matrix by the inverse of parent's world transform:

M_loc = M_parent_inv * M
Max
  • 16,679
  • 4
  • 44
  • 57
  • 3
    The principle is the same: you subtract parent world pos from world position, if rotation is matrix, then you multiply world rot matrix by parent rot inverse, if quaternion then world rot quaternion by parent rot quaternion conjugate, and world scale you divide by the parent's world scale. – Max Aug 12 '12 at 08:54
  • "parent rot quaternion conjugate"? –  Aug 12 '12 at 16:55
  • Conjugate of the parent rotation quaternion – Max Aug 12 '12 at 18:35
  • I don't know what a conjugate of a quaternion means. –  Aug 12 '12 at 19:02