- Timestamp:
- Dec 16, 2008, 6:01:13 PM (17 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
-
code/branches/presentation/src/orxonox/objects/worldentities/WorldEntity.cc
r2481 r2485 95 95 { 96 96 this->node_->detachAllObjects(); 97 98 for (std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ) 99 delete (*(it++)); 100 101 if (this->parent_) 102 this->detachFromParent(); 103 104 this->node_->removeAllChildren(); 105 97 106 if (this->getScene()->getSceneManager()) 98 107 this->getScene()->getSceneManager()->destroySceneNode(this->node_->getName()); … … 140 149 void WorldEntity::registerVariables() 141 150 { 151 registerVariable(this->mainStateName_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainState)); 152 142 153 registerVariable(this->bActive_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity)); 143 154 registerVariable(this->bVisible_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility)); … … 212 223 } 213 224 225 void WorldEntity::attachNode(Ogre::SceneNode* node) 226 { 227 Ogre::Node* parent = node->getParent(); 228 if (parent) 229 parent->removeChild(node); 230 this->node_->addChild(node); 231 } 232 233 void WorldEntity::detachNode(Ogre::SceneNode* node) 234 { 235 this->node_->removeChild(node); 236 // this->getScene()->getRootSceneNode()->addChild(node); 237 } 238 239 void WorldEntity::attachToNode(Ogre::SceneNode* node) 240 { 241 Ogre::Node* parent = this->node_->getParent(); 242 if (parent) 243 parent->removeChild(this->node_); 244 node->addChild(this->node_); 245 } 246 247 void WorldEntity::detachFromNode(Ogre::SceneNode* node) 248 { 249 node->removeChild(this->node_); 250 // this->getScene()->getRootSceneNode()->addChild(this->node_); 251 } 252 214 253 void WorldEntity::attach(WorldEntity* object) 215 254 { … … 243 282 } 244 283 284 if (object == this) 285 { 286 COUT(2) << "Warning: Can't attach a WorldEntity to itself." << std::endl; 287 return; 288 } 289 245 290 if (object->getParent()) 246 291 object->detachFromParent(); 247 else 248 { 249 Ogre::Node* parent = object->node_->getParent(); 250 if (parent) 251 parent->removeChild(object->node_); 252 } 253 254 this->node_->addChild(object->node_); 292 293 this->attachNode(object->node_); 294 255 295 this->children_.insert(object); 256 296 object->parent_ = this; … … 275 315 } 276 316 277 this-> node_->removeChild(object->node_);317 this->detachNode(object->node_); 278 318 this->children_.erase(object); 279 319 object->parent_ = 0; 280 320 object->parentID_ = OBJECTID_UNKNOWN; 281 // this->getScene()->getRootSceneNode()->addChild(object->node_);282 321 283 322 // Note: It is possible that the object has physics but was disabled when attaching … … 466 505 467 506 this->node_->setScale(scale); 507 508 this->changedScale(); 509 } 510 511 const Vector3& WorldEntity::getWorldScale3D() const 512 { 513 return this->node_->_getDerivedScale(); 514 } 515 516 float WorldEntity::getWorldScale() const 517 { 518 Vector3 scale = this->getWorldScale3D(); 519 return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; 468 520 } 469 521
Note: See TracChangeset
for help on using the changeset viewer.