I think that the easiest way is to use OpenGL's glPushMatrix and glPopMatrix. The pseudocode for drawing would be
Code:
procedure TBone.DrawBone;
var
i : integer;
begin
glPushMatrix;
RelativeTranslation;
RelativeRotation;
for i := 0 to ChildrenCount - 1 do
Children[i].DrawBone;
glPopMatrix;
end;
procedure TSkeleton.Draw;
begin
root.DrawBone;
end;
If you dont want to use glPushMatrix and glPopMatrix (or you dont use OpenGL) then in each bone (or joint?) you should store relative position/rotation (bone's local coordinate system) and absolute position/rotation (world coordinate system) Then to calculate new absolute values:
Code:
AbsoluteMatrix := RelativeMatrix*Parent.AbsoluteMatrix;
I hope it helps.
Bookmarks