Game Development Reference
In-Depth Information
Glu.gluLookAt( cameraPosition.X, cameraPosition.Y,
cameraPosition.Z,
cameraLookAt.X,
cameraLookAt.Y,
cameraLookAt.Z,
cameraUpVector.X, cameraUpVector.Y,
cameraUpVector.Z);
Gl.glBegin(Gl.GL_TRIANGLE_FAN);
{
Gl.glColor3d(1, 0, 0);
Gl.glVertex3d(0.0f, 100, 0.0f);
Gl.glColor3d(0, 1, 0);
Gl.glVertex3d(-100, -100, 100);
Gl.glColor3d(0, 0, 1);
Gl.glVertex3d(100, -100, 100);
Gl.glColor3d(0, 1, 0);
Gl.glVertex3d(100, -100, -100);
Gl.glColor3d(0, 0, 1);
Gl.glVertex3d(-100, -100, -100);
Gl.glColor3d(0, 1, 0);
Gl.glVertex3d(-100, -100, 100);
}
Gl.glEnd();
}
}
The function call to Glu.gluLookAt is new and it sets up the positioning of a
3D camera to view the scene through. The position of the camera is made of
three vectors: the first is the position of the camera in the world, the second is the
position of what the camera should point at, and the final vector points upwards.
If the up vector were reversed by setting the Y component to -1 then the scene
shown in Figure 11.1 would appear upside down.
If you wish to learn more about using 3D graphics in games, then I suggest the
following steps.
 
Search WWH ::




Custom Search