   Moving camera
  I have three double variables that represent the position of my character: posX, posY, and posZ.gluLookAt(posX,posY,posZ,cos(view_angle)+posX, sin(sight)+posY, sin(view_angle)+posZ, posX,posY+10,posZ);   //cameraI was hoping that this would allow me to move around my world by changing those variables. So I thought this should work. If i move my character it works, but if I move my character and then try to change my camera angle by changing view_angle, it doesn't work. I'm assuming it has something to do with the second three variables, but I can't figure out what to do.   
  Try multiplying the fourth, fifth and sixth sin/cos values in your gluLookAt function by 100 or so, then add the player position to that.   ;  I tried that, and it didn't help at ALL. So i tried 1000, and 10000 but those didn't do anything either. It didn't get worse, but it stayed the same.   ;Quote:Original post by bballmitchI tried that, and it didn't help at ALL. So i tried 1000, and 10000 but those didn't do anything either. It didn't get worse, but it stayed the same.You might post the code where you update the position. Also, your arguments to gluLookAt() aren't quite right. Try this:gluLookAt(   posX,   posY,   posZ,   posX+cos(view_angle)*cos(sight),   posY+sin(sight),   posZ+sin(view_angle)*cos(sight),   0.0f,   1.0f,   0.0f);;  that didn't work. It's almost as if the up vector isn't correct. Its like as you rotate the camera left or right, the camera tilts. I don't alter posY, or posX for now, but here's this code that might help:if(keys[65])  { view_angle-=PI/40;  } if(keys[87])  { if(sight < 0.4)sight+=0.05;  } if(keys[68])  { view_angle+=PI/40;  }if(keys[83])  { if(sight > -0.6)sight-=0.05;  }   if(keys[VK_UP])  {  posZ -= 0.2;  }    if(keys[VK_DOWN])  {  posZ += 0.2;  } ;  Can you post where you're calling gluLookAt()?   ;  The problem is indeed the up vector.I assume sight is the angle for looking up or down.Your up vector is posX,posY+10,posZ.This vector should change if you look up or down.if I'm right,gluLookAt(posX,posY,posZ,cos(view_angle)+posX, posY, sin(view_angle)+posZ, posX,posY+10,posZ); //delete "sin(sight)+"should work. But you cant look up or down.Let me know if this works so I don't torture my brain calculating the sin and cos stuff for nothing.[Edited by - Kwak on February 26, 2006 10:35:35 AM];Quote:Original post by KwakYour up vector is posX,posY+10,posZ.This vector should change if you look up or down.This is still wrong; the up vector should be a vector, not a point.@The OP: Again, you should post your current gluLookAt() code so we can see what the problem is.   ;  You are right about that. (I'm not so familiar with lookat function)void gluLookAt(eyex, eyey, eyez,  //The position of the eye point. centerx, centery, centerz,  //The position of the reference point.upx, upy, upz  //The direction of the up vector. );So gluLookAt(posX,posY,posZ,cos(view_angle)+posX, posY, sin(view_angle)+posZ, 0,10,0);should work. But you cant look up or down.If you want to be able to look up/down, the reference point and the up vector are more difficult to calculate:The position of the eye point -----------------------------posXposYposZThe position of the reference point-----------------------------------posX + cos(view_angle)*cos(sight)posY + sin(sight)posZ + sin(view_angle)*cos(sight)The direction of the up vector-------------------------------sin(sight)*cos(view_angle)cos(sight)-sin(sight)*sin(view_angle)I suggest you trygluLookAt(posX, posY, posZ,cos(view_angle)+posX, posY, sin(view_angle)+posZ,0, 10, 0);first, so you know the problem is not caused by something else. If it works (except looking up/down) trygluLookAt(posX, posY, posZ,posX + cos(view_angle)*cos(sight), posY + sin(sight), posZ + sin(view_angle)*cos(sight),-sin(sight)*cos(view_angle), cos(sight), -sin(sight)*sin(view_angle));Good luck!   ;  I'd like to be able to look up and down. But here's the area where i call gluLookAt() :int DrawGLScene(GLvoid)// Here's Where We Do All The Drawing{glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );gluLookAt(0,0,0,cos(view_angle), sin(sight), sin(view_angle), 0,10,0);   //camera//gluLookAt(posX,posY,posZ,posX+cos(view_angle)*cos(sight),posY+sin(sight),posZ+sin(view_angle)*cos(sight), posX,posY+10,posZ);   //cameraglEnable(GL_FOG);glPushMatrix();if(player1.getHealth() > 0)   glColor3f(1.0,1.0,1.0);   else{   glColor3f(1.0,0.0,0.0);zom.setSpeed(300);}glRotatef(skyRotation, 0, 1, 0);glTranslatef(0,-5.5,0);//draws skyglScalef(0.5,0.5,0.5);Sky->draw();skyRotation+=0.03;glPopMatrix();glPushMatrix();    //draws landglScalef(0.15,0.3,0.3);glTranslatef(0,-10,0);Land->draw();glPopMatrix();if(!inMenu){b.approach();if( findDistance( zom.getX() , zom.getY() - 1.2, zom.getZ(), b.getX(), b.getY(), b.getZ() ) < 2.0 ){    //if distance of bullet and zombie is less than radius zom.die();}glEnable(GL_LIGHTING);   //draw everything that requires lighting; everything 3DglPushMatrix();glTranslatef(0,0,0);zom.approach(0,0,-3);   zom.draw();zom.determineMovement();glPopMatrix();glPushMatrix();  //draw aimerglTranslatef(cos(view_angle), sin(sight) ,sin(view_angle));glColor3f(0.0,1.0,0.0);auxSolidSphere(0.02);glPopMatrix();glDisable( GL_LIGHTING );glDisable(GL_FOG);glLoadIdentity();if(player1.unShot() == false){glPushMatrix();glColor3f(1.0,0.0,0.0);   //call printHealth methodprintHealth();glPopMatrix();    }}else{glDisable( GL_LIGHTING );glLoadIdentity();glPushMatrix();if(screen == 1)    glColor3f(1.0,0.0,0.0);else    glColor3f(1.0,1.0,0.0);printNewGame();if(screen == 0)    glColor3f(1.0,0.0,0.0);else    glColor3f(1.0,1.0,0.0);printQuit();glPopMatrix();}return TRUE;// Everything Went OK}