Changeset 4462 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Jun 2, 2005, 12:50:37 AM (19 years ago)
- Location:
- orxonox/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/scripts/orxodox.checkFiles.pl
r3997 r4462 74 74 # Project related configuration options \ 75 75 #--------------------------------------------------------------------------- \ 76 PROJECT_NAME = Orxonox \76 PROJECT_NAME = orxonox \ 77 77 PROJECT_NUMBER = 1 \ 78 78 OUTPUT_DIRECTORY = doxygen/ \ -
orxonox/trunk/src/lib/graphics/importer/md2Model.cc
r4461 r4462 81 81 { 82 82 /* this creates the data container via ressource manager */ 83 this->data = new MD2Data(modelFileName,skinFileName);83 this->data = (MD2Data*)ResourceManager::getInstance()->load(modelFileName, MD2, RP_GAME, (void*)skinFileName); 84 84 this->scaleFactor = this->data->scaleFactor; 85 85 … … 94 94 MD2Model::~MD2Model() 95 95 { 96 96 ResourceManager::getInstance()->unload(this->data); 97 97 } 98 98 -
orxonox/trunk/src/util/resource_manager.cc
r4381 r4462 21 21 #include "objModel.h" 22 22 #include "primitive_model.h" 23 #include "md2Model.h" 23 24 #include "texture.h" 24 25 #include "text_engine.h" … … 173 174 { 174 175 ResourceType tmpType; 176 175 177 if (!strncmp(fileName+(strlen(fileName)-4), ".obj", 4)) 176 178 tmpType = OBJ; 179 if (!strncmp(fileName+(strlen(fileName)-4), ".md2", 4)) 180 tmpType = MD2; 177 181 else if (!strncmp(fileName+(strlen(fileName)-4), ".wav", 4)) 178 182 tmpType = WAV; … … 226 230 227 231 // creating the full name. (directoryName + FileName) 228 char* fullName = new char[strlen(this->getDataDir())+strlen(fileName)+1]; 229 sprintf(fullName, "%s%s", this->getDataDir(), fileName); 232 char* fullName = ResourceManager::getFullName(fileName); 230 233 // Checking for the type of resource \see ResourceType 231 234 switch(type) … … 262 265 tmpResource->pointer = new PrimitiveModel(CONE, tmpResource->modelSize); 263 266 break; 267 case MD2: 268 if(ResourceManager::isFile(fullName)) 269 { 270 if (param1) 271 { 272 tmpResource->skinFileName = new char[strlen((const char*)param1)+1]; 273 strcpy(tmpResource->skinFileName, (const char*) fileName); 274 } 275 else 276 tmpResource->skinFileName = NULL; 277 char* skinFileName = ResourceManager::getFullName(tmpResource->skinFileName); 278 tmpResource->pointer = new MD2Data(fullName, skinFileName); 279 delete []skinFileName; 280 } 281 break; 264 282 case TTF: 265 283 if (param1) … … 373 391 delete (Model*)resource->pointer; 374 392 break; 393 case MD2: 394 delete (MD2Data*)resource->pointer; 395 break; 375 396 case IMAGE: 376 397 delete (Texture*)resource->pointer; … … 425 446 \returns a Pointer to the Resource if found, NULL otherwise. 426 447 */ 427 Resource* ResourceManager::locateResourceByInfo(const char* fileName, ResourceType type, void* param1, void* param2, void* param3) 448 Resource* ResourceManager::locateResourceByInfo(const char* fileName, ResourceType type, 449 void* param1, void* param2, void* param3) 428 450 { 429 451 // Resource* enumRes = resourceList->enumerate(); … … 436 458 bool match = false; 437 459 bool subMatch = false; 460 438 461 switch (type) 439 462 { … … 446 469 } 447 470 else if (enumRes->modelSize == *(float*)param1) 471 match = true; 472 break; 473 case MD2: 474 if (!param1) 475 { 476 if (enumRes->skinFileName == NULL) 477 match = true; 478 } 479 else if (!strcmp(enumRes->skinFileName, (const char*) param1)) 448 480 match = true; 449 481 break; … … 519 551 bool ResourceManager::isDir(const char* directoryName) 520 552 { 553 if (directoryName == NULL) 554 return false; 555 521 556 char* tmpDirName = NULL; 522 557 struct stat status; … … 563 598 bool ResourceManager::isFile(const char* fileName) 564 599 { 600 if (fileName == NULL) 601 return false; 565 602 char* tmpFileName = ResourceManager::homeDirCheck(fileName); 566 603 // actually checks the File … … 597 634 { 598 635 char* tmpName = ResourceManager::homeDirCheck(fileName); 599 636 if (tmpName == NULL) 637 return false; 600 638 FILE* stream; 601 639 if( (stream = fopen (tmpName, "w")) == NULL) … … 615 653 bool ResourceManager::deleteFile(const char* fileName) 616 654 { 655 if (fileName == NULL) 656 return false; 617 657 char* tmpName = ResourceManager::homeDirCheck(fileName); 618 658 unlink(tmpName); … … 627 667 char* ResourceManager::homeDirCheck(const char* name) 628 668 { 669 if (name == NULL) 670 return NULL; 629 671 char* retName; 630 672 if (!strncmp(name, "~/", 2)) … … 654 696 char* ResourceManager::getFullName(const char* fileName) 655 697 { 698 if (fileName == NULL) 699 return NULL; 700 656 701 char* retName = new char[strlen(ResourceManager::getInstance()->getDataDir()) 657 702 + strlen(fileName) + 1]; 658 703 sprintf(retName, "%s%s", ResourceManager::getInstance()->getDataDir(), fileName); 659 if (ResourceManager::isFile(retName) )704 if (ResourceManager::isFile(retName) || ResourceManager::isDir(retName)) 660 705 return retName; 661 706 else -
orxonox/trunk/src/util/resource_manager.h
r4381 r4462 19 19 template<class T> class tList; 20 20 21 //! An eumerator for different fileTypes the resourceManager supports \todo WAV, MP3, OGG support 22 enum ResourceType {OBJ, 23 PRIM, 24 WAV, 25 MP3, 26 OGG, 27 TTF, 28 IMAGE}; 21 //! An eumerator for different fileTypes the resourceManager supports 22 typedef enum ResourceType { OBJ, 23 PRIM, 24 MD2, 25 WAV, 26 MP3, 27 OGG, 28 TTF, 29 IMAGE }; 30 29 31 //! An enumerator for different UNLOAD-types. 30 32 /** 31 RP_NO: will be unloaded on request32 RP_LEVEL: will be unloaded at the end of a Level33 RP_CAMPAIGN: will be unloaded at the end of a Campaign34 RP_GAME: will be unloaded at the end of the whole Game (when closing orxonox)33 RP_NO: will be unloaded on request 34 RP_LEVEL: will be unloaded at the end of a Level 35 RP_CAMPAIGN: will be unloaded at the end of a Campaign 36 RP_GAME: will be unloaded at the end of the whole Game (when closing orxonox) 35 37 */ 36 enum ResourcePriority {RP_NO =0,37 RP_LEVEL =1,38 RP_CAMPAIGN =2,39 RP_GAME = 3};38 typedef enum ResourcePriority { RP_NO = 0, 39 RP_LEVEL = 1, 40 RP_CAMPAIGN = 2, 41 RP_GAME = 4 }; 40 42 41 43 //! A Struct that keeps track about A resource its name its Type, and so on … … 55 57 unsigned char ttfColorG; 56 58 unsigned char ttfColorB; 59 char* skinFileName; 57 60 }; 58 61 … … 66 69 67 70 It does it by looking, if a desired file has already been loaded. 68 69 \todo loading also dependant by parameters.70 71 */ 71 72 class ResourceManager : public BaseObject -
orxonox/trunk/src/world_entities/test_entity.cc
r4459 r4462 30 30 this->setClassID(CL_TEST_ENTITY, "TestEntity"); 31 31 32 this->md2Model = new MD2Model(" ../data/models/tris.md2", "../data/models/tris.pcx");32 this->md2Model = new MD2Model("models/tris.md2", "models/tris.pcx"); 33 33 this->md2Model->debug(); 34 34 } … … 36 36 37 37 TestEntity::~TestEntity () 38 {} 38 { 39 delete this->md2Model; 40 } 39 41 40 42
Note: See TracChangeset
for help on using the changeset viewer.