Presentation is loading. Please wait.

Presentation is loading. Please wait.

CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 5.

Similar presentations


Presentation on theme: "CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 5."— Presentation transcript:

1 CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 5

2 Viewing  Classical viewing –Need to be able to reproduce classical views for a variety of applications –Isometric  Preserves measurements –Elevation  View a face of object –Perspective  Reflects size change of distant objects

3 Viewing Terminology  Center of Projection (COP) –Point where all projectors meet –Center of camera or eye lens –Origin of synthetic camera frame  Direction of Projection (DOP) –Direction of projectors when COP is moved to infinity

4 Types of Viewing  Classical (many) –Orthographic –One-, two-, and 3-point perspectives  Computer –Orthographic –Perspective

5 Classical Viewing Concepts  Principal face –Primary surface of view  Based on rectangular solid structures  Orthographic Projection –Single view –Multiview  Show three orthogonal views

6

7 Axonometric Projections  Projectors are orthogonal to the projection plane but plane can be at angle to principal face –Isometric – symmetric with all three axes –Dimetric – symmetric with two axes –Trimetric – general case –Produces foreshortening of distances

8 Oblique Projection  Most general parallel view –Projectors make arbitrary angle with projection plane  In computer graphics system, isometric, axonometric and oblique projections are all variations on one case

9 Perspective  Characterized by diminution of size of more distant objects  Classically, viewer is symmetrical with respect to the projection plane  One-, two-, and three-point perspectives depending on number of vanishing points

10 Computer Viewing  Choose parallel or perspective view  No separation of perspective degrees  Two key elements –Position camera –Apply projection transformaton

11 OpenGL Camera  Default –Camera at origin –Pointing in negative z direction –Orthogonal view –Viewing volume is cube  Centered at origin  Side of length 2

12 Default Camera

13 Positioning Camera Frame  Can construct camera frame through translation and rotation of model view to get camera to desired viewing position from default position  For orthographic view, this does not change clipping volume set by glOrtho() –Size is unchanged –What is seen will change

14 View as Change of Frames  Set View-Reference Point (VRP) –Center of camera  View plane defined by –View-plane normal (VPN) –View-up vector (VUP) –Project VUP onto projection plane to get up direction (v up )  Construct new frame with basis for view plane, u-v and normal n; u-v-n

15 Look-At Positioning

16 OpenGL Look-At  OpenGL simplifies camera positioning as follows – e = eye point – a = look-at point –Determines vpn as e – a glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glLoadIdentity(); gluLookAt(eyex, eyey, eyez, gluLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz); /* define objects here */

17 Perspective Projection  Note: x/z = x p /d or x p = x/(z/d) –Similarly for y –Provides non-uniform foreshortening  Perspective Transformation –(x, y, z) -> (x p, y p, z p )

18 Perspective Projection (cont)  Moving to 4 dimensions, consider (wx, wy, wz, w) T  Perspective transformation matrix 10 0 0takes 0 1 0 0(x, y, z, 1) T 0 0 1 0 to 0 0 1/d 0(x, y, z, z/d) T  Division by last coordinate gives (x p, y p, d, 1), the projection (x p, y p, d, 1), the projection

19 Orthogonal Projection in OpenGL  Simply map z into zero

20 Projection in OpenGL  Clipping region is a frustum, a truncated pyramid

21 OpenGL Frustum  glFrustum(xmin, xmax, ymin, ymax, near, far); // left, right, top, bottom, near, far

22 Parallel Viewing in OpenGL  glOrtho(xmin, xmax, ymin, ymax, near, far);

23 Hidden Surface Removal  Remove hidden surfaces  Different view –Visible-surface algoritims  Identify visible surfaces  Work in either –Object space –Image space

24 Z-Buffer Algorithm  Image Space  Requires depth buffer, called z-buffer to store depth  Depth resolution usually 16, 24, or 32 bits  As polygon is rasterized, depth is computed and compared with current z- buffer value; only nearer values update  Very efficient

25 OpenGL Implementation  Enable with –glutInitDisplayMode(GLUT_DEPTH…); –glEnabel(GL_DEPTH_TEST);  Clear with –glClear(GL_DEPTH_BUFFER_BIT);

26 Scene Walkthrough  Move camera to view color cube from different locations –cubeview.c

27 Parallel-Projection Matrices  Previous projection matrices do not cover all possibilities  Projection Normalization –convert all projections to orthogonal –by distorting objects –distortion is called normalization  Map viewing volume into 2x2x2 cube at origin; translate and then scale

28 Oblique Projection  Projectors do not need to be orthogonal to projection plane as in standard OpenGL projection  Equivalent to a shear transformation of the objects

29 Perspective-Projection Matrices  Again, distort object  Skipping details  OpenGL Perspective Transformations 2z/(X-x) 0 (X+x)/(X-x) 0 0 2z/(Y-y) (Y+y)/(Y-y) 0 0 2z/(Y-y) (Y+y)/(Y-y) 0 0 0 -(f+n)/(f-n) -2fn/(f-n) 0 0 -(f+n)/(f-n) -2fn/(f-n) 0 0 -1 0 0 0 -1 0

30 Projections and Shadows  Shadow –projection of original polygon onto surface –center of projection is light source –shadow-polygon –shadow.c

31


Download ppt "CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 5."

Similar presentations


Ads by Google