What I am looking to do is to be able to push and pop transform matrices into SpriteBatch. I have 2 sprites, parent and child, and the child should be scaled, rotated, translated relative to the parent.
I currently have an implementation using textured quads but I think this should be possible using the built in SpriteBatch class and using Matrix.Decompose(). I’m not sure how to pass the decomposed values to SpriteBatch once I’ve decomposed them though.
I understand how to keep the matrix stack, I’m just looking for an example of using values coming from Matrix.Decompose() in conjunction with SpriteBatch.
Figured this one out myself finally. Most of the credit belongs to this blog post though.
You can use this method to decompose your matrix:
You can then build a transform matrix your leaf sprites like so:
For your parent sprites, include the origin:
Multiply by all the matrices in the stack in reverse order.