Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6169 in orxonox.OLD for branches/christmas_branche/src


Ignore:
Timestamp:
Dec 20, 2005, 12:22:17 AM (18 years ago)
Author:
patrick
Message:

christmas: model loading progress

Location:
branches/christmas_branche/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/christmas_branche/src/lib/event/event_handler.cc

    r6167 r6169  
    259259{
    260260  this->eventsGrabbed = grabEvents;
    261 //   if(!grabEvents)
    262 //     SDL_WM_GrabInput(SDL_GRAB_OFF);
    263 //   else
    264 //     SDL_WM_GrabInput(SDL_GRAB_ON);
     261  if(!grabEvents)
     262    SDL_WM_GrabInput(SDL_GRAB_OFF);
     263  else
     264    SDL_WM_GrabInput(SDL_GRAB_ON);
    265265}
    266266
  • branches/christmas_branche/src/lib/graphics/importer/md2Model.cc

    r6022 r6169  
    156156{
    157157  this->animationState.localTime += time;
     158
     159  if( likely(this->animationState.localTime > 0.0))
     160    this->animate();
     161
     162  static sVec3D verticesList[MD2_MAX_VERTICES]; /* performance: created only once in a lifetime */
     163  this->processLighting();
     164  this->interpolate(verticesList);
    158165}
    159166
     
    164171 * FIXME
    165172 */
    166 void MD2Model::draw()
    167 {
    168   if( likely(this->animationState.localTime > 0.0))
    169     this->animate();
    170 
    171   glPushMatrix();
     173void MD2Model::draw() const
     174{
     175//   glPushMatrix();
    172176
    173177  this->renderFrame();
    174178
    175   glPopMatrix();
     179//   glPopMatrix();
    176180}
    177181
     
    180184  \brief this is an internal function to render this special frame selected by animate()
    181185*/
    182 void MD2Model::renderFrame()
     186void MD2Model::renderFrame() const
    183187{
    184188  static sVec3D verticesList[MD2_MAX_VERTICES]; /* performance: created only once in a lifetime */
     
    191195  glCullFace(GL_BACK);
    192196
    193   this->processLighting();
    194   this->interpolate(verticesList);
     197
    195198  this->data->material->select();
    196199
     
    406409        }
    407410    }
     411    PRINTF(4)("Finished loading the md2 file\n");
    408412
    409413  delete [] buffer;
  • branches/christmas_branche/src/lib/graphics/importer/md2Model.h

    r6022 r6169  
    143143  virtual ~MD2Model();
    144144
    145   void draw();
     145  virtual void draw() const;
    146146
    147147  void setAnim(int type);
     
    160160  void processLighting();
    161161  void interpolate(sVec3D* verticesList);
    162   void renderFrame();
     162  void renderFrame() const;
    163163
    164164
  • branches/christmas_branche/src/util/loading/resource_manager.cc

    r5994 r6169  
    389389              else
    390390                tmpResource->secFileName = NULL;
    391               tmpResource->pointer = new MD2Data(fullName, tmpResource->secFileName);
     391                tmpResource->pointer = new MD2Data(fullName, tmpResource->secFileName);
     392//               tmpResource->pointer = new MD2Model(fullName, tmpResource->secFileName);
     393
    392394            }
    393395              break;
  • branches/christmas_branche/src/world_entities/space_ships/space_ship.cc

    r6162 r6169  
    267267  velocity += ((this->getAbsDirX())*travelSpeed-velocity)*airViscosity;
    268268  velocity = (velocity.getNormalized())*travelSpeed;
    269  
     269
    270270  //orient the spaceship in direction of the mouse
    271271   rotQuat = Quaternion::quatSlerp( this->getAbsDir(),mouseDir,fabsf(time)*3);
    272    if (this->getAbsDir().distance(rotQuat) > 0.001) 
     272   if (this->getAbsDir().distance(rotQuat) > 0.001)
    273273    this->setAbsDir( rotQuat);
    274274   //this->setAbsDirSoft(mouseDir,5);
    275    
     275
    276276  // this is the air friction (necessary for a smooth control)
    277277  if(velocity.len() != 0) velocity -= velocity*0.01;
     
    312312     //this->shiftCoor(this->getAbsDirX());
    313313      accel += (this->getAbsDirX())*2;
    314      
     314
    315315      /* Heli-Steuerung
    316316         accel += (this->getAbsDirX()*2;
  • branches/christmas_branche/src/world_entities/world_entity.cc

    r6167 r6169  
    2121
    2222#include "model.h"
     23#include "md2Model.h"
    2324#include "resource_manager.h"
    2425#include "load_param.h"
     
    5657  this->objectListNumber = OM_INIT;
    5758  this->objectListIterator = NULL;
     59  this->supportsLOD = false;
    5860
    5961  this->toList(OM_NULL);
     
    117119              this->loadModel(lodFile, scaling, i);
    118120          }
     121          this->supportsLOD = true;
    119122        return;
    120123      }
     
    134137      {
    135138        PRINTF(4)("fetching MD2 file: %s\n", fileName);
    136         this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0);
     139//         MD2Model* m = (MD2Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN);
     140        MD2Model* m = new MD2Model(fileName, "/home/boenzlip/orxonox/data/maps/santa_claus.pcx");
     141        m->debug();
     142        //this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0);
     143        this->setModel((Model*)m, 0);
    137144      }
    138145  }
     
    154161  {
    155162    Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(this->models[modelNumber]);
    156     if (resource != NULL)
    157       ResourceManager::getInstance()->unload(resource, RP_LEVEL);
    158     else
    159       delete this->models[modelNumber];
    160   }
     163//     if (resource != NULL)
     164    ResourceManager::getInstance()->unload(resource, RP_LEVEL);
     165  }
     166  else
     167    delete this->models[modelNumber];
     168
    161169  this->models[modelNumber] = model;
     170
    162171
    163172//   if (this->model != NULL)
     
    281290}
    282291
     292
     293/**
     294 *  this functions draws the model automaticaly in multiple LOD
     295 */
    283296void WorldEntity::drawLODsafe() const
    284297{
    285   if (!this->models.empty())
    286   {
    287     glMatrixMode(GL_MODELVIEW);
    288     glPushMatrix();
    289 
    290     /* translate */
    291     glTranslatef (this->getAbsCoor ().x,
    292                   this->getAbsCoor ().y,
    293                   this->getAbsCoor ().z);
    294     Vector tmpRot = this->getAbsDir().getSpacialAxis();
    295     glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
     298  if (!unlikely(this->models.empty()))
     299  {
     300    if( likely(this->supportsLOD))
     301    {
     302      glMatrixMode(GL_MODELVIEW);
     303      glPushMatrix();
     304
     305      /* translate */
     306      glTranslatef (this->getAbsCoor ().x,
     307                    this->getAbsCoor ().y,
     308                    this->getAbsCoor ().z);
     309      Vector tmpRot = this->getAbsDir().getSpacialAxis();
     310      glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
    296311
    297312
    298313    // This Draws the LOD's
    299     float cameraDistance = (State::getCamera()->getAbsCoor() - this->getAbsCoor()).len();
    300     if (cameraDistance > 30 && this->models.size() >= 3 && this->models[2] != NULL)
     314      float cameraDistance = (State::getCamera()->getAbsCoor() - this->getAbsCoor()).len();
     315      if (cameraDistance > 30 && this->models.size() >= 3 && this->models[2] != NULL)
     316      {
     317        this->models[2]->draw();
     318      }
     319      else if (cameraDistance > 10 && this->models.size() >= 2 && this->models[1] != NULL)
     320      {
     321        this->models[1]->draw();
     322      }
     323      else if (this->models.size() >= 1 && this->models[0] != NULL)
     324      {
     325        this->models[0]->draw();
     326      }
     327      glPopMatrix();
     328    }
     329    else // no LOD
    301330    {
    302        this->models[2]->draw();
     331      glMatrixMode(GL_MODELVIEW);
     332      glPushMatrix();
     333
     334      /* translate */
     335      glTranslatef (this->getAbsCoor ().x,
     336                    this->getAbsCoor ().y,
     337                    this->getAbsCoor ().z);
     338      Vector tmpRot = this->getAbsDir().getSpacialAxis();
     339      glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
     340
     341      this->models[0]->draw();
     342
     343      glPopMatrix();
    303344    }
    304     else if (cameraDistance > 10 && this->models.size() >= 2 && this->models[1] != NULL)
    305     {
    306       this->models[1]->draw();
    307     }
    308     else if (this->models.size() >= 1 && this->models[0] != NULL)
    309     {
    310       this->models[0]->draw();
    311     }
    312     glPopMatrix();
    313   }
     345  }
     346
    314347}
    315348
  • branches/christmas_branche/src/world_entities/world_entity.h

    r6142 r6169  
    7777 private:
    7878  std::vector<Model*>     models;             //!< The model that should be loaded for this entity.
     79  bool                    supportsLOD;        //!< If this model format supports LOD (level of detail) this is true
    7980  BVTree*                 obbTree;            //!< this is the obb tree reference needed for collision detection
    8081
Note: See TracChangeset for help on using the changeset viewer.