1 / 27

Modelling & Representation

Modelling & Representation. Representation of Objects in 3D. Parametric Surface: (R2->R3) Polygon mesh High-order surface patch Implicit: (Solid/Volumetric:R3->0) implicit Volxels CSG. Polygon Mesh. must be convex better be planar or triangulation is required

Download Presentation

Modelling & Representation

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. Modelling & Representation

  2. Representation of Objects in 3D • Parametric Surface: (R2->R3) • Polygon mesh • High-order surface patch • Implicit: (Solid/Volumetric:R3->0) • implicit • Volxels • CSG

  3. Polygon Mesh • must be convex • better be planar or triangulation is required • can be represented either be a loop of vertices or edges • mostly be a loop of vertices • the order can be either clockwise or counter-clockwise • two popular representations • polygon soup • indexed-face mesh

  4. Polygon Soup • face = a list of vertex coordinates • object= a list of faces

  5. Indexed-face Mesh • All vertex coordinates are placed in an array • Faces = a list of indices to the vertex coordinate array • Objects=a list of such indexed faces

  6. Example

  7. Example) in Polygon Soup • Pyramid={{{0,1,0},{0,0,1},{1,0,0}},...,{{0,0,1},{-1,0,0},{0,0,-1},{1,0,0}}}

  8. V1 (0,1,0) V[0] V2 (1,0,0) V[1] V3 (0,0,1) V[2] V4 (-1,0,0) V[3] V5 (0,0,-1) V[4] F1 (v1,v3,v2) (0,2,1) F[0] F2 (v1,v4,v3) (0,3,2) F[1] F3 (v1,v5,v4) (0,4,3) F[2] F4 (v1,v2,v5) (0,1,4) F[3] F5 (v3,v4,v5) (2,3,4) F[4] F6 (v2,v3,v5) (1,2,4) F[5] Example) in Indexed-face Mesh

  9. Draw Methods • Geometric primitives • Begin-end structure • Vertex specifying order • Array • Display List

  10. Geometric primitives • GL_POINTS: Individual points • GL_LINES: Vertices pairs, individual line segments • GL_LINE_STRIP • GL_LINE_LOOP • GL_TRIANGLES: Vertices triplets interpreted as triangles • GL_TRIANGLE_STRIP • GL_TRIANGLE_FAN • GL_QUADS: Vertices quadruples, 4 sided polygons • GL_QUAD_STRIP • GL_POLYGON: Boundary of a simple, convex polygon

  11. Begin-end structure • A Primitive is started by • glBegin(GLenum mode); • And ended using • glEnd(); • Between them you can specify the primitive coordinates, color, normal etc.

  12. Vertex specifying order GL_TRIANGLE_FAN GL_TRIANGLES GL_TRIANGLE_STRIP GL_QUADS GL_QUAD_STRIP

  13. glBegin(GL_QUADS); glNormal3f(-1, 0, 0); glVertex3d(0.0, 1.0, 0.0); glVertex3d(0.0, 0.0, 0.0); glVertex3d(0.0, 0.0, -1.0); glVertex3d(0.0, 1.0, -1.0); glNormal3f(0, 1, 0); glVertex3d(0.0, 0.0, 0.0); glVertex3d(1.0, 0.0, 0.0); glVertex3d(1.0, 0.0, -1.0); glVertex3d(0.0, 0.0, -1.0); glNormal3f(1, 0, 0); glVertex3d(1.0, 0.0, 0.0); glVertex3d(1.0, 1.0, 0.0); glVertex3d(1.0, 1.0, -1.0); glVertex3d(1.0, 0.0, -1.0); glEnd(); Example

  14. Display Lists • Create a display list: • GLuint id; • void init( void ){ • id = glGenLists( 1 ); • glNewList( id, GL_COMPILE ); • … • glEndList(); • } • Call a created list: • void display( void ){ • glCallList( id ); • }

  15. Display Lists • Not all OpenGL routines can be stored in display lists • State changes persist, even after a display list is finished • Display lists can call other display lists • Display lists are not editable, but you can fake it • make a list (A) which calls other lists (B, C, and D) • delete and replace B, C, and D, as needed

  16. Vertex Arrays • Enable the client states: • glEnableClientState( GL_VERTEX_ARRAY) • Setup the pointers: • Vertex array :glVertexPointers() • Color array:glColorPointers() • Normal array:glNormalPointers() • Draw with the arrays: • glDrawArrays( GL_TRIANGLE_STRIP, 0, numVerts ); • void glDrawElements(GLenum mode,GLsizei count,GLenum type,const GLvoid *indices);

  17. glEnableClientState() • void glEnableClientState( GLenum array ); • Parameters • array • A symbolic constant for the array you want to enable or disable. This parameter can assume one of the following values: • GL_COLOR_ARRAY • If enabled, use color arrays with calls to glArrayElement, glDrawElements, or glDrawArrays. See also glColorPointer. • GL_EDGE_FLAG_ARRAY • If enabled, use edge flag arrays with calls to glArrayElement, glDrawElements, or glDrawArrays. See also glEdgeFlagPointer. • GL_INDEX_ARRAY • If enabled, use index arrays with calls to glArrayElement, glDrawElements, or glDrawArrays. See also glIndexPointer. • GL_NORMAL_ARRAY • If enabled, use normal arrays with calls to glArrayElement, glDrawElements, or glDrawArrays. See also glNormalPointer. • GL_TEXTURE_COORD_ARRAY • If enabled, use texture coordinate arrays with calls to glArrayElement, glDrawElements, or glDrawArrays. See also glTexCoordPointer. • GL_VERTEX_ARRAY • If enabled, use vertex arrays with calls to glArrayElement, glDrawElements, or glDrawArrays. See also glVertexPointer.

  18. glVertexPointer() • The glVertexPointer function defines an array of vertex data. • void glVertexPointer( GLint size,GLenum type,GLsizei stride,GLsizei count,const GLvoid *pointer); • Parameters • size • The number of coordinates per vertex. The value of size must be 2, 3, or 4. • type • The data type of each coordinate in the array using the following symbolic constants: GL_SHORT, GL_INT, GL_FLOAT, and GL_DOUBLE. • stride • The byte offset between consecutive vertices. When stride is zero, the vertices are tightly packed in the array. • count • The number of vertices, counting from the first, that are static. • pointer • A pointer to the first coordinate of the first vertex in the array.

  19. glColorPointer() • The glColorPointer function defines an array of colors. • void glColorPointer( GLint size,GLenum type,GLsizei stride,GLsizei count,const GLvoid * pointer); • Parameters • size • The number of components per color. The value must be either 3 or 4. • type • The data type of each color component in a color array. Acceptable data types are specified with the following constants: GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, GL_INT, GL_UNSIGNED_INT, GL_FLOAT, or GL_DOUBLE. • stride • The byte offset between consecutive colors. When stride is zero, the colors are tightly packed in the array. • count • The number of static colors, counting from the first color. • pointer • A pointer to the first component of the first color element in a color array.

  20. glNormalPointer() • The glNormalPointer function defines an array of normals. • void glNormalPointer( GLenum type,GLsizei stride,GLsizei count,const GLvoid *pointer); • Parameters • type • The data type of each coordinate in the array using the following symbolic constants: GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT, and GL_DOUBLE. • stride • The byte offset between consecutive normals. When stride is zero, the normals are tightly packed in the array. • count • The number of normals, counting from the first, that are static. • pointer • A pointer to the first normal in the array.

  21. glDrawArrays() • The glDrawArrays function specifies multiple primitives to render. • void glDrawArrays( GLenum mode,GLint first,GLsizei count); • Parameters • mode • The kind of primitives to render. The following constants specify acceptable types of primitives: GL_POINTS, GL_LINE_STRIP, GL_LINE_LOOP, GL_LINES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_TRIANGLES, GL_QUAD_STRIP, GL_QUADS, and GL_POLYGON. • first • The starting index in the enabled arrays. • count • The number of indexes to render.

  22. glDrawElements • void glDrawElements( GLenum mode,GLsizei count, GLenum type, const GLvoid *indices ); • Parameters • mode • The kind of primitives to render. It can assume one of the following symbolic values: GL_POINTS, GL_LINE_STRIP, GL_LINE_LOOP, GL_LINES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_TRIANGLES, GL_QUAD_STRIP, GL_QUADS, and GL_POLYGON. • count • The number of elements to be rendered. • type • The type of the values in indices. Must be one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_UNSIGNED_INT. • indices • A pointer to the location where the indices are stored.

  23. Display Lists & Vertex Arrays • Better performance than immediate mode rendering • Display lists can be shared between multiple OpenGL context • reduce memory usage for multi-context applications • Vertex arrays may format data for better memory access

  24. Appearance • Color • Vertex color: Specified on a per-vertex basis • Face color: Specified on a per-primitive basis using glColor3f(). • Must enable color material for color tracking: • glEnable(GL_COLOR_MATERIAL); • Material: • AMBIENT • DIFFUSE • SPECULAR • SHININESS

  25. Color format – RGBA

  26. Color format – color index

  27. Material Properties • Define the surface properties of a primitive glMaterialfv(face, property, value ); • separate materials for front and back

More Related