Changeset 3916 in orxonox.OLD for orxonox/trunk/src/lib/graphics
- Timestamp:
- Apr 21, 2005, 3:07:36 AM (20 years ago)
- Location:
- orxonox/trunk/src/lib/graphics/importer
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/importer/model.cc
r3915 r3916 33 33 \brief Creates a 3D-Model. and assigns it a Name. 34 34 */ 35 Model::Model(const char* modelName )35 Model::Model(const char* modelName, MODEL_TYPE type) 36 36 { 37 37 PRINTF(4)("new 3D-Model is being created\n"); 38 38 this->name = NULL; 39 39 this->setName(modelName); 40 40 this->type = type; 41 41 42 42 this->finalized = false; … … 82 82 } 83 83 84 // deleting Arrays 85 this->deleteArrays(); 86 84 87 // deleting the MaterialList 85 88 PRINTF(5)("Deleting Materials.\n"); 86 87 89 tIterator<Material>* tmpIt = this->materialList->getIterator(); 88 90 Material* material = tmpIt->nextElement(); … … 101 103 void Model::finalize(void) 102 104 { 103 this->importToGL (); 105 // this creates the display List. 106 this->importToDisplayList(); 104 107 108 109 // deletes everything we allocated. 110 if (this->type == MODEL_DISPLAY_LIST) 111 this->deleteArrays(); 105 112 this->cleanup(); 106 113 … … 248 255 249 256 /** 250 \brief finalizes an Model. 251 This funcion is needed, to delete all the Lists, and arrays that are no more needed because they are already imported into openGL. This will be applied at the end of the importing Process. 252 */ 253 bool Model::cleanup(void) 254 { 255 PRINTF(4)("cleaning up the 3D-Model to save Memory.\n"); 256 257 \brief deletes all the arrays 258 */ 259 bool Model::deleteArrays(void) 260 { 257 261 if (this->vertices) 258 262 delete this->vertices; … … 261 265 if (this->normals) 262 266 delete this->normals; 263 267 this->vertices = NULL; 268 this->vTexture = NULL; 269 this->normals = NULL; 270 } 271 272 /** 273 \brief finalizes an Model. 274 This funcion is needed, to delete all the Lists, and arrays that are no more needed because they are already imported into openGL. This will be applied at the end of the importing Process. 275 */ 276 bool Model::cleanup(void) 277 { 278 PRINTF(4)("cleaning up the 3D-Model to save Memory.\n"); 264 279 this->cleanupGroup(this->firstGroup); 265 280 return true; … … 703 718 \brief reads and includes the Faces/Materials into the openGL state Machine 704 719 */ 705 bool Model::importToGL (void) 706 { 707 720 bool Model::importToDisplayList(void) 721 { 708 722 // finalize the Arrays 709 723 this->vertices->finalizeArray(); … … 794 808 795 809 /** 810 \brief reads and includes the Faces/Materials into the openGL state Machine 811 */ 812 bool Model::importToVertexArray(void) 813 { 814 // finalize the Arrays 815 this->vertices->finalizeArray(); 816 this->vTexture->finalizeArray(); 817 if (normals->getCount() == 0) // vertices-Array must be built for this 818 this->buildVertexNormals(); 819 this->normals->finalizeArray(); 820 821 this->currentGroup = this->firstGroup; 822 823 824 } 825 826 827 828 /** 796 829 \brief Adds a Face-element (one vertex of a face) with all its information. 797 830 \param elem The FaceElement to add to the OpenGL-environment. -
orxonox/trunk/src/lib/graphics/importer/model.h
r3915 r3916 14 14 template<class T> class tList; 15 15 16 //! an enumerator fot the different Model Types. 17 /** 18 MODEL_DISPLAY_LIST means, that a DisplayList will be built out of the model. This model will be STATIC, meaning it cannot be changed after initialisation. 19 MODEL_VERTEX_ARRAY means, that a VertexArray will be built out of the model. This moel will be DYNAMIX, meaning that one can change the properties from outside of the model. 20 */ 21 typedef enum MODEL_TYPE {MODEL_DISPLAY_LIST, 22 MODEL_VERTEX_ARRAY}; 16 23 17 18 using namespace std;19 24 20 25 // definition of different modes for setting up Faces … … 23 28 #define TEXCOORD 2 //!< If Faces are created WITH TextureCoordinate 24 29 //! an enumerator for VERTEX_FORMAT 25 enum VERTEX_FORMAT {VERTEX_ONLY = VERTEX,30 typedef enum VERTEX_FORMAT {VERTEX_ONLY = VERTEX, 26 31 VERTEX_NORMAL = NORMAL, 27 32 VERTEX_TEXCOORD = TEXCOORD, … … 70 75 71 76 char* name; //!< This is the name of the Model. 77 MODEL_TYPE type; 72 78 bool finalized; //!< Sets the Object to be finalized. 73 79 … … 81 87 int groupCount; //!< The Count of Groups. 82 88 89 tList<Material>* materialList; 90 91 83 92 bool initGroup(Group* group); 84 93 bool initFace (Face* face); … … 86 95 bool buildVertexNormals(void); 87 96 88 bool importTo GL(void);97 bool importToDisplayList(void); 89 98 bool addGLElement(FaceElement* elem); 90 99 100 bool importToVertexArray(void); 101 102 bool deleteArrays(void); 91 103 bool cleanup(void); 92 104 bool cleanupGroup(Group* group); … … 94 106 bool cleanupFaceElement(FaceElement* faceElem); 95 107 96 tList<Material>* materialList;97 108 98 109 protected: … … 104 115 105 116 public: 106 Model(const char* modelName = NULL );117 Model(const char* modelName = NULL, MODEL_TYPE type = MODEL_DISPLAY_LIST); 107 118 virtual ~Model(void); 108 119 -
orxonox/trunk/src/lib/graphics/importer/objModel.cc
r3915 r3916 32 32 \param scaling The factor that the model will be scaled with. 33 33 */ 34 OBJModel::OBJModel(c har* fileName, float scaling)34 OBJModel::OBJModel(const char* fileName, float scaling) : Model(fileName) 35 35 { 36 36 this->initializeOBJ(); … … 72 72 \param fileName The file to import 73 73 */ 74 bool OBJModel::importFile (c har* fileName)74 bool OBJModel::importFile (const char* fileName) 75 75 { 76 76 PRINTF(4)("preparing to read in file: %s\n", fileName); … … 84 84 char pathSplitter='/'; 85 85 #endif /* __WIN32__ */ 86 char* tmpName = fileName; 86 char* tmpName; 87 strcpy(tmpName, fileName); 87 88 if (tmpName[0] == pathSplitter) 88 89 tmpName++; … … 191 192 192 193 */ 193 bool OBJModel::readMtlLib (c har* mtlFile)194 bool OBJModel::readMtlLib (const char* mtlFile) 194 195 { 195 196 this->mtlFileName = new char [strlen(mtlFile)+1]; -
orxonox/trunk/src/lib/graphics/importer/objModel.h
r3655 r3916 13 13 { 14 14 public: 15 OBJModel(c har* fileName, float scaling = 1.0);15 OBJModel(const char* fileName, float scaling = 1.0); 16 16 virtual ~OBJModel(); 17 17 void initializeOBJ(void); … … 24 24 25 25 ///// readin ///// 26 bool importFile (c har* fileName);26 bool importFile (const char* fileName); 27 27 bool readFromObjFile (void); 28 bool readMtlLib (c har* matFile);28 bool readMtlLib (const char* matFile); 29 29 }; 30 30
Note: See TracChangeset
for help on using the changeset viewer.