Geometric Objects and Transformations(I)课件.pptVIP

  • 2
  • 0
  • 约2.17千字
  • 约 30页
  • 2017-08-12 发布于河南
  • 举报
Geometric Objects and Transformations(I)课件

Geometric Objects and Transformations (I) ;;Outline;3D Primitives;Complexity and Efficiency;Three Features;Coordinate System;Frames;Changes of Coordinate Systems;Transformation for Vectors;Homogeneous Coordinates;Transformation for Frames;Homogeneous Coordinates;Working with Representations;Find the Transformation Matrix;Hence, we have;Frames in OpenGL;Camera Frame;Example: moving the camera;Example: camera in the world frame;Modeling a Colored Cube;Modeling of a Cube;Inward and Outward Faces;Vertices of the cube in cube.c: GLfloat vertices[][3] Facets of the cube in cube.c: void polygon (int a, int b, int c , int d) The cube in cube.c: void colorcube(void);The Color Cube;Bilinear Interpolation;Vertex Arrays;OpenGL allows 6 different types of arrays Vertex, color, color index, normal, texture coordinate and edge flag. Corresponding to 6 items that can be set between a glBegin and glEnd. For the color cube, we only need colors and vertices. We enable the corresponding arrays by glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); The arrays are the same as before: cubev.c;We tell OpenGL where the arrays is glVertexPointer(3, GL_FLOAT, 0, vertices); glColorPointer(3,GL_FLOAT, 0, colors); The 1st 3 arguments state that the elements are 3D vertices and colors stored as floats and that the elements are contiguous (byte offset = 0). Now we have to provide the information in our data structure about the relationship between the vertices and faces of the cube. This is done by specifying an array that holds the 24 ordered vertex indices for the 6 faces GLubyte cubeIndices[] in cubev.c;We use the following function to render the cube: void glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ) mode: the type of the element, e.g., line or polygon, …. count: the number of elements to draw type : the data type in the index arrays index: the first index to use One way to render the cube is for (i = 0; i 6; i++) glDrawElements

文档评论(0)

1亿VIP精品文档

相关文档