1 / 33

Projection and Clipping

Projection and Clipping. 網媒所 林宏祥 2012.10.02. Overview. Orthogonal Projection. X. x camera. x viewport. -Z. Perspective P rojection. X. x camera. x viewport. -Z. d. z. View Volume—orthogonal projection. y. -z. x. Left C lipping Plane. Far C lipping Plane. Top Clipping Plane.

uttara
Download Presentation

Projection and Clipping

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Projection and Clipping 網媒所林宏祥2012.10.02

  2. Overview

  3. Orthogonal Projection X xcamera xviewport -Z

  4. Perspective Projection X xcamera xviewport -Z d z

  5. View Volume—orthogonal projection y -z x Left Clipping Plane Far Clipping Plane Top Clipping Plane Bottom Clipping Plane Near Clipping Plane Right Clipping Plane

  6. View Volume—Perspective projection model y -z x Left Clipping Plane Far Clipping Plane Top Clipping Plane Near Clipping Plane Bottom Clipping Plane Right Clipping Plane

  7. Clipping Cuboid: transformed volume after projection Y viewport coordinates x z

  8. Implementation behind OpenGL Functions….

  9. In OpenGL, the clipping cuboid is fixed. (Since the screen size is fixed)

  10. Clipping Cuboid: enclosed by: xviewport= 1,xviewport=-1,yviewport=1,yviewport=-1,zviewport =1,zviewport=-1 Y x z

  11. The openGL functions ensure the view volume fits clipping cuboid.

  12. glOrtho(left, right, bottom, top, nearVal, farVal) left farVal top bottom nearVal right

  13. glOrtho(left, right, bottom, top, nearVal, farVal)

  14. Orthogonal Projection X xcamera xviewport -Z some scaling

  15. A linear mapping for orthogonal projection

  16. A canonical view.. Clipping cuboid Viewing Volume 1 left right -1 xviewport 0 xcamera

  17. Same mapping ways in y direction and z direction..

  18. gluPerspective(fovy, aspect, zNear, zFar) Left Clipping Plane Far Clipping Plane Top Clipping Plane Near Clipping Plane Bottom Clipping Plane Right Clipping Plane

  19. gluPerspective(fovy, aspect, zNear, zFar)

  20. Perspective Projection X X xcamera xcamera xviewport xviewport -Z -Z d d = 1 z z some scaling

  21. A canonical view.. Y -zFar -zNear ycamera fovy zcamera -Z

  22. Y -zFar -zNear ycamera fovy zcamera -Z

  23. Y -zFar -zNear ycamera fovy zcamera -Z After projection, the boundaries should map to 1, -1

  24. Similarly in x, but consider the aspect.

  25. Mapping on z: To present more details in closer objects, the viewport coordinate is inverse proportional to camera coordinates.

  26. -zFar is mapping to 1, -zNear is mapping to -1, then

  27. Remember perspective projection? (xcamera, ycamera coordinates will be divided by zcamera)

  28. Perspective projection <--> maintaining homogeneous coordinates

  29. In the clipping part of your homework..

  30. You need to create your own clipping cuboid which is different from openGL clipping cuboid. NOT modify the viewing volume. (eg: xviewport: [-0.5,0.5], yviewport:[-0.5,0.5], zviewport:[-0.5, 0.5]) You need to adjust the coordinates in glVertex3f()

  31. You need to calculate intersection In 2D example, screen One capable way to handle it: Cohen-Sutherland Algorithm

  32. Any Question?

More Related