Graphics Reference
In-Depth Information
Although the concepts behind the view and projection matrices are new and non-
trivial, the graphics API programming mechanisms involved for 3D are actually
quite similar to our experience from 2D. In fact, much of what we have learned in
2D applies to 3D:
Primitive class. We will continue to design graphical objects based on
the Primitive class.
SceneNode class. We will continue to use the SceneNode class to work
with the matrix stack and load the WORLD matrix processor with the proper
OC-to-WC transformation matrices.
CModel class. We will continue to define a CModel class to instantiate,
arrange, and simulate the interactions of the graphical objects based on the
semantics of the application.
In this way, we will continue to use the SceneNode class to define models, and
the Model class to arrange the scene of our application. Listing 15.1 shows pseu-
docode of a typical WindowHandler class we worked with in 2D space. Recall
that we designed this class to bind the GUI API drawing area (at label A) with the
graphics API device (at label B). A WC window (at label C) is defined to present
a different part of the scene to the GUI drawing area. We have defined transfor-
mation functions (at label D) to support proper output drawing and input mouse
clicks. During each redraw in the DrawGraphics() function, we must set up the
matrix processors (at label E) before we can invoke the CModel to draw the scene
(at label F). Recall that in our CModel::DrawModel() , we redraw every object in
the scene. It is the matrix processor settings, M w 2 n , that ensures only appropriate
objects are transformed into the bounds of the NDC space and thus are visible
on the GUI drawing area. Listing 15.2 shows a typical WindowHandler class we
would work with in 3D space. We have labeled the programming code to cor-
respond to that of Listing 15.1 for the convenience of clear comparison. Instead
of the 2D WC window, at label C a UWB _ Camera is defined to present the 3D
view in the GUI drawing area. The transformation functions at label D are now
defined for 3D cases. During redraw, in the DrawGraphics() function, the only
difference between 2D and 3D is how the matrix processors are set up at label E.
In the 3D case, we must load both the view and projection matrices to transform
from WC to NDC. The tutorials from the rest of this chapter will examine this
functionality in more detail.
Search WWH ::




Custom Search