Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 27, 2008, 8:07:29 AM (16 years ago)
Author:
rgrieder
Message:

updated input branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/input/src/orxonox/objects/WorldEntity.cc

    r1505 r1629  
    4545    unsigned int WorldEntity::worldEntityCounter_s = 0;
    4646
    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()
    5548    {
    5649        RegisterObject(WorldEntity);
     
    5851        if (GraphicsEngine::getSingleton().getSceneManager())
    5952        {
    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());
    6457
    65           registerAllVariables();
     58            registerAllVariables();
    6659        }
     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;
    6771    }
    68    
     72
    6973
    7074    WorldEntity::~WorldEntity()
    7175    {
    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        }
    7581    }
    7682
    7783    void WorldEntity::tick(float dt)
    7884    {
    79         if (!this->bStatic_)
     85        if (!this->bStatic_ && this->isActive())
    8086        {
    8187//             COUT(4) << "acceleration: " << this->acceleration_ << " velocity: " << this->velocity_ << std::endl;
     
    8995    }
    9096
    91     void WorldEntity::loadParams(TiXmlElement* xmlElem)
    92     {
    93 
    94         BaseObject::loadParams(xmlElem);
    95         create();
    96     }
    97    
    9897
    9998    void WorldEntity::setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll)
     
    122121
    123122        XMLPortObject(WorldEntity, WorldEntity, "attached", attachWorldEntity, getAttachedWorldEntity, xmlelement, mode, false, true);
    124        
     123
    125124        WorldEntity::create();
    126125    }
     
    129128    void WorldEntity::registerAllVariables()
    130129    {
     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);
    131133      // register coordinates
    132134      registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA, 0x3);
     
    163165    {
    164166        this->attachedWorldEntities_.push_back(entity);
     167        this->attachObject(entity);
    165168    }
    166169
     
    172175            return 0;
    173176    }
     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    }
    174189}
Note: See TracChangeset for help on using the changeset viewer.