Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 26, 2006, 3:44:38 PM (18 years ago)
Author:
bensch
Message:

orxonox/new_class_id: Loading via the new Interface works, (it seems)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/world_entities/world_entity.cc

    r9727 r9832  
    2020#include "shell_command.h"
    2121
    22 #include "model.h"
     22#include "util/loading/new_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"
     
    8383
    8484  // registering default reactions:
    85 /// FIXME  this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, /*CL_WORLD_ENTITY*/ CL_PROJECTILE);
     85  /// FIXME  this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, /*CL_WORLD_ENTITY*/ CL_PROJECTILE);
    8686
    8787  this->toList(OM_NULL);
     
    162162  std::string name = fileName;
    163163
    164   if (  name.find( ResourceManager::getInstance()->getDataDir() ) == 0 )
    165   {
    166     name.erase(ResourceManager::getInstance()->getDataDir().size());
     164  if (  name.find( Resources::NewResourceManager::getInstance()->mainGlobalPath().name() ) == 0 )
     165  {
     166    name.erase(Resources::NewResourceManager::getInstance()->mainGlobalPath().name().size());
    167167  }
    168168
     
    180180      {
    181181        lodFile[offset] = 48+(int)i;
    182         if (ResourceManager::isInDataDir(lodFile))
     182        if (Resources::NewResourceManager::getInstance()->checkFileInMainPath( lodFile))
    183183          this->loadModel(lodFile, scaling, i);
    184184      }
     
    190190      this->scaling = 1.0;
    191191    }
     192    /// LOADING AN OBJ FILE
    192193    if(fileName.find(".obj") != std::string::npos)
    193194    {
    194195      PRINTF(4)("fetching OBJ file: %s\n", fileName.c_str());
    195       BaseObject* loadedModel = ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, this->scaling);
    196       if (loadedModel != NULL)
    197         this->setModel(dynamic_cast<Model*>(loadedModel), modelNumber);
     196      StaticModel* model = new StaticModel();
     197      *model = ResourceOBJ(fileName, this->scaling);
     198      if (model->getVertexCount() > 0)
     199      {
     200        this->setModel(model, modelNumber);
     201        if( modelNumber == 0 /* FIXME && !this->isA(CL_WEAPON) */)
     202          this->buildObbTree(obbTreeDepth);
     203      }
    198204      else
    199         PRINTF(1)("OBJ-File %s not found.\n", fileName.c_str());
    200 
    201       if( modelNumber == 0 /* FIXME && !this->isA(CL_WEAPON) */)
    202         this->buildObbTree(obbTreeDepth);
    203     }
     205        delete model;
     206    }
     207    /// LOADING AN MD2-model
    204208    else if(fileName.find(".md2") != std::string::npos)
    205209    {
     
    212216        this->buildObbTree(obbTreeDepth);
    213217    }
     218    /// LOADING AN MD3-MODEL.
    214219    else if(fileName.find(".md3") != std::string::npos)
    215220    {
     
    218223      this->setModel(m, 0);
    219224
    220 //       if( m != NULL)
    221 //         this->buildObbTree(obbTreeDepth);
     225      //       if( m != NULL)
     226      //         this->buildObbTree(obbTreeDepth);
    222227    }
    223228  }
     
    240245  if (this->models[modelNumber] != NULL)
    241246  {
    242     Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(dynamic_cast<BaseObject*>(this->models[modelNumber]));
    243     if (resource != NULL)
    244       ResourceManager::getInstance()->unload(resource, RP_LEVEL);
    245     else
    246     {
    247       PRINTF(4)("Forcing model deletion\n");
    248       delete this->models[modelNumber];
    249     }
     247    delete this->models[modelNumber];
    250248  }
    251249
     
    283281  }
    284282
    285   if( this->models[0] != NULL) {
     283  if( this->models[0] != NULL)
     284  {
    286285    this->aabbNode = new AABBTreeNode();
    287286    this->aabbNode->spawnBVTree(this->models[0]);
     
    367366void WorldEntity::subscribeReaction(CREngine::CRType type)
    368367{
    369   if( this->collisionHandles[type] != NULL)  {
     368  if( this->collisionHandles[type] != NULL)
     369  {
    370370    PRINTF(2)("Registering for a CollisionReaction already subscribed to! Skipping\n");
    371371    return;
     
    498498void removeFromReflectionList()
    499499{
    500 /// TODO
    501 ///  State::getObject
     500  /// TODO
     501  ///  State::getObject
    502502}
    503503
     
    558558  {
    559559
    560   this->setAbsCoor(ray_2 - v);
    561 
    562   }
    563     else
     560    this->setAbsCoor(ray_2 - v);
     561
     562  }
     563  else
    564564  {
    565565    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)
     
    645645    }
    646646
    647 //     if( this->aabbNode != NULL)
    648 //       this->aabbNode->drawBV(0, DRAW_BV_POLYGON, Vector(1, 0.6, 0.2), true);
     647    //     if( this->aabbNode != NULL)
     648    //       this->aabbNode->drawBV(0, DRAW_BV_POLYGON, Vector(1, 0.6, 0.2), true);
    649649
    650650    glPopMatrix();
Note: See TracChangeset for help on using the changeset viewer.