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/Skybox.cc

    r1505 r1558  
    5454    }
    5555
    56     void Skybox::loadParams(TiXmlElement* xmlElem)
     56    void Skybox::setSkybox(const std::string& skyboxname)
    5757    {
    58         if (xmlElem->Attribute("src"))
    59         {
    60                 skyboxSrc_ = xmlElem->Attribute("src");
    61         this->create();
     58        GraphicsEngine::getSingleton().getSceneManager()->setSkyBox(true, skyboxname);
     59    }
    6260
    63                 COUT(4) << "Loader: Set skybox: "<< skyboxSrc_ << std::endl << std::endl;
    64         }
    65    }
     61    void Skybox::setSkyboxSrc(const std::string& src)
     62    {
     63        this->skyboxSrc_ = src;
     64    }
    6665
    67    void Skybox::setSkybox(const std::string& skyboxname)
    68    {
    69         GraphicsEngine::getSingleton().getSceneManager()->setSkyBox(true, skyboxname);
    70    }
    71 
    72    void Skybox::setSkyboxSrc(const std::string& src){
    73      skyboxSrc_ = src;
    74    }
    75    
    7666    /**
    7767        @brief XML loading and saving.
     
    8777        create();
    8878    }
    89    
    90     bool Skybox::create(){
    91       this->setSkybox(skyboxSrc_);
    92       return Synchronisable::create();
     79
     80    bool Skybox::create()
     81    {
     82        this->setSkybox(this->skyboxSrc_);
     83        return Synchronisable::create();
    9384    }
    94    
    95     void Skybox::registerAllVariables(){
    96       registerVar(&skyboxSrc_, skyboxSrc_.length()+1 ,network::STRING);
     85
     86    void Skybox::registerAllVariables()
     87    {
     88        registerVar(&skyboxSrc_, skyboxSrc_.length()+1 ,network::STRING);
    9789    }
    98    
     90
     91    void Skybox::changedVisibility()
     92    {
     93        BaseObject::changedVisibility();
     94        GraphicsEngine::getSingleton().getSceneManager()->setSkyBox(this->isVisible(), this->skyboxSrc_);
     95    }
    9996}
Note: See TracChangeset for help on using the changeset viewer.