Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Godrays: Safety commit. 90017 N8

File:
1 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.
Note: See TracChangeset for help on using the changeset viewer.