Notifications
Clear all

[Closed] Get bone position / rotation relative to parent?

I’m writing an animation exporter in maxscript, but I’ve hit a dead end.
I need to export the position and rotation (as quaternion) for each bone relative to their parent bones.
I found the .posInParent and .rotInParent members, which seem to be what I’m looking for.
I’m not quite sure about what they represent however.

local pos = node.posInParent
if(node.parent != undefined) then
(
	pos *= (inverse node.parent.rotation)
	pos += node.parent.position
)

It seems to me that this should result in the same position as node.position, but it doesn’t. What am I missing?

Additionally, .rotInParent is a point3 vector, so I’m assuming euler angles. Is there a way to convert them to a quaternion or will I have to do that manually? (‘as quat’ results in an error)

1 Reply
 PEN

tm=child.transform*inverse parent.transform
tm.pos
tm.rotation