Hello Guys
I have an atlas with the rotation around y-axis of a circle. I’m interest just in the lower row, 16 element (per 16 in heigth). I want then to rotate around z-axis.
So I should first offset the right sprite and rotate it.
To offset a texture, if my atlas contains 16x16 elements I should divide gl_TexCoord by numsprite (16) and add (offset/numsprite) for each further i wanna address. f.e. (offset = 0 for lower left element, 1 for the second in the row and so on)
That said for rotating:
- translate the texture to its origin
- rotate around z
- translate back
I do this by combining these 3 matrix and multipling the result for the original (gl_TexCoord.xy/numsprite). The left lower sprite rotates correctly that is: subtract 0.5/numsprite to x and y texture component to center it, rotate, translate back…
But when I try to rotate the next in the row this fails…(for example offset = 1.5)
Any suggestion or alternative?
thank you