Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 24, 2005, 10:32:34 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/physics: merged the trunk back to branches/physics
merged with command
svn merge -r 4223:HEAD ../../trunk/ .
conflicts additively included

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/physics/src/world_entities/world_entity.cc

    r4178 r4283  
    2323#include "vector.h"
    2424
    25 //#include "stdincl.h"
    26 //#include "collision.h"
    27 
    2825using namespace std;
    2926
    3027/**
    31    \brief standard constructor
    32 */
    33 WorldEntity::WorldEntity ()
     28   \brief Loads the WordEntity-specific Part of any derived Class
     29*/
     30WorldEntity::WorldEntity(const TiXmlElement* root)
    3431{
    3532  this->setClassName ("WorldEntity");
     33  this->model = NULL;
     34
     35  if (root)
     36    this->loadParams(root);
     37
    3638  this->bDraw = true;
    37   this->model = NULL;
    38   //  collisioncluster = NULL;
    39 }
    40 
    41 /**
    42    \brief Loads the WordEntity-specific Part of any derived Class
    43 */
    44 WorldEntity::WorldEntity(TiXmlElement* root)
    45 {
    46   // Name Setup
    47   char* temp;
    48   const char* string;
    49   string = grabParameter( root, "name");
    50   if( string == NULL)
    51     {
    52       PRINTF(2)("WorldEntity is missing a proper 'name'\n");
    53       string = "Unknown";
    54       temp = new char[strlen(string + 2)];
    55       strcpy( temp, string);
    56       this->setName( temp);
    57     }
    58   else
    59     {
    60       temp = new char[strlen(string + 2)];
    61       strcpy( temp, string);
    62       this->setName( temp);
    63     }
     39}
     40
     41void WorldEntity::loadParams(const TiXmlElement* root)
     42{
     43  // name setup
     44  LoadParam<WorldEntity>(root, "name", this, &WorldEntity::setName)
     45    .describe("the name of the Object at hand");
     46
    6447  // Model Loading     
    65   this->model = NULL;
    66   string = grabParameter( root, "model");
    67   if( string != NULL)
    68     this->model = (Model*)ResourceManager::getInstance()->load(string, OBJ, RP_CAMPAIGN);
    69   else
    70     {
    71       PRINTF(2)("WorldEntity is missing a proper 'model'\n");
    72       this->model = NULL;
    73     }
    74   if( this->model == NULL)
    75     {
    76       PRINTF(2)("WorldEntity model '%s' could not be loaded\n", string);
    77     }
    78   this->bDraw = true;
     48  LoadParam<WorldEntity>(root, "model", this, &WorldEntity::loadModel)
     49    .describe("the fileName of the model, that should be loaded onto this world-entity. (must be relative to the data-dir)") ;
    7950}
    8051
     
    8758  if (this->model)
    8859    ResourceManager::getInstance()->unload(this->model);
     60}
     61
     62/**
     63   \brief loads a Model onto a WorldEntity
     64   \param fileName the name of the model to load
     65*/
     66void WorldEntity::loadModel(const char* fileName)
     67{
     68  if (this->model)
     69    ResourceManager::getInstance()->unload(this->model, RP_LEVEL);
     70  this->model = (Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN);
    8971}
    9072
Note: See TracChangeset for help on using the changeset viewer.