252 CHAPTER 8: Putting It All Together^
-(void)setFieldOfView:(float)fov
{
m_FieldOfView=fov;
[self setClipping];
}
Then move setClipping() from the view controller to the solar-system
controller, and swap out the autovariable fieldOfView for m_FieldOfView, making sure
to initialize it to something like 30° at program startup and to call setClipping() at object
creation, as used to be done in the view controller. Reinitializing the projection matrix is
now necessary, because setClipping() will be called repeatedly during the pinch-to-
zoom operations, and we don’t want them to build on each other. Otherwise, the view
quickly gets wacky.
Finally, you need to add two stubs, which will prevent a crash should you accidentally
do a drag operation. This will be filled in for the next task. To your view controller, add:
-(void)setHoverPosition:(unsigned)nFlags location:(CGPoint)location
prevLocation:(CGPoint)prevLocation
{
}
To the solar-system controller, add:
-(void)lookAtTarget
{
}
If all works as designed, you should be able to zoom in and out from the earth model, as
shown in Figure 8-3.