Changeset 6222 in orxonox.OLD for trunk/src/world_entities/world_entity.cc
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property
svn:ignore
set to
Makefile.in
Makefile
configure
*.kdevelop
Doxyfile
config.log
config.h
config.status
stamp-h1
autom4te.cache
aclocal.m4
-
Property
svn:ignore
set to
-
trunk/src
-
Property
svn:ignore
set to
.deps
orxonox
Makefile
Makefile.in
-
Property
svn:ignore
set to
-
trunk/src/world_entities/world_entity.cc
r6142 r6222 21 21 22 22 #include "model.h" 23 #include "md2Model.h" 23 24 #include "resource_manager.h" 24 25 #include "load_param.h" 25 #include "list.h"26 26 #include "vector.h" 27 27 #include "obb_tree.h" … … 84 84 // Do the PNode loading stuff 85 85 static_cast<PNode*>(this)->loadParams(root); 86 87 LoadParam(root, "md2texture", this, WorldEntity, loadMD2Texture) 88 .describe("the fileName of the texture, that should be loaded onto this world-entity. (must be relative to the data-dir)") 89 .defaultValues(1, NULL); 86 90 87 91 // Model Loading … … 89 93 .describe("the fileName of the model, that should be loaded onto this world-entity. (must be relative to the data-dir)") 90 94 .defaultValues(3, NULL, 1.0f, 0); 91 92 } 95 } 96 93 97 94 98 /** … … 103 107 if (fileName != NULL) 104 108 { 105 109 // search for the special character # in the LoadParam 106 110 if (strchr(fileName, '#') != NULL) 111 { 112 PRINTF(4)("Found # in %s... searching for LOD's\n", fileName); 113 char* lodFile = new char[strlen(fileName)+1]; 114 strcpy(lodFile, fileName); 115 char* depth = strchr(lodFile, '#'); 116 for (unsigned int i = 0; i < 5; i++) 107 117 { 108 PRINTF(4)("Found # in %s... searching for LOD's\n", fileName); 109 char* lodFile = new char[strlen(fileName)+1]; 110 strcpy(lodFile, fileName); 111 char* depth = strchr(lodFile, '#'); 112 for (unsigned int i = 0; i < 5; i++) 113 { 114 *depth = 48+(int)i; 115 printf("-------%s\n", lodFile); 116 if (ResourceManager::isInDataDir(lodFile)) 117 this->loadModel(lodFile, scaling, i); 118 } 119 return; 118 *depth = 48+(int)i; 119 printf("-------%s\n", lodFile); 120 if (ResourceManager::isInDataDir(lodFile)) 121 this->loadModel(lodFile, scaling, i); 120 122 } 121 122 PRINTF(4)("fetching %s\n", fileName); 123 if (scaling == 1.0) 124 this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN), modelNumber); 125 else 126 this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, &scaling), modelNumber); 127 if (modelNumber == 0) 128 this->buildObbTree(4); 123 return; 124 } 125 126 if(strstr(fileName, ".obj")) 127 { 128 PRINTF(4)("fetching OBJ file: %s\n", fileName); 129 if (scaling == 1.0) 130 this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN), modelNumber); 131 else 132 this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, &scaling), modelNumber); 133 134 if( modelNumber == 0) 135 this->buildObbTree(4); 136 } 137 else if(strstr(fileName, ".md2")) 138 { 139 PRINTF(4)("fetching MD2 file: %s\n", fileName); 140 Model* m = new MD2Model(fileName, this->md2TextureFileName); 141 //this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0); 142 this->setModel(m, 0); 143 } 129 144 } 130 145 else … … 145 160 { 146 161 Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(this->models[modelNumber]); 147 if (resource != NULL) 148 ResourceManager::getInstance()->unload(resource, RP_LEVEL); 149 else 150 delete this->models[modelNumber]; 151 } 162 // if (resource != NULL) 163 ResourceManager::getInstance()->unload(resource, RP_LEVEL); 164 } 165 else 166 delete this->models[modelNumber]; 167 152 168 this->models[modelNumber] = model; 169 153 170 154 171 // if (this->model != NULL) … … 272 289 } 273 290 291 292 /** 293 * this functions draws the model automaticaly in multiple LOD 294 */ 274 295 void WorldEntity::drawLODsafe() const 275 296 { 276 if (! this->models.empty())297 if (!unlikely(this->models.empty())) 277 298 { 278 299 glMatrixMode(GL_MODELVIEW); … … 291 312 if (cameraDistance > 30 && this->models.size() >= 3 && this->models[2] != NULL) 292 313 { 293 314 this->models[2]->draw(); 294 315 } 295 316 else if (cameraDistance > 10 && this->models.size() >= 2 && this->models[1] != NULL)
Note: See TracChangeset
for help on using the changeset viewer.