Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9832 in orxonox.OLD for branches/new_class_id


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)

Location:
branches/new_class_id/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/graphics/importer/static_model.cc

    r9830 r9832  
    3737 */
    3838StaticModel::StaticModel(const std::string& modelName)
    39   : data(new StaticModelData(modelName))
     39    : data(new StaticModelData(modelName))
    4040{
    4141  this->registerObject(this, StaticModel::_objectList);
     
    4343  this->setName(modelName);
    4444}
     45
     46StaticModel::StaticModel(const StaticModel& staticModel)
     47  : data(staticModel.data)
     48{
     49  this->registerObject(this, StaticModel::_objectList);
     50  this->setName(staticModel.getName());
     51  this->updateBase();
     52}
     53
    4554
    4655/**
     
    6069}
    6170
     71StaticModel& StaticModel::operator=(const StaticModel& model)
     72{
     73  this->data = model.data;
     74  this->updateBase();
     75  return *this;
     76};
     77
     78
    6279/**
    6380 * @brief Finalizes an Object. This can be done outside of the Class.
     
    6683{
    6784  data->finalize();
     85  this->updateBase();
     86}
    6887
    69   // write out the modelInfo data used for the collision detection!
    70   this->pModelInfo.pVertices = &this->data->getVertices()[0];
    71   this->pModelInfo.numVertices = this->data->getVertices().size();
    72   this->pModelInfo.pNormals = &this->data->getNormals()[0];
    73   this->pModelInfo.numNormals = this->data->getNormals().size();
    74   this->pModelInfo.pTexCoor = &this->data->getTexCoords()[0];
    75   this->pModelInfo.numTexCoor = this->data->getTexCoords().size();
    76 
    77   this->pModelInfo.pTriangles = this->data->getTrianglesExt();
    78   this->pModelInfo.numTriangles = this->data->getTriangles().size();
     88void StaticModel::acquireData(const StaticModelData::Pointer& data)
     89{
     90  this->data = data;
     91  this->updateBase();
    7992}
    8093
     
    92105  return retVal;
    93106}
     107
     108void StaticModel::updateBase()
     109{
     110  // write out the modelInfo data used for the collision detection!
     111  this->pModelInfo.pVertices = &this->data->getVertices()[0];
     112  this->pModelInfo.numVertices = this->data->getVertices().size();
     113  this->pModelInfo.pNormals = &this->data->getNormals()[0];
     114  this->pModelInfo.numNormals = this->data->getNormals().size();
     115  this->pModelInfo.pTexCoor = &this->data->getTexCoords()[0];
     116  this->pModelInfo.numTexCoor = this->data->getTexCoords().size();
     117
     118  this->pModelInfo.pTriangles = this->data->getTrianglesExt();
     119  this->pModelInfo.numTriangles = this->data->getTriangles().size();
     120}
     121
    94122
    95123/**
  • branches/new_class_id/src/lib/graphics/importer/static_model.h

    r9831 r9832  
    2424{
    2525  ObjectListDeclaration(StaticModel);
    26   public:
     26public:
    2727  StaticModel(const std::string& modelName = "");
     28  StaticModel(const StaticModel& staticModel);
    2829  virtual ~StaticModel();
    2930
    30   StaticModel& operator=(const StaticModel& model) { this->data = model.data; return *this; };
     31  StaticModel& operator=(const StaticModel& model);
    3132
    3233  virtual void draw() const { data->draw(); };
     
    5859  void finalize();
    5960
    60   void acquireData(const StaticModelData::Pointer& data) { this->data = data; };
     61  void acquireData(const StaticModelData::Pointer& data);
    6162  const StaticModelData::Pointer& dataPointer() const { return this->data; };
    6263
     
    6465  float getScaleFactor() const { return data->getScaleFactor(); }
    6566
    66  protected:
     67protected:
    6768  void cubeModel();
    6869
    69  private:
    70    StaticModelData::Pointer         data;
     70private:
     71  void updateBase();
     72private:
     73  StaticModelData::Pointer         data;
    7174};
    7275
  • 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.