forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

sceGumRotateX problem

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
sigutis



Joined: 21 Mar 2009
Posts: 7

PostPosted: Thu Mar 26, 2009 7:32 pm    Post subject: sceGumRotateX problem Reply with quote

Hello, I am trying to rotate an image like this
Code:

        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?
Back to top
View user's profile Send private message
Noware



Joined: 03 Jan 2009
Posts: 1

PostPosted: Fri Mar 27, 2009 4:20 am    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message
sigutis



Joined: 21 Mar 2009
Posts: 7

PostPosted: Fri Mar 27, 2009 6:30 am    Post subject: Reply with quote

I figured I have to set GU_TRANSFORM_2D to GU_TRANSFORM_3D but now I can't see anything. The further the better....
Back to top
View user's profile Send private message
Smong



Joined: 04 Sep 2007
Posts: 82

PostPosted: Fri Mar 27, 2009 7:38 am    Post subject: Reply with quote

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.
_________________
(+[__]%)
Back to top
View user's profile Send private message
sigutis



Joined: 21 Mar 2009
Posts: 7

PostPosted: Fri Mar 27, 2009 4:21 pm    Post subject: Reply with quote

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:

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?
Back to top
View user's profile Send private message
Smong



Joined: 04 Sep 2007
Posts: 82

PostPosted: Sat Mar 28, 2009 7:42 am    Post subject: Reply with quote

Have a look at samples/gu/common/geometry.h
For 32BITF you want something like:
Code:
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.
_________________
(+[__]%)
Back to top
View user's profile Send private message
sigutis



Joined: 21 Mar 2009
Posts: 7

PostPosted: Sun Mar 29, 2009 3:34 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Smong



Joined: 04 Sep 2007
Posts: 82

PostPosted: Sun Mar 29, 2009 5:10 am    Post subject: Reply with quote

You could have a look at the ortho sample included in pspsdk. It draws a triangle and rotates it.
_________________
(+[__]%)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group