Download presentation
Presentation is loading. Please wait.
Published byDale Shepherd Modified over 9 years ago
1
1 Building Models Ed Angel Professor Emeritus of Computer Science University of New Mexico Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
2
2 Objectives Introduce simple data structures for building polygonal models Vertex lists Edge lists Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
3
3 Representing a Mesh Consider a mesh There are 8 nodes and 12 edges 5 interior polygons 6 interior (shared) edges Each vertex has a location v i = (x i y i z i ) v1v1 v2v2 v7v7 v6v6 v8v8 v5v5 v4v4 v3v3 e1e1 e8e8 e3e3 e2e2 e 11 e6e6 e7e7 e 10 e5e5 e4e4 e9e9 e 12 Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
4
4 Simple Representation Define each polygon by the geometric locations of its vertices Leads to WebGL code such as Inefficient and unstructured Consider moving a vertex to a new location Must search for all occurrences vertex.push(vec3(x1, y1, z1)); vertex.push(vec3(x6, y6, z6)); vertex.push(vec3(x7, y7, z7)); Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
5
5 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 OpenGL 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 OpenGL can treat inward and outward facing polygons differently Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
6
6 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 7E © Addison-Wesley 2015
7
7 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 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 P1 P2 P3 P4 P5 v1v7v6v1v7v6 v8v5v6v8v5v6 topology geometry Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
8
8 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 7E © Addison-Wesley 2015
9
9 Edge List v1v1 v2v2 v7v7 v6v6 v8v8 v5v5 v3v3 e1e1 e8e8 e3e3 e2e2 e 11 e6e6 e7e7 e 10 e5e5 e4e4 e9e9 e 12 e1 e2 e3 e4 e5 e6 e7 e8 e9 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 v1 v6 Note polygons are not represented Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
10
10 Draw cube from faces var colorCube( ) { 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); } 0 56 2 4 7 1 3 Angel and Shreiner: Interactive Computer Graphics 7E © Addison-Wesley 2015
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.