| [566] | 1 | #include <OgreSceneManager.h> | 
|---|
 | 2 | #include <string> | 
|---|
 | 3 |  | 
|---|
| [614] | 4 | #include "../Orxonox.h" | 
|---|
| [566] | 5 | #include "../../tinyxml/tinyxml.h" | 
|---|
 | 6 | #include "../../misc/Tokenizer.h" | 
|---|
 | 7 | #include "../../misc/String2Number.h" | 
|---|
 | 8 |  | 
|---|
 | 9 | #include "BaseEntity.h" | 
|---|
 | 10 |  | 
|---|
 | 11 | namespace orxonox | 
|---|
 | 12 | { | 
|---|
 | 13 |     CreateFactory(BaseEntity); | 
|---|
 | 14 |  | 
|---|
 | 15 |     BaseEntity::BaseEntity() | 
|---|
 | 16 |     { | 
|---|
 | 17 |         RegisterObject(BaseEntity); | 
|---|
 | 18 |         valid=false; | 
|---|
 | 19 |     } | 
|---|
 | 20 |  | 
|---|
 | 21 |     BaseEntity::~BaseEntity() | 
|---|
 | 22 |     { | 
|---|
 | 23 |     } | 
|---|
 | 24 |  | 
|---|
 | 25 |     void BaseEntity::loadParams(TiXmlElement* xmlElem) | 
|---|
 | 26 |     { | 
|---|
 | 27 |         if (xmlElem->Attribute("name") && xmlElem->Attribute("src")) | 
|---|
 | 28 |         { | 
|---|
 | 29 |         // save params | 
|---|
 | 30 |         name_ = xmlElem->Attribute("name"); | 
|---|
 | 31 |         mesh_ = xmlElem->Attribute("src"); | 
|---|
| [590] | 32 |         node_ = xmlElem->Attribute("node"); | 
|---|
| [580] | 33 |  | 
|---|
| [566] | 34 |         // register variables to be synchronised | 
|---|
 | 35 |         registerAllVariables(); | 
|---|
 | 36 |         valid=true; | 
|---|
 | 37 |         create(); | 
|---|
 | 38 |  | 
|---|
| [590] | 39 |                 std::cout << "Loader: Created entity "<< name_ <<" with source " << mesh_  << " at node " << node_  << std::endl << std::endl; | 
|---|
| [566] | 40 |         } | 
|---|
 | 41 |    } | 
|---|
| [616] | 42 |  | 
|---|
| [566] | 43 |    void BaseEntity::registerAllVariables(){ | 
|---|
| [567] | 44 |      WorldEntity::registerAllVariables(); | 
|---|
| [566] | 45 |      registerVar(&name_, name_.length()+1, network::STRING); | 
|---|
 | 46 |      registerVar(&mesh_, mesh_.length()+1, network::STRING); | 
|---|
| [590] | 47 |      registerVar(&node_, node_.length()+1, network::STRING); | 
|---|
| [566] | 48 |    } | 
|---|
| [616] | 49 |  | 
|---|
| [566] | 50 |    bool BaseEntity::create(){ | 
|---|
 | 51 |      if(!valid) | 
|---|
 | 52 |        return false; | 
|---|
| [590] | 53 |      // get the node | 
|---|
 | 54 |      this->setNode(Orxonox::getSingleton()->getSceneManager()->getSceneNode(node_)); | 
|---|
| [566] | 55 |      Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager(); | 
|---|
| [616] | 56 |  | 
|---|
| [566] | 57 |      Ogre::Entity* entity = mgr->createEntity(name_, mesh_); | 
|---|
| [616] | 58 |  | 
|---|
| [580] | 59 |      //Ogre::MovableObject *ent = (Ogre::MovableObject *)entity; | 
|---|
 | 60 |      getNode()->attachObject(entity); // big problem here: sigsegv | 
|---|
| [566] | 61 |      return true; | 
|---|
 | 62 |    } | 
|---|
 | 63 | } | 
|---|