Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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

orxonox/trunk: preparations for LOD's

File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.