Computer Graphics: Programming, Problem Solving, and Visual ...

Computer Graphics: Programming, Problem Solving, and Visual ...

Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College PowerPoint Instructors Resource Implementing Modeling in OpenGL Going from concepts to images

Modeling Topics Specifying geometry

GLU and GLUT tools Transformations Transformation Stack Drawing text Inverting the eyepoint transformation Display lists Specifying Geometry General model is glBegin(grouping_mode); vertex list

glEnd(); The grouping mode identifies how the vertices are to be used The vertices in the vertex list can be done manually or by computation Specifying Geometry (2) There are many different grouping modes that OpenGL recognizes Simple modes:


GL_QUAD_STRIP 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

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

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

Some Sample OpenGL Objects Triangle fan used to create a cone Triangle strips used to create a surface (one strip shown) 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) 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 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) 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 GLUT Objects GLUT provides a number of additional graphical objects you can use easily

Cone Sphere Cube Torus

Dodecahedron Icosahedron Octahedron Tetrahedron Teapot Each of these can be either wireframe or solid Examples of GLU and GLUT

Objects 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 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(); 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 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 Inverting the Eyepoint (2) The eyepoint motion will probably be set by using simple transformations If these simple transformations are T1*T2*T3* *TN then their inverse is TN-1**T3-1*T2-1*T1-1

and each of the inverses is simple 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 Creating Display Lists

Display lists are OpenGLs 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);

Recently Viewed Presentations

  • HERPES SIMPLEX VIRUS Characteristics of HSV DNA double

    HERPES SIMPLEX VIRUS Characteristics of HSV DNA double

    HERPES SIMPLEX VIRUS Characteristics of HSV DNA double stranded virus, linear 125-250 Kb long, relatively big Enveloped Virion size 200 nm, relatively big 9 HSVs, Ex. Varicella, EBV, CMV Diseases: Chickenbox, Mononucleosis, Hepatitis, Encephalitis Recurrent eye, mouth and genital lesions...
  • Introduction to Developing, Monitoring and Evaluating Projects Noah

    Introduction to Developing, Monitoring and Evaluating Projects Noah

    Project Summary. Indicators. Means of Verification (MoV)Assumptions. Goal. The trans* activist community is well funded. Income of participating organisations rises by 20% by 2016
  • IL-NET Presents an IL Conversation - APRIL

    IL-NET Presents an IL Conversation - APRIL

    IL-NET Presents an IL Conversation. ... In 2016, the other CIL in Denver relinquished it's contract leaving the Atlantis Community as the sole CIL in Denver. The Administration for Community Living had a grant to establish CILs in American Samoa,...
  • Hands on Beaglebone - 國立中興大學

    Hands on Beaglebone - 國立中興大學

    The value written is the GPIO pin number, which you'll recall was specified in the table earlier in index.js. For Port 8 Pin 3, it was defined as gpio1+6, or 38. The export file is a funky weird file: when...
  • Elements and Principles

    Elements and Principles

    Diverse art elements and principles found in a picture (contrast) like light and dark, big and small, smooth and rough . Variety is created with objects or subjects, colors, textures, movement or shapes . Adds interest. Involves senses and creates...
  • OGLA All Coaches Meeting

    OGLA All Coaches Meeting

    OGLA Code of Conduct (this is done through the registration process) Concussion training certification ... USL Level 1 certificate (you do not need to upload it again if you did this last year) Ali. New this Fall: Safe Sport training...
  • Financial Accounting and Accounting Standards

    Financial Accounting and Accounting Standards

    NRV = Estimasi harga jual normal dikurangi estimasi biaya produksi - estimas biaya penjualan. Illustration 9-1 Illustration of LCNRV LO 1 Describe and apply the lower-of-cost-or-net realizable value rule. Illustration 9-3 Illustration 9-4 Methods of Applying LCNRV LO 1 Describe...
  • How did the Monkey Scopes Trial show intolerance in 1920s ...

    How did the Monkey Scopes Trial show intolerance in 1920s ...

    The theory of evolution. The 'Bible Belt'. The Tennessee Anti-Evolution Law. How does the Monkey Trial show America as an intolerant nation? Write a press report for the 'Monkey Trial' which includes a catchy headline, the arguments for and against...