Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10232 in orxonox.OLD for branches/mount_points/src


Ignore:
Timestamp:
Jan 11, 2007, 12:10:24 AM (18 years ago)
Author:
patrick
Message:

mount point xml file parsing and object creation

Location:
branches/mount_points/src/world_entities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/mount_points/src/world_entities/mount_point.cc

    r10231 r10232  
    8484    while( element != NULL)
    8585    {
    86       BaseObject* created = Factory::fabricate(element);
    87       if( created != NULL )
    88         PRINTF(4)("Created a %s: %s\n", created->getClassCName(), created->getCName());
     86      std::string name = element->Value();
    8987
    90       //todo do this more elegant
    91       if( element->Value() == "SkyBox" && created->isA(SkyBox::staticClassID()))
     88      // check if we got the right mount point
     89      if( name == this->_name)
    9290      {
    93         this->sky = dynamic_cast<WorldEntity*>(created);
    94         State::setSkyBox(dynamic_cast<SkyBox*>(this->sky));
     91        // load it
     92        this->loadParam(element);
    9593      }
    96       if( element->Value() == "Terrain" && created->isA(Terrain::staticClassID()))
    97       {
    98         this->terrain = dynamic_cast<Terrain*>(created);
    99         CDEngine::getInstance()->setTerrain(terrain);
    100       }
     94
    10195      element = element->NextSiblingElement();
    102       this->glmis->step(); //! @todo temporary
    10396    }
    104     PRINTF(4)("Done loading WorldEntities\n");
    10597  }
     98}
     99
     100
     101
     102/**
     103 * load the parameters from the xml section
     104 * @param root the root element of this xml branche
     105 */
     106void MountPoint::loadParam(const TiXmlElement* root)
     107{
     108   LoadParam(root, "description", this, WorldEntity, setDescription)
     109    .describe("Sets this mount point a description");
     110
     111
     112   LoadParam(root, "OrxClass", this, WorldEntity, setOrxClass)
     113    .describe("Sets the class this mount points should host");
     114}
     115
     116
     117
     118/**
     119 * setst the description (optional) via xml tag
     120 * @param description string containing the description
     121 */
     122void MountPoint::setDescription(const std::string& description)
     123{
     124  this->_description = description;
     125}
     126
     127
     128
     129/**
     130 * sets the class of this mount point
     131 * @param orxClass class
     132 */
     133void MountPoint::setOrxClass(const std::string& orxClass)
     134{
     135  // create the object for this mount point
     136  this->_mount = Factory::fabricate(orxClass);
     137  // check if the object is created correctly
     138  if( this->_mount == NULL)
     139    PRINTF(1)("Couldn't create %s for this mount point (%s)\n", orxClass.c_str(), this->_name.c_str());
    106140}
    107141
  • branches/mount_points/src/world_entities/mount_point.h

    r10231 r10232  
    1717    void init();
    1818    void initMountPoint(const TiXmlElement* root);
     19    void loadParam(const TiXmlElement* root);
    1920
     21    void setDescription(const std::string& description);
     22    void setOrxClass(const std::string& orxClass);
    2023
    2124    virtual void tick (float time);
     
    3336    std::string          _name;        //!< the name of the mount point
    3437
     38    std::string          _description; //!< string containing an optional description
     39
    3540};
    3641
Note: See TracChangeset for help on using the changeset viewer.