Projection (Part 1) Created by Dr. Slim BECHIKH for SPSU course - - - PowerPoint PPT Presentation

projection part 1 created by dr slim bechikh for spsu
SMART_READER_LITE
LIVE PREVIEW

Projection (Part 1) Created by Dr. Slim BECHIKH for SPSU course - - - PowerPoint PPT Presentation

Projection (Part 1) Created by Dr. Slim BECHIKH for SPSU course - CS4363 Computer Graphics and Multimedia Fall 2014 Recall: 3D Viewing and View Volume Now: Set view volume Previously: Lookat( ) to set camera position


slide-1
SLIDE 1

Projection (Part 1) Created by Dr. Slim BECHIKH for SPSU course - CS4363 Computer Graphics and Multimedia Fall 2014

slide-2
SLIDE 2

Recall:3DViewingandViewVolume

Previously: Lookat( ) to set camera position Now: Set view volume

slide-3
SLIDE 3

Recall:DifferentViewVolumeShapes

Differentviewvolume=>differentlook Foreshortening?Nearobjectsbigger x y z x y z Perspective view volume (exhibits foreshortening) Orthogonal view volume (no foreshortening)

slide-4
SLIDE 4

ViewVolumeParameters

Needtosetviewvolumeparameters

Projectiontype:perspective,orthographic,etc. Fieldofviewandaspectratio Nearandfarclippingplanes

slide-5
SLIDE 5

FieldofView

Viewvolumeparameter Determineshowmuchofworldinpicture(vertically) Largerfieldofview=smallerobjectsdrawn x y z y z field of view (view angle) center of projection

slide-6
SLIDE 6

NearandFarClippingPlanes

Onlyobjectsbetweennearandfarplanesdrawn

x y z Near plane Far plane

slide-7
SLIDE 7

ViewingFrustrum

Nearplane+farplane+fieldofview=ViewingFrustum Objectsoutsidethefrustumareclipped

x y z Near plane Far plane Viewing Frustum

slide-8
SLIDE 8

SettingupViewVolume/ProjectionType

PreviousOpenGLprojectioncommandsdeprecated!!

Perspectiveviewvolume/projection:

gluPerspective(fovy,aspect,near,far)or glFrustum(left,right,bottom,top,near,far)

Orthographic:

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

Usefulfunctions,soweimplementsimilarinmat.h:

Perspective(fovy,aspect,near,far)or Frustum(left,right,bottom,top,near,far) Ortho(left,right,bottom,top,near,far)

x y z x y z What are these arguments? Next!

slide-9
SLIDE 9

Perspective(fovy,aspect,near,far)

Aspectratiousedtocalculatewindowwidth

x y z y z fovy near far Aspect = w / h w h

Nearplane

slide-10
SLIDE 10

Frustum(left,right,bottom,top,near,far)

CanuseFrustrum()inplaceofPerspective() Sameviewvolumeshape,differentarguments

x y z left right bottom top near far

near and far measured from camera

slide-11
SLIDE 11

Ortho(left,right,bottom,top,near,far)

Fororthographicprojection

x y z left right bottom top near far

near and far measured from camera

slide-12
SLIDE 12

ExampleUsage: SettingViewVolume/ProjectionType

void display() { // clear screen glClear(GL_COLOR_BUFFER_BIT); ……….. // Set up camera position LookAt(0,0,1,0,0,0,0,1,0); ……….. // set up perspective transformation Perspective(fovy, aspect, near, far); ……….. // draw something display_all(); // your display routine }

slide-13
SLIDE 13

Demo

NateRobbinsdemoonprojection

slide-14
SLIDE 14

VRP COP Object in 3 space Projectors Projected image

PerspectiveProjection

Aftersettingviewvolume,thenprojection

transformation

Projection?

Classic:Converts3Dobjecttocorresponding2Donscreen How?Drawlinefromobjecttoprojectioncenter Calculatewhereeachintersectsprojectionplane

projection plane camera

slide-15
SLIDE 15

How?Drawparallellinesfromeachobjectvertex Theprojectioncenterisatinfinite Inshort,use(x,y)coordinates,justdropzcoordinates

OrthographicProjection

x y z

Triangle In 3D Projection of Triangle in 2D

slide-16
SLIDE 16

Whatifyouuserdoesnotsetupprojection? DefaultOpenGLprojectionisorthogonal(Ortho()); Toprojectpointswithindefaultviewvolume

DefaultViewVolume/Projection?

x y z

Triangle In 3D Projection of Triangle in 2D

xp = x yp = y zp = 0

Vertices after Projection Vertices before Projection

slide-17
SLIDE 17

HomogeneousCoordinate Representation

xp = x yp = y zp = 0 wp = 1 pp = Mp M =

  • 1

1 1

Inpractice,canletM =I,setthe ztermtozerolater default orthographic projection

Vertices after Projection (2D) Vertices before Projection (3D) Default Projection Matrix

slide-18
SLIDE 18

Keeps(x,y)coordintatesfordrawing,dropsz Wemayneedz.Why?

TheProblemwithClassicProjection

x y z

VertexTriangle In 3D Projection of Triangle in 2D

VRP COP Object in 3 space Projectors Projected image

xp = x yp = y zp = 0

Classic Projection Loses z value

slide-19
SLIDE 19

Normalization:KeepszValue

Mostgraphicssystemsuseviewnormalization Normalization: convertallotherprojectiontypesto

  • rthogonalprojectionswiththedefaultviewvolume

x y z x y z Default view volume Clipping against it

Perspectivetransform matrix Orthotransform matrix

slide-20
SLIDE 20

References

InteractiveComputerGraphics(6th edition),Angeland

Shreiner

ComputerGraphicsusingOpenGL(3rd edition),HillandKelley