69
Viewing, projections Hofstra University 1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically more complex objects and scenes. The final scene is in world frame Viewing Model the camera: position , orientation, camera (view) reference frame, projection Viewing transformations: from world to camera coordinates Clipping/hidden surface removal : clip out from consideration parts outside of view volume Projection transformations and hidden surface removal: from 3D viewing coord. to 2D projection coord. and normalized device coordinates Viewport transformations: from normalized device coordinates to screen (device) coordinates

Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

  • View
    222

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 1

Modeling and Viewing

Modeling Use modeling (local) coordinates and geometric

transformations to build hierarchically more complex objects and scenes. The final scene is in world frame

Viewing Model the camera: position , orientation, camera (view)

reference frame, projection Viewing transformations: from world to camera

coordinates Clipping/hidden surface removal: clip out from

consideration parts outside of view volume Projection transformations and hidden surface removal:

from 3D viewing coord. to 2D projection coord. and normalized device coordinates

Viewport transformations: from normalized device coordinates to screen (device) coordinates

Page 2: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 2

Viewing and Projection Transforming

Modeling transformations (affine), 3D to 3D Viewing transformations (affine), 3D to 3D

Linear in homogeneous coordinates Images of parallel lines stay parallel Transformation matrix in homogeneous coordinates

has last row, 0 0 0 1 Projection transformations (not affine), 3D to 2D

Linear in homogeneous coordinates Images of parallel lines may intersect at infinity Transformation matrix most general

Viewport transformations (affine), maps viewing window to viewport, 2D to 2D

Page 3: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 3

Viewing Terminology

Viewing volume: the region in 3D that can contain objects that are visible by the camera

Projection: math transformations that maps from 3D to 2D (or 4D to 3D, in homogeneous)

Projection plane: the plain containing the 2D image Viewing window: the rectangle in the image plane

that will be mapped to the screen eventually Viewport: 2D rectangle within the display window

on the screen that shows the viewing window Clipping: cutting off from consideration parts

outside the view volume (done easier if the view volume is mapped to a canonical view volume which is a cube)

Page 4: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 4

Graphics functions

Graphics systems support viewing by Providing a viewing model whose parameters

specify the camera Providing functions for viewing, projection and

viewport Implementing viewing and projection

transformations as matrix multiplications in homogeneous coordinates

Page 5: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 5

Viewing APIs The the position of the eye or camera

is called the view reference point (VRP) A unit view plane normal (VPN), is in

the viewing direction, it is perpendicular to the image plane. In open GL VPN is in direction opposite to the one in which camera is looking

Another vector called the view-up vector is a vector specifying which is the approximate “up” direction for the camera

Page 6: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 6

Camera Model: viewingVRP: Camera(eye) position,(u,v,n): camera frame. Viewing: specify VRP,n,VUP.

Page 7: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 7

Viewing Coordinate System: (u,v,n)

right handed v, the y-axis of the view frame, is the

perpendicular projection of VUP on the projection plane

n is the z-axis of the view frame u = v × n

Page 8: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 8

Setting up the camera

Construct a scene and then look at it from a point of view, eye:

eye, the eyepoint, is the VRP specified in the world coordinates

Camera is pointed at a point at, the at point

These points determine VPN

vpn = eye – at

Page 9: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 9

Two Points of View

Hold camera frame fixed, move objects in front of the camera

glLoadIdentity(); glTranslatef(0,0,-d); Keep objects stationary and move the

camera away from the objects glLoadIdentity();

glLookAt(0,0,d,0,0,0,0,1,0);

Page 10: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 10

gluLookAt Utility Routine in OpenGL

Defines a viewing transformation matrix M, and M postmultiplies CTM, i.e. CTM=CTM*M

Eye point: eyex, eyey, and eyez. At point: atx, aty,and atz. VUP: upx, upy, and upz

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

Page 11: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 11

Viewing Transformations

Given 3D model of a scene/object in 4D homogeneous coordinates P, with respect to the world coordinate system

Given camera coordinate system (position, VRP, and camera frame (u,v,n) )

Viewing transformation M converts coordinates of objects from world to camera coordinates

How?

Page 12: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 12

Viewing Transformations

Let W=(O,ex,ey,ez) be the world coord. system Let V=(VRP,u,v,n) be the camera coord. System Let M be the change of frame matrix, mapping V to W, M =

R.T(-VRP), where T is a translation mapping VRP to O R is a rotation aligning (u,v,n) with (ex,ey,ez), in 3D affine coordinates

it represented by a matrix with rows u’,v’,n’ Then for a point P with modeling coordinates

w=(xw,yw,zw,1)’ the viewing coordinates are v =(vx,vy,vz,1)’, where

wMvvMw ,)( 1

Page 13: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 13

Custom Utility Routine

You might need to define your own transformation routine

Flight simulator: Display the world from the pilot’s point of view

Pilot see the world in terms of roll, pitch, and heading

Page 14: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 14

Custom Utility Routine

The following routine could serve as the viewing transformation:

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);

}

Page 15: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 15

Custom Utility Routine Orbiting the camera around

an object that's centered at the origin

Use polar coordinates. Let the distance variable

define the radius of the orbit

The azimuth is 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 plane

Page 16: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 16

Projections

Projecting: mapping from 3D viewing coordinates to 2D coordinates in projection plane. In homogeneous coordinates it is a map

from 4D viewing coordinates to 3D. Projections

Parallel: orthogonal and oblique Perspective

Canonical views: orthographic and perspective projections

Page 17: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 17

Perspective projection

Projectors intersect at COP

Page 18: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 18

Parallel Projections

Projectors parallel.COP at infinity.

Page 19: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 19

Parallel projections: summary

Center of projection is at infinity. Projectors are parallel. Parallel lines stay parallel There is no forshorthening Distances and angles are transformed

consistently Used most often in engineering design,

CAD systems. Used for top and side drawings from which measurements could be made.

Page 20: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 20

Orthographic Projection: projectors orthogonal to projection plane

DOPsame for all points

(direction of projectors)(direction of projectors)

Page 21: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 21

Orthographic Projections

DOP is perpendicular to the view plane

Page 22: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 22

Multiview Parallel Projection

Faces are parallel to the projection plane

Page 23: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 23

Isometric Projection

Projector makes equal angles with all three principal axes

All three axes are equally foreshortened

Page 24: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 24

isometric

Mechanical Drawing

Page 25: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 25

Oblique Parallel Projections Most general parallel views Projectors make an arbitrary angle with the

projection plane Angles in planes parallel to the projection plane

are preserved

Page 26: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 26

Oblique Projections: projectors are not orthogonal to image plane

CavalierAngle between projectors and projection plane is 45°. Lines orthogonal to the projection planeRetain their exact length. Perpendicular faces are projected at full scale

CabinetAngle between projectors and projection plane is arctan(2)=63.4°. Lines orthogonal to the projection plane are projected at half length. Perpendicular faces are projected at 50% scale.Looks like forshorthening.

Page 27: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 27

Perspective Projection

Most natural for people In human vision, perspective projection of the world is

created on the retina (back of the eye) Used in CG for creating realistic images Perspective projection images carry depth cues Foreshorthening causes distant objects to appear

smaller Relative lengths and angles are not preserved A perspective image cannot be used for metric

measurements of the 3D world Parallel lines not parallel to the image plane converge

at a vanishing point An axis (principal) vanishing point is a point of

convergence for lines parallel to a principal axis of the object. We distinguish one-, two-, three-point projections.)

Page 28: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 28

Vanishing Points

Page 29: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 29

Vanishing Points

Page 30: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 30

Early Perspective

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

Giotto

Page 31: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 31

Math of Projections:Overview Math of perspective projection, standard

configuration OpenGL perspective projections Math of orthographic projection OpenGL orthographic projections Viewport transformations and setting

them in OpenGL Summary

Viewing transformations Orthographic projection canonical viewing

volume Perspective projection canonical viewing

volume Hidden surface removal

Page 32: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 32

Perspective Viewing

Page 33: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 33

Perspective Projections

-z -z

Viewing direction orthogonalViewing direction orthogonalTo projection planeTo projection plane

Genaral perspective:Genaral perspective:Viewing direction isViewing direction isnot orthogonal tonot orthogonal toprojection plane projection plane

Page 34: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 34

Perspective Projections

The graphics system applies a 4 x 4 projection matrix after the model-view matrix

Page 35: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 35

Math of perspective projection

The discussion here is carried out with respect to the camera (view) reference frame, (VRP,u,v,n)

The projection transformation maps 3D points to 2D points in the projection plane

Standard configuration: COP=VRP Projection plane is orthogonal to z-axis, at

z=d

Page 36: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 36

Math of perspective projection

Standard configuration: Let O be COP Projection plane has equation z=d, d <0 3D point P has homogeneous coordinates (x,y,z,1) It is mapped to point Q (xp,yp,d) in the projection

plane Q is on the segment PO, thus Q=cP+(1-c)O, where 0<c<1 Thus, xp = c.x, yp = c.y, d = c.z c = d/z Thus, xp = (d/z).x, yp = (d/z).y , in affine coordinates

Note that projection is not linear in affine coordates.

Page 37: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 37

Math of perspective projection P=p(x,y,z,1) Q=q(d.x/z, d.y/z, d, 1), in

homogeneous coordinates. Perspective projection is not linear in affine coord. Perspective projection is linear in homogeneous

From homogeneous to affine coordinates: (a,b,c,w) (a/w, b/w,c/w) Thus (x,y,z,d/z) in homogeneous becomes (x/(z/d), y/(z/d),d,1) ==> (d.x/z, d.y/z,1) in proj.

plane

dz

z

y

x

z

y

x

dd

perper

/10/100

0100

0010

0001

0/100

0100

0010

0001

pMqM

Page 38: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 38

Clipping Object parts outside of the of the view volume are

clipped First we will discuss the openGL functions that set

up the projection transformations Next we will discuss the viewport transformation

and setting the viewport in OpenGL Last, we will go back to projection, and see how the

graphics systems carry out efficiently the more general perspective projection by reducing it to the standard perspective, and then to the canonical orthographic

You can set up any projection you want (parallel or perspective) by setting up the the projection matrix directly

Although, more often we use affine transformations to reduce more general projections to the canonical ones

Page 39: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 39

Perspective Viewing in OpenGL

Depth of projection plane (size of clipping window) Depth of projection plane (size of clipping window) inside the pyramid does not matter. inside the pyramid does not matter. All that matters is object size relative to the window.All that matters is object size relative to the window.The projection plane depth does not affect relative The projection plane depth does not affect relative size.size.Thus in CG systems usually far or near plane is Thus in CG systems usually far or near plane is selectedselectedto be the projection plane. Near in openGL.to be the projection plane. Near in openGL.

Page 40: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 40

Projections in OpenGL

Objects not in the view volume are clipped.

View (projection) plane is front clipping plane.

frustum

only fixed point

Page 41: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 41

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

glMatrixMode(GL_PROJECTION);

glLoadIdentity( );

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

The relationship between front(near) plane and The relationship between front(near) plane and COP(origin) define the steepness of the frustumCOP(origin) define the steepness of the frustum

Page 42: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 42

OpenGL Perspective

gluPerspective(fovy, aspect, near, far);

fov is the angle between the top and bottom planes

Page 43: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 43

OpenGL Orthographic Projection

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

Page 44: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 44

Standard Orthographic Projection

11000

0000

0010

0001

1

z

y

x

z

y

x

p

p

p

Page 45: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 45

Viewport Transformation

viewport transformation corresponds to the stage where the size of the developed photograph is chosen

The viewport is measured in pixels, in screen window coordinates, which reflect the position of pixels on the screen relative to the lower left corner of the window

vertices outside the viewing volume have been clipped

Page 46: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 46

Viewport Transformation

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

Page 47: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 47

Defining the Viewport

The window manager, not OpenGL, is responsible for opening a window on the screen

By default the viewport is set to the entire pixel rectangle of the window that's opened

Use 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

Page 48: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 48

Defining The Viewport

By default, the initial viewport values are (0, 0, winWidth, winHeight), where winWidth and winHeight are the size of the

window. The aspect ratio of a viewport should generally

equal the aspect ratio of the viewing volume If the two ratios are different, the projected

image will be distorted as it's mapped to the viewport

Page 49: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 49

Viewport Distortion

Page 50: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 50

Summary

World to View coordiantes Camera position: VRP Viewing transformation

Translate VRP to origin: T(-VRP) Rotate, aligning view frame (u,v,n) with world

frame The composite transformation R.T will have the

effect of transforming the coordinates of vertices from world to view coordinates

Page 51: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 51

Summary

Canonical view orthographic projection VRP at the origin Looking in negative z direction (COP does not

matter) View-up vector is (0,1,0) View volume is a cube of side 2 center at

origin, (left, right, bottom, top, near, far)=(-1,1,-

1,1,1,-1)

(-1,-1,1)

(1,1,-1)

Page 52: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 52

Summary Perspective projection standard viewing

VRP at origin Looking in negative z-direction, look at is (0,0,-1) COP coincides with VRP, viewing direction is

orthogonal to view plane View-up vector is (0,1,0) View volume is a regular frustum (left, right, top, bottom, near, far)=(-1,1,-1,1,1,z_far), The near plane is at –1, the far is at -z. Side clipping planes make 45 deg angles with z axis

Page 53: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 53

Canonical Viewing for Perspective

Page 54: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 54

Hidden Surface Removal

z-buffer algorithm – as the polygons are rasterized we keep track of the distance from the VRP to the closest point on each projector. We display only the closest point

Requires a depth or z buffer to store the necessary depth information

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

glEnable(GL_DEPTH_TEST);

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

Page 55: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 55

Hidden Surface Removal

•Display only visible surfaces (remove hidden)•Painter’s algorithm: sort polygons according to z, project in order of decreasing depth•Pixel based: back track rays from pixels to first intersection•Z-buffer algorithm: based on relative depth after projection

Page 56: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 56

Perspective Normalization

How can we apply general perspective projection? Derive the perspective projection matrix (general 4x4

matrix), load that as a PROJECTION matrix Trick: Using series of affine transformations to alter the

world, so that the image of the distorted world under standard (canonical) projection is the same as the image of the undistorted world under the original general projection

Graphics systems go even farther: perspective projections are implemented internally as orthographic projections (of the distorted world) with respect to the canonical view volume (2x2x2 cube). This way the clipping is very efficient, and z-buffer algorithm is supported by preserving relative depth in the process of transforming objects.

Page 57: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 57

Projection Normalization Idea

Page 58: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 58

Projection Normalization

The distortion is described by a homogeneous-coordinate matrix

Concatenate this matrix with an orthogonal-projection matrix to yield a resulting projection matrix

Page 59: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 59

General Perspective Projection

Projection converts points in 3-D space to points on the projection plane

Three steps (the graphics system implements them): Converts the viewing volume (general

frustum) to the canonical perspective view volume

Next converts the canonical perspective view volume to the canonical orthographic view volume

Applys orthographic projection matrix

Page 60: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 60

The “most” canonical view volume

Orthographic projection with respect to most canonical view volume

Canonical view volume is a 2x2x2 cube whose center is at the origin (default view volume)

How to clip?: simple How to project?: no division

(-1,-1,1)

(1,1,-1)

Page 61: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 61

General Orthogonal ProjectionglMatrixMode(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

Page 62: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 62

Projection Matrix

1000

200

02

0

002

minmax

minmax

minmax

minmax

minmax

minmax

minmax

minmax

minmax

zz

zz

zz

yy

yy

yy

xx

xx

xx

STP

Page 63: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 63

Oblique Projection

degree of obliqueness

Page 64: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 64

Oblique Projection

shearing

Page 65: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 65

Perspective Projection Matrices

Look for a transformation allows a simple canonical projection by distorting the vertices of an object

Three steps: 1) select canonical viewing volume, 2) introduce the perspective normalization transformation and 3) derive the perspective projection matrix

Page 66: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 66

Perspective Projection Matrices

Page 67: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 67

Perspective Projection Matrices

N

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

Page 68: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 68

Projection and Shadows

Shadows are not geometric objects but important for realism

A point is in a shadow if it is not illuminated by any light source

A shadow polygon is a flat shadow that results from projecting the original polygon onto a surface

Page 69: Viewing, projectionsHofstra University1 Modeling and Viewing Modeling Use modeling (local) coordinates and geometric transformations to build hierarchically

Viewing, projections Hofstra University 69

Projection and Shadows

use a modelview matrix