3D Static Viewing 101

View Orientation

View orientation: Map 3D Model Coordinates to 3D Eye Coordinates (MC→EC)

Projections

View Projection: Map 3D Eye Coordinates to 3D Logical Device Space (EC→LDS)

Strategies for Establishing Viewing Parameters

Using the viewing specifications implied by the two figures above and on the right, an observer (e.g., our Robot viewer) would see the image on the display that is shown on the left. The labels in that view show, in order, the actual values used for the eye point, center of attention, up vector, ecZpp, ecXmin, ecXmax, ecYmin, ecYmax, ecZmin, and ecZmax. So what is the significance of the viewing situation we suggested in the two figures on the right above? How did that concept lead to the actual numeric values we used? This will become clear after you read and study the two viewing strategies introduced below.

Before getting into the specifics of the strategies, note that a common issue will be to decide how far from the scene being viewed we should place the eye. This issue is most significant when creating perspective projections – and that will be the focus here – but it is relevant to the others as well. While not directly used in the strategies we discuss below, you may want to understand one interesting and related issue: the amount of perspective distortion we wish to see in a scene and how we control it.

Two Strategies

Here are two specific strategies that can easily be employed in our framework to guide us when computing reasonable values for the (eye, center, up) needed for the MC→EC transformation and the eye coordinate frustum dimensions and projection plane z coordinate needed for the EC→LDS projection transformation. Which strategy you use depends on how you are viewing your 3D scene.

  1. Viewing Strategy #1: You are standing completely outside of the 3D scene, as implied in the teapot images above.
  2. Viewing Strategy #2: You are inside the 3D scene. (Imagine standing inside of a room.) The basic ideas of the eye coordinate system, projection plane, and view frustum are all the same; the only difference is that parts of the scene will likely be all around the viewer.

Where Are These Strategies Implemented?

Implementing one of the two strategies above will provide us with the numeric values required for:

ModelView::getMatrices will actually invoke cryph::Matrix4x4::lookAt and the appropriate projection method, but you need to clearly understand when and how the parameters for these methods are specified. In our framework, establishing values, modifying them interactively, and using them involves three players: main's set3DViewingInformation, ModelView::getMatrices, and various event handlers. The table below summarizes how this works, and this annotated partial implementation of set3DViewingInformation provides more detail and includes an EXERCISE. Be sure you know how to do this exercise.

MatrixParameters
(ModelView class variables)
These parameters are normally initialized in set3DViewingInformation in main.c++ based on the desired Viewing StrategyParameters interactively modifiable? ModelView::getMatrices
(Where parameters are used to compute matrices)
MC→ECeye, center, upThis is where you apply the "View Orientation" portion of Viewing Strategy #1 or #2. yesPasses current values to cryph::Matrix4x4::lookAt.
EC→LDS projectionType yes Determines which cryph::Matrix4x4 projection method is to be used.
ecZpp yes Uses current value when calling appropriate cryph::Matrix4x4 projection method.
ecXmin, ecXmax, ecYmin, ecYmaxInitialization is indirect. The values passed to ModelView::setMCRegionOfInterest in set3DViewingInformation will be used in ModelView::getMatrices to compute values for these four parameters on each display callback. For Viewing Strategy #1, you simply pass the "overall MC Bounding Box" as we have seen to this point. For Viewing Strategy #2, you will want to set the "MC region of interest" as discussed in class and summarized in the Viewing Strategy #2 web page. indirectly via zooming and/or aspect ratio preservation Computes values based on the current MC region of interest, current global zoom, and aspect ratio preservation. Passes resulting values to the appropriate cryph::Matrix4x4 projection method.
ecZmin, ecZmax yes Uses current values when calling appropriate cryph::Matrix4x4 projection method.
projectionDir yes Uses current value if calling cryph::Matrix4x4::oblique.

You need to write code in your ModelView subclass to capture and process an event to modify the value.

The Controller uses keys O, P, and Q to tell the ModelView class to switch among Orthogonal, Perspective, and Oblique, respectively.

Finally…

During display callbacks, instead of calling ModelView::compute2DScaleTrans, we will call ModelView::getMatrices to compute the two required matrices (mc_ec and ec_lds) based on the current state of the possibly interactively modified values.