Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/objects/BaseEntity.cc @ 627

Last change on this file since 627 was 616, checked in by nicolasc, 17 years ago

changed include names to new file names…<

File size: 1.7 KB
Line 
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
11namespace 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        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     WorldEntity::registerAllVariables();
45     registerVar(&name_, name_.length()+1, network::STRING);
46     registerVar(&mesh_, mesh_.length()+1, network::STRING);
47     registerVar(&node_, node_.length()+1, network::STRING);
48   }
49
50   bool BaseEntity::create(){
51     if(!valid)
52       return false;
53     // get the node
54     this->setNode(Orxonox::getSingleton()->getSceneManager()->getSceneNode(node_));
55     Ogre::SceneManager* mgr = orxonox::Orxonox::getSingleton()->getSceneManager();
56
57     Ogre::Entity* entity = mgr->createEntity(name_, mesh_);
58
59     //Ogre::MovableObject *ent = (Ogre::MovableObject *)entity;
60     getNode()->attachObject(entity); // big problem here: sigsegv
61     return true;
62   }
63}
Note: See TracBrowser for help on using the repository browser.