Game Development Reference
In-Depth Information
ï?® centerX , centerY , and centerZ specify a point in the world that the camera
looks at.
ï?® upX , upY , and upZ specify the up vector . Think of it as an arrow coming out at
the top of your skull, pointing upward. Tilt your head to the left or right and
the arrow will point in the same direction as the top of your head.
The up vector is usually set to (0,1,0), even if that's not entirely correct. The gluLookAt() method
can renormalize this up vector in most cases. Figure 10-19 shows our scene with the camera at
(3,3,0), looking at (0,0,-5), as well as its “real� up vector.
Figure 10-19. Our camera at position (3,3,0), looking at (0,0,-3)
We can replace the code in the HierarchyScreen.present() method we changed before with the
following code snippet:
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
GLU.gluLookAt(gl, 3, 3, 0, 0, 0, -5, 0, 1, 0);
This time, we also commented out the call to sun.update() , so the hierarchy will look like the
one shown in Figure 10-19 . Figure 10-20 shows the result of using the camera.
Figure 10-20. The camera in action
Search WWH ::




Custom Search