Changeset 9869 in orxonox.OLD for trunk/src/world_entities/world_entity.cc
- Timestamp:
- Oct 3, 2006, 12:19:30 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/world_entity.cc
r9656 r9869 20 20 #include "shell_command.h" 21 21 22 #include "model.h" 22 #include "util/loading/resource_manager.h" 23 #include "resource_obj.h" 23 24 #include "md2/md2Model.h" 24 25 #include "md3/md3_model.h" … … 26 27 #include "aabb_tree_node.h" 27 28 28 #include "util/loading/resource_manager.h"29 29 #include "util/loading/load_param.h" 30 30 #include "obb_tree.h" … … 39 39 #include "game_rules.h" 40 40 #include "kill.h" 41 41 #include "debug.h" 42 43 #include "projectiles/projectile.h" 42 44 43 45 SHELL_COMMAND(model, WorldEntity, loadModel) … … 47 49 SHELL_COMMAND(debugEntity, WorldEntity, debugWE); 48 50 51 52 ObjectListDefinition(WorldEntity); 49 53 /** 50 54 * Loads the WordEntity-specific Part of any derived Class … … 56 60 : Synchronizeable() 57 61 { 58 this-> setClassID(CL_WORLD_ENTITY, "WorldEntity");62 this->registerObject(this, WorldEntity::_objectList); 59 63 60 64 this->obbTree = NULL; … … 72 76 this->objectListNumber = OM_INIT; 73 77 this->lastObjectListNumber = OM_INIT; 74 this->objectListIterator = NULL;75 78 76 79 // reset all collision handles to NULL == unsubscribed state … … 81 84 82 85 // registering default reactions: 83 this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, /* CL_WORLD_ENTITY*/ CL_PROJECTILE);86 this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, /* WorldEntity::staticClassID(), */ Projectile::staticClassID()); 84 87 85 88 this->toList(OM_NULL); … … 160 163 std::string name = fileName; 161 164 162 if ( name.find( Resource Manager::getInstance()->getDataDir() ) == 0 )163 { 164 name.erase(Resource Manager::getInstance()->getDataDir().size());165 if ( name.find( Resources::ResourceManager::getInstance()->mainGlobalPath().name() ) == 0 ) 166 { 167 name.erase(Resources::ResourceManager::getInstance()->mainGlobalPath().name().size()); 165 168 } 166 169 … … 178 181 { 179 182 lodFile[offset] = 48+(int)i; 180 if (Resource Manager::isInDataDir(lodFile))183 if (Resources::ResourceManager::getInstance()->checkFileInMainPath( lodFile)) 181 184 this->loadModel(lodFile, scaling, i); 182 185 } … … 188 191 this->scaling = 1.0; 189 192 } 193 /// LOADING AN OBJ FILE 190 194 if(fileName.find(".obj") != std::string::npos) 191 195 { 192 196 PRINTF(4)("fetching OBJ file: %s\n", fileName.c_str()); 193 BaseObject* loadedModel = ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, this->scaling); 194 if (loadedModel != NULL) 195 this->setModel(dynamic_cast<Model*>(loadedModel), modelNumber); 197 StaticModel* model = new StaticModel(); 198 *model = ResourceOBJ(fileName, this->scaling); 199 if (model->getVertexCount() > 0) 200 { 201 this->setModel(model, modelNumber); 202 if( modelNumber == 0 /* FIXME && !this->isA(CL_WEAPON) */) 203 this->buildObbTree(obbTreeDepth); 204 } 196 205 else 197 PRINTF(1)("OBJ-File %s not found.\n", fileName.c_str()); 198 199 if( modelNumber == 0 && !this->isA(CL_WEAPON)) 200 this->buildObbTree(obbTreeDepth); 201 } 206 delete model; 207 } 208 /// LOADING AN MD2-model 202 209 else if(fileName.find(".md2") != std::string::npos) 203 210 { … … 210 217 this->buildObbTree(obbTreeDepth); 211 218 } 219 /// LOADING AN MD3-MODEL. 212 220 else if(fileName.find(".md3") != std::string::npos) 213 221 { 214 222 PRINTF(4)("fetching MD3 file: %s\n", fileName.c_str()); 215 Model* m = new md3::MD3Model(fileName, this->scaling);216 this->setModel(m, 0);217 218 // if( m != NULL)219 // this->buildObbTree(obbTreeDepth);223 // Model* m = new md3::MD3Model(fileName, this->scaling); 224 // this->setModel(m, 0); 225 226 // if( m != NULL) 227 // this->buildObbTree(obbTreeDepth); 220 228 } 221 229 } … … 238 246 if (this->models[modelNumber] != NULL) 239 247 { 240 Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(dynamic_cast<BaseObject*>(this->models[modelNumber])); 241 if (resource != NULL) 242 ResourceManager::getInstance()->unload(resource, RP_LEVEL); 243 else 244 { 245 PRINTF(4)("Forcing model deletion\n"); 246 delete this->models[modelNumber]; 247 } 248 delete this->models[modelNumber]; 248 249 } 249 250 … … 281 282 } 282 283 283 if( this->models[0] != NULL) { 284 if( this->models[0] != NULL) 285 { 284 286 this->aabbNode = new AABBTreeNode(); 285 287 this->aabbNode->spawnBVTree(this->models[0]); … … 300 302 * @param target1 a filter target (classID) 301 303 */ 302 void WorldEntity::subscribeReaction(CREngine::CRType type, longtarget1)304 void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1) 303 305 { 304 306 this->subscribeReaction(type); … … 314 316 * @param target1 a filter target (classID) 315 317 */ 316 void WorldEntity::subscribeReaction(CREngine::CRType type, long target1, longtarget2)318 void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2) 317 319 { 318 320 this->subscribeReaction(type); … … 329 331 * @param target1 a filter target (classID) 330 332 */ 331 void WorldEntity::subscribeReaction(CREngine::CRType type, long target1, long target2, longtarget3)333 void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2, const ClassID& target3) 332 334 { 333 335 this->subscribeReaction(type); … … 345 347 * @param target1 a filter target (classID) 346 348 */ 347 void WorldEntity::subscribeReaction(CREngine::CRType type, long target1, long target2, long target3, longtarget4)349 void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2, const ClassID& target3, const ClassID& target4) 348 350 { 349 351 this->subscribeReaction(type); … … 365 367 void WorldEntity::subscribeReaction(CREngine::CRType type) 366 368 { 367 if( this->collisionHandles[type] != NULL) { 369 if( this->collisionHandles[type] != NULL) 370 { 368 371 PRINTF(2)("Registering for a CollisionReaction already subscribed to! Skipping\n"); 369 372 return; … … 496 499 void removeFromReflectionList() 497 500 { 498 /// TODO499 /// State::getObject501 /// TODO 502 /// State::getObject 500 503 } 501 504 … … 556 559 { 557 560 558 this->setAbsCoor(ray_2 - v);559 560 } 561 561 this->setAbsCoor(ray_2 - v); 562 563 } 564 else 562 565 { 563 566 if(ray_1.x == this->getAbsCoor().x + v.x && ray_1.y == this->getAbsCoor().y + v.y + 0.1 && ray_1.z ==this->getAbsCoor().z + v.z) … … 643 646 } 644 647 645 // if( this->aabbNode != NULL)646 // this->aabbNode->drawBV(0, DRAW_BV_POLYGON, Vector(1, 0.6, 0.2), true);648 // if( this->aabbNode != NULL) 649 // this->aabbNode->drawBV(0, DRAW_BV_POLYGON, Vector(1, 0.6, 0.2), true); 647 650 648 651 glPopMatrix();
Note: See TracChangeset
for help on using the changeset viewer.