[Orxonox-commit 3883] r8557 - in code/branches/environment2: . src/libraries/tools src/orxonox src/orxonox/graphics src/orxonox/worldentities

marwegma at orxonox.net marwegma at orxonox.net
Tue May 24 00:28:31 CEST 2011


Author: marwegma
Date: 2011-05-24 00:28:31 +0200 (Tue, 24 May 2011)
New Revision: 8557

Added:
   code/branches/environment2/WorldEntityShader.cpp
   code/branches/environment2/src/orxonox/graphics/GodrayShader.cc
   code/branches/environment2/src/orxonox/graphics/GodrayShader.h
   code/branches/environment2/src/orxonox/graphics/WorldEntityShader.h
Removed:
   code/branches/environment2/src/orxonox/graphics/GlobalGodrayShader.cc
   code/branches/environment2/src/orxonox/graphics/GlobalGodrayShader.h
Modified:
   code/branches/environment2/src/libraries/tools/Shader.h
   code/branches/environment2/src/orxonox/OrxonoxPrereqs.h
   code/branches/environment2/src/orxonox/graphics/CMakeLists.txt
   code/branches/environment2/src/orxonox/graphics/GlobalShader.h
   code/branches/environment2/src/orxonox/worldentities/WorldEntity.cc
   code/branches/environment2/src/orxonox/worldentities/WorldEntity.h
Log:
Godrays: Safety commit. 90017 N8

Added: code/branches/environment2/WorldEntityShader.cpp
===================================================================
--- code/branches/environment2/WorldEntityShader.cpp	                        (rev 0)
+++ code/branches/environment2/WorldEntityShader.cpp	2011-05-23 22:28:31 UTC (rev 8557)
@@ -0,0 +1,37 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Markus 'atok' Wegmann
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ Contains the implementation of the WorldEntityShader class.
+ 
+ @see WorldEntityShader.h
+**/
+
+
+#include "WorldEntityShader.h"

Modified: code/branches/environment2/src/libraries/tools/Shader.h
===================================================================
--- code/branches/environment2/src/libraries/tools/Shader.h	2011-05-23 21:40:58 UTC (rev 8556)
+++ code/branches/environment2/src/libraries/tools/Shader.h	2011-05-23 22:28:31 UTC (rev 8557)
@@ -88,11 +88,15 @@
             /// Returns the scene manager.
             inline Ogre::SceneManager* getSceneManager() const
                 { return this->scenemanager_; }
-
+            
+            /// Returns the compositor instance. Normally used for manually modifiying compositor parameters, when mt-type conversatio.
+            inline Ogre::CompositorInstance* getMutableCompositorInstance()
+                { return this->compositorInstance_; }
+        
             virtual void cameraChanged(Ogre::Viewport* viewport, Ogre::Camera* oldCamera);
 
+            void setParameter(size_t technique, size_t pass, const std::string& parameter, int value);
             void setParameter(size_t technique, size_t pass, const std::string& parameter, float value);
-            void setParameter(size_t technique, size_t pass, const std::string& parameter, int value);
 
             virtual void notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr& materialPtr);
 

Modified: code/branches/environment2/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/branches/environment2/src/orxonox/OrxonoxPrereqs.h	2011-05-23 21:40:58 UTC (rev 8556)
+++ code/branches/environment2/src/orxonox/OrxonoxPrereqs.h	2011-05-23 22:28:31 UTC (rev 8557)
@@ -110,7 +110,7 @@
     class Camera;
     class FadingBillboard;
     class GlobalShader;
-    class GlobalGodrayShader;
+    class GodrayShader;
     class Light;
     class Model;
     class ParticleEmitter;

Modified: code/branches/environment2/src/orxonox/graphics/CMakeLists.txt
===================================================================
--- code/branches/environment2/src/orxonox/graphics/CMakeLists.txt	2011-05-23 21:40:58 UTC (rev 8556)
+++ code/branches/environment2/src/orxonox/graphics/CMakeLists.txt	2011-05-23 22:28:31 UTC (rev 8557)
@@ -3,12 +3,13 @@
   BlinkingBillboard.cc
   FadingBillboard.cc
   GlobalShader.cc
-  GlobalGodrayShader.cc
+  GodrayShader.cc
   MeshLodInformation.cc
   Model.cc
   AnimatedModel.cc
   ParticleEmitter.cc
   ParticleSpawner.cc
+  WorldEntityShader.cc
 COMPILATION_BEGIN GraphicsCompilation.cc
   Backlight.cc
   Camera.cc

Deleted: code/branches/environment2/src/orxonox/graphics/GlobalGodrayShader.cc
===================================================================
--- code/branches/environment2/src/orxonox/graphics/GlobalGodrayShader.cc	2011-05-23 21:40:58 UTC (rev 8556)
+++ code/branches/environment2/src/orxonox/graphics/GlobalGodrayShader.cc	2011-05-23 22:28:31 UTC (rev 8557)
@@ -1,106 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Markus 'atok' Wegmann
- *   Co-authors:
- *      ...
- *
- */
-
-/**
- @file
- 
- @brief Implementation of the GlobalGodrayShader class.
- */
-
-#include "GlobalGodrayShader.h"
-
-#include "util/Exception.h"
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-
-namespace orxonox
-{
-    CreateFactory(GlobalGodrayShader);
-    
-    GlobalGodrayShader::GlobalGodrayShader(BaseObject* creator) : BaseObject(creator), globalShader_(creator)
-    {
-        RegisterObject(GlobalGodrayShader);
-        
-        if (!this->getScene())
-            ThrowException(AbortLoading, "Can't create GlobalGodrayShader, no scene given.");
-        //        if (!this->getScene()->getSceneManager())
-        //            ThrowException(AbortLoading, "Can't create GlobalGodrayShader, no scene manager given.");
-        
-        this->skyColor_ = ColourValue::Black;
-        this->exposure_ = 1.0f;
-        this->decay_ = 0.1f;
-        this->density_ = 0.7f;
-        
-        //// Init ////
-    }
-    
-    GlobalGodrayShader::~GlobalGodrayShader()
-    {
-        this->setVisible(false);
-    }
-    
-    void GlobalGodrayShader::tick(float dt)
-    {
-        // To-Do
-    }
-    
-    void GlobalGodrayShader::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-        SUPER(GlobalGodrayShader, XMLPort, xmlelement, mode);
-        
-        XMLPortParamTemplate(GlobalGodrayShader, "sunPosition", setSunPosition, getSunPosition, xmlelement, mode, const Vector3&);
-        XMLPortParamTemplate(GlobalGodrayShader, "skyColor", setSkyColor, getSkyColor, xmlelement, mode, const ColourValue&);
-        XMLPortParamVariable(GlobalGodrayShader, "exposure", exposure_, xmlelement, mode);
-        XMLPortParamVariable(GlobalGodrayShader, "decay", decay_, xmlelement, mode);
-        XMLPortParamVariable(GlobalGodrayShader, "density", density_, xmlelement, mode);
-    }
-    
-    void GlobalGodrayShader::setSunPosition(const Vector3& position)
-    {
-        this->sunPosition_ = position;
-    }
-    void GlobalGodrayShader::setSkyColor(const ColourValue& color)
-    {
-        this->skyColor_ = color;
-    }
-    const Vector3& GlobalGodrayShader::getSunPosition() const
-    {
-        return this->sunPosition_;
-    }
-    const ColourValue& GlobalGodrayShader::getSkyColor() const
-    {
-        return this->skyColor_;
-    }
-    
-    void GlobalGodrayShader::changedVisibility()
-    {
-        SUPER(GlobalGodrayShader, changedVisibility);
-        
-        this->globalShader_.setVisible(this->isVisible());
-    }
-}

Deleted: code/branches/environment2/src/orxonox/graphics/GlobalGodrayShader.h
===================================================================
--- code/branches/environment2/src/orxonox/graphics/GlobalGodrayShader.h	2011-05-23 21:40:58 UTC (rev 8556)
+++ code/branches/environment2/src/orxonox/graphics/GlobalGodrayShader.h	2011-05-23 22:28:31 UTC (rev 8557)
@@ -1,86 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Markus 'atok' Wegmann
- *   Co-authors:
- *      ...
- *
- */
-
-
-/**
- @file
- 
- @brief Header of the GlobalGodrayShader class.
-*/
-
-
-#ifndef _GlobalGodrayShader_H__
-#define _GlobalGodrayShader_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "tools/interfaces/Tickable.h"
-#include "core/BaseObject.h"
-#include "util/Math.h"
-#include "GlobalShader.h"
-
-
-namespace orxonox
-{
-    /**
-     @brief 
-     
-    */
-    class _OrxonoxExport GlobalGodrayShader : public BaseObject, public Tickable
-    {
-        public:
-            GlobalGodrayShader(BaseObject* creator);
-            virtual ~GlobalGodrayShader();
-            
-            virtual void tick(float dt);
-            
-            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-        
-            virtual void changedVisibility();
-            
-            inline const GlobalShader& getGlobalShader() const
-            { return this->globalShader_; }
-        
-            void setSunPosition(const Vector3& position);
-            void setSkyColor(const ColourValue& color);
-            const Vector3& getSunPosition() const;
-            const ColourValue& getSkyColor() const;
-        
-        private:
-            
-            GlobalShader globalShader_;
-            
-            Vector3 sunPosition_;
-            ColourValue skyColor_;
-            float exposure_;
-            float decay_;
-            float density_;
-    };
-}
-
-#endif /* _GlobalGodrayShader_H__ */

Modified: code/branches/environment2/src/orxonox/graphics/GlobalShader.h
===================================================================
--- code/branches/environment2/src/orxonox/graphics/GlobalShader.h	2011-05-23 21:40:58 UTC (rev 8556)
+++ code/branches/environment2/src/orxonox/graphics/GlobalShader.h	2011-05-23 22:28:31 UTC (rev 8557)
@@ -49,6 +49,9 @@
 
             inline const Shader& getShader() const
                 { return this->shader_; }
+        
+            inline Shader& getMutableShader()
+                { return this->shader_; }
 
         private:
             void registerVariables();

Copied: code/branches/environment2/src/orxonox/graphics/GodrayShader.cc (from rev 8497, code/branches/environment2/src/orxonox/graphics/GlobalGodrayShader.cc)
===================================================================
--- code/branches/environment2/src/orxonox/graphics/GodrayShader.cc	                        (rev 0)
+++ code/branches/environment2/src/orxonox/graphics/GodrayShader.cc	2011-05-23 22:28:31 UTC (rev 8557)
@@ -0,0 +1,126 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Markus 'atok' Wegmann
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ 
+ @brief Implementation of the GodrayShader class.
+ */
+
+
+#include "GodrayShader.h"
+
+#include "util/Exception.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+    CreateFactory(GodrayShader);
+    
+    GodrayShader::GodrayShader(BaseObject* creator) : BaseObject(creator), globalShader_(creator)
+    {
+        RegisterObject(GodrayShader);
+        
+        // Default parameters are initialized
+        this->sunPosition_ = Vector3::Zero;
+        this->sunColor_ = ColourValue::White;
+        this->skyColor_ = ColourValue::Black;
+        this->exposure_ = 1.0f; 
+        this->decay_ = 0.1f;
+        this->density_ = 0.7f;
+        
+        // Godrays.compositor is getting initialized
+        this->globalShader_.getMutableShader().setCompositorName("Godrays");
+        this->compositor_ = this->globalShader_.getMutableShader().getMutableCompositorInstance();
+    }
+    
+    GodrayShader::~GodrayShader()
+    {
+        this->setVisible(false);
+    }
+    
+    void GodrayShader::tick(float dt)
+    {
+        if(this->isVisible())
+        {
+            
+            //Reset sunPosition in the compositor instance every tick
+            this->compositor_->getTechnique()->getTargetPass(2)
+        }
+    }
+    
+    void GodrayShader::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(GodrayShader, XMLPort, xmlelement, mode);
+        
+        XMLPortParamTemplate(GodrayShader, "sunColor", setSunColor, getSunColor, xmlelement, mode, const ColourValue&);
+        XMLPortParamTemplate(GodrayShader, "skyColor", setSkyColor, getSkyColor, xmlelement, mode, const ColourValue&);
+        XMLPortParamVariable(GodrayShader, "exposure", exposure_, xmlelement, mode);
+        XMLPortParamVariable(GodrayShader, "decay", decay_, xmlelement, mode);
+        XMLPortParamVariable(GodrayShader, "density", density_, xmlelement, mode);
+    }
+    
+    void GodrayShader::setWorldEntity(WorldEntity* worldEntity)
+    {
+        this->worldEntity_ = worldEntity;
+        this->setSunPosition(worldEntity->getWorldPosition());
+    }
+    
+    void GodrayShader::setSunPosition(const Vector3& position)
+    {
+        this->sunPosition_ = position;
+    }
+    void GodrayShader::setSunColor(const ColourValue& color)
+    {
+        this->skyColor_ = color;
+    }
+    void GodrayShader::setSkyColor(const ColourValue& color)
+    {
+        this->skyColor_ = color;
+    }
+    const Vector3& GodrayShader::getSunPosition() const
+    {
+        return this->sunPosition_;
+    }
+    const ColourValue& GodrayShader::getSunColor() const
+    {
+        return this->sunColor_;
+    }
+    const ColourValue& GodrayShader::getSkyColor() const
+    {
+        return this->skyColor_;
+    }
+    
+    void GodrayShader::changedVisibility()
+    {
+        SUPER(GodrayShader, changedVisibility);
+        
+        this->globalShader_.setVisible(this->isVisible());
+    }
+}

Copied: code/branches/environment2/src/orxonox/graphics/GodrayShader.h (from rev 8497, code/branches/environment2/src/orxonox/graphics/GlobalGodrayShader.h)
===================================================================
--- code/branches/environment2/src/orxonox/graphics/GodrayShader.h	                        (rev 0)
+++ code/branches/environment2/src/orxonox/graphics/GodrayShader.h	2011-05-23 22:28:31 UTC (rev 8557)
@@ -0,0 +1,97 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Markus 'atok' Wegmann
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+/**
+ @file
+ 
+ @brief Header of the GodrayShader class.
+*/
+
+
+#ifndef _GodrayShader_H__
+#define _GodrayShader_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgreCompositorInstance.h>
+
+#include "tools/interfaces/Tickable.h"
+#include "core/BaseObject.h"
+#include "util/Math.h"
+#include "WorldEntity.h"
+#include "GlobalShader.h"
+
+
+namespace orxonox
+{
+    /**
+     @brief 
+     
+    */
+    class _OrxonoxExport GodrayShader : public BaseObject, public Tickable
+    {
+        public:
+            GodrayShader(BaseObject* creator);
+            virtual ~GodrayShader();
+            
+            virtual void tick(float dt);
+        
+            virtual void updateParameters();
+            
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+        
+            virtual void changedVisibility();
+        
+            void setWorldEntity(WorldEntity* worldEntity);
+            
+            inline const GlobalShader& getGlobalShader() const
+            { return this->globalShader_; }
+        
+            void setSunPosition(const Vector3& position);
+            void setSunColor(const ColourValue& color);
+            void setSkyColor(const ColourValue& color);
+            const Vector3& getSunPosition() const;
+            const ColourValue& getSunColor() const;
+            const ColourValue& getSkyColor() const;
+        
+        private:
+        
+            WorldEntity* worldEntity_;
+            GlobalShader globalShader_;
+            Ogre::CompositorInstance* compositor_;
+            Vector3 sunPosition_;
+            ColourValue sunColor_;
+            ColourValue skyColor_;
+            float exposure_;
+            float decay_;
+            float density_;
+    };
+}
+
+#endif /* _GodrayShader_H__ */

Added: code/branches/environment2/src/orxonox/graphics/WorldEntityShader.h
===================================================================
--- code/branches/environment2/src/orxonox/graphics/WorldEntityShader.h	                        (rev 0)
+++ code/branches/environment2/src/orxonox/graphics/WorldEntityShader.h	2011-05-23 22:28:31 UTC (rev 8557)
@@ -0,0 +1,44 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Markus 'atok' Wegmann
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+    Contains the header of the WorldEntityShader class.
+ @brief
+    WorldEntityShader will be used in the future for "non-material" shaders that depend on WorldEntity data of the creator (such as their world position, orientation, etc.). "Non-material" means that they are not depending on a polygon-mesh of the creator (but can), simply rendering them. Therefore its best purpose is to implement screenspace-effects (e.g. Compositor).
+    Motivation & Advantages: 
+        - WorldEntityShader's classes can be initalized and attached in every other WorldEntity object by XML. This makes leveldesign much more easy.
+        - No id managment of the creators has to be done. Everything can be nested.
+    
+    Case scenarios would be coronas (position), godrays, etc.
+ 
+    Some sort of implementation already exists: The GodrayShader class uses the same approach. It can be used as a (raw) template.
+ **/
+
+
+        
\ No newline at end of file

Modified: code/branches/environment2/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/branches/environment2/src/orxonox/worldentities/WorldEntity.cc	2011-05-23 21:40:58 UTC (rev 8556)
+++ code/branches/environment2/src/orxonox/worldentities/WorldEntity.cc	2011-05-23 22:28:31 UTC (rev 8557)
@@ -176,6 +176,8 @@
         XMLPortObject(WorldEntity, WorldEntity, "attached", attach, getAttachedObject, xmlelement, mode);
         // Attached collision shapes
         XMLPortObject(WorldEntity, CollisionShape, "collisionShapes", attachCollisionShape, getAttachedCollisionShape, xmlelement, mode);
+        // Attach WorldEntityShaders that depend on WorldEntity data (e.g. position). -- TODO -- Extend to WorldEntityShader.
+        XMLPortObject(WorldEntity, GodrayShader, "shaders", attachShader, getAttachedObject, xmlelement, mode);
     }
 
     void WorldEntity::registerVariables()
@@ -509,6 +511,30 @@
         }
         return 0;
     }
+    
+    void WorldEntity::attachShader(GodrayShader* object)
+    {
+        object->setWorldEntity(object);
+        
+        this->shaders_.insert(object);
+    }
+    void WorldEntity::detachShader(GodrayShader* object)
+    {
+        std::set<WorldEntity*>::iterator it = this->children_.find(object);
+        this->shaders_.erase(it);
+        
+    }
+    GodrayShader* WorldEntity::getAttachedShader(unsigned int index)
+    {
+        unsigned int i = 0;
+        for (std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it)
+        {
+            if (i == index)
+                return (*it);
+            ++i;
+        }
+        return 0;
+    }
 
     //! Attaches an Ogre::SceneNode to this WorldEntity.
     void WorldEntity::attachNode(Ogre::SceneNode* node)

Modified: code/branches/environment2/src/orxonox/worldentities/WorldEntity.h
===================================================================
--- code/branches/environment2/src/orxonox/worldentities/WorldEntity.h	2011-05-23 21:40:58 UTC (rev 8556)
+++ code/branches/environment2/src/orxonox/worldentities/WorldEntity.h	2011-05-23 22:28:31 UTC (rev 8557)
@@ -198,6 +198,12 @@
             void detachNode(Ogre::SceneNode* node);
             void attachToNode(Ogre::SceneNode* node);
             void detachFromNode(Ogre::SceneNode* node);
+            
+            void attachShader(GodrayShader* object);
+            void detachShader(GodrayShader* object);
+            GodrayShader* getAttachedShader(unsigned int index);
+            inline const std::set<WorldEntity*>& getAttachedShaders() const
+            { return this->shaders_; }
 
             inline void setDeleteWithParent(bool value)
                 { this->bDeleteWithParent_ = value; }
@@ -233,6 +239,7 @@
             WorldEntity* parent_;
             unsigned int parentID_;
             std::set<WorldEntity*> children_;
+            std::set<WorldEntity*> shaders_;
             bool bDeleteWithParent_;
 
             bool bActiveMem_;




More information about the Orxonox-commit mailing list