Building Models Ed Angel Professor Emeritus of Computer
Building Models Ed Angel Professor Emeritus of Computer Science University of New Mexico Angel and Shreiner: Interactive Computer Graphics 7 E © Addison Wesley 2015 1
Objectives • Introduce simple data structures for building polygonal models Vertex lists Edge lists Angel and Shreiner: Interactive Computer Graphics 7 E © Addison Wesley 2015 2
Representing a Mesh • Consider a mesh e 2 v 6 e 1 v 1 e 6 v 5 e 3 e 8 v e 9 v 4 8 e 11 e 10 e 4 e 7 v 2 e 12 e 5 v 3 • There are 8 nodes and 12 edges 5 interior polygons 6 interior (shared) edges • Each vertex has a location vi = (xi yi zi) Angel and Shreiner: Interactive Computer Graphics 7 E © Addison Wesley 2015 3
Simple Representation • Define each polygon by the geometric locations of its vertices • Leads to Web. GL code such as vertex. push(vec 3(x 1, y 1, z 1)); vertex. push(vec 3(x 6, y 6, z 6)); vertex. push(vec 3(x 7, y 7, z 7)); • Inefficient and unstructured Consider moving a vertex to a new location Must search for all occurrences Angel and Shreiner: Interactive Computer Graphics 7 E © Addison Wesley 2015 4
Inward and Outward Facing Polygons • The order {v 1, v 6, v 7} and {v 6, v 7, v 1} are equivalent in that the same polygon will be rendered by Open. GL but the order {v 1, v 7, v 6} is different • The first two describe outwardly facing polygons • Use the right-hand rule = counter clockwise encirclement of outward pointing normal • Open. GL can treat inward and outward facing polygons differently Angel and Shreiner: Interactive Computer Graphics 7 E © Addison Wesley 2015 5
Geometry vs Topology • Generally it is a good idea to look for data structures that separate the geometry from the topology Geometry: locations of the vertices Topology: organization of the vertices and edges Example: a polygon is an ordered list of vertices with an edge connecting successive pairs of vertices and the last to the first Topology holds even if geometry changes Angel and Shreiner: Interactive Computer Graphics 7 E © Addison Wesley 2015 6
Vertex Lists • Put the geometry in an array • Use pointers from the vertices into this array • Introduce a polygon list x 1 y 1 z 1 v 1 x 2 y 2 z 2 P 1 v 7 x 3 y 3 z 3 P 2 v 6 x 4 y 4 z 4 P 3 x 5 y 5 z 5. P 4 v 8 x 6 y 6 z 6 P 5 v 6 x 7 y 7 z 7 topology geometry x 8 y 8 z 8 Angel and Shreiner: Interactive Computer Graphics 7 E © Addison Wesley 2015 7
Shared Edges • Vertex lists will draw filled polygons correctly but if we draw the polygon by its edges, shared edges are drawn twice • Can store mesh by edge list Angel and Shreiner: Interactive Computer Graphics 7 E © Addison Wesley 2015 8
Edge List e 2 e 1 e 2 e 3 e 4 e 5 e 6 e 7 e 8 e 9 v 1 v 6 x 1 y 1 z 1 x 2 y 2 z 2 x 3 y 3 z 3 x 4 y 4 z 4 x 5 y 5 z 5. x 6 y 6 z 6 x 7 y 7 z 7 x 8 y 8 z 8 v 6 e 1 v 1 e 6 v 5 e 3 e 8 v e 9 8 e 11 e 10 e 4 e 7 v 2 e 12 e 5 v 3 Note polygons are not represented Angel and Shreiner: Interactive Computer Graphics 7 E © Addison Wesley 2015 9
Draw cube from faces var color. Cube( ) { quad(0, 3, 2, 1); quad(2, 3, 7, 6); quad(0, 4, 7, 3); quad(1, 2, 6, 5); quad(4, 5, 6, 7); quad(0, 1, 5, 4); } 5 6 2 1 7 4 0 3 Angel and Shreiner: Interactive Computer Graphics 7 E © Addison Wesley 2015 10
- Slides: 10