Graphics Reference
In-Depth Information
rendering context and replace the MFC drawing area (at label B in Listing 15.9)
onto the CTutorialDlg window. Similarly, the function call at label E will re-
place the CSceneTreeControl object into the CTutoralDlg window. At label F,
we have the opportunity to initialize the camera.
Notice that the two squares and the associated scene hierarchy are defined in
the CModel class and that the instance of CModel is defined in the CTutorialApp
class. In this way, we can think of the CModel as the world, and the m _ MainView
( CDrawHandler ) object as a camera with an associated image area looking at the
CModel . This agrees with our MVC architecture, where the CModel is the model
and the CDrawHandler is an output-only view/controller pair. Now, we should be
able to define multiple view/controller pairs to examine the model.
15.2
Working with Multiple Cameras
Tutorial 15.2.
Project Name:
D3D _ TwoCamera
Library Support:
UWB _ MFC _ Lib1
UWB _ D3D _ Lib14
Tutorial 15.2. Working with Two Cameras
Goal. Demonstrate the MVC architecture framework where we can support
multiple view/controller pairs looking at the model.
Approach. Instantiate multiple WindowHandler objects to look at the two
simple squares CModel scene from multiple viewpoints.
Figure 15.2 is a screenshot of running Tutorial 15.2. This tutorial implements two
different cameras looking at the simple square scene, the main view at the left of
the application window, and the small view underneath the CSceneTreeControl .
To conserve on-screen real estate, the camera and view frustum control param-
eters have been organized into a pop-up control window. The user can activate
the control by clicking on the camera control checkbox and selecting which of
the cameras she wishes to control. Listing 15.11 shows that we only need to in-
clude an additional CDrawHandler object to support the second camera view (at
label B). The new CDrawHandler is also properly initialized and replaced onto
the CTutorialDlg window (at label D). Finally, and very importantly, we must
render from the new CDrawHandler object during OnTimer services (at label G).
At label C is the new camera GUI control object. This object is initialized at
label E, where it is default to be invisible and in control of the main view camera.
Figure 15.2.
Tutorial
15.2.
15.3
Manipulating the Camera
We have learned to describe the camera by specifying the camera position, look-
at position, and up vector, and the view frustum by specifying the near/far planes
and field of view (FOV). Of these parameters:
 
Search WWH ::




Custom Search