159.235 Graphics & Graphical Programming - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

159.235 Graphics & Graphical Programming

Description:

Lecture 20 - 3D Shapes & Polygons Polygons -Outline What are polygons? Types Convexity/concavity Triangles Storage of vertices and edges Rendering wire-frames as ... – PowerPoint PPT presentation

Number of Views:136
Avg rating:3.0/5.0
Slides: 17
Provided by: masseyAc2
Category:

less

Transcript and Presenter's Notes

Title: 159.235 Graphics & Graphical Programming


1
159.235 Graphics Graphical Programming
  • Lecture 20 - 3D Shapes Polygons

2
Polygons -Outline
  • What are polygons?
  • Types
  • Convexity/concavity
  • Triangles
  • Storage of vertices and edges
  • Rendering wire-frames as lines and points

3
Polygonal Surfaces
  • Polygon surfaces are a simple form of
    representation used in most applications
  • Used in all real-time displays as fast to process
  • Other descriptions such as Splines might be used
    in some applications but are generally reduced
    to polygons for processing.
  • Polygon surfaces readily integrated with
    scan-line algorithms.

4
Scan Conversion of Polygons
  • Fill the polygon with colour.
  • Incorporate in a scan conversion algorithm.
  • We may not be drawing actual pixels due to
    anti-aliasing - jargon is that we tile the
    polygon with pixel fragments.

5
Common Types of Polygon
  • Concave
  • Convex
  • Triangles
  • Trapezoids
  • Quadrilaterals
  • Self-intersecting
  • Multiple loops
  • Holes

Concave
6
Convexity/Concavity Definition
  • A polygon is convex if for all edges, all other
    vertices lie on the same side of the edge
  • Otherwise it is concave.
  • Concave polygons often difficult to process
    (algorithms get stuck or miss bits)

Concave
Convex
7
Triangles Always Convex
  • Mathematically, uses simple linear equations.
  • Three points guaranteed co-planar by definition!
  • Any polygon can be decomposed into triangles
  • Triangles can approximate arbitrary shapes
  • For any orientation on screen, a scan line will
    intersect only a single segment (scan).

8
Polygon decomposition into Triangles
Convex polygons easy to decompose but if not
convex may have to add extra vertices to avoid
overlaps or intersection ambiguities
9
Arbitrary shapes with triangles
Any 2D shape, or 3D surface, can be approximated
with locally linear polygons. To improve just
increase the number of edges
10
Quadrilaterals are simple too and often mixed
with triangles
11
Java Swing and Java 3D
  • Swing has various 2D shape classes that allow
    us to implement various geometries
  • Point3d and Vector3d objects are a convenience
  • Java 3D is a Sun Microsystems (currently free)
    graphics library that builds on the 2D stuff
    from Swing
  • Supports some very sophisticated 3D rendering
  • Start by building our own 3D simple renderer

12
Polygon Representation
  • Could store all vertices explicitly - for each
    polygon
  • Makes it hard to edit the vertices (multiple
    copies)
  • Easier to store a table of vertices
  • Index into the vertex table for each polygon
  • Need to search for adjacent polygons
  • Do end up drawing edges twice
  • Tradeoffs!
  • Store all polygon vertices explicitly.
  • Inefficient
  • Cannot manipulate vertex positions.

Polygonal Geometry.
13
Common Polygonal Data Structures
14
Drawing a Wire-frame 3d Polygon
  • Break down into vertices and edges
  • For each edge determine the two vertices
  • Project the vertices from world space or model
    coordinates to screen coordinates
  • Draw the projected line (edge)
  • Repeat for each polygon under given projection

15
Filling, or tiling a triangle.
  • Calculate bounding box for triangle.
  • Loop through pixels in box
  • Test for points lying inside the triangle
  • Draw pixel fragment if inside box
  • Lets us colour in the shape (Java 2D or Swing
    will do this part for us)

Bounding box
16
Polygons - Summary
  • Various sorts of Polygons
  • Convexity often an important property
  • Triangles often useful simplest polygonal form
  • Can store polygons (or triangles) in various
    ways - tradeoffs depending upon algorithm
  • Render wire-frame by decomposing into
    points/lines - need transform to screen
    coordinates
Write a Comment
User Comments (0)
About PowerShow.com