AlepGraphics
02-14-2007, 09:07 AM
hey ..
i'm starting a simple flight simulator .. take the following pic for example:
http://i32.photobucket.com/albums/d17/Merza/1.jpg
the view angle (in red) is about 100deg, and the red object is drawn by :
glTranslate3f(5,0,-5);
draw();
and for the ship filght simulation i used this function ( mentioned in OpenGL redbook, edition 5 ), which mimics ship's movement in moving the environment on the contrary .. and this func is called before sart drawing any object in the scene :
void PlaneView(GLfloat planeX, GLfloat planeY, GLfloat planeZ, // the plane’s position
GLfloat roll, GLfloat pitch, GLfloat yaw) // orientation
{
// roll is rotation about the z axis
glRotatef(roll, 0.0f, 0.0f, 1.0f);
// yaw, or heading, is rotation about the y axis
glRotatef(yaw, 0.0f, 1.0f, 0.0f);
// pitch is rotation about the x axis
glRotatef(pitch, 1.0f, 0.0f, 0.0f);
// move the plane to the plane’s world coordinates
glTranslatef(-planeX, -planeY, -planeZ);
}
so for now, when i'm trying to move to ship toward the red object (or moving the object closer to ship) .. the red object is going naturally on the new Z-Axis as shown ..
http://i32.photobucket.com/albums/d17/Merza/2.jpg
how can this be solved, achieving that whatever the environment is rotated, moving forward is done toward the view center ?!
thankfully ...
i'm starting a simple flight simulator .. take the following pic for example:
http://i32.photobucket.com/albums/d17/Merza/1.jpg
the view angle (in red) is about 100deg, and the red object is drawn by :
glTranslate3f(5,0,-5);
draw();
and for the ship filght simulation i used this function ( mentioned in OpenGL redbook, edition 5 ), which mimics ship's movement in moving the environment on the contrary .. and this func is called before sart drawing any object in the scene :
void PlaneView(GLfloat planeX, GLfloat planeY, GLfloat planeZ, // the plane’s position
GLfloat roll, GLfloat pitch, GLfloat yaw) // orientation
{
// roll is rotation about the z axis
glRotatef(roll, 0.0f, 0.0f, 1.0f);
// yaw, or heading, is rotation about the y axis
glRotatef(yaw, 0.0f, 1.0f, 0.0f);
// pitch is rotation about the x axis
glRotatef(pitch, 1.0f, 0.0f, 0.0f);
// move the plane to the plane’s world coordinates
glTranslatef(-planeX, -planeY, -planeZ);
}
so for now, when i'm trying to move to ship toward the red object (or moving the object closer to ship) .. the red object is going naturally on the new Z-Axis as shown ..
http://i32.photobucket.com/albums/d17/Merza/2.jpg
how can this be solved, achieving that whatever the environment is rotated, moving forward is done toward the view center ?!
thankfully ...