1 / 81

2D Viewing

2D Viewing. Rina Dinkha Zarro. Contents. 3 D Rendering Pipeline 2D Rendering Pipeline Clipping Cohen-Sutherland Line Clipping Sutherland-Hodgeman Polygon Clipping Viewport Transformation Scan Conversion Summary of Transformation. 3 D Rendering Pipeline. 3 D Primitives.

dleopold
Download Presentation

2D Viewing

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. 2D Viewing Rina Dinkha Zarro cgvr.korea.ac.kr

  2. Contents • 3D Rendering Pipeline • 2D Rendering Pipeline • Clipping • Cohen-Sutherland Line Clipping • Sutherland-Hodgeman Polygon Clipping • Viewport Transformation • Scan Conversion • Summary of Transformation cgvr.korea.ac.kr

  3. 3D Rendering Pipeline 3D Primitives 3D Modeling Coordinates Model Transformation 3D World Coordinates Lighting 3D World Coordinates Viewing Transformation 3D ViewingCoordinates Projection Transformation 2D Projection Coordinates Clipping 2D Projection Coordinates Viewport Transformation 2D Device Coordinates Scan Conversion 2D Device Coordinates Image cgvr.korea.ac.kr

  4. 3D Rendering Pipeline 3D Primitives 3D Modeling Coordinates Model Transformation 3D World Coordinates Lighting 3D World Coordinates Viewing Transformation 3D Viewing Coordinates Projection Transformation 2D Projection Coordinates Clipping 2D Projection Coordinates Viewport Transformation 2D Device Coordinates Scan Conversion 2D Device Coordinates Image cgvr.korea.ac.kr

  5. 2D Rendering Pipeline 3D Primitives 2D Primitives Clipping Clip portions of geometric primitives residing outside window Viewport Transformation Transform the clipped primitives from screen to image coordinates Scan Conversion Fill pixel representing primitives in screen coordinates Image cgvr.korea.ac.kr

  6. 2D Rendering Pipeline 3D Primitives 2D Primitives Clipping Clip portions of geometric primitives residing outside window Viewport Transformation Transform the clipped primitives from screen to image coordinates Scan Conversion Fill pixel representing primitives in screen coordinates Image cgvr.korea.ac.kr

  7. Clipping • Avoid Drawing Parts of Primitives Outside Window • Window defines part of scene being viewed • Must draw geometric primitives only inside window World Coordinates cgvr.korea.ac.kr

  8. Clipping • Avoid Drawing Parts of Primitives Outside Window • Window defines part of scene being viewed • Must draw geometric primitives only inside window cgvr.korea.ac.kr

  9. Clipping • Avoid Drawing Parts of Primitives Outside Window • Points • Lines • Polygons • Circles • etc. cgvr.korea.ac.kr

  10. Point Clipping • Is Point(x,y) Inside the Clip Window? wy2 Inside = (x>=wx1) && (x<=wx2) && (y>=wy1) && (y<=wy2); (x, y) wy1 wx1 wx2 cgvr.korea.ac.kr

  11. Line Clipping • Find the Part of a Line Inside the Clip Window P7 P1 P4 P8 P3 P2 P6 P10 P5 P9 Before Clipping cgvr.korea.ac.kr

  12. Line Clipping • Find the Part of a Line Inside the Clip Window P’7 P’8 P4 P3 P6 P’5 After Clipping cgvr.korea.ac.kr

  13. Cohen-Sutherland Line Clipping • Use Simple Tests to Classify Easy Cases First P7 P1 P4 P8 P3 P2 P6 P10 P5 P9 cgvr.korea.ac.kr

  14. Cohen-Sutherland Line Clipping • Classify Some Lines Quickly by AND of Bit Codes Representing Regions of Two Endpoints (Must Be 0) P7 1001 0001 0101 Bit 4 P1 P4 P8 1000 0000 0100 P3 P2 P6 P10 Bit 3 1010 0010 0110 P5 P9 Bit 1 Bit 2 cgvr.korea.ac.kr

  15. Cohen-Sutherland Line Clipping • Classify Some Lines Quickly by AND of Bit Codes Representing Regions of Two Endpoints (Must Be 0) P7 1001 0001 0101 Bit 4 P1 P4 P8 1000 0000 0100 P3 P2 P6 P10 Bit 3 1010 0010 0110 P5 P9 Bit 1 Bit 2 cgvr.korea.ac.kr

  16. Cohen-Sutherland Line Clipping • Classify Some Lines Quickly by AND of Bit Codes Representing Regions of Two Endpoints (Must Be 0) P7 1001 0001 0101 Bit 4 P4 P8 1000 0000 0100 P3 P6 P10 Bit 3 1010 0010 0110 P5 P9 Bit 1 Bit 2 cgvr.korea.ac.kr

  17. Cohen-Sutherland Line Clipping • Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P7 1001 0001 0101 Bit 4 P4 P8 1000 0000 0100 P3 P6 P10 Bit 3 1010 0010 0110 P5 P9 Bit 1 Bit 2 cgvr.korea.ac.kr

  18. Cohen-Sutherland Line Clipping • Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P7 1001 0001 0101 Bit 4 P4 P8 1000 0000 0100 P3 P6 P10 Bit 3 1010 0010 0110 P5 P9 Bit 1 Bit 2 cgvr.korea.ac.kr

  19. Cohen-Sutherland Line Clipping • Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P7 1001 0001 0101 Bit 4 P4 P8 1000 0000 0100 P3 P6 P10 Bit 3 P’5 1010 0010 0110 P9 Bit 1 Bit 2 cgvr.korea.ac.kr

  20. Cohen-Sutherland Line Clipping • Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P7 1001 0001 0101 Bit 4 P4 P8 1000 0000 0100 P3 P6 P10 Bit 3 P’5 1010 0010 0110 P9 Bit 1 Bit 2 cgvr.korea.ac.kr

  21. Cohen-Sutherland Line Clipping • Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P7 1001 0001 0101 Bit 4 P4 P8 1000 0000 0100 P3 P6 P10 Bit 3 P’5 1010 0010 0110 P9 Bit 1 Bit 2 cgvr.korea.ac.kr

  22. Cohen-Sutherland Line Clipping • Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly P7 1001 0001 0101 Bit 4 P4 P8 1000 0000 0100 P3 P6 P10 Bit 3 P’5 1010 0010 0110 P9 Bit 1 Bit 2 cgvr.korea.ac.kr

  23. Cohen-Sutherland Line Clipping • Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly 1001 0001 P’7 0101 Bit 4 P4 P8 1000 0000 0100 P3 P6 P10 Bit 3 P’5 1010 0010 0110 P9 Bit 1 Bit 2 cgvr.korea.ac.kr

  24. Cohen-Sutherland Line Clipping • Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly 1001 0001 P’7 0101 Bit 4 P4 P8 1000 0000 0100 P3 P6 P10 Bit 3 P’5 1010 0010 0110 P9 Bit 1 Bit 2 cgvr.korea.ac.kr

  25. Cohen-Sutherland Line Clipping • Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly 1001 0001 P’7 0101 Bit 4 P’8 P4 1000 0000 0100 P3 P6 P10 Bit 3 P’5 1010 0010 0110 P9 Bit 1 Bit 2 cgvr.korea.ac.kr

  26. Cohen-Sutherland Line Clipping • Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly 1001 0001 P’7 0101 Bit 4 P’8 P4 1000 0000 0100 P3 P6 P10 Bit 3 P’5 1010 0010 0110 P9 Bit 1 Bit 2 cgvr.korea.ac.kr

  27. Cohen-Sutherland Line Clipping • Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly 1001 0001 P’7 0101 Bit 4 P’8 P4 1000 0000 0100 P3 P6 P10 Bit 3 P’5 1010 0010 0110 P9 Bit 1 Bit 2 cgvr.korea.ac.kr

  28. Cohen-Sutherland Line Clipping • Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly 1001 0001 P’7 0101 Bit 4 P’8 P4 1000 0000 0100 P3 P6 P10 Bit 3 P’5 1010 0010 0110 P9 Bit 1 Bit 2 cgvr.korea.ac.kr

  29. Cohen-Sutherland Line Clipping • Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly 1001 0001 P’7 0101 Bit 4 P’8 P4 1000 0000 0100 P3 P6 P10 Bit 3 P’5 P’9 1010 0010 0110 Bit 1 Bit 2 cgvr.korea.ac.kr

  30. Cohen-Sutherland Line Clipping • Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly 1001 0001 P’7 0101 Bit 4 P’8 P4 1000 0000 0100 P3 P6 P10 Bit 3 P’5 P’9 1010 0010 0110 Bit 1 Bit 2 cgvr.korea.ac.kr

  31. Cohen-Sutherland Line Clipping • Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly 1001 0001 P’7 0101 Bit 4 P’8 P4 1000 0000 0100 P3 P6 Bit 3 P’5 1010 0010 0110 Bit 1 Bit 2 cgvr.korea.ac.kr

  32. PolygonClipping • Find the Part of a Polygon Inside the Clip Window? Before Clipping cgvr.korea.ac.kr

  33. PolygonClipping • Find the Part of a Polygon Inside the Clip Window? After Clipping cgvr.korea.ac.kr

  34. Sutherland-Hodgeman Polygon Clipping • Clip to Each Window Boundary One at a Time cgvr.korea.ac.kr

  35. Sutherland-Hodgeman Polygon Clipping • Clip to Each Window Boundary One at a Time cgvr.korea.ac.kr

  36. Sutherland-Hodgeman Polygon Clipping • Clip to Each Window Boundary One at a Time cgvr.korea.ac.kr

  37. Sutherland-Hodgeman Polygon Clipping • Clip to Each Window Boundary One at a Time cgvr.korea.ac.kr

  38. Sutherland-Hodgeman Polygon Clipping • Clip to Each Window Boundary One at a Time cgvr.korea.ac.kr

  39. Sutherland-Hodgman Polygon Clipping • Clip a polygon by processing the polygon boundary as a whole against each window edge. • Processing all polygon vertices against each clip rectangle boundary in turn. • Beginning with the initial set of polygon vertices, we could first clip the polygon against the left rectangle boundary to produce a new sequence of vertices. • The new set of vertices could be successively passed to a right boundary clipper, a bottom boundary clipper, and a top boundary clipper, a right boundary clipper. cgvr.korea.ac.kr

  40. Sutherland-Hodgman Polygon Clipping Lift Clipper Right Clipper Bottom Clipper At each step, a new sequence of output vertices is generated and passed to the next window boundary clipper. Top Clipper cgvr.korea.ac.kr

  41. Sutherland-Hodgman Polygon Clipping There are four possible cases when processing vertices in sequence around the perimeter of a polygon. As each pair of adjacent polygon vertices is passed to a next window boundary clipper, we make the following tests: cgvr.korea.ac.kr

  42. Sutherland-Hodgman Polygon Clipping • If the first vertex is outside the window boundary and the second vertex is inside • Then, both the intersection point of the polygon edge with the window boundary and the second vertex are added to the output vertex list. cgvr.korea.ac.kr

  43. Sutherland-Hodgman Polygon Clipping • If both input vertices are inside the window boundary. • Then, only the second vertex is added to the output vertex list. cgvr.korea.ac.kr

  44. Sutherland-Hodgman Polygon Clipping • If the first vertex is inside the window boundary and the second vertex is outside. • Then, only the edge intersection with the window boundary is added to the output vertex list. cgvr.korea.ac.kr

  45. Sutherland-Hodgman Polygon Clipping • Ifboth input vertices are outside the window boundary. • Then, nothing is added to the output vertex list. cgvr.korea.ac.kr

  46. Sutherland-Hodgman Polygon Clipping Example:- Apply Polygon clipping for following Triangle with Xmin=5, Xmax=20 , Ymin=5 , Ymax=25 B(12,27) B’ B’’ C’ A’ C’’ A’’ C(25,8) A(0,8) cgvr.korea.ac.kr

  47. Sutherland-Hodgman Polygon Clipping • Solution:- • First Step:- we want to check the points if its in or out • A=1000 its out • B= 0001 its out • C=0100 its out • Second Step:- We should find intersection points by using line clipping. • For line A B we have two intersection A’ and B’ • For line B C we have two intersection B’’ and C’ • For Line C A we have two intersection C’’ and A’’

  48. Sutherland-Hodgman Polygon Clipping • Solution:- • Third Step:- Then we will apply Sutherland-Hodgman algorithm (Left, Right, Bottom, Top sequence) toget the clipped polygon. • For Left the output is [A’,B],[C],[A’’] B(12,27) B’ B’’ C’ A’ C’’ A’’ C(25,8) A(0,8)

  49. Sutherland-Hodgman Polygon Clipping • Solution:- • Third Step:- Then we will apply Sutherland-Hodgman algorithm (Left, Right, Bottom, Top sequence) toget the clipped polygon. • 2. For Right the output is [B],[C’],[C’’,A’’] B(12,27) B’ B’’ C’ A’ C’’ A’’ C(25,8) A(0,8)

  50. Sutherland-Hodgman Polygon Clipping • Solution:- • Third Step:- Then we will apply Sutherland-Hodgman algorithm (Left, Right, Bottom, Top sequence) toget the clipped polygon. • 3. For Bottom the output is [B],[C’],[C’’],[A’’],[A’] B(12,27) B’ B’’ C’ A’ C’’ A’’ C(25,8) A(0,8)

More Related