Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCE 441 Computer Graphics 3-D Viewing

Similar presentations


Presentation on theme: "CSCE 441 Computer Graphics 3-D Viewing"— Presentation transcript:

1 CSCE 441 Computer Graphics 3-D Viewing
Dr. Jinxiang Chai

2 Outline 3D Viewing Required readings: HB 7-1 to 7-10
Compile and run the codes in page 388 1

3 Taking Pictures Using A Real Camera
Steps: - Identify interesting objects - Rotate and translate the camera to a desire camera viewpoint - Adjust camera settings such as focal length - Choose desired resolution and aspect ratio, etc. - Take a snapshot

4 Taking Pictures Using A Real Camera
Steps: - Identify interesting objects - Rotate and translate the camera to a desire camera viewpoint - Adjust camera settings such as focal length - Choose desired resolution and aspect ratio, etc. - Take a snapshot Graphics does the same thing for rendering an image for 3D geometric objects

5 3D Geometry Pipeline Object space World space View space
Rotate and translate the camera Object space World space View space Focal length Aspect ratio & resolution Normalized projection space Image space 4

6 3D Geometry Pipeline Model space (Object space)
Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... Model space (Object space)

7 3D Geometry Pipeline World space (Object space)
Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... World space (Object space)

8 3D Geometry Pipeline Eye space (View space)
Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... Eye space (View space)

9 Normalized projection space
3D Geometry Pipeline Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... Normalized projection space

10 Image space, window space, raster space, screen space, device space
3D Geometry Pipeline Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... Image space, window space, raster space, screen space, device space

11 Normalized project space
3D Geometry Pipeline Object space World space View space Normalized project space Image space

12 Translate, scale &rotate
3D Geometry Pipeline Translate, scale &rotate Object space World space glTranslate*(tx,ty,tz)

13 Translate, scale &rotate
3D Geometry Pipeline Translate, scale &rotate Object space World space glScale*(sx,sy,sz)

14 Translate, scale &rotate
3D Geometry Pipeline Translate, scale &rotate Object space World space Rotate about r by the angle glRotate*

15 Normalized project space
3D Geometry Pipeline Object space World space View space Normalized project space Image space Screen space

16 3D Geometry Pipeline World space View space
Now look at how we would compute the world->eye transformation World space View space

17 3D Geometry Pipeline World space View space
Now look at how we would compute the world->eye transformation Rotate&translate World space View space

18 Camera Coordinate

19 Camera Coordinate Canonical coordinate system
- usually right handed (looking down –z axis) - convenient for project and clipping

20 Camera Coordinate Mapping from world to eye coordinates
- eye position maps to origin - right vector maps to x axis - up vector maps to y axis - back vector maps to z axis

21 Viewing Transformation
We have the camera in world coordinates We want to transformation T which takes object from world to camera

22 Viewing Transformation
We have the camera in world coordinates We want to transformation T which takes object from world to camera Trick: find T-1 taking object from camera to world

23 Viewing Transformation
We have the camera in world coordinates We want to transformation T which takes object from world to camera Trick: find T-1 taking object from camera to world ?

24 Review: 3D Coordinate Trans.
Transform object description from to p

25 Review: 3D Coordinate Trans.
Transform object description from to p 24

26 Review: 3D Coordinate Trans.
Transform object description from camera to world

27 Viewing Transformation
Trick: find T-1 taking object from camera to world - eye position maps to origin - back vector maps to z axis - up vector maps to y axis - right vector maps to x axis

28 Viewing Transformation
Trick: find T-1 taking object from camera to world H&B equation (7-4)

29 Viewing Trans: gluLookAt
gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)

30 Viewing Trans: gluLookAt
Mapping from world to eye coordinates gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz) How to determine ?

31 Viewing Trans: gluLookAt
Mapping from world to eye coordinates gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)

32 Viewing Trans: gluLookAt
Mapping from world to eye coordinates gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz)

33 Viewing Trans: gluLookAt
Mapping from world to eye coordinates gluLookAt (eyex,eyey,eyez,atx,aty,atz,upx, upy,upz) Stop here. H&B equation (7-1)

34 3D-3D viewing transformation
3D Geometry Pipeline 3D-3D viewing transformation World space View space

35 Projection General definition
transform points in n-space to m-space (m<n) In computer graphics map 3D coordinates to 2D screen coordinates

36 Projection General definition
transform points in n-space to m-space (m<n) In computer graphics map 3D coordinates to 2D screen coordinates How can we project 3d objects to 2d screen space?

37 How Do We See the World? Let’s design a camera:
idea 1: put a piece of film in front of camera Do we get a reasonable picture?

38 Pin-hole Camera Add a barrier to block off most of the rays
This reduces blurring The opening known as the aperture How does this transform the image?

39 Camera Obscura The first camera Known to Aristotle
Depth of the room is the focal length Pencil of rays – all rays through a point

40 Perspective Projection
Maps points onto “view plane” along projectors emanating from “center of projection” (COP)

41 Perspective Projection
Maps points onto “view plane” along projectors emanating from “center of projection” (COP) What’s relationship between 3D points and projected 2D points? 40

42 3D->2D Consider the projection of a 3D point on the camera plane

43 3D->2D Consider the projection of a 3D point on the camera plane 42

44 3D->2D Consider the projection of a point on the camera plane
By similar triangles, we can compute how much the x and y coordinates are scaled

45 3D->2D Consider the projection of a point on the camera plane
By similar triangles, we can compute how much the x and y coordinates are scaled

46 Homogeneous Coordinates
Is this a linear transformation?

47 Homogeneous Coordinates
Is this a linear transformation? no—division by z is nonlinear

48 Homogeneous Coordinates
Is this a linear transformation? no—division by z is nonlinear Trick: add one more coordinate: homogeneous image coordinates homogeneous scene coordinates

49 Homogeneous Point Revisited
Remember how we said 2D/3D geometric transformations work with the last coordinate always set to one What happens if the coordinate is not one We divide all coordinates by w: If w=1, nothing happens Sometimes, we call this division step the “perspective divide”

50 The Perspective Matrix
Now we can rewrite the perspective projection equation as matrix-vector multiplications

51 The Perspective Matrix
Now we can rewrite the perspective projection equation as matrix-vector multiplications This becomes a linear transformation!

52 The Perspective Matrix
Now we can rewrite the perspective projection equation as matrix-vector multiplications After the division by w, we have

53 Perspective Effects Distant object becomes small
The distortion of items when viewed at an angle (spatial foreshortening)

54 Perspective Effects Distant object becomes small
The distortion of items when viewed at an angle (spatial foreshortening)

55 Perspective Effects Distant object becomes small
The distortion of items when viewed at an angle (spatial foreshortening)

56 Properties of Perspective Proj.
Perspective projection is an example of projective transformation - lines maps to lines - parallel lines do not necessary remain parallel - ratios are not preserved

57 Properties of Perspective Proj.
Perspective projection is an example of projective transformation - lines maps to lines - parallel lines do not necessary remain parallel - ratios are not preserved One of advantages of perspective projection is that size varies inversely proportional to the distance-looks realistic

58 Vanishing Points What happens to parallel lines they are not parallel to the projection plane?

59 Vanishing Points What happens to parallel lines they are not parallel to the projection plane? The equation of the line:

60 Vanishing Points What happens to parallel lines they are not parallel to the projection plane? The equation of the line: After perspective transformation, we have

61 Vanishing Points (cont.)
Letting t go to infinity:

62 Vanishing Points What happens to parallel lines they are not parallel to the projection plane? The equation of the line:

63 Vanishing Points What happens to parallel lines they are not parallel to the projection plane? The equation of the line: How about the line

64 Vanishing Points What happens to parallel lines they are not parallel to the projection plane? The equation of the line: How about the line

65 Vanishing Points What happens to parallel lines they are not parallel to the projection plane? The equation of the line: How about the line Same vanishing point!

66 Vanishing Points What happens to parallel lines they are not parallel to the projection plane? Each set of parallel lines intersect at a vanishing point on the PP

67 Vanishing Points What happens to parallel lines they are not parallel to the projection plane? Each set of parallel lines intersect at a vanishing point on the PP How many vanishing points are there?

68 Vanishing Points What happens to parallel lines they are not parallel to the projection plane? Each set of parallel lines intersect at a vanishing point on the PP How many vanishing points are there?

69 Parallel Projection Center of projection is at infinity
Direction of projection (DOP) same for all points

70 Orthographic Projection
Direction of projection (DOP) perpendicular to view plane

71 Orthographic Projection
Direction of projection (DOP) perpendicular to view plane

72 Oblique Projection DOP not perpendicular to view plane A’ A O

73 Oblique Projection DOP not perpendicular to view plane A’ A O

74 Properties of Parallel Projection
Not realistic looking Good for exact measurement Are actually affine transformation - parallel lines remain parallel - ratios are preserved - angles are often not preserved Most often used in CAD, architectural drawings, etc. where taking exact measurement is important

75 3D->2D Perspective projection from 3D to 2D 74

76 3D->2D Perspective projection from 3D to 2D
But so far, we have not considered the size of film plane! 75

77 Normalized project space
3D Geometry Pipeline Object space World space View space Normalized project space Image space Screen space

78 Perspective Projection Volume
The center of projection and the portion of projection plane that map to the final image form an infinite pyramid. The sides of pyramid called clipping planes Additional clipping planes are inserted to restrict the range of depths

79 OpenGL Perspective-Projection
Normalized project space View space glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar) gluPerspective(fovy,aspect,dnear, dfar) 78

80 General Perspective-Projection
zfar (xwmax,ywmax,znear) (xwmin,ywmin,Znear) View space glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar) Six parameters define six clipping planes!

81 General Perspective-Projection
glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar) Left-vertical clipping plane

82 General Perspective-Projection
glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar) right-vertical clipping plane

83 General Perspective-Projection
glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar) bottom-horizontal clipping plane

84 General Perspective-Projection
glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar) top-horizontal clipping plane

85 General Perspective-Projection
glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar) near clipping plane

86 General Perspective-Projection
glFrustum(xwmin, xwmax,ywmin, ywmax ,dnear,dfar) far clipping plane

87 General Perspective-Projection
B’=(1,1,1) B A A’=(-1,-1,-1) View space (right-handed) Normalized project space (left-handed) A maps to A’, B maps to B’ Keep the directions of x and y axes!

88 General Perspective-Projection
B’=(1,1,1) B A A’=(-1,-1,-1) H&B equation (7-40)

89 OpenGL Symmetric Perspective-Projection Function
gluPerspective(fovy,aspect,dnear, dfar) Assume z-axis is the centerline of 3D view frustum!

90 Normalized project space
3D Geometry Pipeline Object space World space View space Normalized project space Image space

91 Viewport Transformation
(xmin,ymin) Image space-.>Image space gluViewport(xmin, ymin, width, height)

92 Viewport Transformation
(xmin,ymin) Besides x and y, each pixel has a depth value z! Image space-.>Image space gluViewport(xmin, ymin, width, height)

93 Viewport Transformation
B’=(1,1,1) B’’=(xvmax,yvmax,1) Normalized project space A’’=(xvmin,yvmin,0) A’=(-1,-1,-1) Normalized project space Image space

94 Viewport Transformation
B’=(1,1,1) B’’=(xvmax,yvmax,1) Normalized project space A’’=(xvmin,yvmin,0) A’=(-1,-1,-1) Normalized project space Image space H&B equation (7-42)

95 Summary: 3D Geometry Pipeline
Object space World space View space Normalized project space Image space

96 Normalized project space
Taking Steps Together Object space World space View space Normalized project space Image space

97 OpenGL Codes


Download ppt "CSCE 441 Computer Graphics 3-D Viewing"

Similar presentations


Ads by Google