170 likes | 349 Views
CS430 Computer Graphics. Hierarchical Graphics. Topics. Hierarchical Geometric Models Graphics Client and Server Graphics Package Modes Display List in OpenGL. Hierarchical Geometric Models. Model Representation of some (of all) features of a concrete or abstract entity Purposes
E N D
CS430 Computer Graphics Hierarchical Graphics Chi-Cheng Lin, Winona State University
Topics • Hierarchical Geometric Models • Graphics Client and Server • Graphics Package Modes • Display List in OpenGL
Hierarchical Geometric Models • Model • Representation of some (of all) features of a concrete or abstract entity • Purposes • Visualization and understanding of structures or behavior of an entity • Experimentation with and prediction of effects of inputs or changes to the model • Models in computer graphics • Organizational models • Quantitative models • Geometric models
Hierarchical Geometric Models • Geometric model • Collection of components with well-defined geometry and interconnections between components • Representation of • Spatial layout, shape, appearance • Connectivity of components • Application-specific data values and properties
Hierarchical Geometric Models • Purpose of hierarchy • Modularization • Storage economy • Update propagation • Hierarchy in geometric modeling • Complex objects can be built using application-specific atomic components • Symbolized by various tree structures or DAG (Directed Acyclic Graph) • Parent calls child and passes geometric parameters to child
S Hierarchical Geometric Models • Example Tree DAG robot robot upperBody leg leg upperBody leg arm arm arm hand hand hand
Hierarchical Geometric Models • Child-sibling tree (a binary tree) is used to represent the tree hierarchy • Preorder traversal is used for rendering • Example: robot // upperBody leg leg // arm arm // hand // hand //
Graphics Client and Server • Client • Host computer running graphics programs • Server • Workstation with a raster display, a keyboard, and pointing device • Provides output services on its display • Provides input services through the keyboard and pointing device • Services potentially are available to client anywhere on the network
Graphics Package Modes • Immediate mode • As soon as a statement that defines a primitive is executed, the primitive is displayed immediately • Keeps no record of primitives and attributes in memory • Client computes and passes data to server
Graphics Package Modes • Retained mode • Define an object once and put its description in a display list • Display list is stored (cached) in the server and redisplayed by a function call issued from client to server
Graphics Package Modes • Advantages of retained mode • Computation is reduced • Network traffic is reduced • Performance could be optimized, e.g., • Client: good numerical-processing computer • Server: special-purpose graphics computer • Disadvantages of retained mode • Extra server memory required • Overhead in creating and maintaining display lists • Not practical for applications with high dynamics
Graphics Package Modes • Some graphics packages support only one of the modes, some supports both mode • Both modes are supported in OpenGL • Immediate mode is what we’ve been using • Retained mode: display list
Display List in OpenGL • Define a display list of an upright, centralized, red cylinder GLuint myCylinder; myCylinder = glGenLists(1) if (myCylinder != 0) { glNewList(myCylinder, GL_COMPILE); redCylinder(1.0, 1.0, 2.0, 10, 8); glEndList(); } • Call (execute) a display list (e.g., indisplay()) glCallList(myCylinder); Compile and store, but don’t execute
Display List in OpenGL • Definition of a red cylinder GLUquadricObj *qobj; qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_LINE); static void redCylinder(GLdouble b, GLdouble t, GLdouble h, GLint slc, GLint stk) { glColor3f(1.0, 1.0, 1.0); glRotated(-90.0, 1.0, 0.0, 0.0); glTranslated(0, 0, -h/2); gluCylinder(qobj, b, t, h, slc, stk); }
Display List in OpenGL • Problem • The state (e.g., color and transformation matrix) might be changed by a display list • Solution: save/restore state • At the beginning of a display list glPushMatrix(); glPushAttrib(GL_ALL_ATTRIB_BITS); • At the end of a display list glPopAttrib(); glPopMatrix();
Hierarchical Display Lists • A list can call another list • Example • glNewList(bike, GL_COMPILE); glCallList(body); glTranslated(-0.5, 0, 0); glCallList(wheel); glTranslated(1.0, 0, 0); glCallList(wheel); glEndList();
Display List in OpenGL • Once a display list is created it cannot be modified* • E.g., if you are going to rotate a wheel independently, do not include it in the list • Inflexible, but efficient • Use a display list for an atomic object • Matrix operations, lighting models, material properties, textures, patterns, may also be optimized using display list