Pro OpenGL ES for iOS

(singke) #1

74 CHAPTER 3: Building a 3D World^


zFar from 1000 down to 1.5. Why? Remember that the cube’s local origin is 2.0 and its
size is 1.0. So when facing straight at us, the closest point would be 2.5 because each
of the sides would straddle the origin with .5 on each side. So, by changing the value of
zFar to 1.5, the cube would be hidden when it is exactly facing us. But portions will peek
through, looking something like a piece of flotsam poking above the water. The reason is
that when it rotates, the corners are naturally going to be a little closer to the viewing
plane, as shown in Figure 3-12.
So, what happens when I move the near clipping plane farther away? Reset zFar back
to 1000 (a number that is arbitrarily large enough to ensure we can see everything) and
set zNear from .1 to 1.5. What do you think it will look like? It will be the opposite of the
previous example. See Figure 3-13 for the results.

Figure 3-12. Peek-a-boo! The cube is clipped when any part of it is farther away than zFar.
Free download pdf