1 / 23

Computer Graphics: Programming, Problem Solving, and Visual Communication

Computer Graphics: Programming, Problem Solving, and Visual Communication. Steve Cunningham California State University Stanislaus and Grinnell College PowerPoint Instructor’s Resource. Implementing Modeling in OpenGL. Going from concepts to images. Modeling Topics. Specifying geometry

samdavis
Download Presentation

Computer Graphics: Programming, Problem Solving, and Visual Communication

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Graphics:Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College PowerPoint Instructor’s Resource

  2. Implementing Modeling in OpenGL Going from concepts to images

  3. Modeling Topics • Specifying geometry • GLU and GLUT tools • Transformations • Transformation Stack • Drawing text • Inverting the eyepoint transformation • Display lists

  4. Specifying Geometry • General model isglBegin(grouping_mode); vertex listglEnd(); • The grouping mode identifies how the vertices are to be used • The vertices in the vertex list can be done manually or by computation

  5. Specifying Geometry (2) • There are many different grouping modes that OpenGL recognizes • Simple modes: • GL_POINTS • GL_LINES • GL_TRIANGLES • GL_QUADS • GL_POLYGON

  6. Specifying Geometry (3) • Geometry compression modes: • GL_LINE_STRIP • GL_TRIANGLE_STRIP • GL_TRIANGLE_FAN • GL_QUAD_STRIP

  7. Specifying Geometry (4) • Some details of OpenGL geometry: • All OpenGL polygons are assumed to be convex • Polygons use vertices as if they were from a triangle fan • Quad strips use vertices as if they were for triangle strips, so the order is different from GL_QUADS

  8. Specifying Geometry (5) • The vertex list can use vertices of many different types • The vertex data type is specified in the the particular glVertex* function name • glVertex[2|3][i|f|d]{v} • There are additional options, but they are not often used

  9. Specifying Geometry (6) • As you specify the geometry with the vertices, you can specify other data for each vertex (e.g. appearance data) • glColor*(…) • glNormal*(…) • glTexCoord*(…) • Vertices can be given individually or as vertex arrays, reducing function calls

  10. Triangle fan used to create a cone Triangle strips used to create a surface (one strip shown) Some Sample OpenGL Objects

  11. Appearance Information • Simple OpenGL drawing uses edges that are one pixel wide and are not antialiased • You can specify point sizes and line width • You can antialias points, lines, and polygon edges • glEnable(type) as appropriate • glHint(type, value)

  12. Clipping • Besides the automatic clipping on the view volume, you can specify other clipping by defining clip planes • Clip planes are defined by the coordinates in the plane equation glClipPlane(number,plane) • Clip planes may be enabled or disabled as your program runs

  13. GLU Quadric Objects • The GLU utilities include a number of useful objects • gluSphere • gluCylinder • gluDisk • All require that you first create a general GLUquadric pointer: GLUquadric* gluNewQuadric(void)

  14. GLU Quadric Objects (2) • GLU quadric objects are created by invoking a function that uses the GLUquadric* value • The function also defines granularity and size • You can select whether the object is solid or wireframe • You can specify if you want to have normals or texture coordinates generated automatically

  15. Cone Sphere Cube Torus Dodecahedron Icosahedron Octahedron Tetrahedron Teapot GLUT Objects GLUT provides a number of additional graphical objects you can use easily Each of these can be either wireframe or solid

  16. Examples of GLU and GLUT Objects

  17. Transformations in OpenGL • Rotation glRotatef(angle, x, y, z) • Translation glTranslatef(tx, ty, tz) • Scaling glScalef(sx, sy, sz) • Individually these are simple, but they can be composed to create complex transformations

  18. Transformation Stacks • You can create a stack for any of the standard OpenGL transformations • The modelview transformation stack is critically important to manage the scene graph glMatrixMode(GL_MODELVIEW); glPushMatrix(); … glPopMatrix();

  19. Text in OpenGL • Text is handled by a GLUT function that writes a character at a time in the font (usually bitmapped) you choose glutBitmapCharacter(font, char) • Text you create this way is simply placed on the screen and cannot be selected

  20. Inverting the Eyepoints • We saw that it can be useful to move the eyepoint in your model • Of course, you could call glutLookAt(…) with new viewing data each time you redraw the scene • The viewing data uses raw coordinates, though, and this could be difficult to calculate with many eye motions

  21. Inverting the Eyepoint (2) • The eyepoint motion will probably be set by using simple transformations • If these simple transformations areT1*T2*T3* … *TNthen their inverse is TN-1*…*T3-1*T2-1*T1-1 and each of the inverses is simple

  22. Inverting the Eyepoint (3) • In order to make the eyepoint placement easy, you can simply apply the needed inverse transformations at the top of the scene graph (at the beginning of the display function) and then use the default view

  23. Creating Display Lists • Display lists are OpenGL’s way to compile geometry • This lets the system work on geometry that has been optimized, making it faster to draw complex objects glNewList(i); … glEndList(); • You can then use this geometry with glCallList(i);

More Related