Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 24, 2011, 12:28:31 AM (13 years ago)
Author:
marwegma
Message:

Godrays: Safety commit. 90017 N8

Location:
code/branches/environment2/src/orxonox/worldentities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/environment2/src/orxonox/worldentities/WorldEntity.cc

    r7937 r8557  
    177177        // Attached collision shapes
    178178        XMLPortObject(WorldEntity, CollisionShape, "collisionShapes", attachCollisionShape, getAttachedCollisionShape, xmlelement, mode);
     179        // Attach WorldEntityShaders that depend on WorldEntity data (e.g. position). -- TODO -- Extend to WorldEntityShader.
     180        XMLPortObject(WorldEntity, GodrayShader, "shaders", attachShader, getAttachedObject, xmlelement, mode);
    179181    }
    180182
     
    510512        return 0;
    511513    }
     514   
     515    void WorldEntity::attachShader(GodrayShader* object)
     516    {
     517        object->setWorldEntity(object);
     518       
     519        this->shaders_.insert(object);
     520    }
     521    void WorldEntity::detachShader(GodrayShader* object)
     522    {
     523        std::set<WorldEntity*>::iterator it = this->children_.find(object);
     524        this->shaders_.erase(it);
     525       
     526    }
     527    GodrayShader* WorldEntity::getAttachedShader(unsigned int index)
     528    {
     529        unsigned int i = 0;
     530        for (std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it)
     531        {
     532            if (i == index)
     533                return (*it);
     534            ++i;
     535        }
     536        return 0;
     537    }
    512538
    513539    //! Attaches an Ogre::SceneNode to this WorldEntity.
  • code/branches/environment2/src/orxonox/worldentities/WorldEntity.h

    r7910 r8557  
    199199            void attachToNode(Ogre::SceneNode* node);
    200200            void detachFromNode(Ogre::SceneNode* node);
     201           
     202            void attachShader(GodrayShader* object);
     203            void detachShader(GodrayShader* object);
     204            GodrayShader* getAttachedShader(unsigned int index);
     205            inline const std::set<WorldEntity*>& getAttachedShaders() const
     206            { return this->shaders_; }
    201207
    202208            inline void setDeleteWithParent(bool value)
     
    234240            unsigned int parentID_;
    235241            std::set<WorldEntity*> children_;
     242            std::set<WorldEntity*> shaders_;
    236243            bool bDeleteWithParent_;
    237244
Note: See TracChangeset for help on using the changeset viewer.