3D Object Representation

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

'

3D Object Representations
Chapter 8 Sections 1 6 Polygon surface representation Quadrics OpenGL objects

&
1

'

3D Object representations

No single method is suitable for all objects. * Euclidean objects best represented by polygons and quadric surfaces. Procedural methods (fractals, particle systems) are used for terrain, clouds, etc. Physical modeling used for non-rigid objects like cloth. Octree encodings are used for objects that need volume rendering.

&
2

'

Representations

Boundary representations dene objects as a set of surfaces * Polygon facets Spline patches Space partitioning is used to describe interior properties Used for CAT scans

&
3

'

Polyhedrons
The most common boundary representation for 3D objects is the set of surface polygons that enclose the object. In this representation, objects are specied with a set of vertices and the edges that connect them. Often use tables like those we discussed in Chapter 3. Other information like surface normals, colors may also be stored in the tables.

&
4

'

OpenGL Fill Area Functions

Polygon meshes can be constructed out of polygons, triangles or quadrilaterals. GL_POLYGON GL_TRIANGLES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_QUADS GL_QUAD_STRIP Use the function glPolygonMode to control how your polygons look. glPolygonMode( side, fillMode); Filling is turned on and o using GL_FILL, GL_LINES and GL_POINTS. Each polygon has a front face and a back face. You can specify which you want to ll using the constants GL_FRONT_AND_BACK, GL_FRONT and GL_BACK &
5

'

Vertex Arrays

Typically, vertices in a solid object are shared between several edges and faces. For example, a cube has 8 vertices, each of which is used in 3 of the 6 faces. The way we have specied faces up to now requires repeating the same glVertex* call several times.
4 5 7 0 1 2 3 6

Vertex arrays provide a more compact way of specifying the faces of a solid. (Analogous to geometric tables vertex and facets First, list all the vertices in a single array. could use a 2D array with 3 (or 2) position values for each point. or use an array of point objects Then use another array to specify the vertex numbers for each face. &
6

'

OpenGL Vertex Arrays

glEnableClientState( GL_VERTEX_ARRAY); glVertexPointer( 3, GL_INT, 0, vertexArray); glDrawElements( GL_QUADS, 24, GL_UNSIGNED_BYTE, indexArray); glDisableClientState( GL_VERTEX_ARRAY); vertexArray contains the list of vertices and indexArray contains a list of indices into the vertexArray glVertexPointer needs to know how many values per point and what type the values have glDrawElements needs to know the size of indexArray and the type of its elements &
7

'

Platonic Solids

Solids whose faces are identical, regular polygons There are only 5. Tetrahedron 4 equilateral triangles Cube 6 squares Octahedron 8 equilateral triangles Dodecahedron 12 regular pentagons Icosahedron 20 equilateral triangles

&
8

'

Polyhedrons in OpenGL

Polygon ll areas are used to bound 3D objects. GLUT has functions to create wire frame and solid versions of the Platonic solids. Wire Frame glutWireTertrahedron() glutWireCube( Ledge) glutWireOctahedron() glutWireDodecahedron() glutWireIcosahedron() Solid glutSolidTetrahedron() glutSolidCube( Ledge) glutSolidOctahedron() glutSolidDodecahedron() glutSolidIcosahedron() Centervertex distance 3
ledge 2

1.0 1.0 1.0

&
9

'

Curved Surfaces

&
10

'

Quadric Surfaces
Quadric surfaces are dened by quadratic equations. sphere x2 + y 2 + z 2 = r2 ellipsoid ( torus ( x2 + y 2 raxial )2 + z 2 = r2 x 2 y z ) + ( )2 + ( )2 = 1 rx ry rz

&
11

'

Superquadric Surfaces
Superquadrics have the same basic form as quadrics except that the exponent is dierent from 2. Superellipse x rx Superellipsoid x rx
2 s2 2 s 2 s

y ry
s2 s1

= 1

y ry

2 s2

z rz

2 s1

= 1

&
12

'

GLUT Quadric Surfaces


There are both solid and wire frame versions for the functions. Sphere glutWireSphere( r, nLongitudes, nLatitudes) Cone glutWireCone( rBase, height, nLongitudes, nLatitudes) Torus glutWireTorus( rCross, rAxial, nConcentric, nRadial) Utah teapot glutWireTeapot( size)

&
13

'

GLU Quadric Surfaces


To use these, you need to create a GLUquadricObj. GLUquadricObj * obj; obj = gluNewQuadricObj(); gluQuadricDrawStyle( obj, style); where style can be GLU_LINE, GLU_POINT, GLU_SILHOUETTE or GLU_FILL. Then call the appropriate function for the object you are creating see next slide To get rid of the object, use gluDeleteQuadric( obj);

&
14

'

GLU Quadrics
Sphere gluSphere( obj, r, nLongitudes, nLatitudes); Cylinder gluCylinder( obj, rBase, rTop, height, nLongitudes, nLatitudes); Disk gluDisk( obj, rInner, rOuter, nRadii, nRings); PartialDisk gluDisk( obj, rInner, rOuter, nRadii, nRings, startAngle, sweepAngle);

&
15

'

OpenGL Quadrics

&
16

You might also like