Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4283 in orxonox.OLD for orxonox/branches/physics/src/world_entities


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

Location:
orxonox/branches/physics/src/world_entities
Files:
6 edited
2 copied

Legend:

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

    r4178 r4283  
    8080   \todo add more parameters to load
    8181*/
    82 Player::Player(TiXmlElement* root) : WorldEntity(root)
     82Player::Player(const TiXmlElement* root) : WorldEntity(root)
    8383{
    8484  this->weapons = new tList<Weapon>();
  • orxonox/branches/physics/src/world_entities/player.h

    r4178 r4283  
    2222 public:
    2323  Player();
    24   Player(TiXmlElement* root);
     24  Player(const TiXmlElement* root);
    2525  virtual ~Player();
    2626
  • orxonox/branches/physics/src/world_entities/skybox.cc

    r4178 r4283  
    1111
    1212   ### File Specific:
    13    main-programmer: David Gruetter
    14    co-programmer: Benjamin Grauer
    15    
    16    Created by Dave: this file is actually quite similar to player.cc and so is
    17    skybox.h similar to player.h
    18    With that said, things should be clear:)
    19    
    20    Edited:
    21    Bensch: more constructors, changeability, comments...
    22    Patrick: giving it the common orxonox style, not much to do... good work Dave!
    23 
     13   main-programmer: Benjamin Grauer
     14   co-programmer: ...
    2415*/
    2516
     
    4637   \param fileName the file to take as input for the SkyBox
    4738*/
    48 SkyBox::SkyBox(char* fileName)
     39SkyBox::SkyBox(const char* fileName)
    4940{
    5041  this->preInit();
     42  if (fileName)
     43    this->setTextureAndType(fileName, ".jpg");
    5144  this->postInit();
    5245}
    5346
    54 SkyBox::SkyBox(TiXmlElement* root) : WorldEntity(root)
     47SkyBox::SkyBox(const TiXmlElement* root) : WorldEntity(root)
    5548{
    5649  this->preInit();
    5750
    58   const char* string;
    59 
    60   // Model Loading     
    61   string = grabParameter( root, "materialset");
    62   if( string != NULL)
    63     this->setTexture(string, "jpg");
    64   else
    65     {
    66       PRINTF(0)("SkyBox is missing a proper 'MaterialSet'\n");
    67     }
    68   if( this->skyModel == NULL)
    69     {
    70       PRINTF(0)("SkyBox model '%s' could not be loaded\n", string);
    71     }
     51  this->loadParams(root);
     52
    7253  this->postInit();
     54}
     55
     56void SkyBox::loadParams(const TiXmlElement* root)
     57{
     58  LoadParam<SkyBox>(root, "Materialset", this, &SkyBox::setTexture)
     59    .describe("Sets the material on the SkyBox. The string must be the path relative to the data-dir, and without a trailing .jpg");
    7360}
    7461
     
    116103               "skybox_right.jpg", "skybox_front.jpg", "skybox_back.jpg");
    117104*/
    118 void SkyBox::setTexture(const char* name, const char* extension)
     105void SkyBox::setTextureAndType(const char* name, const char* extension)
    119106{
    120107  char* top    = new char[strlen(name)+strlen(extension)+ 10];
     
    219206
    220207  this->skyModel->setMaterial(material[0]);
    221   this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 2,1,3, 3,2,3, 5,3,3, 4,0,3); // top
     208  this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 2,0,3, 3,1,3, 5,2,3, 4,3,3); // top
    222209  this->skyModel->setMaterial(material[1]);
    223   this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,3,1, 7,0,1, 1,1,1, 0,2,1); // bottom
     210  this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,1, 7,1,1, 1,2,1, 0,3,1); // bottom
    224211  this->skyModel->setMaterial(material[2]);
    225   this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 0,0,2, 1,1,2, 3,2,2, 2,3,2); // left
     212  this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 4,2,2, 5,3,2, 7,0,2, 6,1,2); // left
    226213  this->skyModel->setMaterial(material[3]);
    227   this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 4,2,0, 5,3,0, 7,0,0, 6,1,0); // right
     214  this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 0,0,0, 1,1,0, 3,2,0, 2,3,0); // right
    228215  this->skyModel->setMaterial(material[4]);
    229   this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,0,5, 7,1,5, 5,2,5, 3,3,6); // front
     216  this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,0,5, 7,1,5, 5,2,5, 3,3,5); // front
    230217  this->skyModel->setMaterial(material[5]);
    231218  this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,4, 0,1,4, 2,2,4, 4,3,4); // back
  • orxonox/branches/physics/src/world_entities/skybox.h

    r4178 r4283  
    2121{
    2222 public:
    23   SkyBox(char* fileName = NULL);
    24   SkyBox(TiXmlElement* root);
     23  SkyBox(const char* fileName = NULL);
     24  SkyBox(const TiXmlElement* root);
    2525
    2626  virtual ~SkyBox();
     27
     28  void loadParams(const TiXmlElement* root);
    2729
    2830  void preInit(void);
     
    3133
    3234  void setSize(float size);
    33   void setTexture(const char* name, const char* extension);
     35  /** \brief assumes jpg as input-format */
     36  void setTexture(const char* name) { setTextureAndType (name, "jpg");};
     37  void setTextureAndType(const char* name, const char* extension);
    3438  void setTextures(const char* top, const char* bottom, const char* left, const char* right, const char* front, const char* back);
    3539
  • 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
  • orxonox/branches/physics/src/world_entities/world_entity.h

    r4178 r4283  
    1010#include "comincl.h"
    1111#include "resource_manager.h"
     12#include "factory.h"
     13#include "load_param.h"
    1214
    1315
     
    1517class CharacterAttributes;
    1618class Model;
    17 
    18 
    1919//! Basic class from which all interactive stuff in the world is derived from
    2020class WorldEntity : public PNode
     
    2323
    2424 public:
    25   WorldEntity (void);
    26   WorldEntity(TiXmlElement* root);
     25  WorldEntity(const TiXmlElement* root = NULL);
    2726  virtual ~WorldEntity ();
    2827
     28  void loadParams(const TiXmlElement* root);
     29  void loadModel(const char* fileName);
    2930
    3031  //void setCollision (CollisionCluster* newhull);
Note: See TracChangeset for help on using the changeset viewer.