Rev | Line | |
---|
[566] | 1 | #include <OgreSceneManager.h> |
---|
| 2 | #include <string> |
---|
| 3 | |
---|
| 4 | #include "../orxonox.h" |
---|
| 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"); |
---|
| 32 | std::string node = xmlElem->Attribute("node"); |
---|
| 33 | |
---|
| 34 | // register variables to be synchronised |
---|
| 35 | registerAllVariables(); |
---|
| 36 | valid=true; |
---|
| 37 | create(); |
---|
| 38 | |
---|
| 39 | std::cout << "Loader: Created entity "<< name_ <<" with source " << mesh_ << " at node " << node << std::endl << std::endl; |
---|
| 40 | } |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | void BaseEntity::registerAllVariables(){ |
---|
| 44 | registerVar(&name_, name_.length()+1, network::STRING); |
---|
| 45 | registerVar(&mesh_, mesh_.length()+1, network::STRING); |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | bool BaseEntity::create(){ |
---|
| 49 | if(!valid) |
---|
| 50 | return false; |
---|
| 51 | Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager(); |
---|
| 52 | |
---|
| 53 | Ogre::Entity* entity = mgr->createEntity(name_, mesh_); |
---|
| 54 | |
---|
| 55 | Ogre::MovableObject *ent = (Ogre::MovableObject *)entity; |
---|
| 56 | getNode()->attachObject(ent); // big problem here: sigsegv |
---|
| 57 | return true; |
---|
| 58 | } |
---|
| 59 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.