Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 16, 2008, 6:01:13 PM (17 years ago)
Author:
landauf
Message:

Merged objecthierarchy2 into presentation branch

Couln't merge 2 lines in Gamestate.cc and a whole block of code in GSDedicated.cc (it seems like oli implemented in both branches something like a network-tick-limiter but with different approaches)

Not yet tested in network mode and with bots
The SpaceShips movement is also not yet fully adopted to the new physics (see Engine class)

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  
    9595        {
    9696            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
    97106            if (this->getScene()->getSceneManager())
    98107                this->getScene()->getSceneManager()->destroySceneNode(this->node_->getName());
     
    140149    void WorldEntity::registerVariables()
    141150    {
     151        registerVariable(this->mainStateName_,  variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainState));
     152
    142153        registerVariable(this->bActive_,        variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
    143154        registerVariable(this->bVisible_,       variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));
     
    212223    }
    213224
     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
    214253    void WorldEntity::attach(WorldEntity* object)
    215254    {
     
    243282        }
    244283
     284        if (object == this)
     285        {
     286            COUT(2) << "Warning: Can't attach a WorldEntity to itself." << std::endl;
     287            return;
     288        }
     289
    245290        if (object->getParent())
    246291            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
    255295        this->children_.insert(object);
    256296        object->parent_ = this;
     
    275315        }
    276316
    277         this->node_->removeChild(object->node_);
     317        this->detachNode(object->node_);
    278318        this->children_.erase(object);
    279319        object->parent_ = 0;
    280320        object->parentID_ = OBJECTID_UNKNOWN;
    281 //        this->getScene()->getRootSceneNode()->addChild(object->node_);
    282321
    283322        // Note: It is possible that the object has physics but was disabled when attaching
     
    466505
    467506        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;
    468520    }
    469521
Note: See TracChangeset for help on using the changeset viewer.