Inheriting Rotation in Scene Nodes

Started by
1 comment, last by earl 14 years, 5 months ago
I am currently working on a 2D scenegraph system. I have a scene node class that contains a Transform structure describing translation, scaling, and rotation. Child nodes of scene nodes inherit their parents' transformation and then transform relative to that. Translation and scaling are relatively easy to do: just addition and multiplication of the vectors. However, inheriting rotation is difficult. Each node has a rotation relative to its own translation. How do I make child node's calculate their local transformation taking into account the parent's rotation and rotation about their local translations?
Advertisement
I have not tried this in 2D myself, but for each node you could store two transformation matrices, one for local transformation, and one for world transformation.

Whenever a object moves or rotates, update its local matrix, calculate its world matrix my multiplying its parents world matrix by its local matrix, and update all of its child matrices.

http://en.wikipedia.org/wiki/Transformation_matrix
A child nodes local rotation can be converted into its parents space by multiplying the child and parents rotation matrices together. You will probably want to cache the result upon first access, but otherwise the mechanism is the same as for inheriting translation and scale.

This topic is closed to new replies.

Advertisement