Changeset 7221 in orxonox.OLD for trunk/src/world_entities/world_entity.cc
- Timestamp:
- Mar 15, 2006, 3:10:45 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/world_entity.cc
r7198 r7221 61 61 this->bCollide = true; 62 62 63 this->md2TextureFileName = NULL;64 65 63 this->objectListNumber = OM_INIT; 66 64 this->objectListIterator = NULL; … … 120 118 * @param fileName the name of the model to load 121 119 * @param scaling the Scaling of the model 122 * 123 * @todo fix this, so it only has one loadModel-Function. 124 */ 125 void WorldEntity::loadModel(const char* fileName, float scaling, unsigned int modelNumber) 120 */ 121 void WorldEntity::loadModel(const std::string& fileName, float scaling, unsigned int modelNumber) 126 122 { 127 123 this->modelLODName = fileName; 128 124 this->scaling = scaling; 129 if ( fileName != NULL && strcmp(fileName, ""))125 if (!fileName.empty()) 130 126 { 131 127 // search for the special character # in the LoadParam 132 if (strchr(fileName, '#') != NULL) 133 { 134 PRINTF(4)("Found # in %s... searching for LOD's\n", fileName); 135 char* lodFile = new char[strlen(fileName)+1]; 136 strcpy(lodFile, fileName); 137 char* depth = strchr(lodFile, '#'); 128 if (fileName.find('#') != std::string::npos) 129 { 130 PRINTF(4)("Found # in %s... searching for LOD's\n", fileName.c_str()); 131 std::string lodFile = fileName; 132 unsigned int offset = lodFile.find('#'); 138 133 for (unsigned int i = 0; i < 3; i++) 139 134 { 140 *depth= 48+(int)i;135 lodFile[offset] = 48+(int)i; 141 136 if (ResourceManager::isInDataDir(lodFile)) 142 137 this->loadModel(lodFile, scaling, i); … … 149 144 this->scaling = 1.0; 150 145 } 151 if( strstr(fileName, ".obj"))152 { 153 PRINTF(4)("fetching OBJ file: %s\n", fileName );146 if(fileName.find(".obj") != std::string::npos) 147 { 148 PRINTF(4)("fetching OBJ file: %s\n", fileName.c_str()); 154 149 BaseObject* loadedModel = ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, this->scaling); 155 150 if (loadedModel != NULL) 156 151 this->setModel(dynamic_cast<Model*>(loadedModel), modelNumber); 152 else 153 PRINTF(1)("OBJ-File %s not found.\n", fileName.c_str()); 157 154 158 155 if( modelNumber == 0) 159 156 this->buildObbTree(4); 160 157 } 161 else if( strstr(fileName, ".md2"))162 { 163 PRINTF(4)("fetching MD2 file: %s\n", fileName );158 else if(fileName.find(".md2") != std::string::npos) 159 { 160 PRINTF(4)("fetching MD2 file: %s\n", fileName.c_str()); 164 161 Model* m = new MD2Model(fileName, this->md2TextureFileName, this->scaling); 165 162 //this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0); … … 575 572 char* name = (char*)(getModel( 0 )->getName()); 576 573 577 if ( strstr(name, ResourceManager::getInstance()->getDataDir()))578 { 579 name += strlen(ResourceManager::getInstance()->getDataDir());574 if ( ResourceManager::getInstance()->getDataDir() == name ) /// FIXME (do not know what to do here.) 575 { 576 name += ResourceManager::getInstance()->getDataDir().size(); 580 577 } 581 578
Note: See TracChangeset
for help on using the changeset viewer.