Changeset 6037 in orxonox.OLD for trunk/src/lib/graphics
- Timestamp:
- Dec 11, 2005, 12:23:25 AM (19 years ago)
- Location:
- trunk/src/lib/graphics/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/importer/vertex_array_model.cc
r6012 r6037 35 35 this->setClassID(CL_MODEL, "VertexArrayModel"); 36 36 37 this->finalized = false; 37 this->bFinalized = false; 38 this->newStripe(); 38 39 } 39 40 … … 59 60 60 61 /** 61 * @brief Finalizes an Object. This can be done outside of the Class. 62 */ 63 void VertexArrayModel::finalize() 64 { 65 // this creates the display List. 66 this->importToVertexArray(); 67 68 this->finalized = true; 69 } 70 71 72 ////////// 73 // DRAW // 74 ////////// 75 /** 76 * Draws the VertexArrayModels of all Groups. 77 It does this by just calling the Lists that must have been created earlier. 78 */ 79 void VertexArrayModel::draw () const 62 * @brief Draws the VertexArrayModels of all Groups. 63 * 64 * It does this by just calling the Lists that must have been created earlier. 65 */ 66 void VertexArrayModel::draw() const 80 67 { 81 68 PRINTF(4)("drawing the 3D-VertexArrayModels\n"); 82 69 83 glEnableClientState(GL_VERTEX_ARRAY );84 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 85 glEnableClientState(GL_NORMAL_ARRAY);70 glEnableClientState(GL_VERTEX_ARRAY | 71 GL_TEXTURE_COORD_ARRAY | 72 GL_NORMAL_ARRAY); 86 73 // glEnableClientState(GL_INDEX_ARRAY); 87 74 … … 90 77 glTexCoordPointer(2, GL_FLOAT, 0, this->texCoords.getArray()); 91 78 92 printf("%d\n", this->indices.getCount()); 93 glDrawElements(GL_TRIANGLE_STRIP, 94 this->indices.getCount(), 95 GL_UNSIGNED_BYTE, 96 this->indices.getArray()); 97 98 99 100 /* const GLfloat* pVertices = NULL; 101 const GLfloat* pNorm = NULL; 102 103 glBegin(GL_TRIANGLES); 104 for( int i = 0; i < this->triangleCount; ++i) 105 { 106 //printf("int i = %i\n", i); 107 pNorm = &this->normals->getArray()[this->triangles[i].indexToNormals[0]]; 108 pVertices = &this->vertices->getArray()[this->triangles[i].indexToVertices[0]]; 109 glNormal3f(pNorm[0], pNorm[1], pNorm[2]); 110 glVertex3f(pVertices[0], pVertices[1], pVertices[2]); 111 112 pNorm = &this->normals->getArray()[this->triangles[i].indexToNormals[1]]; 113 pVertices = &this->vertices->getArray()[this->triangles[i].indexToVertices[1]]; 114 glNormal3f(pNorm[0], pNorm[1], pNorm[2]); 115 glVertex3f(pVertices[0], pVertices[1], pVertices[2]); 116 117 pNorm = &this->normals->getArray()[this->triangles[i].indexToNormals[2]]; 118 pVertices = &this->vertices->getArray()[this->triangles[i].indexToVertices[2]]; 119 glNormal3f(pNorm[0], pNorm[1], pNorm[2]); 120 glVertex3f(pVertices[0], pVertices[1], pVertices[2]); 121 122 } 123 glEnd(); 124 */ 79 for (GLuint i = 0; i+1 < this->stripes.size(); i++) 80 { 81 glDrawRangeElements(GL_TRIANGLE_STRIP, 82 stripes[i], 83 stripes[i+1], 84 this->indices.getCount(), 85 GL_UNSIGNED_BYTE, 86 this->indices.getArray()); 87 } 125 88 } 126 89 … … 129 92 // MESH // 130 93 ////////// 94 /** 95 * @brief generates a new Stripe in this Model 96 */ 97 void VertexArrayModel::newStripe() 98 { 99 this->stripes.push_back(this->vertices.getCount()-1); 100 } 101 102 131 103 /** 132 104 * @brief parses a vertex-String … … 180 152 { 181 153 this->indices.addEntry(indice); 182 183 } 184 185 186 //////////// 187 // openGL // 188 //////////// 189 /** 190 * reads and includes the Faces/Materials into the openGL state Machine 191 */ 192 void VertexArrayModel::importToVertexArray() 154 } 155 156 157 /** 158 * @brief Finalizes an Object. This can be done outside of the Class. 159 */ 160 void VertexArrayModel::finalize() 193 161 { 194 162 // finalize the Arrays … … 198 166 this->indices.finalizeArray(); 199 167 200 // glEnableClientState(GL_VERTEX_ARRAY); 201 // glEnableClientState(GL_TEXTURE_COORD_ARRAY); 202 // glEnableClientState(GL_NORMAL_ARRAY); 203 // glEnableClientState(GL_INDEX_ARRAY); 168 this->newStripe(); 169 170 /* 171 glEnableClientState(GL_VERTEX_ARRAY | 172 GL_TEXTURE_COORD_ARRAY | 173 GL_NORMAL_ARRAY); 174 */ 175 176 this->bFinalized = true; 204 177 } 205 178 … … 210 183 ///////////// 211 184 /** 212 * Includes a default model185 * @brief Includes a default model 213 186 * 214 187 * This will inject a Cube, because this is the most basic model. 215 188 */ 216 void VertexArrayModel:: cubeModel()189 void VertexArrayModel::planeModel() 217 190 { 218 191 unsigned int i, j; … … 232 205 this->addIndice(i+20); 233 206 } 234 235 /* 236 this->addVertex (-0.5, -0.5, 0.5); 237 this->addVertex (0.5, -0.5, 0.5); 238 this->addVertex (-0.5, 0.5, 0.5); 239 this->addVertex (0.5, 0.5, 0.5); 240 this->addVertex (-0.5, 0.5, -0.5); 241 this->addVertex (0.5, 0.5, -0.5); 242 this->addVertex (-0.5, -0.5, -0.5); 243 this->addVertex (0.5, -0.5, -0.5); 244 245 this->addTexCoor (0.0, 0.0); 246 this->addTexCoor (1.0, 0.0); 247 this->addTexCoor (0.0, 1.0); 248 this->addTexCoor (1.0, 1.0); 249 this->addTexCoor (0.0, 2.0); 250 this->addTexCoor (1.0, 2.0); 251 this->addTexCoor (0.0, 3.0); 252 this->addTexCoor (1.0, 3.0); 253 this->addTexCoor (0.0, 4.0); 254 this->addTexCoor (1.0, 4.0); 255 this->addTexCoor (2.0, 0.0); 256 this->addTexCoor (2.0, 1.0); 257 this->addTexCoor (-1.0, 0.0); 258 this->addTexCoor (-1.0, 1.0); 259 260 this->addNormal (0.0, 0.0, 1.0); 261 this->addNormal (0.0, 0.0, 1.0); 262 this->addNormal (0.0, 0.0, 1.0); 263 this->addNormal (0.0, 0.0, 1.0); 264 this->addNormal (0.0, 1.0, 0.0); 265 this->addNormal (0.0, 1.0, 0.0); 266 this->addNormal (0.0, 1.0, 0.0); 267 this->addNormal (0.0, 1.0, 0.0); 268 this->addNormal (0.0, 0.0, -1.0); 269 this->addNormal (0.0, 0.0, -1.0); 270 this->addNormal (0.0, 0.0, -1.0); 271 this->addNormal (0.0, 0.0, -1.0); 272 this->addNormal (0.0, -1.0, 0.0); 273 this->addNormal (0.0, -1.0, 0.0); 274 this->addNormal (0.0, -1.0, 0.0); 275 this->addNormal (0.0, -1.0, 0.0); 276 this->addNormal (1.0, 0.0, 0.0); 277 this->addNormal (1.0, 0.0, 0.0); 278 this->addNormal (1.0, 0.0, 0.0); 279 this->addNormal (1.0, 0.0, 0.0); 280 this->addNormal (-1.0, 0.0, 0.0); 281 this->addNormal (-1.0, 0.0, 0.0); 282 this->addNormal (-1.0, 0.0, 0.0); 283 this->addNormal (-1.0, 0.0, 0.0); 284 */ 285 } 207 } -
trunk/src/lib/graphics/importer/vertex_array_model.h
r6022 r6037 12 12 13 13 #include "array.h" 14 #include < list>14 #include <vector> 15 15 16 16 /* Forward Declaration */ … … 22 22 ///////////// 23 23 //! Class that handles 3D-Models. it can also read them in and display them. 24 /** 25 * this renders models with help of the OpenGL glVertexArray 26 */ 24 27 class VertexArrayModel : public Model 25 28 { … … 30 33 void draw() const; 31 34 35 36 void newStripe(); 37 32 38 void addVertex(float x, float y, float z); 33 34 39 void addNormal(float x, float y, float z); 35 36 40 void addTexCoor(float u, float v); 37 38 41 void addIndice(GLubyte indice); 39 42 40 43 void finalize(); 41 44 42 43 void cubeModel();45 // 46 void planeModel(); 44 47 45 48 private: … … 47 50 48 51 private: 49 bool finalized; //!< Sets the Object to be finalized.52 bool bFinalized; //!< Sets the Object to be finalized. 50 53 51 54 tArray<GLfloat> vertices; //!< The Array that handles the Vertices. … … 54 57 55 58 tArray<GLubyte> indices; //!< The Array that tells us what Vertex is connected to which other one. 59 60 std::vector<GLuint> stripes; //!< A lsit of Stripes of this Model. 61 56 62 }; 57 63
Note: See TracChangeset
for help on using the changeset viewer.