Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Mar 15, 2006, 3:10:45 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the std-branche back, it runs on windows and Linux

svn merge https://svn.orxonox.net/orxonox/branches/std . -r7202:HEAD

File:
1 edited

Legend:

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

    r7198 r7221  
    6161  this->bCollide = true;
    6262
    63   this->md2TextureFileName = NULL;
    64 
    6563  this->objectListNumber = OM_INIT;
    6664  this->objectListIterator = NULL;
     
    120118 * @param fileName the name of the model to load
    121119 * @param scaling the Scaling of the model
    122  *
    123  * @todo fix this, so it only has one loadModel-Function.
    124 */
    125 void WorldEntity::loadModel(const char* fileName, float scaling, unsigned int modelNumber)
     120 */
     121void WorldEntity::loadModel(const std::string& fileName, float scaling, unsigned int modelNumber)
    126122{
    127123  this->modelLODName = fileName;
    128124  this->scaling = scaling;
    129   if ( fileName != NULL && strcmp(fileName, "") )
     125  if (!fileName.empty())
    130126  {
    131127    // search for the special character # in the LoadParam
    132     if (strchr(fileName, '#') != NULL)
    133     {
    134       PRINTF(4)("Found # in %s... searching for LOD's\n", fileName);
    135       char* lodFile = new char[strlen(fileName)+1];
    136       strcpy(lodFile, fileName);
    137       char* depth = strchr(lodFile, '#');
     128    if (fileName.find('#') != std::string::npos)
     129    {
     130      PRINTF(4)("Found # in %s... searching for LOD's\n", fileName.c_str());
     131      std::string lodFile = fileName;
     132      unsigned int offset = lodFile.find('#');
    138133      for (unsigned int i = 0; i < 3; i++)
    139134      {
    140         *depth = 48+(int)i;
     135        lodFile[offset] = 48+(int)i;
    141136        if (ResourceManager::isInDataDir(lodFile))
    142137          this->loadModel(lodFile, scaling, i);
     
    149144      this->scaling = 1.0;
    150145    }
    151     if(strstr(fileName, ".obj"))
    152     {
    153       PRINTF(4)("fetching OBJ file: %s\n", fileName);
     146    if(fileName.find(".obj") != std::string::npos)
     147    {
     148      PRINTF(4)("fetching OBJ file: %s\n", fileName.c_str());
    154149      BaseObject* loadedModel = ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, this->scaling);
    155150      if (loadedModel != NULL)
    156151        this->setModel(dynamic_cast<Model*>(loadedModel), modelNumber);
     152      else
     153        PRINTF(1)("OBJ-File %s not found.\n", fileName.c_str());
    157154
    158155      if( modelNumber == 0)
    159156        this->buildObbTree(4);
    160157    }
    161     else if(strstr(fileName, ".md2"))
    162     {
    163       PRINTF(4)("fetching MD2 file: %s\n", fileName);
     158    else if(fileName.find(".md2") != std::string::npos)
     159    {
     160      PRINTF(4)("fetching MD2 file: %s\n", fileName.c_str());
    164161      Model* m = new MD2Model(fileName, this->md2TextureFileName, this->scaling);
    165162      //this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0);
     
    575572    char* name = (char*)(getModel( 0 )->getName());
    576573
    577     if ( strstr(name, ResourceManager::getInstance()->getDataDir()) )
    578     {
    579       name += strlen(ResourceManager::getInstance()->getDataDir());
     574    if (  ResourceManager::getInstance()->getDataDir() == name ) /// FIXME (do not know what to do here.)
     575    {
     576      name += ResourceManager::getInstance()->getDataDir().size();
    580577    }
    581578
Note: See TracChangeset for help on using the changeset viewer.