CS 430 Computer Graphics Hierarchical Graphics ChiCheng Lin

  • Slides: 17
Download presentation
CS 430 Computer Graphics Hierarchical Graphics Chi-Cheng Lin, Winona State University

CS 430 Computer Graphics Hierarchical Graphics Chi-Cheng Lin, Winona State University

Topics Hierarchical Geometric Models l Graphics Client and Server l Graphics Package Modes l

Topics Hierarchical Geometric Models l Graphics Client and Server l Graphics Package Modes l Display List in Open. GL l 2

Hierarchical Geometric Models l Model z. Representation of some (of all) features of a

Hierarchical Geometric Models l Model z. Representation of some (of all) features of a concrete or abstract entity z. Purposes y. Visualization and understanding of structures or behavior of an entity y. Experimentation with and prediction of effects of inputs or changes to the model l Models in computer graphics z. Organizational models z. Quantitative models z. Geometric models 3

Hierarchical Geometric Models l Geometric model z. Collection of components with well-defined geometry and

Hierarchical Geometric Models l Geometric model z. Collection of components with well-defined geometry and interconnections between components z. Representation of y. Spatial layout, shape, appearance y. Connectivity of components y. Application-specific data values and properties 4

Hierarchical Geometric Models l Purpose of hierarchy z. Modularization z. Storage economy z. Update

Hierarchical Geometric Models l Purpose of hierarchy z. Modularization z. Storage economy z. Update propagation l Hierarchy in geometric modeling z. Complex objects can be built using application-specific atomic components z. Symbolized by various tree structures or DAG (Directed Acyclic Graph) z. Parent calls child and passes geometric parameters to child 5

Hierarchical Geometric Models l Example Tree robot upper. Body leg DAG robot S upper.

Hierarchical Geometric Models l Example Tree robot upper. Body leg DAG robot S upper. Body leg arm arm hand 6

Hierarchical Geometric Models Child-sibling tree (a binary tree) is used to represent the tree

Hierarchical Geometric Models Child-sibling tree (a binary tree) is used to represent the tree hierarchy l Preorder traversal is used for rendering l Example: robot // l upper. Body arm leg // // hand // 7

Graphics Client and Server l Client z. Host computer running graphics programs l Server

Graphics Client and Server l Client z. Host computer running graphics programs l Server z. Workstation with a raster display, a keyboard, and pointing device z. Provides output services on its display z. Provides input services through the keyboard and pointing device z. Services potentially are available to client anywhere on the network 8

Graphics Package Modes l Immediate mode z. As soon as a statement that defines

Graphics Package Modes l Immediate mode z. As soon as a statement that defines a primitive is executed, the primitive is displayed immediately z. Keeps no record of primitives and attributes in memory z. Client computes and passes data to server 9

Graphics Package Modes l Retained mode z. Define an object once and put its

Graphics Package Modes l Retained mode z. Define an object once and put its description in a display list z. Display list is stored (cached) in the server and redisplayed by a function call issued from client to server 10

Graphics Package Modes l Advantages of retained mode z. Computation is reduced z. Network

Graphics Package Modes l Advantages of retained mode z. Computation is reduced z. Network traffic is reduced z. Performance could be optimized, e. g. , y. Client: good numerical-processing computer y. Server: special-purpose graphics computer l Disadvantages of retained mode z. Extra server memory required z. Overhead in creating and maintaining display lists z. Not practical for applications with high dynamics 11

Graphics Package Modes Some graphics packages support only one of the modes, some supports

Graphics Package Modes Some graphics packages support only one of the modes, some supports both mode l Both modes are supported in Open. GL l z. Immediate mode is what we’ve been using z. Retained mode: display list 12

Display List in Open. GL l Define a display list of an upright, centralized,

Display List in Open. GL l Define a display list of an upright, centralized, red cylinder GLuint my. Cylinder; my. Cylinder = gl. Gen. Lists(1) Compile and store, but don’t execute if (my. Cylinder != 0) { gl. New. List(my. Cylinder, GL_COMPILE); red. Cylinder(1. 0, 2. 0, 10, 8); gl. End. List(); } l Call (execute) a display list (e. g. , indisplay()) gl. Call. List(my. Cylinder); 13

Display List in Open. GL l Definition of a red cylinder GLUquadric. Obj *qobj;

Display List in Open. GL l Definition of a red cylinder GLUquadric. Obj *qobj; qobj = glu. New. Quadric(); glu. Quadric. Draw. Style(qobj, GLU_LINE); static void red. Cylinder(GLdouble b, GLdouble t, GLdouble h, GLint slc, GLint stk) { gl. Color 3 f(1. 0, 1. 0); gl. Rotated(-90. 0, 1. 0, 0. 0); gl. Translated(0, 0, -h/2); glu. Cylinder(qobj, b, t, h, slc, stk); } 14

Display List in Open. GL l Problem z. The state (e. g. , color

Display List in Open. GL l Problem z. The state (e. g. , color and transformation matrix) might be changed by a display list l Solution: save/restore state z. At the beginning of a display list gl. Push. Matrix(); gl. Push. Attrib(GL_ALL_ATTRIB_BITS); z. At the end of a display list gl. Pop. Attrib(); gl. Pop. Matrix(); 15

Hierarchical Display Lists A list can call another list l Example l zgl. New.

Hierarchical Display Lists A list can call another list l Example l zgl. New. List(bike, GL_COMPILE); gl. Call. List(body); gl. Translated(-0. 5, 0, 0); gl. Call. List(wheel); gl. Translated(1. 0, 0, 0); gl. Call. List(wheel); gl. End. List(); 16

Display List in Open. GL l Once a display list is created it cannot

Display List in Open. GL l Once a display list is created it cannot be modified* z. E. g. , if you are going to rotate a wheel independently, do not include it in the list z. Inflexible, but efficient z. Use a display list for an atomic object l Matrix operations, lighting models, material properties, textures, patterns, may also be optimized using display list 17