Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 7, 2008, 2:06:41 AM (16 years ago)
Author:
landauf
Message:

added support for isVisible() and isActive() to all objects.
those functions are provided by BaseObject, combined with virtual functions changedVisibility and changedActivity respectively.
use them, to make orxonox scriptable, say: to change the state of objects with 2 simple functions instead of changing all meshes and emitters and billboards of an object. don't forget to pass calls to changedVisibility and changedActivity to the parent class.

additionally there is a new function, isInitialized(), provided by BaseObject too. this returns true if the constructor of BaseObject passed the object registration. this allows you, to check whether an object was properly initialized or if the constructor returned (as this is the case while creating the class hierarchy). use isInitialized() in your destructor before deleting something.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/objects/SpaceShip.cc

    r1553 r1558  
    251251    }
    252252
     253    void SpaceShip::changedVisibility()
     254    {
     255        Model::changedVisibility();
     256
     257        this->tt1_->setEnabled(this->isVisible());
     258        this->tt2_->setEnabled(this->isVisible());
     259        this->redBillboard_.setVisible(this->isVisible());
     260        this->greenBillboard_.setVisible(this->isVisible());
     261        this->crosshairNear_.setVisible(this->isVisible());
     262        this->crosshairFar_.setVisible(this->isVisible());
     263    }
     264
     265    void SpaceShip::changedActivity()
     266    {
     267        Model::changedActivity();
     268
     269        this->tt1_->setEnabled(this->isVisible());
     270        this->tt2_->setEnabled(this->isVisible());
     271        this->redBillboard_.setVisible(this->isVisible());
     272        this->greenBillboard_.setVisible(this->isVisible());
     273        this->crosshairNear_.setVisible(this->isVisible());
     274        this->crosshairFar_.setVisible(this->isVisible());
     275    }
     276
    253277    void SpaceShip::setCamera(const std::string& camera)
    254278    {
     
    347371    void SpaceShip::tick(float dt)
    348372    {
     373        if (!this->isActive())
     374            return;
     375
    349376        currentDir_ = getOrientation()*initialDir_;
    350377                currentOrth_ = getOrientation()*initialOrth_;
Note: See TracChangeset for help on using the changeset viewer.