sceGumRotateX problem

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
sigutis
Posts: 7
Joined: Sat Mar 21, 2009 6:02 pm

sceGumRotateX problem

Post by sigutis »

Hello, I am trying to rotate an image like this

Code: Select all

        vertices[0].u = minx; 
	vertices[0].v = miny;
	vertices[0].color = 0;
	vertices[0].x = playerX;
	vertices[0].y = playerY;
	vertices[0].z = 0;

	vertices[1].u = minx; 
	vertices[1].v = miny+maxy;
	vertices[1].color = 0;
	vertices[1].x = playerX;
	vertices[1].y = playerY+maxy;
	vertices[1].z = 0;

	vertices[2].u = minx+maxx; 
	vertices[2].v = miny;
	vertices[2].color = 0;
	vertices[2].x = playerX+maxx;
	vertices[2].y = playerY;
	vertices[2].z = 0;


	vertices[3].u = minx+maxx; 
	vertices[3].v = miny+maxy;
	vertices[3].color = 0;
	vertices[3].x = playerX+maxx;
	vertices[3].y = playerY+maxy;
	vertices[3].z = 0;
	sceGumLoadIdentity(); 
	sceGumRotateX(50.0f);
	sceGuDrawArray(GU_TRIANGLE_STRIP,GU_TEXTURE_16BIT|GU_COLOR_8888|GU_VERTEX_16BIT|GU_TRANSFORM_2D,4,0,vertices);
However I can see only half of my image and it is not rotated whatsoever. I am missing anything here?
Noware
Posts: 1
Joined: Sat Jan 03, 2009 3:44 am

Post by Noware »

update the angle

sceGumLoadIdentity();
static float angle = 0.0f;
angle+= 1.0f;
sceGumRotateX(angle);

Noware
Reporter - What do you think of western civilization?
Gandhi - I think it would be a good idea!
sigutis
Posts: 7
Joined: Sat Mar 21, 2009 6:02 pm

Post by sigutis »

I figured I have to set GU_TRANSFORM_2D to GU_TRANSFORM_3D but now I can't see anything. The further the better....
Smong
Posts: 82
Joined: Tue Sep 04, 2007 4:44 am

Post by Smong »

You don't want to use GU_TEXTURE_16BIT and GU_VERTEX_16BIT in GU_TRANSFORM_3D mode unless you prescale your vertices. It would be a lot easier to use the 32BITF versions.
(+[__]%)
sigutis
Posts: 7
Joined: Sat Mar 21, 2009 6:02 pm

Post by sigutis »

I see. Well, there's one thing bothering me about the 32BITF vertices. I am currently using a vertex struct size of 16 bytes in the 16BIT mode. If I was to use 32BITF logically I need a vertex structure of 32 byte size. And I have no idea what could I put in there to double the size.

Code: Select all

struct Vertex
{
	unsigned int u, v;   //texture coordinates
	unsigned int color; //color which I don't use
	int x, y, z;            //coords
	long a,b;              //useless variables to fit into the 32 byte range

};
I have no idea how else could I make a 32 byte vertex, do you?
Smong
Posts: 82
Joined: Tue Sep 04, 2007 4:44 am

Post by Smong »

Have a look at samples/gu/common/geometry.h
For 32BITF you want something like:

Code: Select all

struct Vertex
{
    float u, v;
    float x, y, z;
};
You said you don't use the color so just take GU_COLOR_8888 out of the sceGuDrawArray call.

32BITF means 32 bit float, so that's just a float, not a double. It doesn't mean the vertex struct is 32 bytes, but it may coincidentally be that size.
(+[__]%)
sigutis
Posts: 7
Joined: Sat Mar 21, 2009 6:02 pm

Post by sigutis »

Thanks for the help I really appreciate it. I have done some tweaking using the information you guys provided, but it seems that hardware rotation is just not for me. I switched to manually rotating those vertexes with some trigonometry. Take care.
Smong
Posts: 82
Joined: Tue Sep 04, 2007 4:44 am

Post by Smong »

You could have a look at the ortho sample included in pspsdk. It draws a triangle and rotates it.
(+[__]%)
Post Reply