   OpenGL, Cameras and co-ordinate systems
  Hi, I've just finished writing a simple 2D R-type style shooter for a piece of coursework and I'm having a look at doing something simple in 3D (just roaming around a 3D world) but it seems like I'm missing some basic understanding of the way 3D space is being represented in OpenGL...I'm using the camera to set up and alter exactly where I'm looking at any one time by rotating the scene by the camera's rotation values and translating the scene by it's positional values, this seems to give me the effect of moving around...but only up to a point. What I'd like to do is to allow the camera to pivot on the spot. I thought I'd be able to do this by first translating back to the origin, performing the rotations then translating back to the actual position of the camera. Something like:glTranslatef(camera.GetX(),camera.GetY(),camera.GetZ());glRotatef(camera.GetPitch(),1,0,0);glRotatef(camera.GetYaw(),0,1,0);glRotatef(camera.GetRoll(),0,0,1);glTranslatef(-camera.GetX(),-camera.GetY(),-camera.GetZ());and it works...up until the camera's z position reaches about 700. Once z passes 700 the camera appears to be yaw-ing around the origin without actually translating there first so it no longer appears to be pivotting on the spot. I suspect it's not actually pivoting on the spot at all and the effect only becomes noticable around 700, but if that's the case then the leap between 700 and 701 is oddly dramatic...Or do I have some basic misunderstanding of the 3D co-ordinate system in OpenGL? I had a large amount of trouble trying to set up test polygons using gluPerspective()/glFrustum() (I gave up on glFrustum() in the end, I just couldn't make it do what I wanted), gluLookAt() and my camera's position. I now have a simple scene using gluPerspective(60,window_width/window_height,1.0,20.0) and a couple of polygons as place holders so I know where I am and the direction I should be headed. Is this in some way a mad side-effect of directly using the rotation and translation of my camera to specify my position and orientation rather than feeding it all into gluLookAt()?If any more code's needed (or most clarification) just let me know... thanks for any help.[edited by - Never on February 11, 2004 12:14:32 PM]
  u don''t have to use glLookAt(). first thing to know is that ogl applies transformations in inverse order. that is, the last transform call(translate, rotate, etc) is applied first because the final transform matrix is multiplied with each vertexie: TxRxRxRxTxV where T is translate, R is rotate and V is vertex, so the last T is applied first. u can find basic movment in 3d space at nehe site(nehe.gamedev.net). so u have to translate, then rotate. that means RxTxV. Another possible error is that u don''t call glLoadIdentity() every frame, so the opengl matrix is not reset at every frame, wich can produce very strange results.   Mihai 