Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Dec 21, 2005, 1:49:06 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the christmas branche to the trunk
merged with command:
svn merge -r6165:HEAD christmas_branche/ ../trunk/
no conflicts

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore set to
      Makefile.in
      Makefile
      configure
      *.kdevelop
      Doxyfile
      config.log
      config.h
      config.status
      stamp-h1
      autom4te.cache
      aclocal.m4
  • trunk/src

    • Property svn:ignore set to
      .deps
      orxonox
      Makefile
      Makefile.in

  • trunk/src/world_entities/world_entity.cc

    r6142 r6222  
    2121
    2222#include "model.h"
     23#include "md2Model.h"
    2324#include "resource_manager.h"
    2425#include "load_param.h"
    25 #include "list.h"
    2626#include "vector.h"
    2727#include "obb_tree.h"
     
    8484  // Do the PNode loading stuff
    8585  static_cast<PNode*>(this)->loadParams(root);
     86
     87  LoadParam(root, "md2texture", this, WorldEntity, loadMD2Texture)
     88      .describe("the fileName of the texture, that should be loaded onto this world-entity. (must be relative to the data-dir)")
     89      .defaultValues(1, NULL);
    8690
    8791  // Model Loading
     
    8993      .describe("the fileName of the model, that should be loaded onto this world-entity. (must be relative to the data-dir)")
    9094      .defaultValues(3, NULL, 1.0f, 0);
    91 
    92 }
     95}
     96
    9397
    9498/**
     
    103107  if (fileName != NULL)
    104108  {
    105     // search for the special character # in the LoadParam
     109   // search for the special character # in the LoadParam
    106110    if (strchr(fileName, '#') != NULL)
     111    {
     112      PRINTF(4)("Found # in %s... searching for LOD's\n", fileName);
     113      char* lodFile = new char[strlen(fileName)+1];
     114      strcpy(lodFile, fileName);
     115      char* depth = strchr(lodFile, '#');
     116      for (unsigned int i = 0; i < 5; i++)
    107117      {
    108         PRINTF(4)("Found # in %s... searching for LOD's\n", fileName);
    109         char* lodFile = new char[strlen(fileName)+1];
    110         strcpy(lodFile, fileName);
    111         char* depth = strchr(lodFile, '#');
    112         for (unsigned int i = 0; i < 5; i++)
    113           {
    114             *depth = 48+(int)i;
    115             printf("-------%s\n", lodFile);
    116             if (ResourceManager::isInDataDir(lodFile))
    117               this->loadModel(lodFile, scaling, i);
    118           }
    119         return;
     118        *depth = 48+(int)i;
     119        printf("-------%s\n", lodFile);
     120        if (ResourceManager::isInDataDir(lodFile))
     121          this->loadModel(lodFile, scaling, i);
    120122      }
    121 
    122     PRINTF(4)("fetching %s\n", fileName);
    123     if (scaling == 1.0)
    124       this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN), modelNumber);
    125     else
    126       this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, &scaling), modelNumber);
    127     if (modelNumber == 0)
    128     this->buildObbTree(4);
     123      return;
     124    }
     125
     126    if(strstr(fileName, ".obj"))
     127    {
     128      PRINTF(4)("fetching OBJ file: %s\n", fileName);
     129      if (scaling == 1.0)
     130        this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN), modelNumber);
     131      else
     132        this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, &scaling), modelNumber);
     133
     134      if( modelNumber == 0)
     135        this->buildObbTree(4);
     136    }
     137    else if(strstr(fileName, ".md2"))
     138    {
     139      PRINTF(4)("fetching MD2 file: %s\n", fileName);
     140      Model* m = new MD2Model(fileName, this->md2TextureFileName);
     141        //this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0);
     142      this->setModel(m, 0);
     143    }
    129144  }
    130145  else
     
    145160  {
    146161    Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(this->models[modelNumber]);
    147     if (resource != NULL)
    148       ResourceManager::getInstance()->unload(resource, RP_LEVEL);
    149     else
    150       delete this->models[modelNumber];
    151   }
     162//     if (resource != NULL)
     163    ResourceManager::getInstance()->unload(resource, RP_LEVEL);
     164  }
     165  else
     166    delete this->models[modelNumber];
     167
    152168  this->models[modelNumber] = model;
     169
    153170
    154171//   if (this->model != NULL)
     
    272289}
    273290
     291
     292/**
     293 *  this functions draws the model automaticaly in multiple LOD
     294 */
    274295void WorldEntity::drawLODsafe() const
    275296{
    276   if (!this->models.empty())
     297  if (!unlikely(this->models.empty()))
    277298  {
    278299    glMatrixMode(GL_MODELVIEW);
     
    291312    if (cameraDistance > 30 && this->models.size() >= 3 && this->models[2] != NULL)
    292313    {
    293        this->models[2]->draw();
     314      this->models[2]->draw();
    294315    }
    295316    else if (cameraDistance > 10 && this->models.size() >= 2 && this->models[1] != NULL)
Note: See TracChangeset for help on using the changeset viewer.