Changeset 7203 in orxonox.OLD for branches/std/src/lib/graphics/importer/md2Model.cc
- Timestamp:
- Mar 9, 2006, 5:28:10 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/std/src/lib/graphics/importer/md2Model.cc
r7193 r7203 75 75 \brief simple constructor initializing all variables 76 76 */ 77 MD2Model::MD2Model(const char* modelFileName, const char*skinFileName, float scale)77 MD2Model::MD2Model(const std::string& modelFileName, const std::string& skinFileName, float scale) 78 78 { 79 79 this->setClassID(CL_MD2_MODEL, "MD2Model"); … … 352 352 { 353 353 PRINT(0)("\n==========================| MD2Model::debug() |===\n"); 354 PRINT(0)("= Model FileName:\t%s\n", this->data->fileName );355 PRINT(0)("= Skin FileName:\t%s\n", this->data->skinFileName );354 PRINT(0)("= Model FileName:\t%s\n", this->data->fileName.c_str()); 355 PRINT(0)("= Skin FileName:\t%s\n", this->data->skinFileName.c_str()); 356 356 PRINT(0)("= Size in Memory:\t%i Bytes\n", this->data->header->frameSize * this->data->header->numFrames + 64); // 64bytes is the header size 357 357 PRINT(0)("= Number of Vertices:\t%i\n", this->data->header->numVertices); … … 370 370 \brief simple constructor 371 371 */ 372 MD2Data::MD2Data(const char* modelFileName, const char*skinFileName, float scale)372 MD2Data::MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale) 373 373 { 374 374 scale *= 0.1f; … … 387 387 this->scaleFactor = scale; 388 388 389 this->fileName = NULL;390 this->skinFileName = NULL;389 this->fileName = ""; 390 this->skinFileName = ""; 391 391 this->loadModel(modelFileName); 392 392 this->loadSkin(skinFileName); … … 401 401 MD2Data::~MD2Data() 402 402 { 403 delete [] this->fileName;404 delete [] this->skinFileName;405 403 delete this->header; 406 404 … … 419 417 \return true if success 420 418 */ 421 bool MD2Data::loadModel(const char*fileName)419 bool MD2Data::loadModel(const std::string& fileName) 422 420 { 423 421 FILE *pFile; //file stream … … 428 426 429 427 //! @todo this chek should include deleting a loaded model (eventually) 430 if (fileName == NULL)428 if (fileName.empty()) 431 429 return false; 432 430 433 pFile = fopen(fileName , "rb");431 pFile = fopen(fileName.c_str(), "rb"); 434 432 if( unlikely(!pFile)) 435 433 { … … 442 440 if( unlikely(this->header->version != MD2_VERSION) && unlikely(this->header->ident != MD2_IDENT)) 443 441 { 444 PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName );442 PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName.c_str()); 445 443 return false; 446 444 } 447 445 448 this->fileName = new char[strlen(fileName)+1]; 449 strcpy(this->fileName, fileName); 446 this->fileName =fileName; 450 447 /* got the data: map it to locals */ 451 448 this->numFrames = this->header->numFrames; … … 507 504 \return true if success 508 505 */ 509 bool MD2Data::loadSkin(const char*fileName)510 { 511 if( fileName == NULL)512 { 513 this->skinFileName = NULL;506 bool MD2Data::loadSkin(const std::string& fileName) 507 { 508 if( fileName.empty()) 509 { 510 this->skinFileName = ""; 514 511 return false; 515 512 } 516 513 517 this->skinFileName = new char[strlen(fileName)+1]; 518 strcpy(this->skinFileName, fileName); 514 this->skinFileName =fileName; 519 515 520 516 this->material.setName("md2ModelMaterial");
Note: See TracChangeset
for help on using the changeset viewer.