Hi All,
I have checked many sites and tutorials on handling a camera and objects positionning but there are thing that does not work as they should ...
Firstly, here is my Display function for OpenGL :
void MyDisplayFunc(){
if ( BasicCamera.Backdrop == 1 ){
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
}
UpdateCamera();
Basic3D_UpdateWorld();
glSwapBuffers();
}
Here is the UpdateCamera() function :
void UpdateCamera(){
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
// Rotation under the 3 axis
glRotatef( Camera.XRot[ CurrentCamera ], 1.0, 0.0, 0.0 );
glRotatef( Camera.YRot[ CurrentCamera ], 0.0, 1.0, 0.0 );
glRotatef( Camera.ZRot[ CurrentCamera ], 0.0, 0.0, 1.0 );
// Positionning of the camera.
glTranslatef( Camera.XPos[ CurrentCamera ], Camera.YPos[ CurrentCamera], Camera.ZPos[ CurrentCamera ] );
glMatrixMode( GL_MODELVIEW );
}
And Here is the object update function per object :
void INTERNAL_Trace3DObject( int ObjectID ){
Object3DPointer MyObject;
MyObject = GetObjectPTR( ObjectID );
if ( MyObject != NULL ){
int *ObjectMeshPTR;
ObjectMeshPTR = GetObjectMeshPTR( ObjectID );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glColor3f( MyObject->RGBRed, MyObject->RGBGreen, MyObject->RGBBlue );
glTranslatef( MyObject->XPos, MyObject->YPos, MyObject->ZPos );
glRotatef( MyObject->XRot, 1.0, 0.0, 0.0 );
glRotatef( MyObject->YRot, 0.0, 1.0, 0.0 );
glRotatef( MyObject->ZRot, 0.0, 0.0, 1.0 );
glEnableClientState( GL_VERTEX_ARRAY );
ObjectMeshPTR = ObjectMeshPTR + 12;
glVertexPointer( 3, GL_FLOAT, 24, ObjectMeshPTR );
glDrawArrays( GL_TRIANGLES, 0, 12 );
glDisableClientState( GL_VERTEX_ARRAY );
}
}
The function Basic3D_UpdateWorld() only check if object exist and if it exist it call the INTERNAL_Trace3DObject function to display it.
Here are now the problems :
What work correctly :
1. Object rotation is ok
What's wrong :
2. Object positionning. If I modify X, Y or Z of object position ... it does no more appear on camera
3. Camera position. if I modify X, Y or Z nothing appear on screen (black screen).
4. Camera rotation. if I modify X, Y or Z nothing appear on screen (black screen). (even of 0.1 degree )
Does someone have any clue ?
PS : I have tried to understand how gluLookAt function work but I did not find any solution with it too...
Thank you.
Regards,
Freddix/AmiDARK
Edited by freddix on 2009/9/23 0:47:47
Edited by freddix on 2009/9/30 21:44:13