Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5995 in orxonox.OLD for trunk/src/world_entities


Ignore:
Timestamp:
Dec 9, 2005, 11:26:02 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: preparations for LOD's

Location:
trunk/src/world_entities
Files:
2 edited

Legend:

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

    r5994 r5995  
    4444  this->setClassID(CL_WORLD_ENTITY, "WorldEntity");
    4545
    46   this->model = NULL;
    4746  this->obbTree = NULL;
    4847
    49   if (root)
     48  if (root != NULL)
    5049    this->loadParams(root);
    5150
     
    7877  LoadParam(root, "model", this, WorldEntity, loadModel)
    7978      .describe("the fileName of the model, that should be loaded onto this world-entity. (must be relative to the data-dir)")
    80       .defaultValues(2, NULL, 1.0f);
     79      .defaultValues(3, NULL, 1.0f, 0);
    8180
    8281}
     
    8988 * @todo fix this, so it only has one loadModel-Function.
    9089*/
    91 void WorldEntity::loadModel(const char* fileName, float scaling)
     90void WorldEntity::loadModel(const char* fileName, float scaling, unsigned int modelNumber)
    9291{
    9392  if (fileName != NULL)
     
    102101  }
    103102  else
    104     this->model = NULL;
     103    this->setModel(NULL);
    105104}
    106105
     
    112111void WorldEntity::setModel(Model* model, unsigned int modelNumber)
    113112{
    114   if (this->model != NULL)
     113  if (this->models.size() <= modelNumber)
     114    this->models.resize(modelNumber+1, NULL);
     115
     116  if (this->models[modelNumber] != NULL)
    115117  {
    116     Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(this->model);
     118    Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(this->models[modelNumber]);
    117119    if (resource != NULL)
    118120      ResourceManager::getInstance()->unload(resource, RP_LEVEL);
    119121    else
    120       delete this->model;
    121   }
    122   this->model = model;
     122      delete this->models[modelNumber];
     123  }
     124  this->models[modelNumber] = model;
    123125
    124126//   if (this->model != NULL) 
     
    136138    delete this->obbTree;
    137139
    138   if (this->model != NULL)
     140  if (this->models[0] != NULL)
    139141  {
    140142    PRINTF(4)("creating obb tree\n");
    141143
    142144
    143     this->obbTree = new OBBTree(depth, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());
     145    this->obbTree = new OBBTree(depth, (sVec3D*)this->models[0]->getVertexArray(), this->models[0]->getVertexCount());
    144146    return true;
    145147  }
     
    236238  glMultMatrixf((float*)matrix);
    237239
    238   if (this->model)
    239     this->model->draw();
     240  if (this->models[0])
     241    this->models[0]->draw();
    240242  glPopMatrix();
    241243}
  • trunk/src/world_entities/world_entity.h

    r5994 r5995  
    1010
    1111#include "glincl.h"
     12#include <vector>
    1213
    1314// FORWARD DECLARATION
     
    2930  void loadParams(const TiXmlElement* root);
    3031
    31   void loadModel(const char* fileName, float scaling = 1.0f);
     32  void loadModel(const char* fileName, float scaling = 1.0f, unsigned int modelNumber = 0);
    3233  void setModel(Model* model, unsigned int modelNumber = 0);
    33   Model* getModel(unsigned int modelNumber = 0) const { return this->model; };
     34  Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; };
    3435
    3536  bool buildObbTree(unsigned int depth);
     
    6566
    6667 private:
    67   Model*                  model;            //!< The model that should be loaded for this entity.
     68  std::vector<Model*>     models;            //!< The model that should be loaded for this entity.
    6869  BVTree*                 obbTree;          //!< this is the obb tree reference needed for collision detection
    6970
Note: See TracChangeset for help on using the changeset viewer.