tags:

views:

328

answers:

2
+4  Q: 

2D Bone system

I'm trying to write a 2D Bone system in XNA.

My initial thought was using matrices to keep track of the rotations and positioning through out the bone tree so items could easily displayed.

Cool I thought, and then dismay hit me in the face when I saw matrices could only be applied to single sprite batch.Begin call and not on a per draw call!

I ran some performance tests to check if my dismay was desevered, and it was, calling spritebatch.Begin and End a bunch of time drops my frame rate by a huge (and unacceptable) amount.

So, before drawing a single bones image I'm going to have to construct it's final position and rotation (and maybe scale in the future) manually. In this case would you still use matrices and somehow extract the information at the end just before drawng the bone? If so, any ideas on how to get the final information I need? Or would it be easier to try and construct it all from the raw positions and rotations of it's parent nodes?

Thanks in advance to anyone with ideas.

+4  A: 

Honestly I would ditch the Sprite rendering object and switch to screen space quads. There are no artificial limitations to screen space quads and you can use the standard implementation of bone systems: traverse down the tree applying transforms as you go, then pop them as you move back up the tree.

Ron Warholic
A: 

Aren't matrices overkill when you are working in 2D anyway? I mean 16 scalar multiplications for each matrix-vector product when you can do with 4 multiplications for rotation and 2 summations for translation?

Cecil Has a Name