Rotation of Sprites Through Z Dimension?

Monkey Forums/Monkey Programming/Rotation of Sprites Through Z Dimension?

zoqfotpik(Posted 2013) [#1]
Is it possible to rotate sprites up through the Z dimension? This might sound like a silly question but the draws are all OpenGL, are they not? I have a somewhat ghetto version of this using scaling but that isn't true perspective rotation.

To understand what I mean, imagine if your square sprite was attached down through the Y dimension of the sprite to a line and was then rotating around that.

Any ideas?


AdamRedwoods(Posted 2013) [#2]
that's rotating around the Y axis, and adding perspective (things closer appear larger than things further away). you can do this by carefully calculating the vertices of your textured poly. it's an undocumented, but very powerful command:
Function DrawPoly( verts#[],image:Image,frame:Int=0 )

the array is per vertice [x0,y0,u0,v0, x1,y1,u1,v1, x2,y2,u2,v2]. it takes 3 vertices per triangle (as shown 0,1,2). an image uses two triangles (called a quad).
you'll have to apply a 4x4 rotation+perspective matrix to your 2d points. you may be able to cheat and simplify the process a bit.


SLotman(Posted 2013) [#3]
If you need rotation only on Y or X axis, you can use Scale.

try something like this:

For local f:Float = -1 to 1 step .5
Scale f,1
DrawImage <some_image_here>,100,100
Next
Scale 1,1