1 / 115

CSCE 441: Computer Graphics Scan Conversion of Polygons

CSCE 441: Computer Graphics Scan Conversion of Polygons. Jinxiang Chai. GL_LINES. GL_POLYGON. GL_LINE_STRIP. GL_LINE_LOOP. GL_POINTS. GL_TRIANGLES. GL_QUADS. GL_TRIANGLE_FAN. GL_TRIANGLE_STRIP. GL_QUAD_STRIP. OpenGL Geometric Primitives.

christner
Télécharger la présentation

CSCE 441: Computer Graphics Scan Conversion of Polygons

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. CSCE 441: Computer GraphicsScan Conversion of Polygons Jinxiang Chai

  2. GL_LINES GL_POLYGON GL_LINE_STRIP GL_LINE_LOOP GL_POINTS GL_TRIANGLES GL_QUADS GL_TRIANGLE_FAN GL_TRIANGLE_STRIP GL_QUAD_STRIP OpenGL Geometric Primitives • All geometric primitives are specified by vertices

  3. GL_LINES GL_POLYGON GL_LINE_STRIP GL_LINE_LOOP GL_POINTS GL_TRIANGLES GL_QUADS GL_TRIANGLE_FAN GL_TRIANGLE_STRIP GL_QUAD_STRIP OpenGL Geometric Primitives • All geometric primitives are specified by vertices

  4. GL_LINES GL_POLYGON GL_LINE_STRIP GL_LINE_LOOP GL_POINTS GL_TRIANGLES GL_QUADS GL_TRIANGLE_FAN GL_TRIANGLE_STRIP GL_QUAD_STRIP OpenGL Geometric Primitives • All geometric primitives are specified by vertices

  5. Drawing General Polygons • How to draw every interior pixel? ?

  6. Drawing General Polygons • How to draw every interior pixel?

  7. Drawing Curved Objects • How to draw every interior pixels?

  8. Outline • Methods for drawing polygons or curved objects - Scanline conversion of polygons - Boundary-fill - Flood-fill • Required readings: - HB 6-10 to 6-14

  9. Drawing Rectangles Which pixels should be filled?

  10. Drawing Rectangles Is this correct?

  11. Drawing Rectangles What if two rectangles overlap?

  12. Drawing Rectangles Is this correct?

  13. Drawing Rectangles Overlap!!! Is this correct?

  14. Drawing Rectangles Solution: Exclude pixels on top and right

  15. Drawing Rectangles Artifacts are possible

  16. General Polygons – Basic Idea • How to draw every interior pixel? - process the screen scan line from the bottom of the boundaries to the top - draw every interior pixel for each scan line.

  17. General Polygons – Basic Idea • How to draw every interior pixel for a scan line?

  18. General Polygons – Basic Idea • Intersect scan lines with edges • Find ranges along x • Fill interior of those ranges

  19. General Polygons – Basic Idea • Intersect scan lines with edges • Find ranges along x • Fill interior of those ranges

  20. General Polygons – Basic Idea • Intersect scan lines with edges • Find ranges along x • Fill interior of those ranges • What about this line?

  21. General Polygons – Basic Idea • Intersect scan lines with edges • Find ranges along x • Fill interior of those ranges • Draw odd intervals only

  22. General Polygons – Basic Idea • Intersect scan lines with edges • Find ranges along x • Fill interior of those ranges • Draw odd intervals only • Don’t fill top/right • Edges may NOT match • with line drawing algorithm

  23. General Polygons – Basic Idea Use coherence to speed up • Intersect scan lines with edges • Find ranges along x • Fill interior of those ranges • Draw odd intervals only

  24. General Polygons – Basic Idea Use coherence to speed up • Intersect scan lines with edges • Find ranges along x • Fill interior of those ranges • Draw odd intervals only Edges intersecting one scan line are mostly same as those intersecting previous scan line

  25. General Polygons – Basic Idea Use coherence to speed up • Intersect scan lines with edges • Find ranges along x • Fill interior of those ranges • Draw odd intervals only The x-value of an intersection with one scan line is close to the intersection with the previous one

  26. How to store polygon edges?

  27. How to store polygon edges? Associate polygon edges with scan lines Scan Lines

  28. How to store polygon edges? Associate polygon edges with scan lines: use the lowest end point of a edge to find the corresponding scan line Scan Lines

  29. How to store polygon edges? Associate polygon edges with scan lines: use the lowest end point of a edge to find the corresponding scan line Scan Lines

  30. How to store polygon edges? Associate polygon edges with scan lines: use the lowest end point of a edge to find the corresponding scan line Scan Lines

  31. General Polygons – Data Structures • Sorted Edge Table: Store a linked-list per scan-line. Insert edges into table at scan-line associated with lowest end-point. Scan Lines Edges

  32. General Polygons – Example C Sorted Edge Table B D G F E A Insert edges into table at scan-line associated with lowest end-point!

  33. General Polygons – Example C Sorted Edge Table B D G F E A Insert edges into table at scan-line associated with lowest end-point!

  34. General Polygons – Example C Sorted Edge Table B D G AB AG F E A Insert edges into table at scan-line associated with lowest end-point!

  35. General Polygons – Example C Sorted Edge Table B D G AB AG F E Exclude horizontal edges! A Insert edges into table at scan-line associated with lowest end-point!

  36. General Polygons – Example C Sorted Edge Table B D G FG ED AB AG F E A Insert edges into table at scan-line associated with lowest end-point!

  37. General Polygons – Example C Sorted Edge Table B D CD G FG ED AB AG F E A Insert edges into table at scan-line associated with lowest end-point!

  38. General Polygons – Example C Sorted Edge Table B BC D CD G FG ED AB AG F E A Insert edges into table at scan-line associated with lowest end-point!

  39. General Polygons – Example C Sorted Edge Table B BC D CD G FG ED AB AG F E Which edges are intersecting with the current scan line? A Insert edges into table at scan-line associated with lowest end-point!

  40. General Polygons – Data Structures • Active Edge List: List of all edges intersecting current scan-line sorted by their x-values Edges

  41. Edge mazY currentX xIncr General Polygons – Data Structures • Edge: maxY: highest y-value currentX: x-value of end-point with lowest y-value xIncr: 1 / slope

  42. Edge mazY currentX xIncr Scan line intersection Scan line yk+1 Scan line yk

  43. Edge mazY currentX xIncr Scan line intersection Scan line yk+1 Scan line yk • with xk and 1/m, we can efficiently compute the next endpoint! • - increment yk by 1 • - increment xk by 1/m • with yend, we know when to end the edge.

  44. General Polygons – Data Structures • Edge: maxY: highest y-value currentX: x-value of end-point with lowest y-value xIncr: 1 / slope Edge mazY currentX xIncr Horizontal edges will not be used!!!

  45. General Polygons – Algorithm line = 0 While (line < height ) Add edges to Active Edge List from Sorted Edge Table starting at line Remove edges that end at line Fill interior pixels on the current scan line Increment x-values on edges in Active Edge List Increment line

  46. General Polygons – Algorithm line = 0 While (line < height ) Add edges to Active Edge List from Sorted Edge Table starting at line Remove edges that end at line Fill interior pixels on the current scan line Increment x-values on edges in Active Edge List Increment line Incrementally update the coordinates of intersection points!

  47. General Polygons – Example C Sorted Edge Table B BC D CD G FG ED AB AG Active Edge List F E A

  48. General Polygons – Algorithm line = 0 While (line < height ) Add edges to Active Edge List from Sorted Edge Table starting at line Remove edges that end at line Fill pixels Increment x-values on edges in Active Edge List Increment line

  49. General Polygons – Example C Sorted Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG A maxY currentX xIncr

  50. General Polygons – Example C Sorted Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG A maxY currentX xIncr

More Related