Page 1 of 1

Transformation Stack and SpriteBatch

Posted: Fri Aug 01, 2014 1:05 pm
by mode7
Hey everyone, I'm working on a modular animation runtime for my game, similar to spine, spriter or anime studio (whose file format I'm currently parsing). Drawing these animations results in a high number of draw calls which can be really slow for many characters.

Using a texture atlas and a spriteBatch can really speed this up but my problem is, that I have to rely on coordinate system transformations via the love2d transformations stack especially (with push and pop) as I'm doing several transformations (e.g. one for the layer, one for the bone).

The spriteBatch's add and set methods unfortunately ignore the transformation stack. I can however put values for scaling, rotation and shearing in there.

I think if I could do the coordinate system transformations myself but I don't know how to pull it off. Especially as I need to have controll over the order in which the transformation is applied. For example sometimes I need to scale a rotated image resulting in some shearing. But how do I calculate this kn a way that I can pass it to spritebatch:add?

I hope any of this makes any sense. Thanks in advance
Alex