Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9869 in orxonox.OLD for trunk/src/world_entities/world_entity.cc


Ignore:
Timestamp:
Oct 3, 2006, 12:19:30 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/world_entity.cc

    r9656 r9869  
    2020#include "shell_command.h"
    2121
    22 #include "model.h"
     22#include "util/loading/resource_manager.h"
     23#include "resource_obj.h"
    2324#include "md2/md2Model.h"
    2425#include "md3/md3_model.h"
     
    2627#include "aabb_tree_node.h"
    2728
    28 #include "util/loading/resource_manager.h"
    2929#include "util/loading/load_param.h"
    3030#include "obb_tree.h"
     
    3939#include "game_rules.h"
    4040#include "kill.h"
    41 
     41#include "debug.h"
     42
     43#include "projectiles/projectile.h"
    4244
    4345SHELL_COMMAND(model, WorldEntity, loadModel)
     
    4749SHELL_COMMAND(debugEntity, WorldEntity, debugWE);
    4850
     51
     52ObjectListDefinition(WorldEntity);
    4953/**
    5054 *  Loads the WordEntity-specific Part of any derived Class
     
    5660    : Synchronizeable()
    5761{
    58   this->setClassID(CL_WORLD_ENTITY, "WorldEntity");
     62  this->registerObject(this, WorldEntity::_objectList);
    5963
    6064  this->obbTree = NULL;
     
    7276  this->objectListNumber = OM_INIT;
    7377  this->lastObjectListNumber = OM_INIT;
    74   this->objectListIterator = NULL;
    7578
    7679  // reset all collision handles to NULL == unsubscribed state
     
    8184
    8285  // 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());
    8487
    8588  this->toList(OM_NULL);
     
    160163  std::string name = fileName;
    161164
    162   if (  name.find( ResourceManager::getInstance()->getDataDir() ) == 0 )
    163   {
    164     name.erase(ResourceManager::getInstance()->getDataDir().size());
     165  if (  name.find( Resources::ResourceManager::getInstance()->mainGlobalPath().name() ) == 0 )
     166  {
     167    name.erase(Resources::ResourceManager::getInstance()->mainGlobalPath().name().size());
    165168  }
    166169
     
    178181      {
    179182        lodFile[offset] = 48+(int)i;
    180         if (ResourceManager::isInDataDir(lodFile))
     183        if (Resources::ResourceManager::getInstance()->checkFileInMainPath( lodFile))
    181184          this->loadModel(lodFile, scaling, i);
    182185      }
     
    188191      this->scaling = 1.0;
    189192    }
     193    /// LOADING AN OBJ FILE
    190194    if(fileName.find(".obj") != std::string::npos)
    191195    {
    192196      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      }
    196205      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
    202209    else if(fileName.find(".md2") != std::string::npos)
    203210    {
     
    210217        this->buildObbTree(obbTreeDepth);
    211218    }
     219    /// LOADING AN MD3-MODEL.
    212220    else if(fileName.find(".md3") != std::string::npos)
    213221    {
    214222      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);
    220228    }
    221229  }
     
    238246  if (this->models[modelNumber] != NULL)
    239247  {
    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];
    248249  }
    249250
     
    281282  }
    282283
    283   if( this->models[0] != NULL) {
     284  if( this->models[0] != NULL)
     285  {
    284286    this->aabbNode = new AABBTreeNode();
    285287    this->aabbNode->spawnBVTree(this->models[0]);
     
    300302 *  @param target1 a filter target (classID)
    301303 */
    302 void WorldEntity::subscribeReaction(CREngine::CRType type, long target1)
     304void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1)
    303305{
    304306  this->subscribeReaction(type);
     
    314316 *  @param target1 a filter target (classID)
    315317 */
    316 void WorldEntity::subscribeReaction(CREngine::CRType type, long target1, long target2)
     318void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2)
    317319{
    318320  this->subscribeReaction(type);
     
    329331 *  @param target1 a filter target (classID)
    330332 */
    331 void WorldEntity::subscribeReaction(CREngine::CRType type, long target1, long target2, long target3)
     333void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2, const ClassID& target3)
    332334{
    333335  this->subscribeReaction(type);
     
    345347 *  @param target1 a filter target (classID)
    346348 */
    347 void WorldEntity::subscribeReaction(CREngine::CRType type, long target1, long target2, long target3, long target4)
     349void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2, const ClassID& target3, const ClassID& target4)
    348350{
    349351  this->subscribeReaction(type);
     
    365367void WorldEntity::subscribeReaction(CREngine::CRType type)
    366368{
    367   if( this->collisionHandles[type] != NULL)  {
     369  if( this->collisionHandles[type] != NULL)
     370  {
    368371    PRINTF(2)("Registering for a CollisionReaction already subscribed to! Skipping\n");
    369372    return;
     
    496499void removeFromReflectionList()
    497500{
    498 /// TODO
    499 ///  State::getObject
     501  /// TODO
     502  ///  State::getObject
    500503}
    501504
     
    556559  {
    557560
    558   this->setAbsCoor(ray_2 - v);
    559 
    560   }
    561     else
     561    this->setAbsCoor(ray_2 - v);
     562
     563  }
     564  else
    562565  {
    563566    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)
     
    643646    }
    644647
    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);
    647650
    648651    glPopMatrix();
Note: See TracChangeset for help on using the changeset viewer.