Changeset 3909 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Apr 21, 2005, 12:27:19 AM (20 years ago)
- Location:
- orxonox/trunk/src/lib/graphics/importer
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/importer/framework.cc
r3657 r3909 58 58 int main(int argc, char *argv[]) 59 59 { 60 verbose = 3;60 verbose = 4; 61 61 62 62 Uint8* keys; // This variable will be used in the keyboard routine -
orxonox/trunk/src/lib/graphics/importer/model.cc
r3905 r3909 27 27 28 28 /** 29 \brief Creates a 3D-Model.30 31 This only initializes a 3D-Model, but does not cleanup the Faces.32 */33 Model::Model(void)34 {35 this->initialize();36 }37 38 /**39 29 \brief Creates a 3D-Model. and assigns it a Name. 40 30 */ 41 Model::Model(char* modelName) 42 { 43 this->initialize(); 31 Model::Model(const char* modelName) 32 { 33 PRINTF(4)("new 3D-Model is being created\n"); 34 this->name = NULL; 44 35 this->setName(modelName); 36 37 38 this->finalized = false; 39 // setting the start group; 40 this->firstGroup = new Group; 41 this->currentGroup = this->firstGroup; 42 this->groupCount = 0; 43 44 this->initGroup (this->currentGroup); 45 this->scaleFactor = 1; 46 this->material = new Material(); 47 48 this->vertices = new Array(); 49 this->vTexture = new Array(); 50 this->normals = new Array(); 51 45 52 } 46 53 … … 169 176 170 177 /** 171 \brief initializes the Model.172 173 This Function initializes all the needed arrays, Lists and clientStates.174 It also defines default values.175 */176 bool Model::initialize (void)177 {178 PRINTF(4)("new 3D-Model is being created\n");179 180 this->name = NULL;181 this->finalized = false;182 // setting the start group;183 this->firstGroup = new Group;184 this->currentGroup = this->firstGroup;185 this->groupCount = 0;186 187 this->initGroup (this->currentGroup);188 this->scaleFactor = 1;189 this->material = new Material();190 191 this->vertices = new Array();192 this->vTexture = new Array();193 this->normals = new Array();194 195 return true;196 }197 198 /**199 178 \brief sets a name to the Model 200 179 \param name The name to set to this Model … … 204 183 if (this->name) 205 184 delete this->name; 206 this->name = new char[strlen(name)+1]; 207 strcpy(this->name, name); 185 if (name) 186 { 187 this->name = new char[strlen(name)+1]; 188 strcpy(this->name, name); 189 } 190 else 191 this->name = NULL; 208 192 } 209 193 /** … … 348 332 If a vertex line is found this function will inject it into the vertex-Array 349 333 */ 350 bool Model::addVertex (c har* vertexString)334 bool Model::addVertex (const char* vertexString) 351 335 { 352 336 float subbuffer1; … … 379 363 If a face line is found this function will add it to the glList. 380 364 */ 381 bool Model::addFace (c har* faceString)365 bool Model::addFace (const char* faceString) 382 366 { 383 367 if (this->currentGroup->faceCount >0) … … 477 461 If a vertexNormal line is found this function will inject it into the vertexNormal-Array 478 462 */ 479 bool Model::addVertexNormal (c har* normalString)463 bool Model::addVertexNormal (const char* normalString) 480 464 { 481 465 float subbuffer1; … … 509 493 this function will inject it into the vertexTexture-Array 510 494 */ 511 bool Model::addVertexTexture (c har* vTextureString)495 bool Model::addVertexTexture (const char* vTextureString) 512 496 { 513 497 float subbuffer1; … … 540 524 bool Model::addUseMtl (const char* matString) 541 525 { 542 /*543 if (!this->mtlFileName)544 {545 PRINTF(4)("Not using new defined material, because no mtlFile found yet\n");546 return false;547 }548 */549 526 if (this->currentGroup->faceCount > 0) 550 527 this->currentGroup->currentFace = this->currentGroup->currentFace->next = new Face; -
orxonox/trunk/src/lib/graphics/importer/model.h
r3895 r3909 29 29 { 30 30 public: 31 Model(void); 32 Model(char* modelName); 31 Model(const char* modelName = NULL); 33 32 virtual ~Model(void); 34 33 … … 92 91 float scaleFactor; //!< The Factor with which the Model should be scaled. \todo maybe one wants to scale the Model after Initialisation 93 92 94 bool initialize(void);95 93 bool initGroup(Group* group); 96 94 bool initFace (Face* face); … … 102 100 public: 103 101 bool addGroup(const char* groupString); 104 bool addVertex(c har* vertexString);102 bool addVertex(const char* vertexString); 105 103 bool addVertex(float x, float y, float z); 106 bool addFace(c har* faceString);104 bool addFace(const char* faceString); 107 105 bool addFace(int faceElemCount, VERTEX_FORMAT type, ...); 108 bool addVertexNormal(c har* normalString);106 bool addVertexNormal(const char* normalString); 109 107 bool addVertexNormal(float x, float y, float z); 110 bool addVertexTexture(c har* vTextureString);108 bool addVertexTexture(const char* vTextureString); 111 109 bool addVertexTexture(float u, float v); 112 110 bool addUseMtl(const char* mtlString); -
orxonox/trunk/src/lib/graphics/importer/objModel.cc
r3908 r3909 23 23 24 24 #define PARSELINELENGTH 8192 25 26 #include <fstream>27 25 28 26 #include "debug.h" … … 69 67 this->objFileName = NULL; 70 68 this->mtlFileName = NULL; 71 72 this->initialize();73 69 } 74 70 … … 135 131 char readLine[PARSELINELENGTH]; 136 132 char buffer[PARSELINELENGTH]; 137 int i = 0;138 133 while(fgets(readLine, PARSELINELENGTH, stream)) 139 134 { 140 135 strcpy(buffer, readLine); 141 i++;142 136 // case vertice 143 137 if (!strncmp(buffer, "v ", 2)) … … 206 200 207 201 208 PRINTF(4)("Opening mtlFile: %s\n", fileName); 209 210 ifstream* MTL_FILE = new ifstream (fileName); 211 if (MTL_FILE->fail()) 212 { 213 PRINTF(2)("unable to open file: %s\n", fileName); 214 MTL_FILE->close(); 215 delete []fileName; 216 delete MTL_FILE; 202 FILE* stream; 203 if( (stream = fopen (fileName, "r")) == NULL) 204 { 205 printf("IniParser could not open %s\n", fileName); 217 206 return false; 218 207 } 219 char buffer[500]; 208 209 char readLine[PARSELINELENGTH]; 210 char buffer[PARSELINELENGTH]; 220 211 Material* tmpMat = material; 221 while(!MTL_FILE->eof()) 222 { 223 MTL_FILE->getline(buffer, 500); 212 while(fgets(readLine, PARSELINELENGTH, stream)) 213 { 224 214 PRINTF(5)("found line in mtlFile: %s\n", buffer); 225 226 215 227 216 // create new Material … … 286 275 287 276 } 288 MTL_FILE->close();277 fclose(stream); 289 278 delete []fileName; 290 delete MTL_FILE;291 279 return true; 292 280 } -
orxonox/trunk/src/lib/graphics/importer/primitive_model.cc
r3896 r3909 33 33 PrimitiveModel::PrimitiveModel(PRIMITIVE type, float size, unsigned int detail) 34 34 { 35 this->initialize();36 37 35 switch (type) 38 36 {
Note: See TracChangeset
for help on using the changeset viewer.