Pro OpenGL ES for iOS

(singke) #1

52 CHAPTER 3: Building a 3D World^


math coordinates (although that can be adjusted as needed by using some of the Core
Graphics transformation routines).
Now jumping to OpenGL 3D coordinates, we have a slightly different system using
Cartesian coordinates, the standard of expressing locations in space. Going back to the
math coordinates, OpenGL has the origin in the lower-left corner, with +Y going up. But
now we add a third dimension expressed as Z. In this case, +Z is pointing out toward
you, as shown in Figure 3-1.

Figure 3-1. OpenGL ES 3D Cartesian coordinate system (image by Jorge Stolfi)

In fact, we have several kinds of coordinate systems, or spaces, in OpenGL, with each
space being transformed to the next:
„ Object space, which is relative to each of your objects.
„ Camera (or eye) space, local to your viewpoint.
„ Projection (or clip) space, which is the 2D screen or viewport that
displays the final image.
„ Normalized device coordinates (NDCs), which express the xyz values
normalized from -1 to 1. That is, a value or set of values are
normalized such that they fit inside a cube 2 units on a side.
„ Windows (or screen) coordinates, which are the final locations of your
scene when displayed in the actual screen.
These coordinate systems can be expressed in pipeline form, as shown in Figure 3-2.
Free download pdf