Changeset 1629 for code/branches/input/src/orxonox/objects/WorldEntity.cc
- Timestamp:
- Jun 27, 2008, 8:07:29 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/orxonox/objects/WorldEntity.cc
r1505 r1629 45 45 unsigned int WorldEntity::worldEntityCounter_s = 0; 46 46 47 WorldEntity::WorldEntity() : 48 velocity_ (0, 0, 0), 49 acceleration_(0, 0, 0), 50 rotationAxis_(0, 1, 0), 51 rotationRate_(0), 52 momentum_ (0), 53 node_ (0), 54 bStatic_ (true) 47 WorldEntity::WorldEntity() 55 48 { 56 49 RegisterObject(WorldEntity); … … 58 51 if (GraphicsEngine::getSingleton().getSceneManager()) 59 52 { 60 std::ostringstream name;61 name << (WorldEntity::worldEntityCounter_s++);62 this->setName("WorldEntity" + name.str());63 this->node_ = GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName());53 std::ostringstream name; 54 name << (WorldEntity::worldEntityCounter_s++); 55 this->setName("WorldEntity" + name.str()); 56 this->node_ = GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName()); 64 57 65 registerAllVariables();58 registerAllVariables(); 66 59 } 60 else 61 { 62 this->node_ = 0; 63 } 64 65 this->bStatic_ = true; 66 this->velocity_ = Vector3(0, 0, 0); 67 this->acceleration_ = Vector3(0, 0, 0); 68 this->rotationAxis_ = Vector3(0, 1, 0); 69 this->rotationRate_ = 0; 70 this->momentum_ = 0; 67 71 } 68 72 69 73 70 74 WorldEntity::~WorldEntity() 71 75 { 72 // just to make sure we clean out all scene nodes 73 if(this->getNode()) 74 this->getNode()->removeAndDestroyAllChildren(); 76 if (this->isInitialized()) 77 { 78 this->getNode()->removeAndDestroyAllChildren(); 79 GraphicsEngine::getSingleton().getSceneManager()->destroySceneNode(this->getName()); 80 } 75 81 } 76 82 77 83 void WorldEntity::tick(float dt) 78 84 { 79 if (!this->bStatic_ )85 if (!this->bStatic_ && this->isActive()) 80 86 { 81 87 // COUT(4) << "acceleration: " << this->acceleration_ << " velocity: " << this->velocity_ << std::endl; … … 89 95 } 90 96 91 void WorldEntity::loadParams(TiXmlElement* xmlElem)92 {93 94 BaseObject::loadParams(xmlElem);95 create();96 }97 98 97 99 98 void WorldEntity::setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll) … … 122 121 123 122 XMLPortObject(WorldEntity, WorldEntity, "attached", attachWorldEntity, getAttachedWorldEntity, xmlelement, mode, false, true); 124 123 125 124 WorldEntity::create(); 126 125 } … … 129 128 void WorldEntity::registerAllVariables() 130 129 { 130 // register inheritec variables from BaseObject 131 registerVar( (void*) &(this->bActive_), sizeof(this->bActive_), network::DATA, 0x3); 132 registerVar( (void*) &(this->bVisible_), sizeof(this->bVisible_), network::DATA, 0x3); 131 133 // register coordinates 132 134 registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA, 0x3); … … 163 165 { 164 166 this->attachedWorldEntities_.push_back(entity); 167 this->attachObject(entity); 165 168 } 166 169 … … 172 175 return 0; 173 176 } 177 178 void WorldEntity::attachObject(const WorldEntity& obj) const 179 { 180 GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->removeChild(obj.getNode()); 181 this->getNode()->addChild(obj.getNode()); 182 } 183 184 void WorldEntity::attachObject(WorldEntity* obj) const 185 { 186 GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->removeChild(obj->getNode()); 187 this->getNode()->addChild(obj->getNode()); 188 } 174 189 }
Note: See TracChangeset
for help on using the changeset viewer.