Meshes - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

Meshes

Description:

Title: PowerPoint Presentation Author: Scott Schaefer Last modified by: schaefer Created Date: 1/1/1601 12:00:00 AM Document presentation format: On-screen Show (4:3) – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 27
Provided by: ScottS230
Category:
Tags: indexing | meshes

less

Transcript and Presenter's Notes

Title: Meshes


1
Meshes
  • Dr. Scott Schaefer

2
3D Surfaces
3
3D Surfaces
4
3D Surfaces
5
3D Surfaces
6
3D Surfaces
7
3D Surfaces
Vertex Table
8
3D Surfaces
Polygon Table
Vertex Table
9
3D Surfaces
Polygon Table
Vertex Table
10
3D File Formats
  • Way too many!
  • OBJ
  • STL
  • MA
  • PLY
  • MAX, 3DS
  • BLEND
  • DAW
  • LWO
  • X
  • .

11
OBJ File Format (Simplified)
  • Text Format Easy to read!
  • Line based file consisting of
  • Vertices (starts with v)
  • Faces (starts with f)
  • Comments (starts with )

12
OBJ File Format (Simplified)
  • Vertex Definition
  • v x y z vertex with coordinates (x,y,z)
  • vt u v texture coordinates (u,v)
  • vn nx ny nz normal (nx,ny,nz)

13
OBJ File Format (Simplified)
  • Face Definition
  • f g1/t1/n1 g2/t2/n2
  • Faces may be variable length!
  • Indexing starts at 1 not 0!
  • First index is guaranteed to be geometry index
  • ti, ni are optional

14
OBJ File Format Example
  • This is a comment
  • v 0 0 0
  • v 0 1 0
  • v 1 0 0
  • v 0 0 1
  • f 1 2 3
  • f 1 3 4
  • f 1 4 2
  • f 2 3 4

15
OBJ File Format Example
  • This is a comment
  • v 0 0 0
  • v 0 1 0
  • v 1 0 0
  • v 0 0 1
  • vn -1 -1 -1
  • vn 1 1 1
  • vn -1 1 1
  • vn 1 -1 1
  • f 1//2 2//1 3//3
  • f 1//2 3//3 4//4
  • f 1//2 4//4 2//1
  • f 2//1 3//3 4//4

16
OBJ File Format Complications
  • Vertices may appear after faces
  • Faces may not be triangles (must triangulate)
  • Faces may use negative indexing
  • Not all OBJ files conform to the OBJ standard

17
Drawing 3D Objects with OpenGL
  • Immediate Mode
  • Display Lists
  • Vertex Arrays
  • Vertex Buffer Objects

18
Immediate Mode
  • glBegin ( GL_TRIANGLES )
  • glNormal3f ( nx1, ny1, nz1 )
  • glVertex3f ( x1, y1, z1 )
  • glNormal3f ( nx2, ny2, nz2 )
  • glVertex3f ( x2, y2, z2 )
  • glEnd ( )

19
Immediate Mode
  • Advantages
  • Easy to send a few polygons to OpenGL
  • Disadvantages
  • Lots of data transferred on the stack
  • Lots of function calls
  • Vertices duplicated many times
  • Really, really slow

20
Display Lists
  • Initialize display list
  • firstList glGenLists ( numLists )
  • glNewList ( firstList, GL_COMPILE_AND_EXECUTE )
  • // draw model in immediate mode
  • glEndList ( )
  • Draw the display list
  • glCallList ( firstList )

21
Display Lists
  • Relies on graphics driver for optimization
  • Advantages
  • Faster than immediate mode
  • Disadvantages
  • Still not great performance

22
Vertex Arrays
  • glEnableClientState ( GL_(VERTEX/TEXTURE_COORD/NOR
    MAL)_ARRAY )
  • glVertexPointer ( numComp, GL_FLOAT, bytes to
    next vertex, pointer to geometry)
  • glTexCoordPointer ( numComp, GL_FLOAT, bytes to
    next texture coord, pointer to texture coords)
  • glNormalPointer ( GL_FLOAT, bytes to next normal,
    pointer to normals )
  • glDrawElements ( GL_TRIANGLES, number of indices
    in array, GL_UNSIGNED_INT, pointer to index
    array)
  • glDisableClientState ( GL_(VERTEX/TEXTURE_COORD/NO
    RMAL)_ARRAY )

23
Vertex Arrays
  • Advantages
  • Only transfers vertices once and not an expected
    value of 6 times
  • Much faster than even display lists (usually)
  • Format similar to most mesh formats
  • Disadvantages
  • Still transfers vertices to GPU every frame
  • Bandwidth to GPU very problematic

24
Vertex Buffer Objects
  • New Functions
  • glGenBuffersARB
  • glBindBufferARB
  • glBufferDataARB
  • Use glVertexPointer with NULL pointer as
    argument
  • Use glDrawElements with NULL pointer as argument

25
Vertex Buffer Objects
  • Advantages
  • Can store data directly in video memory or AGP
  • Greatly reduces bandwidth problem to GPU
  • Disadvantages
  • Not supported by MS OpenGL headers
  • Must load function pointers out of DLL using
    WGLGetProcAddress
  • Dynamic geometry doesnt get as much benefit

26
Performance
Nvidia 7300 GT1 Nvidia 8800 GTX1 AMD Radeon HD 48502 AMD Radeon HD 48503
Immediate Mode 15.5 15.5 21.0 35.0
Display Lists 28.3 22.0 463.5 497.0
Vertex Arrays 33.5 35.5 75.0 280.0
Vertex Buffer Objects 50.0 200.0 476.3 504.0
Frames per second displaying a 413,236 triangle
model. CPU was an Intel Core 2 67001 or Core i7
9402. 3Same as 2 but new drivers.
Write a Comment
User Comments (0)
About PowerShow.com