I've been looking through the libGU samples, and while rotating a billboard sprite in a 3D world seems easy enough, I'm not sure how you could rotate a sprite using the GU_TRANSFORM_2D setup.  Does anyone know how it's done?
-Sean Givan
			
			
									
									
						Rotating a 2D sprite in libGU?
Well, if you're using GU_TRANSFORM_2D, you have to deal with it yourself. Either, you could setup a Ortho-matrix (2D projection) and use GU_TRANSFORM_3D, or use the following formula
to rotate you coordinates before displaying them.
Or, you could use matrix-math to transform coordinates, but then I'd suggest you setup a ortho-matrix anyway.
I should perhaps do a small example on doing 2D projections, as people seem to want to know how to do them.
			
			
									
									Code: Select all
x = cos(a)*x - sin(a)*y
y = sin(a)*x + cos(a)*y
Or, you could use matrix-math to transform coordinates, but then I'd suggest you setup a ortho-matrix anyway.
I should perhaps do a small example on doing 2D projections, as people seem to want to know how to do them.
GE Dominator
						Code: Select all
	float width = right-left;
	float height = bottom-top;
	float depth = near-far; //depth is reversed on psp
	m[0*4+0] = 2.0f/width;
	m[1*4+1] = 2.0f/height;
	m[2*4+2] = 2.0f/depth;
	m[3*4+0] = -(left+right)/width;
	m[3*4+1] = -(top+bottom)/height;
	m[3*4+2] = -(near+far)/depth;
	m[3*4+3] = 1.0f;You may want to negate the Y axis though depending on your preference.
- 
				dctrvenkman
- Posts: 4
- Joined: Tue Aug 02, 2005 3:13 am
I'm looking for more information on using GU_TRANSFORM_2D also.  Altho I'm not trying to rotate just simple translations.  I've been trying to translate by updating the x and y coords in my vertices but I've been getting weird reactions. For example save in my vertices array I have 12 vertices (4 triangles) and I update the x member for all of them (thinking all 4 triangles should move horizontally). Only some of the vertices will update in the display (not even necessarily all verts in a triangle). Another issuse is when I attach the x or y transforms to key presses (dpad) its like the view doest update in real time tho the code works fine if I use GU_TRANSFORM_3D. maybe I'd doing something really stupid. A nice little demo using GU_TRANSFORM_2D and some simple transforms might be nice.
			
			
									
									
						- 
				dctrvenkman
- Posts: 4
- Joined: Tue Aug 02, 2005 3:13 am
- 
				dctrvenkman
- Posts: 4
- Joined: Tue Aug 02, 2005 3:13 am