Session 3 - Viewing
    This section covers the following procedures:
    •  Viewing geometric models in any orientation
    •  Controlling the location of the viewpoint in 3-space
    • Clipping undesired portions of the model out of the scene
    • Manipulating the appropriate matrix stack for viewing and manipulating the model
    • Combining multiple transformation for sophistcated systems
    • Reverse the operations of a the pipeline

     
     
     
     
     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Viewing (cont)
  • Image on book cover
  •  Ch 2 described how to draw the blocks 
    • how are they positioned?
    • how is the vantage point specified?

     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

3-D Image generation
  • Image generation is a process of taking a 3-dimensional model and viewpoint and forming a 2-D image
  •  It is the job of the graphics processor to do that transformation - not the developer
  •  Application code should manipulate the model in 3-D and ignore the process of generating the image

  •  

     
     
     
     
     
     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

The Camera Analogy:
  • To Produce a photograph the following steps have to be taken: (Figure 3-1)


  •  
1. Set up your tripod and pointing the camera at the scene (viewing transformation). 
2. Arrange the scene to be photographed into the desired composition (modeling transformation). 
3. Choose a camera lens or adjust the zoom (projection transformation). 
4. Determine how large you want the final photograph to be - for example, you might want it enlarged (viewport transformation).
     
     
     
     
     
     
     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

The transformation process
  • The camera analogy maps to a series of matrix multiplications on the vertices of the model 
  •  The order of operations is modified slightly from the camera analogy
  •  Figure 3-2


  •  
     
     
     
     
     
     
     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Drawing of 3D models
  • Example 3-1 
  •  A few new routines in display()
    • glLoadIdentity()
    • gluLookAt()
    • glScalef()
  •  New routines in reshape()
    •  glLoadIdentity()
    •  glFrustrum()
    •  glMatrixMode()
  • Note that some of these calls are part of the GL Utility Library (GLU) and some are OpenGL calls 

  •  

     
     
     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

The Viewing Transformation
  • Analogous to positioning and aiming the camera
  •  Clear out the current value with glLoadIdentity()
    •  Most of the time you will want to clear
  • gluLookAt() specifies:
    • the position of the camera
    • the point to look at
    • the "up" vector (roll-stability)
  •  The default position of the viewpoint is at the origin looking down the -z axis with +y as the "up" vector

  •  

     
     
     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

The Modeling Transformation
  • The modelling transformation is used to position and orient the model
  •  The following calls will perform these operations:
    •  glRotatef()
    • glTranslatef()
    • glScalef()
  •  Scales of 1.0 or tranlations/rotations of 0.0 have no effect
  •  These calls affect the modelview (or projection) matrices

  •  

     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Duality in viewpoint/model spevification
  • Where tranformations are done is up to the application.
  •  Whether you move the camera or move the model (or both) is up to the developer
  •  Viewing and modeling transformations are combined into the modelview matrix anyway

  •  

     
     
     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

The Projection Transformation
  • Specifying a projection transformation is similiar to choosing a lens for the camera
  •  The viewing frustrum determines how much of the scene is visible (FOV)
  •  The projection of the objects on the screen is also specified (separate from FOV)
  •  Perspective projections can be specified with glFrustrum() 
  •  Orthographic transformations do not scale model vertices based on range (measurements are preserved)

  •