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 

First Person Camera using sceGumLookAt..

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



Joined: 11 Feb 2006
Posts: 13

PostPosted: Sat Feb 25, 2006 10:10 pm    Post subject: First Person Camera using sceGumLookAt.. Reply with quote

I am trying to put some sort of First Person Camera in my scene that can move in all directions..

I have sucessfully implemented the function so I can move forward and backward and also rotate left and right aswell as looking up and down..

the thing is that once I turn left or right by 90°, the up and down does not work anymore.. It works fine when I look forward or backward..

I can't find a solution on this and it's bugging me for a while now.. Anybody out there that can give me some sort of hint on this..

Below is some code to show what I am doing:


Init:
Code:

eye.x = 0.0f;
eye.y = -10.0f;
eye.z = 2.5f;
center.x = 0.0f;
center.y = 0.0f;
center.z = 0.0f;
up.x = 0.0f;
up.y = 0.0f;
up.z = 1.0f;
sceGumLookAt( &eye, &center, &up ); // Set viewpoint matrix   




and in the main loop i do:


Code:



sceGumMatrixMode(GU_VIEW);
sceGumLoadIdentity();
sceGumLookAt( &eye, &center, &up ); // Set viewpoint matrix   


With the Pad Control:
   if (padd & PSP_CTRL_UP) {
      angle += 0.01;
      angle_y = angle;
      angle_z = angle;
      center.z += angle_y * 2;
      orientMe(-angle_z,0);
      
   }
   if (padd & PSP_CTRL_DOWN) {
      angle -= 0.01;
      angle_y = angle;
      angle_z = angle;
      center.z += angle_y * 2;
      orientMe(-angle_z,0);
   }
   if (padd & PSP_CTRL_LEFT) {
      orientMe(camspeed,0);
   }
   if (padd & PSP_CTRL_RIGHT) {
      orientMe(-camspeed,0);
   }

   if (padd & PSP_CTRL_CIRCLE) {
      moveMeFlat(-camspeed);
   }

   if (padd & PSP_CTRL_CROSS) {
      moveMeFlat(camspeed);
   }

void orientMe(float speed, int mode) {
ScePspFVector3 vVect;
vVect.x = center.x - eye.x;
vVect.y = center.y - eye.y;
vVect.z = center.z - eye.z;
center.y = (float)(eye.y + sinf(speed)*vVect.x + cosf(speed)*vVect.y);
center.x = (float)(eye.x + cosf(speed)*vVect.x - sinf(speed)*vVect.y);
}

void moveMeFlat(float speed) {
   ScePspFVector3 vVect;
   vVect.x = center.x - eye.x;
   vVect.y = center.y - eye.y;
   vVect.z = center.z - eye.z;

   eye.x = eye.x + vVect.x * speed;
   eye.y = eye.y + vVect.y * speed;
   eye.z = eye.z + vVect.z * speed;
   center.x = center.x + vVect.x * speed;
   center.y = center.y + vVect.y * speed;
   center.z = center.z + vVect.z * speed;
}



Any help would be greatly appreciated since I am really getting frustrated :(
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