Changeset 6259 in orxonox.OLD for branches/height_map
- Timestamp:
- Dec 22, 2005, 2:36:03 PM (19 years ago)
- Location:
- branches/height_map/src/lib/graphics/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/height_map/src/lib/graphics/importer/vertex_array_model.cc
r6249 r6259 68 68 PRINTF(4)("drawing the 3D-VertexArrayModels\n"); 69 69 70 glEnableClientState(GL_VERTEX_ARRAY | 71 GL_TEXTURE_COORD_ARRAY | 72 GL_NORMAL_ARRAY); 73 glEnableClientState(GL_INDEX_ARRAY); 70 glEnableClientState(GL_VERTEX_ARRAY ); 71 glEnableClientState(GL_TEXTURE_COORD_ARRAY ); 72 glEnableClientState(GL_NORMAL_ARRAY ); 73 glEnableClientState(GL_COLOR_ARRAY ); 74 74 75 75 76 glVertexPointer(3, GL_FLOAT, 0, this->vertices.getArray()); 76 77 glNormalPointer(GL_FLOAT, 0, this->normals.getArray()); 77 glTexCoordPointer(2, GL_FLOAT, 0, this->texCoords.getArray()); 78 79 glDrawElements(GL_TRIANGLE_STRIP, this->indices.getCount(), GL_UNSIGNED_BYTE, this->indices.getArray()); 80 /* for (GLuint i = 1; i < this->stripes.size(); ++i) 78 glTexCoordPointer(2, GL_FLOAT, 0, this->texCoords.getArray()); 79 glColorPointer(3, GL_FLOAT, 0, this->colors.getArray()); 80 81 // glDrawElements(GL_TRIANGLE_STRIP, this->indices.getCount(), GL_UNSIGNED_BYTE, this->indices.getArray()); 82 for (GLuint i = 1; i < this->stripes.size(); ++i) 81 83 { 82 84 glDrawRangeElements(GL_TRIANGLE_STRIP, … … 86 88 GL_UNSIGNED_BYTE, 87 89 this->indices.getArray()); 88 } */90 } 89 91 } 90 92 … … 131 133 132 134 /** 133 * adds a Texture Coordinate135 * @brief adds a Texture Coordinate 134 136 * @param u The u coordinate of the TextureCoordinate. 135 137 * @param v The y coordinate of the TextureCoordinate. … … 142 144 this->texCoords.addEntry(v); 143 145 this->pModelInfo.numTexCoor++; 146 } 147 148 /** 149 * @brief adds a new Color 150 * @param r the Red Component of the VertexColor to add. 151 * @param g the Green Component of the VertexColor to add. 152 * @param b the Blue of the VertexColor to add. 153 */ 154 void VertexArrayModel::addColor(float r, float g, float b) 155 { 156 this->colors.addEntry(r, g, b); 157 // FIXME 144 158 } 145 159 … … 165 179 this->texCoords.finalizeArray(); 166 180 this->normals.finalizeArray(); 181 this->colors.finalizeArray(); 167 182 this->indices.finalizeArray(); 168 183 … … 184 199 ///////////// 185 200 /** 186 187 188 189 201 * @brief Includes a default model 202 * 203 * This will inject a Cube, because this is the most basic model. 204 */ 190 205 void VertexArrayModel::planeModel() 191 206 { 207 unsigned int sizeX = 20, sizeY = 10; 208 192 209 unsigned int i, j; 193 for (i = 0; i < 20; i++)210 for (i = 0; i < sizeY; i++) 194 211 { 195 for (j = 0; j < 20; j++)196 197 this->addVertex((float)i, .5, (float)(j));198 this->addNormal(0, 1, 0);199 this->addTexCoor((float)i/20.0, (float)j/20.0);200 201 212 for (j = 0; j < sizeX; j++) 213 { 214 this->addVertex((float)i - sizeY/2.0, -(float)i * (float)j/(float)sizeY/(float)sizeX * 10.0 , (float)(j) - sizeX/2.0); 215 this->addNormal((float)i/(float)sizeY, 1, (float)j/(float)sizeX); 216 this->addTexCoor((float)i/(float)sizeY, (float)j/(float)sizeY); 217 this->addColor((float)i/20.0, 0.0, (float)j/20.0); 218 } 202 219 } 203 for (i = 0; i < 20; i++) 220 221 for (i = 0; i < sizeY-1; i++) 222 { 223 for (j = 0; j < sizeX; j++) 204 224 { 205 this->addIndice( i);206 this->addIndice( i+20);225 this->addIndice(sizeX*i + j); 226 this->addIndice(sizeX*(i+1) + j); 207 227 } 208 } 228 if (i < sizeY -1 ) 229 this->newStripe(); 230 } 231 } -
branches/height_map/src/lib/graphics/importer/vertex_array_model.h
r6037 r6259 39 39 void addNormal(float x, float y, float z); 40 40 void addTexCoor(float u, float v); 41 void addColor(float r, float g, float b); 42 41 43 void addIndice(GLubyte indice); 42 44 43 45 void finalize(); 44 46 45 // 47 // 46 48 void planeModel(); 47 49 … … 55 57 tArray<GLfloat> normals; //!< The Array that handles the Normals. 56 58 tArray<GLfloat> texCoords; //!< The Array that handles the VertexTextureCoordinates. 59 tArray<GLfloat> colors; //!< The Array that handles Colors. 57 60 58 61 tArray<GLubyte> indices; //!< The Array that tells us what Vertex is connected to which other one.
Note: See TracChangeset
for help on using the changeset viewer.