[Orxonox-commit 4776] r9445 - code/branches/shaders/src/orxonox/graphics

davidsa at orxonox.net davidsa at orxonox.net
Tue Nov 13 16:54:24 CET 2012


Author: davidsa
Date: 2012-11-13 16:54:24 +0100 (Tue, 13 Nov 2012)
New Revision: 9445

Added:
   code/branches/shaders/src/orxonox/graphics/LensFlare.cc
   code/branches/shaders/src/orxonox/graphics/LensFlare.h
Modified:
   code/branches/shaders/src/orxonox/graphics/CMakeLists.txt
Log:
Added orxonox::LensFlare, to add LensFlare effects, this is still very much WIP, still needs more flare components, more configurability and hardware occlusion queries

Modified: code/branches/shaders/src/orxonox/graphics/CMakeLists.txt
===================================================================
--- code/branches/shaders/src/orxonox/graphics/CMakeLists.txt	2012-11-12 22:07:01 UTC (rev 9444)
+++ code/branches/shaders/src/orxonox/graphics/CMakeLists.txt	2012-11-13 15:54:24 UTC (rev 9445)
@@ -12,6 +12,7 @@
 BUILD_UNIT GraphicsBuildUnit.cc
   Backlight.cc
   Camera.cc
+  LensFlare.cc
   Light.cc
 END_BUILD_UNIT
 )

Added: code/branches/shaders/src/orxonox/graphics/LensFlare.cc
===================================================================
--- code/branches/shaders/src/orxonox/graphics/LensFlare.cc	                        (rev 0)
+++ code/branches/shaders/src/orxonox/graphics/LensFlare.cc	2012-11-13 15:54:24 UTC (rev 9445)
@@ -0,0 +1,100 @@
+ /*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *      Reto Grieder (physics)
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+  @file LensFlare.cc
+  @brief Implementation of the LensFlare class.
+*/
+
+#include "LensFlare.h"
+
+#include "core/XMLPort.h"
+#include "graphics/Billboard.h"
+#include "CameraManager.h"
+
+namespace orxonox
+{
+    CreateFactory(LensFlare);
+    
+    LensFlare::LensFlare(BaseObject* creator) : StaticEntity(creator)
+    {
+        RegisterObject(LensFlare);
+        
+        this->createBillboards();
+        
+        this->registerVariables();
+    }
+
+    LensFlare::~LensFlare()
+    {
+    }
+
+    void LensFlare::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(LensFlare, XMLPort, xmlelement, mode);
+    }
+    
+    void LensFlare::registerVariables()
+    {
+      
+    }
+    
+    void LensFlare::createBillboards()
+    {
+        Billboard* burst = new Billboard(this);
+        burst->setMaterial("lensflare/burst");
+        burst->setPosition(this->getPosition());
+        burst->setVisible(false);
+        this->attach(burst);
+    }
+    
+    void LensFlare::updateBillboardPositions()
+    {
+        Ogre::Camera* camera=CameraManager::getInstance().getActiveCamera()->getOgreCamera(); //get active Ogre Camera Instance, so we can check whether the light source is visible
+        bool lightIsVisible=camera->isVisible(this->getPosition()); //is the light source visible from our point of view?
+        int scale=camera->getPosition().distance(this->getPosition());
+        
+        Billboard* burst=static_cast<Billboard*>(getAttachedObject(0));
+        burst->setPosition(this->getPosition());
+        burst->setVisible(lightIsVisible);
+        burst->setDefaultDimensions(scale,scale);
+    }
+
+    void LensFlare::tick(float dt)
+    {
+        if(this->isVisible())
+        {
+            updateBillboardPositions();
+        }
+    }
+
+    void LensFlare::changedVisibility()
+    {
+    }
+}
\ No newline at end of file

Added: code/branches/shaders/src/orxonox/graphics/LensFlare.h
===================================================================
--- code/branches/shaders/src/orxonox/graphics/LensFlare.h	                        (rev 0)
+++ code/branches/shaders/src/orxonox/graphics/LensFlare.h	2012-11-13 15:54:24 UTC (rev 9445)
@@ -0,0 +1,77 @@
+ /*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *      Reto Grieder (physics)
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+  @file LensFlare.h
+  @brief Definition of the LensFlare class.
+*/
+
+#ifndef _LensFlare_H__
+#define _LensFlare_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "OgreBillboardSet.h"
+
+#include "util/Math.h"
+#include "worldentities/StaticEntity.h"
+#include "graphics/Billboard.h"
+
+namespace orxonox
+{
+      /**
+    @brief
+        This class adds a configurable LensFlare effect by adding multiple billboards for the several components of lens flare.
+        It uses orxonox::Billboard to render this effect, the used images can be changed in lensflare.material
+
+    @author
+        David 'davidsa' Salvisberg
+    */
+    class _OrxonoxExport LensFlare : public StaticEntity, public Tickable
+    {
+        public:
+            LensFlare(BaseObject* creator);
+            virtual ~LensFlare();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            virtual void tick(float dt);
+
+            virtual void changedVisibility();
+
+        private:
+            void registerVariables();
+            
+            void createBillboards();
+            
+            void updateBillboardPositions();
+    };
+}
+
+#endif /* _LensFlare_H__ */
\ No newline at end of file




More information about the Orxonox-commit mailing list