Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Dec 9, 2005, 5:30:44 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: implemented the helicopter

File:
1 edited

Legend:

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

    r5996 r6002  
    2727#include "obb_tree.h"
    2828
     29#include "state.h"
     30
    2931using namespace std;
    3032
     
    9597    PRINTF(4)("fetching %s\n", fileName);
    9698    if (scaling == 1.0)
    97       this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN));
     99      this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN), modelNumber);
    98100    else
    99       this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, &scaling));
    100 
     101      this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, &scaling), modelNumber);
     102    if (modelNumber == 0)
    101103    this->buildObbTree(4);
    102104  }
     
    227229void WorldEntity::draw() const
    228230{
    229   glMatrixMode(GL_MODELVIEW);
    230   glPushMatrix();
    231   float matrix[4][4];
    232 
    233   /* translate */
    234   glTranslatef (this->getAbsCoor ().x,
    235                 this->getAbsCoor ().y,
    236                 this->getAbsCoor ().z);
    237   /* rotate */ // FIXME: devise a new Way to rotate this
    238   this->getAbsDir ().matrix (matrix);
    239   glMultMatrixf((float*)matrix);
    240 
    241   if (this->models[0])
    242     this->models[0]->draw();
    243   glPopMatrix();
     231  if (!this->models.empty())
     232  {
     233    glMatrixMode(GL_MODELVIEW);
     234    glPushMatrix();
     235    float matrix[4][4];
     236
     237    /* translate */
     238    glTranslatef (this->getAbsCoor ().x,
     239                  this->getAbsCoor ().y,
     240                  this->getAbsCoor ().z);
     241   /* rotate */ // FIXME: devise a new Way to rotate this
     242    this->getAbsDir ().matrix (matrix);
     243    glMultMatrixf((float*)matrix);
     244
     245    float cameraDistance = (State::getCamera()->getAbsCoor() - this->getAbsCoor()).len();
     246    if (this->isA(CL_HELICOPTER))
     247        printf("Test %f %d\n", cameraDistance, this->models.size());
     248    if (cameraDistance > 100 && this->models.size() >= 3 && this->models[2] != NULL)
     249    {
     250      if (this->isA(CL_HELICOPTER))printf("====== 2 ===\n");
     251       this->models[2]->draw();
     252    }
     253    else if (cameraDistance > 50 && this->models.size() >= 2 && this->models[1] != NULL)
     254    {
     255      if (this->isA(CL_HELICOPTER))printf("====== 1 ===\n");
     256      this->models[1]->draw();
     257    }
     258    else if (this->models.size() >= 1 && this->models[0] != NULL)
     259    {
     260      if (this->isA(CL_HELICOPTER))printf("====== 0 ===\n");
     261      this->models[0]->draw();
     262    }
     263    glPopMatrix();
     264  }
    244265}
    245266
Note: See TracChangeset for help on using the changeset viewer.