Advertisement

Looking up, down,left,right

Started by May 17, 2002 05:07 PM
2 comments, last by iamtio 22 years, 9 months ago
Hell,I need some help with this I am trying to make a box and place a camera in that box. The position of the camera is fixed so it can't move. All I want to do is to look around. Well, I made a box and placed a camera. I can even look around but I dont think this is the way to do it really. So plz take a look at my code.
    
	if (keys[VK_UP])
	{
	  angleYZ += 0.002f;
	  lookPos=1;	
	}					
	if (keys[VK_DOWN])
	{
	  angleYZ -= 0.002f;
	  lookPos=1;	
	}
	if (keys[VK_RIGHT])
	{
	  angleXZ -= 0.002f;
	  lookPos=2;
	}
	if (keys[VK_LEFT])
	{
	  angleXZ += 0.002f;
	  lookPos=2;	
	}
   
      
void calcLookPos(int lookPos)
{
    switch(lookPos)
    {
     case 1:
     {
       lookX = (aLine * cos(angleYZ)) * cos(angleXZ);
       lookZ = (aLine * cos(angleYZ)) * sin(angleXZ);
       lookY = aLine * sin(angleYZ);	
       break;
     }					
     case 2:	
     {
        lookX = (aLine * cos(angleYZ)) * cos(angleXZ);
        lookZ = (aLine * cos(angleYZ)) * sin(angleXZ);	
        break;
      }	
    }  
}

//in DrawGLScene

gluLookAt(1.0f,16.0f,-1.0f,lookX,lookY,-lookZ,0.0f,1.0f,0.0f);
    
With my way, I cant handle if a user pressed up key and down key at the same time. I feel like I am using the dumpest mathematical method. Any idea? [edited by - iamtio on May 17, 2002 6:08:51 PM] [edited by - iamtio on May 17, 2002 6:10:12 PM]
soooomebodyyyyyyyy pleeeeaaase
Advertisement
Push Matrix -> Rotate Cam-> Pop Matrix

use glRotate. Trash thoose sines.
______________________________Only dead fish go with the main-stream.
thx, but I dont want it to rotate anyway
problem solved.
i had to use angle/180*PI

This topic is closed to new replies.

Advertisement