Pro OpenGL ES for iOS

(singke) #1

CHAPTER 3: Building a 3D World (^75)
Figure 3-13. The zFar plane is reset, while the zNear plane is moved back to clip any part of the cube that is
too close.
Using Z-axis clipping such as this is very helpful when dealing with large and
complicated worlds. You’d likely not want all objects you might be ‘‘looking at’’ to be
rendered, because many could be too far away to really see. Setting zFar and zNear to
limit the visibility distance could speed up the system. However, this would not be the
best substitute for preculling your objects before they get into the pipeline.
Field of View
Remember that the viewer’s FOV can also be changed in the frustum settings. Go back
to our bouncy friend again and make sure your zNear and zFar settings are back to the
normal values of .1 and 1000. Now change the z value in drawInRect() to -20 and run
again. Figure 3-14 (left) is what you should see.
Next we’re going to zoom in. Go to setClipping() and change fieldOfView =5 degrees
from 60 degrees. The results are depicted in Figure 3-14 (center). Notice how the cube
has no apparent vanishing point or no perspective when compared to Figure 3-14 (right).

Free download pdf