ece 104 y x z y - uni-due.de 104 fundamentals of ... isometric projection projector makes equal...

13
ECE 104 Fundamentals of Computer Graphics BERKELEY • DAVIS • IRVINE • LOS ANGELES • RIVERSIDE • SAN DIEGO • SAN FRANCISCO SANTA BARBARA • SANTA CRUZ Viewing Transformations Slides Courtesy of Vinnie Costa of Hofstra University 2 Classical and Computer Viewing Perspective Views x y z x y 3 Classical and Computer Viewing Perspective Views x y z x y 4 Classical And Computer Viewing Parallel Views x y z x y 5 Classical And Computer Viewing Parallel Views x y z x y 6 Vanishing Points

Upload: vuongnhu

Post on 20-Mar-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ECE 104 y x z y - uni-due.de 104 Fundamentals of ... Isometric Projection Projector makes equal angles with all three principal axes ... principal axes or if the projection plane

1

ECE 104Fundamentals of Computer Graphics

BERKELEY • DAVIS • IRVINE • LOS ANGELES • RIVERSIDE • SAN DIEGO • SAN FRANCISCO SANTA BARBARA • SANTA CRUZ

Viewing Transformations

Slides Courtesy of Vinnie Costa of Hofstra University

2

Classical and Computer Viewing

Perspective Views

x

y

z

x

y

3

Classical and Computer Viewing

Perspective Views

x

y

z

x

y

4

Classical And Computer Viewing

Parallel Views

x

y

z

x

y

5

Classical And Computer Viewing

Parallel Views

x

y

z

x

y

6

Vanishing Points

Page 2: ECE 104 y x z y - uni-due.de 104 Fundamentals of ... Isometric Projection Projector makes equal angles with all three principal axes ... principal axes or if the projection plane

2

7

Vanishing Points

8

Vanishing Point

9

Classical Viewing

Underlying notion principal face10

Orthographic Projection

DOPsame for all points

x

y

z

90°

90°

11

Orthographic Projections

DOP is perpendicular to the view plane

xz

y

x

y

z

yx

z

12

Multiview Parallel Projection

Faces are parallel to the projection plane

Page 3: ECE 104 y x z y - uni-due.de 104 Fundamentals of ... Isometric Projection Projector makes equal angles with all three principal axes ... principal axes or if the projection plane

3

13

Axonometric ProjectionsDOP are still orthogonal to the projection plane, but the projection plane can have any orientation with respect to the objectParallel lines remain parallel, and receding lines are equally foreshortened by some factor.

14

Isometric Projection

Projector makes equal angles with all three principal axes

All three axes are equally foreshortened

15

Dimetric Projection

Projector makes equal angles with two of the principal axes

Two of three axes are equally foreshortened

16

Trimetric Projection

Projector makes unequal angles with each principal axes

All three axes are unequally foreshortened

17

isometric trimetric

Mechanical Drawing

18

Oblique Projections

Most general parallel viewsProjectors make an arbitrary angle with the projection planeAngles in planes parallel to the projection plane are preservedHuman visual system and most physical systems are not oblique

Page 4: ECE 104 y x z y - uni-due.de 104 Fundamentals of ... Isometric Projection Projector makes equal angles with all three principal axes ... principal axes or if the projection plane

4

19

Oblique Projections

20

Perspective Projection

Characterized by diminution by sizeThe farther the object, the smaller the imageForeshortening depends on distance from viewerCan’t be used for measurementsVanishing points

21

Early Perspective

Not systematic--lines do not converge to a single "vanishing" point

Giotto

22

First Perspective ProjectionsBrunelleschi

Invented systematic method of determining perspective projections in early 1400's

23

Treatise on Similar TrianglesAlbrecht Dürer (1471-1528)

Artist Drawing a Lute, 1525

24

Influential Point of View

Are royal couple in mirror about to enter room? Or is their image a reflection of the painting on the far left?

Diego Velàzquez

Las Meninas, 1656

Page 5: ECE 104 y x z y - uni-due.de 104 Fundamentals of ... Isometric Projection Projector makes equal angles with all three principal axes ... principal axes or if the projection plane

5

25

Geometrical Construction

Vredeman de Vries,Perspective,

26

Modern Perspective

Escher, Ascending and Decending, 1960

27

Taxonomy of Projections

28

Perspective Viewing

29

1-Point PerspectiveOne point perspective occurs when the projection plane is parallel to two principal axis. VP = No. of principal coordinate axes intersected by the proj. planeReceding lines along one of the principal axis converge to a vanishing point

30

2-Point PerspectiveIf the projection plane is parallel to one of the principal axes or if the projection plane intersects exactly two principal axes, a two-point perspective projection occurs

Page 6: ECE 104 y x z y - uni-due.de 104 Fundamentals of ... Isometric Projection Projector makes equal angles with all three principal axes ... principal axes or if the projection plane

6

31

3-Point PerspectiveIf the projection plane is not parallel to any principal axis, a three-point projection occurs

32

Perspective Projection

3-point 2-point 1-point

33

Transformation Process

Camera Analogy

• Setting up your tripod and pointing the camera at the scene (viewing transformation).

• Arranging the scene to be photographed into the desired composition (modeling transformation).

• Choosing a camera lens or adjusting the zoom (projection transformation).

• Determining how large you want the final photograph to be - for example, you might want it enlarged (viewport transformation).

34

Frames In OpenGLWe use two frames: the camera frame and the world frameWe regard the camera frame as fixedThe model-view matrix positions the world frame relative to the camera framePerform homogeneous coordinate transformations on object in other frames to define new frames relative to the camera frame

35

Frames In OpenGL

camera frame

world frame

36

Stages of Vertex Transformation

Page 7: ECE 104 y x z y - uni-due.de 104 Fundamentals of ... Isometric Projection Projector makes equal angles with all three principal axes ... principal axes or if the projection plane

7

37

Initial Camera Position

• Objects are modeled independently from the location of the camera

• OpenGL places a camera at the origin of the world frame pointing in the negative z direction

• If model view matrix is an identity matrix, then the camera frame and world frame are identical

38

Movement of the Frames

pp =′

pp C=′

39

Thinking About Transformations

1-rotate

2-translate 1-translate

2-rotate

40

Moving The Camera

glMatrixMode(GL_MODELVIEW);glLoadIdentity( );glTranslatef( -d, 0.0, 0.0);glRotatef(-90.0, 0.0, 1.0, 0.0)

41

Two Points of View

Hold camera frame fixed, move objects in front of the cameraModel objects stationary and move the camera away from the objects

42

Default Position

Object and Viewpoint at the Origin

Page 8: ECE 104 y x z y - uni-due.de 104 Fundamentals of ... Isometric Projection Projector makes equal angles with all three principal axes ... principal axes or if the projection plane

8

43

Viewing APIsView plane is the projection plane or the back of the cameraThe origin of this plane which defines the position of the eye or camera is called the view reference point (VRP)A unit vector to this plane is the view plane normal (VPN) Another vector called the view-up vector is a unit vector perpendicular to the VPN

44

Camera Frame

45

Viewing Coordinate SystemUsually a left handed system called the u-v-n system is usedv, the y-axis of the view coordinate system is the perpendicular projection of VUP on the view planeu, the x-axis of the view coordinates, is orthogonal to v and n, i.e. u = v × nn is the z-axis of the view coordinate. It increases in positive direction with depth of a point from the eye

46

An Arbitrary ViewpointConstruct a scene and then look at it from an arbitrary point of viewPoint e is called the eyepoint, specified in the world frameIt is pointed at a second point a, called the at pointThese points determine a VPN and a VRPvpn = e - a

47

gluLookAt Utility RoutineDefines a viewing matrix and multiplies it to the right of the current matrixThe desired eyepoint is specified by eyex, eyey, and eyez. The atx, aty,and atz arguments specify any point along the desired line of sight. The upx, upy, and upz arguments indicate which direction is up

gluLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz);

48

Custom Utility Routine

You might need to define your own transformation routineFlight simulator: Display the world from the pilot’s point of viewPilot see the world in terms of roll, pitch, and heading (these are rotation angles of the plane relative to its center of gravity)

Page 9: ECE 104 y x z y - uni-due.de 104 Fundamentals of ... Isometric Projection Projector makes equal angles with all three principal axes ... principal axes or if the projection plane

9

49

Custom Utility RoutineOrbiting the camera around an object that's centered at the originUse polar coordinates. Let the distance variable define the radius of the orbitThe azimuth describes the angle of rotation of the camera about the object in the x-y plane elevation is the angle of rotation of the camera in the y-z planetwist represents the rotation of the viewing volume around its line of sight.

50

Projections

After we position the camera, we must select a lensThis determines how much of the world in front of the camera appears in the imageDistinguish between parallel and perspective views

51

Perspective Projections

-z -z

52

Perspective Projections

Nonuniform foreshortening – images of objects farther from the center of projection are reduced in sizeWe apply a 4 x 4 projection matrix after the model-view matrix

53

Orthogonal Projection

=

11000000000100001

1zyx

zyx

p

p

p

54

Projections in OpenGL

Objects not in the view volume are clipped

frustum

only fixed point

Page 10: ECE 104 y x z y - uni-due.de 104 Fundamentals of ... Isometric Projection Projector makes equal angles with all three principal axes ... principal axes or if the projection plane

10

55

OpenGL PerspectiveglFrustum(left, right, bottom, top, near, far);

glMatrixMode(GL_PROJECTION);

glLoadIdentity( );

glFrustum(left, right, bottom, top, near, far);

56

OpenGL PerspectivegluPerspective(fovy, aspect, near, far);

fov is the angle between the top and bottom planes

57

OpenGL Parallel ViewglOrtho(left, right, bottom, top, near, far);

58

Hidden Surface Removal

z-buffer algorithm – as the polygons are rasterized we keep track of the distance from the COP to the closest point on each projector. We display only the closest pointRequires a depth or z buffer to store the necessary depth information

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

glEnable(GL_DEPTH_TEST);

59

z-buffer Algorithm

60

Projection Normalization

Convert all projections into orthogonal projections by first distorting the objects such that the orthogonal projection of the distorted objects is the same as the desired projection of the original objects

Page 11: ECE 104 y x z y - uni-due.de 104 Fundamentals of ... Isometric Projection Projector makes equal angles with all three principal axes ... principal axes or if the projection plane

11

61

Projection Normalization

62

Projection Normalization

The distortion is described by a homogeneous-coordinate matrixConcatenate this matrix with an orthogonal-projection matrix to yield a projection matrix

63

Orthogonal Projection Matrices

Projection converts points in 3-D space to points on the projection planeParallel viewing is a special case of perspective viewingAll points along a projector project into the same point on the projection planeTwo steps: 1) convert viewing volume to a standard volume, 2) orthogonal projection

64

Projection MatrixThe first part of the process, converting the viewing volume to a standard volume, defines the projection matrixCanonical view volume is a 2x2x2 cube whose center is at the origin (default view volume)

(-1,-1,1)

(1,1,-1)

65

Projection MatrixglMatrixMode(GL_PROJECTION);

glLoadIdentity( );

glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);

determine which objects are clipped out

Projection Matrix maps a view volume to the canonical view volume

66

Projection Matrix

−+

−−

−+

−−

−+

−−

==

1000

200

02

0

002

minmax

minmax

minmax

minmax

minmax

minmax

minmax

minmax

minmax

zzzz

zz

yyyy

yy

xxxx

xx

STP

Page 12: ECE 104 y x z y - uni-due.de 104 Fundamentals of ... Isometric Projection Projector makes equal angles with all three principal axes ... principal axes or if the projection plane

12

67

Oblique Projection

degree of obliqueness

68

Oblique Projection

shearing

69

Perspective Projection Matrices

Look for a transformation that allows a simple canonical projection by distorting the vertices of an objectThree steps: 1) select canonical viewing volume, 2) introduce the perspective normalization transformation and 3) derive the perspective projection matrix

70

Perspective Projection Matrices

71

Perspective Projection Matrices

N

N is called the perspective normalization matrix. It converts a perspective projection to an orthogonal projection

72

Projection and Shadows

Shadows are not geometric objects but important for realismA point is in a shadow if it is not illuminated by any light sourceA shadow polygon is a flat shadow that results from projecting the original polygon onto a surface

Page 13: ECE 104 y x z y - uni-due.de 104 Fundamentals of ... Isometric Projection Projector makes equal angles with all three principal axes ... principal axes or if the projection plane

13

73

Projection and Shadows

use a mode-view matrix

74

Viewport Transformation

viewport transformation corresponds to the stage where the size of the developed photograph is chosenThe viewport is measured in window coordinates, which reflect the position of pixels on the screen relative to the lower left corner of the windowvertices outside the viewing volume have been clipped

75

Viewport Transformation

viewport is the rectangular region of the window where the image is drawn

76

Defining The ViewportThe window manager, not OpenGL, is responsible for opening a window on the screenBy default the viewport is set to the entire pixel rectangle of the window that's openedUse the glViewport() command to choose a smaller drawing region

void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);

lower left corner size of viewport rectangle

77

Defining The Viewport

By default, the initial viewport values are (0, 0, winWidth, winHeight), where winWidth andwinHeight are the size of the window. The aspect ratio of a viewport should generally equal the aspect ratio of the viewing volumeIf the two ratios are different, the projected image will be distorted as it's mapped to the viewport

78

Viewport Distortion