Viewing Projection

2,973 views

Published on

Published in: Art & Photos, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,973
On SlideShare
0
From Embeds
0
Number of Embeds
18
Actions
Shares
0
Downloads
85
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Viewing Projection

  1. 1. Viewing & Projection
  2. 2. The 3D camera model <ul><li>Camera has position and orientation in world space and looks into the scene. </li></ul><ul><li>Though we think of it as a camera or eye, we use a point, a couple vectors to give orientation, and an image plane between the camera and the visible scene. </li></ul>
  3. 3. Viewing coordinates <ul><li>We need a canonical coordinate system for view space: </li></ul><ul><ul><li>viewing-coordinate system or view reference coordinate system </li></ul></ul><ul><li>It’s time to pick a convention: </li></ul><ul><ul><li>In the viewing coordinates, we’ll look down the positive z-axis (right-handed system). </li></ul></ul><ul><li>There are a number of ways we could set up this coordinate system. The most intuitive is the “ look at ” system. </li></ul>
  4. 4. The view reference point <ul><li>We start with a view reference point – the camera position. </li></ul><ul><li>This is given in world space coordinates. </li></ul><ul><li>This point will become the origin of the view reference system. </li></ul>
  5. 5. Look at point <ul><li>The first step in orienting the camera is to define the look at vector , typically be giving a point in world space the camera is pointed towards. </li></ul><ul><li>This gives us the axis in world space we are looking down (which we want to map to the z axis in view space). </li></ul>
  6. 6. View-up vector <ul><li>This leaves us with a degree of freedom in camera orientation: the camera could be rotated any angle around the view axis </li></ul><ul><li>We define a view-up vector as the camera’s up vector. </li></ul>
  7. 7. Projections <ul><li>Once in view coordinates, we need to project coordinates onto the image plane (think film in the camera). </li></ul><ul><li>2 types : </li></ul><ul><li>1. Parallel projection </li></ul><ul><li>all lines of projection are parallel </li></ul><ul><li>We could drop the z coordinate: </li></ul><ul><li>2. Perspective projection </li></ul><ul><li>the further away an object, the smaller its projection onto the image plane </li></ul><ul><li>We could divide by the z coordinate: </li></ul>
  8. 8. Parallel projection <ul><li>Orthographic (view direction parallel to projection direction) </li></ul>
  9. 9. Parallel projection <ul><li>Oblique (view direction not parallel to projection direction) </li></ul><ul><li>A shear is applied to x and y based on the value of z. The shear is defined by two angles: </li></ul>(x,y,z) (x,y) (x p ,y p )  
  10. 10. Parallel projection <ul><li>Problem 1: We’ve wiped out our z coordinate. Now how can we tell what’s closer to the camera? </li></ul><ul><li>Problem 2: Our coordinates are still based on the world coordinate system. This means our clipper has to be more general (more general = more slow) </li></ul>We want to 1) preserve some measure of depth, and 2) normalize the coordinate space Different systems pick slightly different normalizations left right top bottom near far
  11. 11. Opengl for orthographic projection <ul><li>glMatrixMode(GL_PROJECTION); </li></ul><ul><li>glLoadIdentity( ); </li></ul><ul><li>glOrtho(Left, Right, Bottom, Top, Near, Far); </li></ul><ul><li>Example </li></ul><ul><li>glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); </li></ul>
  12. 12. Perspective projection <ul><li>Features of perspective projection: </li></ul><ul><ul><li>Foreshortening – objects appear smaller the further they are from the view reference point </li></ul></ul><ul><ul><li>Vanishing point – parallel lines intersect at infinity </li></ul></ul>
  13. 13. Perspective projection
  14. 14. Perspective - a side view <ul><li>The camera is at the view reference point looking in the negative z direction </li></ul><ul><li>The image plane is at the near plane </li></ul>(x,y,z) (x p ,y p ,z vp ) (0,0,z vrp )
  15. 15. The view frustum left right top bottom far near
  16. 16. Opengl for perspective projection <ul><li>glMatrixMode(GL_PROJECTION); // make the projection matrix current </li></ul><ul><li>glLoadIdentity( ); </li></ul><ul><li>gluPerspective(viewAngle, aspectRatio, N, F); </li></ul><ul><li>- N – distance from the eye to the near plane </li></ul><ul><li>- F - .. .. .. .. .. .. Far plane </li></ul>N F 

×