Chapter 3 Viewing - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

Chapter 3 Viewing

Description:

View a geometric model in any orientation. Control the location in 3D space ... Rectangular parallelepiped. Orthographic Projection -2 ... – PowerPoint PPT presentation

Number of Views:63
Avg rating:3.0/5.0
Slides: 25
Provided by: kucgKo
Category:

less

Transcript and Presenter's Notes

Title: Chapter 3 Viewing


1
Chapter 3 Viewing
2
Contents
  • Overview The Camera Analogy
  • Viewing and Modeling Transformation
  • Projection Transformation
  • Viewport Transformation

3
Chapter Objectives
  • View a geometric model in any orientation
  • Control the location in 3D space
  • Clip Undesired portions of the model

4
Overview -The Camera Analogy-
5
Overview 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

6
Method for Transformation - 1
  • The Viewing Transformation
  • glTranslatef()
  • glRotatef()
  • gluLookAt()
  • The Modeling Transformation
  • glTranslatef()
  • glRotatef()
  • glScalef()

7
Method for Transformation - 2
  • The Projection Transformation
  • Perspective
  • Orthographic
  • Order of Setting
  • glMatrixMode(types)
  • glLoadIdentity()
  • glFrustum() or gluPerspective(), glOrtho()

8
General-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

9
General-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

10
Viewing and Modeling Transformations
11
Thinking about Transformation
  • To performing viewing or modeling transformation
  • glMatrixMode(GL_MODELVIEW)

12
2 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

13
Modeling 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)

14
Viewing Transformation - 1
  • glTranslate() or glRotate()
  • Moving forward camera
  • Moving Backward Object
  • gluLookAt()
  • Void gluLookAt(
  • eyex, eyey, eyez,
  • centerx, centery, centerz,
  • upx, upy, upz)

15
Viewing 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)

16
Projection Transformations
17
Projection 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()

18
Perspective Projection - 1
  • Foreshortening
  • The farther, the smaller object appears in the
    final image
  • glFrustum(left, right,
  • bottm, top, near, far)

19
Perspective Projection - 2
  • gluPerspective(fov, aspect, near, far)

20
Orthographic Projection -1
  • View Volume
  • Rectangular parallelepiped

21
Orthographic Projection -2
  • glOrtho(left, right, bottom, top, near, far)
  • glOrtho2D (left, right, bottom, top)

22
Viewport Transformation
23
Defining the Viewport
  • glViewport(x, y, width, height)
  • gluPerspective(fov, 2.0, near, far)
  • glViewport(0, 0, 400, 200)
  • The Transformed
  • Depth coordinates

24
Program Demo
  • Transformation\lesson1.exe
Write a Comment
User Comments (0)
About PowerShow.com