projection part 1 created by dr slim bechikh for spsu
play

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


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

  2. Recall: � 3D � Viewing � and � View � Volume Now: Set view volume Previously: Lookat( ) to set camera position

  3. Recall: � Different � View � Volume � Shapes y y z z x x Perspective view volume Orthogonal view volume (exhibits foreshortening) (no foreshortening) � Different � view � volume � => � different � look � Foreshortening? � Near � objects � bigger

  4. View � Volume � Parameters � Need � to � set � view � volume � parameters � Projection � type: � perspective, � orthographic, � etc. � Field � of � view � and � aspect � ratio � Near � and � far � clipping � planes

  5. Field � of � View � View � volume � parameter � Determines � how � much � of � world � in � picture � (vertically) � Larger � field � of � view � = � smaller � objects � drawn center of projection field of view (view angle) y y z z x

  6. Near � and � Far � Clipping � Planes � Only � objects � between � near � and � far � planes � drawn Near plane Far plane y z x

  7. Viewing � Frustrum � Near � plane � + � far � plane � + � field � of � view � = � Viewing � Frustum � Objects � outside � the � frustum � are � clipped Near plane Far plane y z x Viewing Frustum

  8. Setting � up � View � Volume/Projection � Type � Previous � OpenGL � projection � commands � deprecated !! � Perspective � view � volume/projection: y � gluPerspective (fovy, � aspect, � near, � far) � or z x � glFrustum (left, � right, � bottom, � top, � near, � far) � Orthographic: � y � glOrtho (left, � right, � bottom, � top, � near, � far) � z x � Useful �� functions, � so � we � implement � similar � in � mat.h : � Perspective (fovy, � aspect, � near, � far) � or � Frustum (left, � right, � bottom, � top, � near, � far) � Ortho (left, � right, � bottom, � top, � near, � far) � What are these arguments? Next!

  9. Perspective(fovy, � aspect, � near, � far) � Aspect � ratio � used � to � calculate � window � width Near � plane y y w fovy z z h x Aspect = w / h near far

  10. Frustum(left, � right, � bottom, � top, � near, � far) � Can � use � Frustrum( � ) � in � place � of � Perspective () � Same � view � volume � shape , � different � arguments left top y z x right bottom near far near and far measured from camera

  11. Ortho(left, � right, � bottom, � top, � near, � far) � For � orthographic � projection top left y z x right bottom near far near and far measured from camera

  12. Example � Usage: � Setting � View � Volume/Projection � Type 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 }

  13. Demo � Nate � Robbins � demo � on � projection

  14. Perspective � Projection � After � setting � view � volume, � then � projection � transformation � Projection? � Classic: � Converts � 3D � object � to � corresponding � 2D � on � screen � � How? � Draw � line � from � object � to � projection � center � Calculate � where � each � intersects � projection � plane Projectors camera Object in 3 space Projected image VRP projection plane COP

  15. Orthographic � Projection � How? � Draw � parallel � lines � from � each � object � vertex � The � projection � center � is � at � infinite � In � short, � use � (x,y) � coordinates, �� just � drop � z � coordinates y z x Triangle Projection of In 3D Triangle in 2D

  16. Default � View � Volume/Projection? � What � if � you � user � does � not � set � up � projection? � Default � OpenGL � projection � is � orthogonal � (Ortho( � )); � To � project � points � within � default � view � volume x p = x y p = y z p = 0 y z x Vertices before Vertices after Projection Projection Triangle Projection of In 3D Triangle in 2D

  17. Homogeneous � Coordinate � Representation default orthographic projection x p = x p p = Mp y p = y z p = 0 � � 1 0 0 0 w p = 1 � � 0 1 0 0 � � Default M = � � Projection 0 0 0 0 Vertices before Vertices after Matrix � � Projection (3D) Projection (2D) � � 0 0 0 1 In � practice, � can � let � M = � I, � set � the z � term � to � zero � later

  18. The � Problem � with � Classic � Projection � Keeps � (x,y) � coordintates � for � drawing, � drops � z � We � may � need � z. � Why? Projectors Object in 3 space Projected image VRP y COP z x p = x x y p = y VertexTriangle Classic Projection z p = 0 Projection of In 3D Triangle in 2D Loses z value

  19. Normalization: � Keeps � z � Value � Most � graphics � systems � use � view � normalization � Normalization: convert � all � other � projection � types � to � orthogonal � projections � with � the � default � view � volume Perspective � transform y matrix z x Default view volume Clipping against it y z Ortho � transform matrix x

  20. References � Interactive � Computer � Graphics � (6 th edition), � Angel � and � Shreiner � Computer � Graphics � using � OpenGL � (3 rd edition), � Hill � and � Kelley

Recommend


More recommend