Changeset 5304 in orxonox.OLD for trunk/src/lib/graphics
- Timestamp:
- Oct 7, 2005, 3:28:25 PM (19 years ago)
- Location:
- trunk/src/lib/graphics/importer
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/importer/md2Model.h
r5087 r5304 103 103 104 104 //! class to store the md2 data in 105 class MD2Data 105 class MD2Data : public BaseObject 106 106 { 107 107 public: -
trunk/src/lib/graphics/importer/model.cc
r5218 r5304 167 167 this->normals = new Array<GLfloat>(); 168 168 169 this->materialList = new tList<Material>; 170 this->materialsExtern = false; 169 this->materialList = new tList<ModelMaterial>; 171 170 172 171 if (this->type == MODEL_VERTEX_ARRAY) … … 196 195 197 196 // deleting the MaterialList 198 if (!this->materialsExtern) 197 PRINTF(5)("Deleting Materials.\n"); 198 199 tIterator<ModelMaterial>* tmpIt = this->materialList->getIterator(); 200 ModelMaterial* modMat = tmpIt->firstElement(); 201 //! @todo do we really have to delete this material?? 202 while(modMat != NULL) 199 203 { 200 PRINTF(5)("Deleting Materials.\n"); 201 202 tIterator<Material>* tmpIt = this->materialList->getIterator(); 203 Material* material = tmpIt->firstElement(); 204 //! @todo do we really have to delete this material?? 205 while(material) 206 { 207 delete material; 208 material = tmpIt->nextElement(); 209 } 210 delete tmpIt; 204 if (!modMat->external) 205 delete modMat->material; 206 delete modMat; 207 modMat = tmpIt->nextElement(); 211 208 } 209 delete tmpIt; 212 210 delete materialList; 213 211 delete this->pModelInfo; … … 391 389 * this also tells this Model, that all the Materials are handled externally 392 390 * with this option set the Materials will not be deleted with the Model. 393 * !! -> NO MATERIALS GET DELETED WITH ONE CALL TO THIS FUNCTION !! 394 */ 391 */ 395 392 Material* Model::addMaterial(Material* material) 396 393 { 397 this->materialList->add(material); 398 this->materialsExtern = true; 399 return material; 394 ModelMaterial* modMat = new ModelMaterial; 395 modMat->external = true; 396 modMat->material = material; 397 this->materialList->add(modMat); 398 return modMat->material; 400 399 } 401 400 … … 407 406 Material* Model::addMaterial(const char* materialName) 408 407 { 409 Material* newMat = new Material(); 410 newMat->setName(materialName); 408 ModelMaterial* modMat = new ModelMaterial; 409 modMat->external = false; 410 modMat->material = new Material(); 411 modMat->material->setName(materialName); 411 412 412 413 // adding material to the List of materials 413 this->materialList->add( newMat);414 return newMat;414 this->materialList->add(modMat); 415 return modMat->material; 415 416 } 416 417 … … 422 423 Material* Model::findMaterialByName(const char* materialName) 423 424 { 424 tIterator<M aterial>* tmpIt = this->materialList->getIterator();425 M aterial* material= tmpIt->firstElement();426 while(m aterial)427 { 428 if (!strcmp(m aterial->getName(), materialName))425 tIterator<ModelMaterial>* tmpIt = this->materialList->getIterator(); 426 ModelMaterial* modMat = tmpIt->firstElement(); 427 while(modMat != NULL) 428 { 429 if (!strcmp(modMat->material->getName(), materialName)) 429 430 { 430 431 delete tmpIt; 431 return m aterial;432 return modMat->material; 432 433 } 433 m aterial= tmpIt->nextElement();434 modMat = tmpIt->nextElement(); 434 435 } 435 436 delete tmpIt; -
trunk/src/lib/graphics/importer/model.h
r4836 r5304 96 96 }; 97 97 98 struct ModelMaterial 99 { 100 Material* material; 101 bool external; 102 }; 103 98 104 ///////////// 99 105 /// MODEL /// 100 106 ///////////// 101 102 107 //! Class that handles 3D-Models. it can also read them in and display them. 103 108 class Model : public AbstractModel … … 172 177 173 178 private: 174 MODEL_TYPE type; //!< A type for the Model175 bool finalized; //!< Sets the Object to be finalized.179 MODEL_TYPE type; //!< A type for the Model 180 bool finalized; //!< Sets the Object to be finalized. 176 181 177 unsigned int vertexCount; //!< A modelwide Counter for vertices.178 unsigned int normalCount; //!< A modelwide Counter for the normals.179 unsigned int texCoordCount; //!< A modelwide Counter for the texCoord.180 unsigned int faceCount; //!< A modelwide Counter for the faces181 unsigned int triangleCount; //!< Number of triangles >= faceCount182 Array<GLfloat>* vertices; //!< The Array that handles the Vertices.183 Array<GLfloat>* normals; //!< The Array that handles the Normals.184 Array<GLfloat>* vTexture; //!< The Array that handles the VertexTextureCoordinates.185 sTriangleExt* triangles; //!< The Array of triangles in the abstract_model.h style182 unsigned int vertexCount; //!< A modelwide Counter for vertices. 183 unsigned int normalCount; //!< A modelwide Counter for the normals. 184 unsigned int texCoordCount; //!< A modelwide Counter for the texCoord. 185 unsigned int faceCount; //!< A modelwide Counter for the faces 186 unsigned int triangleCount; //!< Number of triangles >= faceCount 187 Array<GLfloat>* vertices; //!< The Array that handles the Vertices. 188 Array<GLfloat>* normals; //!< The Array that handles the Normals. 189 Array<GLfloat>* vTexture; //!< The Array that handles the VertexTextureCoordinates. 190 sTriangleExt* triangles; //!< The Array of triangles in the abstract_model.h style 186 191 187 ModelGroup* firstGroup; //!< The first of all groups.188 ModelGroup* currentGroup; //!< The currentGroup. this is the one we will work with.189 int groupCount; //!< The Count of Groups.192 ModelGroup* firstGroup; //!< The first of all groups. 193 ModelGroup* currentGroup; //!< The currentGroup. this is the one we will work with. 194 int groupCount; //!< The Count of Groups. 190 195 191 tList<Material>* materialList; //!< A list for all the Materials in this Model 192 bool materialsExtern; //!< If the materials given to this Object are extern. 196 tList<ModelMaterial>* materialList; //!< A list for all the Materials in this Model 193 197 }; 194 198 -
trunk/src/lib/graphics/importer/texture.cc
r5293 r5304 32 32 Texture::Texture(const char* imageName) 33 33 { 34 this->setClassID(CL_TEXTURE, "Texture"); 35 34 36 this->bAlpha = false; 35 37 this->texture = 0; -
trunk/src/lib/graphics/importer/texture.h
r5239 r5304 10 10 11 11 #include "glincl.h" 12 #include "base_object.h" 12 13 13 14 #include "debug.h" … … 20 21 21 22 //! A Class, that reads in Textures from different fileformats. 22 class Texture 23 class Texture : public BaseObject 23 24 { 24 25 public:
Note: See TracChangeset
for help on using the changeset viewer.