[Orxonox-commit 6416] r11073 - in code/branches/shaders_merge: . data/levels src/libraries/tools src/orxonox src/orxonox/graphics

landauf at orxonox.net landauf at orxonox.net
Mon Jan 18 22:12:53 CET 2016


Author: landauf
Date: 2016-01-18 22:12:53 +0100 (Mon, 18 Jan 2016)
New Revision: 11073

Added:
   code/branches/shaders_merge/data/levels/shadertest.oxw
   code/branches/shaders_merge/src/orxonox/RenderQueueListener.cc
   code/branches/shaders_merge/src/orxonox/RenderQueueListener.h
   code/branches/shaders_merge/src/orxonox/graphics/LensFlare.cc
   code/branches/shaders_merge/src/orxonox/graphics/LensFlare.h
Modified:
   code/branches/shaders_merge/
   code/branches/shaders_merge/src/libraries/tools/Mesh.cc
   code/branches/shaders_merge/src/libraries/tools/Mesh.h
   code/branches/shaders_merge/src/orxonox/CMakeLists.txt
   code/branches/shaders_merge/src/orxonox/OrxonoxPrereqs.h
   code/branches/shaders_merge/src/orxonox/Scene.cc
   code/branches/shaders_merge/src/orxonox/Scene.h
   code/branches/shaders_merge/src/orxonox/graphics/Billboard.cc
   code/branches/shaders_merge/src/orxonox/graphics/Billboard.h
   code/branches/shaders_merge/src/orxonox/graphics/CMakeLists.txt
   code/branches/shaders_merge/src/orxonox/graphics/Model.cc
   code/branches/shaders_merge/src/orxonox/graphics/Model.h
Log:
merged branch 'shaders' into branch 'shaders_merge'


Property changes on: code/branches/shaders_merge
___________________________________________________________________
Modified: svn:mergeinfo
   - /code/branches/AI_HS15:10640-10832
/code/branches/ParticleEffectsFS15:10309-10612
/code/branches/Racingbot:9388-9513
/code/branches/SciptableControllerFS15:10308-10613
/code/branches/ScriptableController:9999-10075
/code/branches/ai:6592-7033
/code/branches/ai2:8721-8880
/code/branches/bigships:8137-8588
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/campaignHS15:10639-10973
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/clangenb:10385-10609
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/core6:9552-9666
/code/branches/core7:10328-10623
/code/branches/cpp11:10439-10732
/code/branches/cpp11_v2:10732-11067
/code/branches/cpp11_v3:11053-11070
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dockingsystem:8101-8192
/code/branches/dockingsystem2:8196-8560
/code/branches/dynamicmatch:6584-7030
/code/branches/environment3:8887-8975
/code/branches/explosionChunksHS15:10641-10961
/code/branches/fabienHS15:10685-11033
/code/branches/formation:8885-8991
/code/branches/formationFS15:10320-10610
/code/branches/formationupdate:9580-9624
/code/branches/fps:6591-7072
/code/branches/gamecontent:8893-8968
/code/branches/gameimmersion:8102-8577
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hoverHS15:10633-10959
/code/branches/hud:8883-8986
/code/branches/hudHS14:10083-10241
/code/branches/hudelements:6584-6941
/code/branches/hudimprovements:7920-8672
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/invaders:9694-9896
/code/branches/ipv6:7293-7458
/code/branches/keckslevelHS14:10082-10222
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/largeShip1:9384-9515
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/levelElias:9697-9921
/code/branches/levelKaan:9695-9921
/code/branches/levelMichael:9696-9921
/code/branches/leveljoemeHS14:10087-10223
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/libs:9668-9674
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/masterserverfix:8933-8936
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/menue:8884-8976
/code/branches/minigame4DHS14:10081-10230
/code/branches/miniprojects:2754-2824
/code/branches/modularships:9994-10071
/code/branches/multiplayerFS15:10324-10611
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/newlevel2012:9033-9244
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/output:8739-8857
/code/branches/overlay:2117-2385
/code/branches/pCuts:9023-9284
/code/branches/particleEffectsHS15:10644-10962
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup:8145-8555
/code/branches/pickup2:5942-6405
/code/branches/pickup2012:9029-9189
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/pickupsFS14:10000-10259
/code/branches/planetLevelHS15:10637-10966
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/portals2:8460-8602
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786,8500-8705
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation2011:8974-9015
/code/branches/presentation2012:9189-9268
/code/branches/presentation2012merge:9266-9347
/code/branches/presentation3:6913-7162
/code/branches/presentationFS14:10069-10215
/code/branches/presentationFS15:10499
/code/branches/presentationFS15merge:10595-10621
/code/branches/presentationHS12:9481-9525
/code/branches/presentationHS13:9891-9938
/code/branches/presentationHS14merge:10222-10257
/code/branches/presentationHS15:10959-11055
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/radarDreiD:9690-9901
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/sfxThilo:9691-9917
/code/branches/shipSelection:9038-9206
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound2012:9205-9214
/code/branches/sound3:5941-6102
/code/branches/soundEffects:9382-11020
/code/branches/spaceNavigation:9381-9497
/code/branches/spaceboundaries:8085-8457
/code/branches/spaceboundaries2:8460-8613
/code/branches/spacerace:8182-8630
/code/branches/spaceraceTwo:8881-8996
/code/branches/spacestationentry:9699-9905
/code/branches/steering:5949-6091,8140-8595
/code/branches/storymodeHS14:10085-10254
/code/branches/surfaceRace:9028-9199
/code/branches/surfaceraceHS14:10080-10236
/code/branches/testing:9015-9549
/code/branches/tetris:8100-8563
/code/branches/towerdefenseFS15:10283-10614
/code/branches/towerdefenseHS14:10086-10247
/code/branches/turret:9380-9501
/code/branches/turretFS14:9998-10070
/code/branches/tutoriallevel:7827-8370
/code/branches/tutoriallevel2:8370-8452
/code/branches/tutoriallevel3:8453-8636
/code/branches/unity_build:8440-8716
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weaponFS15:10302-10615
/code/branches/weapons:2897-3051,8143-8591
/code/branches/weaponsystem:2742-2890
/code/branches/weaponupdateHS14:10084-10237
   + /code/branches/AI_HS15:10640-10832
/code/branches/ParticleEffectsFS15:10309-10612
/code/branches/Racingbot:9388-9513
/code/branches/SciptableControllerFS15:10308-10613
/code/branches/ScriptableController:9999-10075
/code/branches/ai:6592-7033
/code/branches/ai2:8721-8880
/code/branches/bigships:8137-8588
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/campaignHS15:10639-10973
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/clangenb:10385-10609
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/core6:9552-9666
/code/branches/core7:10328-10623
/code/branches/cpp11:10439-10732
/code/branches/cpp11_v2:10732-11067
/code/branches/cpp11_v3:11053-11070
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dockingsystem:8101-8192
/code/branches/dockingsystem2:8196-8560
/code/branches/dynamicmatch:6584-7030
/code/branches/environment3:8887-8975
/code/branches/explosionChunksHS15:10641-10961
/code/branches/fabienHS15:10685-11033
/code/branches/formation:8885-8991
/code/branches/formationFS15:10320-10610
/code/branches/formationupdate:9580-9624
/code/branches/fps:6591-7072
/code/branches/gamecontent:8893-8968
/code/branches/gameimmersion:8102-8577
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hoverHS15:10633-10959
/code/branches/hud:8883-8986
/code/branches/hudHS14:10083-10241
/code/branches/hudelements:6584-6941
/code/branches/hudimprovements:7920-8672
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/invaders:9694-9896
/code/branches/ipv6:7293-7458
/code/branches/keckslevelHS14:10082-10222
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/largeShip1:9384-9515
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/levelElias:9697-9921
/code/branches/levelKaan:9695-9921
/code/branches/levelMichael:9696-9921
/code/branches/leveljoemeHS14:10087-10223
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/libs:9668-9674
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/masterserverfix:8933-8936
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/menue:8884-8976
/code/branches/minigame4DHS14:10081-10230
/code/branches/miniprojects:2754-2824
/code/branches/modularships:9994-10071
/code/branches/multiplayerFS15:10324-10611
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/newlevel2012:9033-9244
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/output:8739-8857
/code/branches/overlay:2117-2385
/code/branches/pCuts:9023-9284
/code/branches/particleEffectsHS15:10644-10962
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup:8145-8555
/code/branches/pickup2:5942-6405
/code/branches/pickup2012:9029-9189
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/pickupsFS14:10000-10259
/code/branches/planetLevelHS15:10637-10966
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/portals2:8460-8602
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786,8500-8705
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation2011:8974-9015
/code/branches/presentation2012:9189-9268
/code/branches/presentation2012merge:9266-9347
/code/branches/presentation3:6913-7162
/code/branches/presentationFS14:10069-10215
/code/branches/presentationFS15:10499
/code/branches/presentationFS15merge:10595-10621
/code/branches/presentationHS12:9481-9525
/code/branches/presentationHS13:9891-9938
/code/branches/presentationHS14merge:10222-10257
/code/branches/presentationHS15:10959-11055
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/radarDreiD:9690-9901
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/sfxThilo:9691-9917
/code/branches/shaders:9379-11072
/code/branches/shipSelection:9038-9206
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound2012:9205-9214
/code/branches/sound3:5941-6102
/code/branches/soundEffects:9382-11020
/code/branches/spaceNavigation:9381-9497
/code/branches/spaceboundaries:8085-8457
/code/branches/spaceboundaries2:8460-8613
/code/branches/spacerace:8182-8630
/code/branches/spaceraceTwo:8881-8996
/code/branches/spacestationentry:9699-9905
/code/branches/steering:5949-6091,8140-8595
/code/branches/storymodeHS14:10085-10254
/code/branches/surfaceRace:9028-9199
/code/branches/surfaceraceHS14:10080-10236
/code/branches/testing:9015-9549
/code/branches/tetris:8100-8563
/code/branches/towerdefenseFS15:10283-10614
/code/branches/towerdefenseHS14:10086-10247
/code/branches/turret:9380-9501
/code/branches/turretFS14:9998-10070
/code/branches/tutoriallevel:7827-8370
/code/branches/tutoriallevel2:8370-8452
/code/branches/tutoriallevel3:8453-8636
/code/branches/unity_build:8440-8716
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weaponFS15:10302-10615
/code/branches/weapons:2897-3051,8143-8591
/code/branches/weaponsystem:2742-2890
/code/branches/weaponupdateHS14:10084-10237

Copied: code/branches/shaders_merge/data/levels/shadertest.oxw (from rev 11072, code/branches/shaders/data/levels/shadertest.oxw)
===================================================================
--- code/branches/shaders_merge/data/levels/shadertest.oxw	                        (rev 0)
+++ code/branches/shaders_merge/data/levels/shadertest.oxw	2016-01-18 21:12:53 UTC (rev 11073)
@@ -0,0 +1,112 @@
+<LevelInfo
+ name = "Shader Test"
+ description = "Level to test shader functionality. Based on Asteroidfields."
+ tags = "test"
+ screenshot = "codingtutorial.png"
+ startingships = "spaceshipassff, spaceshipghost, spaceshipspacecruiser"
+/>
+
+<?lua
+  include("stats.oxo")
+  include("HUDTemplates3.oxo")
+  include("templates/lodInformation.oxt")
+?>
+
+<?lua
+  include("templates/spaceshipAssff.oxt")
+  include("templates/spaceshipPirate.oxt")
+?>
+
+<Level
+ name         = "Sample"
+ description  = "Just a few tests"
+>
+  <templates>
+    <Template link=lodtemplate_default />
+  </templates>
+  <?lua include("includes/notifications.oxi") ?>
+
+  <Scene
+    ambientlight = "0.8, 0.8, 0.8"
+    skybox       = "Orxonox/Starbox"
+    hasPhysics   = true
+  >
+
+    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
+    <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+
+
+
+
+    <!-- Belt that's far away  *** TURNED OFF FOR PERFORMANCE REASONS *** -->
+    <!-- Generate asteroid field and asteroid belt -->
+    <!--
+    <?lua
+        dofile("includes/asteroidField.lua")
+        asteroidBelt(0, 0, 0, -48, -34, 70, 100, 200, 219900, 210000, 900, 1)
+    ?>
+    -->
+
+
+    <!-- triple large belt around the planet  -->
+    <?lua
+        dofile("includes/asteroidField.lua")
+        asteroidBelt(15000, 0, 0, 30, 0, 30, 30, 50, 7190, 7800, 250, 1)
+    ?>
+    <?lua
+        dofile("includes/asteroidField.lua")
+        asteroidBelt(15000, 0, 0, 30, 0, 30, 30, 50, 10000, 11000, 300, 1)
+    ?>
+    <?lua
+        dofile("includes/asteroidField.lua")
+        asteroidBelt(15000, 0, 0, 30, 0, 30, 30, 50, 14000, 15000, 350, 1)
+    ?>
+
+<Drone name="meineDrohne" primarythrust="80" auxilarythrust="10" rotationthrust="10" mass="50" linearDamping="0.9" angularDamping="0.7">
+  <attached>
+    <Model position="10,10,10" scale="30" mesh="planets/earth.mesh" renderQueueGroup="stencil glow" material="glow"/>
+    <Model position="10,10,10" scale="30" mesh="planets/earth.mesh" renderQueueGroup="main" />
+  </attached>
+  <collisionShapes>
+    <SphereCollisionShape position="10,10,10" radius="30" />
+  </collisionShapes>
+</Drone>
+
+<LensFlare position="10000,20,5000" fadeOnViewBorder="true" fadeResolution="11" fadeExponent="2.0" scale="1.0" colour="1.0,0.85,0.8">
+</LensFlare>
+
+    <!-- Planet close to spawn point -->
+
+    <Planet
+      position="15000,0,-1000"
+      scale="5000"
+      collisionType="dynamic"
+      linearDamping="0.8"
+      angularDamping="0"
+      mass="10000000"
+      pitch="0"
+      mesh="planets/muunilinst.mesh"
+      atmosphere="atmosphere1"
+      rotationaxis="1,0,0"
+      rotationrate="1.0"
+      atmospheresize="80.0f"
+      imagesize="1024.0f"
+      collisiondamage = 2
+      enablecollisiondamage = true
+    >
+      <attached>
+        <ForceField position="5000,0,0" mode="sphere" diameter="10000" velocity="-50" />
+      </attached>
+      <collisionShapes>
+        <SphereCollisionShape radius="5000" position="0,0,0" />
+      </collisionShapes>
+    </Planet>
+
+
+
+
+
+
+
+  </Scene>
+</Level>

Modified: code/branches/shaders_merge/src/libraries/tools/Mesh.cc
===================================================================
--- code/branches/shaders_merge/src/libraries/tools/Mesh.cc	2016-01-18 20:58:41 UTC (rev 11072)
+++ code/branches/shaders_merge/src/libraries/tools/Mesh.cc	2016-01-18 21:12:53 UTC (rev 11073)
@@ -32,6 +32,7 @@
 #include <sstream>
 #include <string>
 #include <OgreEntity.h>
+#include <OgreSubEntity.h>
 #include <OgreSceneManager.h>
 
 #include "util/Convert.h"
@@ -92,6 +93,25 @@
             return BLANKSTRING;
     }
 
+    void Mesh::setMaterial(const std::string& name)
+    {
+        if (this->entity_)
+            this->entity_->setMaterialName(name);
+    }
+
+    const std::string& Mesh::getMaterial() const
+    {
+        if (this->entity_)
+        {
+            if(this->entity_->getSubEntity(0))
+                return this->entity_->getSubEntity(0)->getMaterialName(); //return the Material of the first SubEntity, should be enough for now
+            else
+                return BLANKSTRING;
+        }
+        else
+            return BLANKSTRING;
+    }
+
     void Mesh::setVisible(bool bVisible)
     {
         if (this->entity_)

Modified: code/branches/shaders_merge/src/libraries/tools/Mesh.h
===================================================================
--- code/branches/shaders_merge/src/libraries/tools/Mesh.h	2016-01-18 20:58:41 UTC (rev 11072)
+++ code/branches/shaders_merge/src/libraries/tools/Mesh.h	2016-01-18 21:12:53 UTC (rev 11073)
@@ -47,6 +47,9 @@
 
             const std::string& getName() const;
 
+            void setMaterial(const std::string& name);
+            const std::string& getMaterial() const;
+
             void setVisible(bool bVisible);
             bool isVisible() const;
 

Modified: code/branches/shaders_merge/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/shaders_merge/src/orxonox/CMakeLists.txt	2016-01-18 20:58:41 UTC (rev 11072)
+++ code/branches/shaders_merge/src/orxonox/CMakeLists.txt	2016-01-18 21:12:53 UTC (rev 11073)
@@ -35,6 +35,7 @@
 BUILD_UNIT SceneBuildUnit.cc
   CameraManager.cc
   Scene.cc
+  RenderQueueListener.cc
 END_BUILD_UNIT
 )
 

Modified: code/branches/shaders_merge/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/branches/shaders_merge/src/orxonox/OrxonoxPrereqs.h	2016-01-18 20:58:41 UTC (rev 11072)
+++ code/branches/shaders_merge/src/orxonox/OrxonoxPrereqs.h	2016-01-18 21:12:53 UTC (rev 11073)
@@ -74,6 +74,7 @@
     class LevelManager;
     class PlayerManager;
     class Radar;
+    class RenderQueueListener;
     class Scene;
     class GSLevelMemento;
     struct GSLevelMementoState;

Copied: code/branches/shaders_merge/src/orxonox/RenderQueueListener.cc (from rev 11072, code/branches/shaders/src/orxonox/RenderQueueListener.cc)
===================================================================
--- code/branches/shaders_merge/src/orxonox/RenderQueueListener.cc	                        (rev 0)
+++ code/branches/shaders_merge/src/orxonox/RenderQueueListener.cc	2016-01-18 21:12:53 UTC (rev 11073)
@@ -0,0 +1,124 @@
+/*
+ *   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 RenderQueueListener.cc
+  @brief Implementation of the RenderQueueListener class.
+*/
+
+#include "RenderQueueListener.h"
+
+#include <OgreRoot.h>
+#include <OgreRenderQueueListener.h>
+#include <OgreHardwareOcclusionQuery.h>
+
+namespace orxonox
+{
+    RenderQueueListener::RenderQueueListener() : pixelCount_(0), pixelState_(RenderQueueListener::READY_FOR_RENDER)
+    {
+        hardwareOcclusionQuery_ = Ogre::Root::getSingleton().getRenderSystem()->createHardwareOcclusionQuery(); //create a new HOQ for the scene this listener is used in
+    }
+    
+    RenderQueueListener::~RenderQueueListener()
+    {
+        Ogre::Root::getSingleton().getRenderSystem()->destroyHardwareOcclusionQuery(hardwareOcclusionQuery_); //destroy the created HOQ
+    }
+    
+    /**
+    @brief
+    This function is returning the current pixel count and resets the pixel state if we're ready to do another Hardware Occlusion Query
+    
+    @return
+    current pixel count taken from the last Hardware Occlusion Query
+    */
+    unsigned int RenderQueueListener::getPixelCount()
+    {
+        if(this->pixelState_==RenderQueueListener::READY_FOR_ACCESS)
+        {
+            this->hardwareOcclusionQuery_->pullOcclusionQuery(&(this->pixelCount_));
+            this->pixelState_=RenderQueueListener::READY_FOR_RENDER;
+        }
+        return this->pixelCount_;
+    }
+    
+    /**
+    @brief
+    This function is called just before a RenderQueueGroup is rendered, this function is called by Ogre automatically with the correct parameters.
+
+    In this case we use it to set the stencil buffer parameters of the render system and issue a Hardware Occlusion Query
+    */
+    void RenderQueueListener::renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation)
+    {
+        if (queueGroupId == RENDER_QUEUE_STENCIL_OBJECTS)
+        { 
+            Ogre::RenderSystem * renderSystem = Ogre::Root::getSingleton().getRenderSystem(); 
+
+            renderSystem->clearFrameBuffer(Ogre::FBT_STENCIL); 
+            renderSystem->setStencilCheckEnabled(true); 
+            renderSystem->setStencilBufferParams(Ogre::CMPF_ALWAYS_PASS,
+                STENCIL_VALUE_FOR_GLOW, STENCIL_FULL_MASK, 
+                Ogre::SOP_KEEP,Ogre::SOP_KEEP,Ogre::SOP_REPLACE,false);       
+        } 
+        if (queueGroupId == RENDER_QUEUE_STENCIL_GLOW)
+        { 
+            Ogre::RenderSystem * renderSystem = Ogre::Root::getSingleton().getRenderSystem(); 
+            renderSystem->setStencilCheckEnabled(true); 
+            renderSystem->setStencilBufferParams(Ogre::CMPF_NOT_EQUAL,
+                STENCIL_VALUE_FOR_GLOW, STENCIL_FULL_MASK, 
+                Ogre::SOP_KEEP,Ogre::SOP_KEEP,Ogre::SOP_REPLACE,false);       
+        }
+        if (queueGroupId == RENDER_QUEUE_HOQ && this->pixelState_==RenderQueueListener::READY_FOR_RENDER)
+        { 
+            this->hardwareOcclusionQuery_->beginOcclusionQuery();
+            this->pixelState_=RenderQueueListener::QUERY_STARTED;
+            //TODO: Skip this rendering step altogheter if we haven't requested the pixel count yet, not sure if this is possible without a custom SceneManager
+        }
+    }
+    
+    /**
+    @brief
+        This function is called just after a RenderQueueGroup has been rendered, this function is called by Ogre automatically with the correct parameters.
+        
+        in this case we use it to unset the stencil buffer parameters, so the rest of the render queue is unaffected by it.
+    */
+    void RenderQueueListener::renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation)
+    {
+        if (queueGroupId == RENDER_QUEUE_STENCIL_LAST) 
+        {
+            Ogre::RenderSystem * renderSystem = Ogre::Root::getSingleton().getRenderSystem(); 
+            renderSystem->setStencilCheckEnabled(false); 
+            renderSystem->setStencilBufferParams(); 
+        }
+        if (queueGroupId == RENDER_QUEUE_HOQ && this->pixelState_==RenderQueueListener::QUERY_STARTED)
+        {
+            this->hardwareOcclusionQuery_->endOcclusionQuery();
+            this->pixelState_=RenderQueueListener::READY_FOR_ACCESS;
+        }
+    }
+}
\ No newline at end of file

Copied: code/branches/shaders_merge/src/orxonox/RenderQueueListener.h (from rev 11072, code/branches/shaders/src/orxonox/RenderQueueListener.h)
===================================================================
--- code/branches/shaders_merge/src/orxonox/RenderQueueListener.h	                        (rev 0)
+++ code/branches/shaders_merge/src/orxonox/RenderQueueListener.h	2016-01-18 21:12:53 UTC (rev 11073)
@@ -0,0 +1,111 @@
+/*
+ *   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 RenderQueueListener.h
+  @brief Definition of the RenderQueueListener class.
+*/
+
+#ifndef _ORenderQueueListener_H__
+#define _ORenderQueueListener_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgreRenderQueueListener.h>
+#include <OgreHardwareOcclusionQuery.h>
+
+namespace orxonox
+{
+    enum RenderQueueGroupID //!< these are IDs for render queues that are executed just after the main render queue defined by Ogre, we need more than one for Stencil Glow
+    {
+        RENDER_QUEUE_MAIN = Ogre::RENDER_QUEUE_MAIN, //reference to the main render queue
+        RENDER_QUEUE_STENCIL_OBJECTS = RENDER_QUEUE_MAIN+1,
+        RENDER_QUEUE_STENCIL_GLOW = RENDER_QUEUE_MAIN+2,
+        RENDER_QUEUE_STENCIL_LAST = RENDER_QUEUE_STENCIL_GLOW, //this is a reference to the last render queue to be affected by stencil glow effects
+        RENDER_QUEUE_HOQ = RENDER_QUEUE_STENCIL_LAST+1 //this is where we render the objects for occlusion queries (use transparent material)
+    };
+
+    const int STENCIL_VALUE_FOR_GLOW = 1; //!< this is a reference value for our mask, 
+                                          //!< if more than one type of stencil mask is to be used, each of them need their own value
+    const int STENCIL_FULL_MASK = 0xFFFFFFFF; //!< this is a reference mask used in our stencil buffer
+    
+    /**
+    @brief
+        This class derives from the Ogre-Class RenderQueueListener and provides a way to define new rendering stages to enable use of e.g. stencil buffers
+        to increase the number of shader effects we can create. Especially important for shader-based alpha blending.
+
+    @author
+        David 'davidsa' Salvisberg
+    */
+    class _OrxonoxExport RenderQueueListener : public Ogre::RenderQueueListener
+    {
+        public:
+            RenderQueueListener();
+            ~RenderQueueListener();
+    
+            /**
+            @brief
+            This function is returning the current pixel count and resets the pixel state if we're ready to do another Hardware Occlusion Query
+            
+            @return
+            current pixel count taken from the last Hardware Occlusion Query
+            */
+            unsigned int getPixelCount();
+            
+            /**
+            @brief
+                This function is called just before a RenderQueueGroup is rendered, this function is called by Ogre automatically with the correct parameters.
+                
+                In this case we use it to set the stencil buffer parameters of the render system
+            */
+            virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation);
+            /**
+            @brief
+                This function is called just after a RenderQueueGroup has been rendered, this function is called by Ogre automatically with the correct parameters.
+                
+                in this case we use it to unset the stencil buffer parameters, so the rest of the render queue is unaffected by it.
+            */
+            virtual void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation);
+            
+        private:
+            Ogre::HardwareOcclusionQuery* hardwareOcclusionQuery_; //!< this stores the current instance of the HOQ used in the render system
+            unsigned int pixelCount_; //!< this stores the last pixel count returned by the last HOQ in the corresponding render group
+            
+            enum PixelState //!< enum to distinguish the several HOQ pixel count states
+            {
+                READY_FOR_RENDER,
+                QUERY_STARTED,
+                READY_FOR_ACCESS
+            };
+            
+            PixelState pixelState_; //!< this stores the current state of the Hardware Occlusion Query
+    };
+}
+
+#endif /* _ORenderQueueListener_H__ */
\ No newline at end of file

Modified: code/branches/shaders_merge/src/orxonox/Scene.cc
===================================================================
--- code/branches/shaders_merge/src/orxonox/Scene.cc	2016-01-18 20:58:41 UTC (rev 11072)
+++ code/branches/shaders_merge/src/orxonox/Scene.cc	2016-01-18 21:12:53 UTC (rev 11073)
@@ -27,6 +27,12 @@
  *
  */
 
+/**
+ at file Scene.cc
+ at brief Implementation of Scene Class
+*/
+
+
 #include "Scene.h"
 
 #include <OgreRoot.h>
@@ -50,11 +56,17 @@
 #include "Radar.h"
 #include "worldentities/WorldEntity.h"
 #include "Level.h"
+#include "RenderQueueListener.h"
 
 namespace orxonox
 {
     RegisterClass(Scene);
-
+    
+    /**
+    @brief 
+        Constructor, it sets common standard paramters for a scene depending on whether it will be rendered or not.
+        It also makes sure we user our own render queue listener for rendering instead of the standard listener provided by Ogre
+    */
     SetConsoleCommand("Scene", "debugDrawPhysics", &Scene::consoleCommand_debugDrawPhysics).addShortcut().defaultValue(1, true).defaultValue(2, 0.5f);
 
     Scene::Scene(Context* context) : BaseObject(context), Synchronisable(context), Context(context)
@@ -74,6 +86,8 @@
             assert(Ogre::Root::getSingletonPtr());
             this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);
             this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
+            this->renderQueueListener_ = new RenderQueueListener();
+            this->sceneManager_->addRenderQueueListener(this->renderQueueListener_);//add our own renderQueueListener
 
             this->radar_ = new Radar();
         }

Modified: code/branches/shaders_merge/src/orxonox/Scene.h
===================================================================
--- code/branches/shaders_merge/src/orxonox/Scene.h	2016-01-18 20:58:41 UTC (rev 11072)
+++ code/branches/shaders_merge/src/orxonox/Scene.h	2016-01-18 21:12:53 UTC (rev 11073)
@@ -27,6 +27,11 @@
  *
  */
 
+/**
+ at file Scene.h
+ at brief Definition of Scene Class
+*/
+
 #ifndef _Scene_H__
 #define _Scene_H__
 
@@ -48,6 +53,12 @@
     class _OrxonoxExport Scene : public BaseObject, public Synchronisable, public Tickable, public Context
     {
         public:
+            /**
+            @brief 
+                This class holds a Scene which is a collection of all kinds of objects to be rendered in the same space,
+                with the same physics and the same light properties. Objects can be anything from a light source, over non physical objects
+                like Billboards to just plain Models with an attached Mesh
+            */
             Scene(Context* context);
             virtual ~Scene();
 
@@ -58,6 +69,8 @@
                 { return this->sceneManager_; }
             inline Ogre::SceneNode* getRootSceneNode() const
                 { return this->rootSceneNode_; }
+            inline RenderQueueListener* getRenderQueueListener() const
+                { return this->renderQueueListener_; }
 
             void setSkybox(const std::string& skybox);
             inline const std::string& getSkybox() const
@@ -94,15 +107,16 @@
             void networkcallback_applyShadows()
                 { this->setShadow(this->bShadows_); }
 
-            Ogre::SceneManager*      sceneManager_;
-            Ogre::SceneNode*         rootSceneNode_;
+            Ogre::SceneManager*      sceneManager_; //!< This is a pointer to the Ogre SceneManager we're using to render the Scene
+            Ogre::SceneNode*         rootSceneNode_; //!< This is a pointer to the root node of the Scene tree
+            RenderQueueListener*     renderQueueListener_; //!< this is a pointer to the RenderQueueListener we're using for this Scene
 
-            std::string              skybox_;
-            ColourValue              ambientLight_;
-            std::list<BaseObject*>   objects_;
-            bool                     bShadows_;
-            float                    soundReferenceDistance_;
-            Radar*                   radar_;
+            std::string              skybox_; //!< This string holds information about the skybox we're using
+            ColourValue              ambientLight_; //!< This variable holds the color value for the ambient light in our scene, usually black in space
+            std::list<BaseObject*>   objects_; //!< This list holds all the objects created in our scene
+            bool                     bShadows_; //!< Do we want shadows in our scene?
+            float                    soundReferenceDistance_; //!< This holds a reference distance, which represents the distance between our scene and the listener
+            Radar*                   radar_; //!< This is a pointer to a Radar object assigned with this scene
 
 
         /////////////

Modified: code/branches/shaders_merge/src/orxonox/graphics/Billboard.cc
===================================================================
--- code/branches/shaders_merge/src/orxonox/graphics/Billboard.cc	2016-01-18 20:58:41 UTC (rev 11072)
+++ code/branches/shaders_merge/src/orxonox/graphics/Billboard.cc	2016-01-18 21:12:53 UTC (rev 11073)
@@ -170,4 +170,22 @@
             bSet->setDefaultDimensions(width, height);
         }
     }
+    
+    void Billboard::setRenderQueueGroup(unsigned char groupID)
+    {
+        Ogre::BillboardSet* bSet = this->billboard_.getBillboardSet();
+        if( bSet != NULL )
+        {
+            bSet->setRenderQueueGroup(groupID);
+        }
+    }
+    
+    void Billboard::disableFrustumCulling()
+    {
+        Ogre::BillboardSet* bSet = this->billboard_.getBillboardSet();
+        if( bSet != NULL )
+        {
+            bSet->setBounds(Ogre::AxisAlignedBox(Ogre::AxisAlignedBox::EXTENT_INFINITE),0);
+        }
+    }
 }

Modified: code/branches/shaders_merge/src/orxonox/graphics/Billboard.h
===================================================================
--- code/branches/shaders_merge/src/orxonox/graphics/Billboard.h	2016-01-18 20:58:41 UTC (rev 11072)
+++ code/branches/shaders_merge/src/orxonox/graphics/Billboard.h	2016-01-18 21:12:53 UTC (rev 11073)
@@ -80,6 +80,10 @@
             void setCommonUpVector(Vector3 vec); //!< normalised Vector vec as argument
             
             void setDefaultDimensions(float width, float height);
+            
+            void setRenderQueueGroup(unsigned char groupID);
+            
+            void disableFrustumCulling();
 
 
         protected:

Modified: code/branches/shaders_merge/src/orxonox/graphics/CMakeLists.txt
===================================================================
--- code/branches/shaders_merge/src/orxonox/graphics/CMakeLists.txt	2016-01-18 20:58:41 UTC (rev 11072)
+++ code/branches/shaders_merge/src/orxonox/graphics/CMakeLists.txt	2016-01-18 21:12:53 UTC (rev 11073)
@@ -12,6 +12,7 @@
 BUILD_UNIT GraphicsBuildUnit.cc
   Backlight.cc
   Camera.cc
+  LensFlare.cc
   Light.cc
 END_BUILD_UNIT
 )

Copied: code/branches/shaders_merge/src/orxonox/graphics/LensFlare.cc (from rev 11072, code/branches/shaders/src/orxonox/graphics/LensFlare.cc)
===================================================================
--- code/branches/shaders_merge/src/orxonox/graphics/LensFlare.cc	                        (rev 0)
+++ code/branches/shaders_merge/src/orxonox/graphics/LensFlare.cc	2016-01-18 21:12:53 UTC (rev 11073)
@@ -0,0 +1,229 @@
+ /*
+ *   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"
+#include "RenderQueueListener.h"
+
+#include <OgreSphere.h>
+#include <OgreRenderWindow.h>
+
+namespace orxonox
+{
+    RegisterClass(LensFlare);
+    
+    LensFlare::LensFlare(Context* context) : StaticEntity(context), scale_(1.0f), fadeOnViewBorder_(true), fadeResolution_(7), fadeExponent_(2.0f), colour_(new ColourValue(1.0f,0.9f,0.9f))
+    {
+        RegisterObject(LensFlare);
+        
+        this->lensConfiguration_=new std::vector<LensFlare::Lens*>();
+        this->lensConfiguration_->push_back(new LensFlare::Lens(new std::string("lensflare/burst"),1.0f,1.0f,1.0f)); //main burst
+        this->lensConfiguration_->push_back(new LensFlare::Lens(new std::string("lensflare/burst"),0.7f,1.2f,1.05f)); //secondary burst
+        this->lensConfiguration_->push_back(new LensFlare::Lens(new std::string("lensflare/bursthalo"),0.7f,0.9f,1.0f)); //halo around main burst
+        this->lensConfiguration_->push_back(new LensFlare::Lens(new std::string("lensflare/ring"),0.1f,2.5f,0.9f)); //all the different distanced lenses
+        this->lensConfiguration_->push_back(new LensFlare::Lens(new std::string("lensflare/iris"),0.1f,0.2f,0.5f));
+        this->lensConfiguration_->push_back(new LensFlare::Lens(new std::string("lensflare/halo5"),0.1f,0.3f,0.45f));
+        this->lensConfiguration_->push_back(new LensFlare::Lens(new std::string("lensflare/halo5"),0.4f,0.2f,0.35f));
+        this->lensConfiguration_->push_back(new LensFlare::Lens(new std::string("lensflare/iris"),0.1f,0.4f,0.25f));
+        this->lensConfiguration_->push_back(new LensFlare::Lens(new std::string("lensflare/halo4"),0.05f,0.2f,0.2f));
+        
+        this->createBillboards();
+        
+        this->registerVariables();
+    }
+
+    LensFlare::~LensFlare()
+    {
+    }
+
+    void LensFlare::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(LensFlare, XMLPort, xmlelement, mode);
+        XMLPortParam(LensFlare, "scale", setScale, getScale, xmlelement, mode).defaultValues(1.0f);
+        XMLPortParam(LensFlare, "fadeOnViewBorder", setFadeOnViewBorder, isFadeOnViewBorder, xmlelement, mode).defaultValues(true);
+        XMLPortParam(LensFlare, "fadeResolution", setFadeResolution, getFadeResolution, xmlelement, mode).defaultValues(7);
+        XMLPortParam(LensFlare, "fadeExponent", setFadeExponent, getFadeExponent, xmlelement, mode).defaultValues(2.0f);
+        XMLPortParam(LensFlare, "colour", setColour, getColour, xmlelement, mode);
+    }
+    
+    void LensFlare::registerVariables()
+    {
+        registerVariable(this->scale_, VariableDirection::ToClient);
+        registerVariable(this->fadeOnViewBorder_, VariableDirection::ToClient);
+        registerVariable(this->fadeResolution_, VariableDirection::ToClient);
+    }
+
+    /**
+    @brief
+        This function creates all the billboards needed for the flare effect
+    */
+    void LensFlare::createBillboards()
+    {
+        this->occlusionBillboard_ = new Billboard(this->getContext());
+        this->occlusionBillboard_->setMaterial("lensflare/hoq");
+        this->occlusionBillboard_->setVisible(false);
+        this->occlusionBillboard_->disableFrustumCulling();
+        this->occlusionBillboard_->setRenderQueueGroup(RENDER_QUEUE_HOQ);
+        this->attach(this->occlusionBillboard_);
+        
+        for(std::vector<LensFlare::Lens*>::iterator it = lensConfiguration_->begin(); it != lensConfiguration_->end(); ++it) {
+            Billboard* lensPart=new Billboard(this->getContext());
+            lensPart->setMaterial(*(*it)->material_);
+            lensPart->disableFrustumCulling();
+            lensPart->setVisible(true);
+            this->attach(lensPart);
+        }
+    }
+
+    /**
+    @brief
+        This function updates the states of all the billboards, i.e. their positions, visibilty and dimensions
+    @param viewDirection
+        normalised vector pointing from the current camera to the point light center
+    @param dimension
+        the current dimension of the main billboard, we're always using square billboards
+    @param lightIsVisible
+        is the (point-)light source currently visible
+    */
+    void LensFlare::updateBillboardStates(Vector3& viewDirection, float dimension, bool lightIsVisible)
+    { 
+        this->occlusionBillboard_->setDefaultDimensions(dimension*0.5f,dimension*0.5f);
+        this->occlusionBillboard_->setVisible(lightIsVisible);
+        std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin();
+        it++;
+        for(int i=0; it != this->getAttachedObjects().end(); it++) {
+            Billboard* billboard=static_cast<Billboard*>(*it);
+            LensFlare::Lens* lens=lensConfiguration_->at(i);
+            billboard->setPosition(-viewDirection*(1.0f-lens->position_));
+            billboard->setVisible(lightIsVisible);
+            billboard->setDefaultDimensions(dimension*lens->scale_,dimension*lens->scale_);
+            i++;
+        }
+    }
+
+    /**
+    @brief
+        This function updates the alpha values for all billboards except for the one used for Hardware Occlusion Querying
+    @param alpha
+        the new alpha value all visible billboards should use
+    */
+    void LensFlare::updateBillboardAlphas(float alpha)
+    {
+        this->colour_->a=alpha;
+        std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin();
+        it++;
+        for(int i=0;it!=this->getAttachedObjects().end(); it++) {
+            ColourValue* cur=new ColourValue(0,0,0,0);
+            (*cur)+= *(this->colour_);
+            cur->a*=lensConfiguration_->at(i)->alpha_;
+            Billboard* billboard=static_cast<Billboard*>(*it);
+            billboard->setColour(*cur);
+            i++;
+        }
+    }
+    
+    /**
+    @brief
+        This function generates point samples of the main burst billboard according to the fadeResolution and returns how many of them are in the view port
+    @param dimension
+        the current dimension of the main billboard, we're always using square billboards
+    @return
+        the absolute amount of point samples that are currently captured by the camera of the view port
+    */
+    unsigned int LensFlare::getPointCount(float dimension) const
+    {
+        Ogre::Camera* camera=CameraManager::getInstance().getActiveCamera()->getOgreCamera();
+        Vector3 position = this->getWorldPosition();
+        Vector3 nX = camera->getDerivedOrientation().xAxis().normalisedCopy();
+        Vector3 nY = camera->getDerivedOrientation().yAxis().normalisedCopy();
+        int halfRes=fadeResolution_/2;
+        float resDim=dimension/fadeResolution_;
+        unsigned int count=0;
+        for(int i=-halfRes;i<=halfRes;i++)
+        {
+            for(int j=-halfRes;j<=halfRes;j++)
+            {
+                Vector3 point=position+(i*resDim)*nX+(j*resDim)*nY;//generate point samples
+                if(camera->isVisible(point))
+                {
+                    count++;
+                }
+            }
+        }
+        return count;
+    }
+
+    void LensFlare::tick(float dt)
+    {
+        if(this->isVisible())
+        {
+            Ogre::Camera* camera=CameraManager::getInstance().getActiveCamera()->getOgreCamera(); //get active Ogre Camera Instance, so we can check whether the light source is visible
+            this->cameraDistance_=camera->getDerivedPosition().distance(this->getPosition());
+            float dimension=this->cameraDistance_*this->scale_;
+            if(!this->fadeOnViewBorder_)
+            {
+                this->fadeResolution_=3;//this is so we can still determine when the billboard has left the screen
+            }
+            unsigned int pointCount=this->getPointCount(dimension*0.25f*this->scale_);
+            Vector3 viewDirection=this->getWorldPosition()-camera->getDerivedPosition()-camera->getDerivedDirection()*this->cameraDistance_;
+            updateBillboardStates(viewDirection,dimension,pointCount>0);
+            if(pointCount>0) {
+                Ogre::Sphere* sphere=new Ogre::Sphere(this->getPosition(),dimension*0.25f*this->scale_);
+                float left, right, top, bottom;
+                camera->projectSphere(*sphere,&left,&top,&right,&bottom);//approximate maximum pixel count of billboard with a sphere
+                delete sphere;
+                
+                Ogre::RenderWindow* window = GraphicsManager::getInstance().getRenderWindow();
+                float maxCount=(right-left)*(top-bottom)*window->getWidth()*window->getHeight()*0.25f;
+                float pixelCount=this->getScene()->getRenderQueueListener()->getPixelCount();//get pixel count
+                float ratio=(maxCount<0.0f)?0.0f:(pixelCount/maxCount);//prevent underflow and division by zero
+                float borderRatio=1.0f;
+                if(this->fadeOnViewBorder_)
+                {
+                    borderRatio=((float) pointCount)/(((float) fadeResolution_)*((float) fadeResolution_));//ratio for the border fade
+                }
+                //update alpha values of all billboards except the HOQ billboard
+                this->updateBillboardAlphas(std::min(1.0f,std::pow(std::min(ratio,borderRatio),this->fadeExponent_)));
+            }
+        }
+    }
+
+    void LensFlare::changedVisibility()
+    {
+      
+    }
+}
\ No newline at end of file

Copied: code/branches/shaders_merge/src/orxonox/graphics/LensFlare.h (from rev 11072, code/branches/shaders/src/orxonox/graphics/LensFlare.h)
===================================================================
--- code/branches/shaders_merge/src/orxonox/graphics/LensFlare.h	                        (rev 0)
+++ code/branches/shaders_merge/src/orxonox/graphics/LensFlare.h	2016-01-18 21:12:53 UTC (rev 11073)
@@ -0,0 +1,194 @@
+ /*
+ *   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 "core/GraphicsManager.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
+    */
+    //TODO: The Hardware Occlusion only works properly for a single Flare on the screen,
+    // if we have multiple strong lights it'll become way more complicated to determine how much of every object is occluded individually
+    // there's below a 100 render queue groups, so maybe we should take turns for each object to be tested, so we only have one of the objects rendered at a time
+    // obviously we shouldn't use too many of these effects anyways, since they use a lot of processing power, so not sure whether it's worth implementing a solution that works for multiple lens flares on screen 
+    class _OrxonoxExport LensFlare : public StaticEntity, public Tickable
+    {
+          /**
+          @brief
+              This is a nested Class used to easily set properties of the different sublenses of a LensFlare effect
+          */
+          class Lens
+          {
+              public:
+                  std::string* material_;//!< Which material should the Lens use, current choices include burst, bursthalo, halo1, halo2, halo3
+                  float alpha_;//!< Which base alpha value should the Lens use
+                  float scale_;//!< Which base scale should the Lens Flare have
+                  float position_;//!< This defines how far along the view direction the flare should be positioned, e.g. 0.5 would position the flare halfway between the viewer and the base burst, 0 at the camera, 1 at the burst
+                  Lens(std::string* material, float alpha, float scale, float position)
+                  {
+                      this->material_=material;
+                      this->alpha_=alpha;
+                      this->scale_=scale;
+                      this->position_=position;
+                  }
+          };
+          
+        public:
+            LensFlare(Context* context);
+            virtual ~LensFlare();
+            
+            inline void setScale(float scale)
+                { this->scale_=scale; }
+            inline float getScale() const
+                { return this->scale_; }
+                
+            /**
+            @brief
+                This sets the base colour of the billboards
+            @param colour
+                Vector3 containing r,g,b values
+            */
+            inline void setColour(const ColourValue& colour)
+            {
+                this->colour_->r=colour.r;
+                this->colour_->g=colour.g;
+                this->colour_->b=colour.b;
+            }
+            /**
+            @brief
+                This returns the current base colour of the billboards
+            @return a Vector3 containing r,g,b values
+            */
+            inline const ColourValue& getColour() const
+                { return *(new ColourValue(this->colour_->r,this->colour_->g,this->colour_->b)); }
+                
+            /**
+            @brief
+                This sets the resolution of the out-of-screen-fade-effect
+                
+                the higher the resolution, the smoother the transition, but it will also have a greater impact on the performance
+                this happens with O(n^2) since it's a two dimensional operation.
+            @param fadeResolution
+                how many point samples should be used per axis
+                
+                note: this will always be an odd number, so the center point is included in the samples
+            */
+            inline void setFadeResolution(unsigned int fadeResolution)
+                { this->fadeResolution_=fadeResolution>0?fadeResolution:1; }
+            /**
+            @brief
+                This returns the resolution of the out-of-screen-fade-effect
+            @return how many point samples are being used per axis
+            */
+            inline unsigned int getFadeResolution() const
+                { return this->fadeResolution_; }
+                
+            /**
+            @brief
+                This sets the exponent of the fade-out function
+            @param exponent
+                how strong should the fade-out effect be
+            */
+            inline void setFadeExponent(float exponent)
+                { this->fadeExponent_=exponent; }
+            /**
+            @brief
+                This returns the exponent of the fade-out function
+            @return the exponent of the fade-out function
+            */
+            inline float getFadeExponent() const
+                { return this->fadeExponent_; }
+                
+            /**
+            @brief
+               Turn the out-of-screen-fade-effect on or off
+            @param fadeOnViewBorder
+                true to turn the effect on, false to turn it off
+            */
+            inline void setFadeOnViewBorder(bool fadeOnViewBorder)
+                { this->fadeOnViewBorder_=fadeOnViewBorder; }
+            /**
+            @brief
+               Determine whether the out-of-screen-fade-effect is on or off
+            @return
+                true if the effect is on, false if it is off
+            */
+            inline bool isFadeOnViewBorder() const
+                { return this->fadeOnViewBorder_; }
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            virtual void tick(float dt);
+
+            virtual void changedVisibility();
+
+        private:
+            void registerVariables();
+            
+            void createBillboards();
+            
+            void updateBillboardStates(Vector3& viewDirection, float dimension, bool isLightVisible);
+            
+            void updateBillboardAlphas(float alpha);
+            
+            unsigned int getPointCount(float dimension) const;
+            
+            std::vector<Lens*>* lensConfiguration_;//!< this stores the lensConfiguration
+            Billboard* occlusionBillboard_;//!< this is a transparent billboard used solely for the Hardware Occlusion Query
+            float cameraDistance_;//!< current distance of the lensflare center from the camera
+            float scale_;//!< this factor is used to scale the billboard to the desired size
+            bool fadeOnViewBorder_;//!< should the effect fade out on the border of the view?
+            unsigned int fadeResolution_;//!< how many points should be sampled per axis for the screen border fade. High number => smooth fade, but uses more processing power
+            float fadeExponent_;//!< this determines how fast the flare fades away as it gets obstructed
+            ColourValue* colour_;//!< this stores the base colour of the light
+    };
+}
+
+#endif /* _LensFlare_H__ */
\ No newline at end of file

Modified: code/branches/shaders_merge/src/orxonox/graphics/Model.cc
===================================================================
--- code/branches/shaders_merge/src/orxonox/graphics/Model.cc	2016-01-18 20:58:41 UTC (rev 11072)
+++ code/branches/shaders_merge/src/orxonox/graphics/Model.cc	2016-01-18 21:12:53 UTC (rev 11073)
@@ -36,6 +36,7 @@
 #include "core/GameMode.h"
 #include "core/XMLPort.h"
 #include "Scene.h"
+#include "RenderQueueListener.h"
 #include "graphics/MeshLodInformation.h"
 #include "Level.h"
 
@@ -44,7 +45,7 @@
     RegisterClass(Model);
 
     Model::Model(Context* context) :
-        StaticEntity(context), bCastShadows_(true), lodLevel_(5), bLodEnabled_(true), numLodLevels_(10), lodReductionRate_(.15f)
+        StaticEntity(context), bCastShadows_(true), renderQueueGroup_(RENDER_QUEUE_MAIN), lodLevel_(5), bLodEnabled_(true), numLodLevels_(10), lodReductionRate_(.15f)
     {
         RegisterObject(Model);
 
@@ -71,12 +72,38 @@
         XMLPortParam(Model, "lodLevel", setLodLevel, getLodLevel, xmlelement, mode);
 
         XMLPortParam(Model, "mesh", setMeshSource, getMeshSource, xmlelement, mode);
+        XMLPortParam(Model, "renderQueueGroup", setRenderQueueGroup, getRenderQueueGroup, xmlelement, mode);
+        XMLPortParam(Model, "material", setMaterial, getMaterial, xmlelement, mode);
         XMLPortParam(Model, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true);
     }
+    
+    /**
+    @brief
+        This function turns a string from XML Port into a usable ID for the rendering system
+        It defaults to the main queue if the group isn't recognized.
+        
+    @param renderQueueGroup
+        This is a string representing the render queue group. Accepted values:
+        'main', 'stencil glow', 'stencil object'
+    */
+    const unsigned int Model::getRenderQueueGroupID(const std::string& renderQueueGroup) const
+    {
+        if(renderQueueGroup.compare("stencil glow")==0)
+        {
+            return RENDER_QUEUE_STENCIL_GLOW;
+        }
+        if(renderQueueGroup.compare("stencil object")==0)
+        {
+            return RENDER_QUEUE_STENCIL_OBJECTS;
+        }
+        return RENDER_QUEUE_MAIN;
+    }
 
     void Model::registerVariables()
     {
         registerVariable(this->meshSrc_,    VariableDirection::ToClient, new NetworkCallback<Model>(this, &Model::changedMesh));
+        registerVariable(this->renderQueueGroup_,    VariableDirection::ToClient, new NetworkCallback<Model>(this, &Model::changedRenderQueueGroup));
+        registerVariable(this->materialName_,    VariableDirection::ToClient, new NetworkCallback<Model>(this, &Model::changedMaterial));
         registerVariable(this->bCastShadows_, VariableDirection::ToClient, new NetworkCallback<Model>(this, &Model::changedShadows));
     }
 
@@ -103,6 +130,7 @@
             {
                 this->attachOgreObject(this->mesh_.getEntity());
                 this->mesh_.getEntity()->setCastShadows(this->bCastShadows_);
+                this->mesh_.getEntity()->setRenderQueueGroup(this->renderQueueGroup_);
                 this->mesh_.setVisible(this->isVisible());
 
                 if (this->bGlobalEnableLod_)
@@ -111,6 +139,22 @@
         }
     }
 
+    void Model::changedRenderQueueGroup()
+    {
+        if (GameMode::showsGraphics())
+        {
+            if (this->mesh_.getEntity())
+            {
+                this->mesh_.getEntity()->setRenderQueueGroup(this->renderQueueGroup_);
+            }
+        }
+    }
+
+    void Model::changedMaterial()
+    {
+        this->mesh_.setMaterial(this->materialName_);
+    }
+
     void Model::changedShadows()
     {
         this->mesh_.setCastShadows(this->bCastShadows_);

Modified: code/branches/shaders_merge/src/orxonox/graphics/Model.h
===================================================================
--- code/branches/shaders_merge/src/orxonox/graphics/Model.h	2016-01-18 20:58:41 UTC (rev 11072)
+++ code/branches/shaders_merge/src/orxonox/graphics/Model.h	2016-01-18 21:12:53 UTC (rev 11073)
@@ -26,6 +26,11 @@
  *
  */
 
+/**
+  @file Model.h
+  @brief Definition of Model Class
+*/
+
 #ifndef _Model_H__
 #define _Model_H__
 
@@ -33,12 +38,20 @@
 
 #include <string>
 #include "tools/Mesh.h"
+#include "RenderQueueListener.h"
 #include "worldentities/StaticEntity.h"
 
 namespace orxonox
 {
     class _OrxonoxExport Model : public StaticEntity
     {
+        /**
+        @brief
+            The class Model stores a Mesh and some additional properties, so you can easily render any Model and apply different effects to it.
+            
+            You can assign any Material to any Mesh to completely change the way it looks, to further add versatility you can also assign the Model
+            to a render queue group, to enable proper rendering of fancy effect like glowing edges around objects with alpha blending.
+        */
         public:
             Model(Context* context);
             virtual ~Model();
@@ -57,14 +70,37 @@
             inline const std::string& getMeshSource() const
                 { return this->meshSrc_; }
 
+            inline void setRenderQueueGroup(const std::string& renderQueueGroup)
+                { this->renderQueueGroup_ = getRenderQueueGroupID(renderQueueGroup); this->changedRenderQueueGroup(); }
+            inline const int getRenderQueueGroup() const
+                { return this->renderQueueGroup_; }
+
             inline void setCastShadows(bool bCastShadows)
                 { this->bCastShadows_ = bCastShadows; this->changedShadows(); }
             inline bool getCastShadows() const
                 { return this->bCastShadows_; }
 
+            inline void setMaterial(const std::string& materialname)
+                { this->materialName_ = materialname; this->changedMaterial(); }
+            inline const std::string& getMaterial() const
+                { return this->materialName_; }
+
         protected:
+            /**
+            @brief
+                This function turns a string from XML Port into a usable ID for the rendering system
+                It defaults to the main queue if the group isn't recognized.
+                
+            @param renderQueueGroup
+                This is a string representing the render queue group. Accepted values:
+                main, stencil glow, stencil object
+            */
+            const unsigned int getRenderQueueGroupID(const std::string& renderQueueGroup) const;
+
             void registerVariables();
             void changedMesh();
+            void changedRenderQueueGroup();
+            void changedMaterial();
             void changedShadows();
 
             //LoD
@@ -76,16 +112,18 @@
                 { return this->lodLevel_; }
             float getBiggestScale(Vector3 scale3d);
 
-            std::string meshSrc_;
-            Mesh mesh_;
-            bool bCastShadows_;
+            std::string meshSrc_; //!< This string stores the path where the mesh is stored
+            Mesh mesh_; //!< This is the mesh object linked to this Object, it stores the data from the mesh file in a usable format for the Ogre engine
+            bool bCastShadows_; //!< This value determines whether a Model is casting a shadow or not, turn it off to save performance, when not needed
+            unsigned int renderQueueGroup_; //!< This variable stores which render queue group this object is assigned to
+            std::string materialName_; //!< This string stores the name of the material to be applied to the mesh/model
 
             //LoD
-            bool bGlobalEnableLod_;
-            float lodLevel_;
-            bool bLodEnabled_;
-            unsigned int numLodLevels_;
-            float lodReductionRate_;
+            bool bGlobalEnableLod_; //!< Has LoD been turned on in the graphics configuration?
+            float lodLevel_; //!< Standard LoD Level
+            bool bLodEnabled_; //!< Is LoD to be used on this model?
+            unsigned int numLodLevels_; //!< How many LoD does this model feature
+            float lodReductionRate_; //!< How fast should be switched to lower LoDs
 
     };
 }




More information about the Orxonox-commit mailing list