Title: Chapter 3 Viewing
1Chapter 3 Viewing
2Contents
- Overview The Camera Analogy
- Viewing and Modeling Transformation
- Projection Transformation
- Viewport Transformation
3Chapter Objectives
- View a geometric model in any orientation
- Control the location in 3D space
- Clip Undesired portions of the model
4Overview -The Camera Analogy-
5Overview The Camera Analogy
- Viewing Transformation
- Positioning the view volume in the world
- Modeling Transformation
- Positioning models in the world
- Projection Transformation
- Determining the shape of the view volume
- Viewport Transformation
6Method for Transformation - 1
- The Viewing Transformation
- glTranslatef()
- glRotatef()
- gluLookAt()
- The Modeling Transformation
- glTranslatef()
- glRotatef()
- glScalef()
7Method for Transformation - 2
- The Projection Transformation
- Perspective
- Orthographic
- Order of Setting
- glMatrixMode(types)
- glLoadIdentity()
- glFrustum() or gluPerspective(), glOrtho()
8General-Purpose Transformation Commands
- glMatrixMode(GLenum mode)
- Specifies which matrix will be modified
- GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE
- glLoadIdentity()
- Sets the currently modifiable matrix to the 44
identity matrix
9General-Purpose Transformation Commands
- glMultMatrixfd(const Type m)
- Multiply the current matrix by the matrix passed
in as an argument - glLoadMatrixfd(const Type m)
- Set the 16 values of the current matrix to those
specified by m
10Viewing and Modeling Transformations
11Thinking about Transformation
- To performing viewing or modeling transformation
- glMatrixMode(GL_MODELVIEW)
122 Types of Coordinate System
- Example
- glMatrixMode(GL_MODELVIEW)
- glloadIdentity()
- glMultiMatrixf(N)
- glMultiMatrixf(M)
- glBegin(GL_POINTS)
- glVertex3f(v)
- glEnd()
- Grand, Fixed Coordinate System
- Moving a Local Coordinate System
13Modeling Transformation
- Translate
- Void glTranslatefd(x, y, z)
- Rotate
- Void glRotatefd(angle, x, y, z)
- Scale
- Void glScalefd(x, y, z)
- glScalef(2.0, -1.5, 1.0)
14Viewing Transformation - 1
- glTranslate() or glRotate()
- Moving forward camera
- Moving Backward Object
- gluLookAt()
- Void gluLookAt(
- eyex, eyey, eyez,
- centerx, centery, centerz,
- upx, upy, upz)
15Viewing Transformation - 2
- Creating a Custom Utility Routine
- Void PilotView(GLdouble planex, Gldouble planey,
Gldouble planez, Gldouble roll, Gldouble pitch,
Gldouble heading) -
- glRotated(roll, 0.0, 0.0, 1.0)
- glRotated(pitch, 0.0, 1.0, 0.0)
- glRotated(heading, 1.0, 0.0, 0.0)
- glTranslated(-planex, -planey, -planez)
16Projection Transformations
17Projection Transformations
- Purpose
- To define a viewing volume
- How an object is projected onto the screen
- How to Clip the object
- Setting for projection transformation
- glMatrixMode(GL_PROJECTION)
- glLoadIdentity()
18Perspective Projection - 1
- Foreshortening
- The farther, the smaller object appears in the
final image - glFrustum(left, right,
- bottm, top, near, far)
19Perspective Projection - 2
- gluPerspective(fov, aspect, near, far)
20Orthographic Projection -1
- View Volume
- Rectangular parallelepiped
21Orthographic Projection -2
- glOrtho(left, right, bottom, top, near, far)
- glOrtho2D (left, right, bottom, top)
22Viewport Transformation
23Defining the Viewport
- glViewport(x, y, width, height)
- gluPerspective(fov, 2.0, near, far)
- glViewport(0, 0, 400, 200)
- The Transformed
- Depth coordinates
24Program Demo
- Transformation\lesson1.exe