[Orxonox-commit 2210] r6926 - in code/branches/presentation3: . data/levels data/levels/templates src/libraries/core src/orxonox src/orxonox/graphics

scheusso at orxonox.net scheusso at orxonox.net
Thu May 20 10:23:22 CEST 2010


Author: scheusso
Date: 2010-05-20 10:23:22 +0200 (Thu, 20 May 2010)
New Revision: 6926

Added:
   code/branches/presentation3/data/levels/presentationLOD.oxw
   code/branches/presentation3/data/levels/presentationLODdif.oxw
   code/branches/presentation3/data/levels/templates/lodinformation.oxt
   code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.cc
   code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.h
Modified:
   code/branches/presentation3/
   code/branches/presentation3/data/levels/empty_level.oxw
   code/branches/presentation3/data/levels/gametype_asteroids.oxw
   code/branches/presentation3/data/levels/gametype_underattack.oxw
   code/branches/presentation3/data/levels/teambasematchlevel.oxw
   code/branches/presentation3/data/levels/teamdeathmatch.oxw
   code/branches/presentation3/src/libraries/core/BaseObject.cc
   code/branches/presentation3/src/libraries/core/BaseObject.h
   code/branches/presentation3/src/orxonox/Level.cc
   code/branches/presentation3/src/orxonox/Level.h
   code/branches/presentation3/src/orxonox/LevelManager.cc
   code/branches/presentation3/src/orxonox/graphics/CMakeLists.txt
   code/branches/presentation3/src/orxonox/graphics/Model.cc
   code/branches/presentation3/src/orxonox/graphics/Model.h
Log:
merging lod branch into presentation3 merger branch



Property changes on: code/branches/presentation3
___________________________________________________________________
Modified: svn:mergeinfo
   - /code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/console:5941-6104
/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/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/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lodfinal:2372-2411
/code/branches/map:2801-3086,3089
/code/branches/menu:5941-6146,6148
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network64:2210-2355
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/overlay:2117-2385
/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/pickup2:5942-6405
/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/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/presentation:2369-2652,2654-2660
/code/branches/presentation2:6106-6416
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/script_trigger:1295-1953,1955
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890
   + /code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/console:5941-6104
/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/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/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/map:2801-3086,3089
/code/branches/menu:5941-6146,6148
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network64:2210-2355
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/overlay:2117-2385
/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/pickup2:5942-6405
/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/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/presentation:2369-2652,2654-2660
/code/branches/presentation2:6106-6416
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/script_trigger:1295-1953,1955
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890

Modified: code/branches/presentation3/data/levels/empty_level.oxw
===================================================================
--- code/branches/presentation3/data/levels/empty_level.oxw	2010-05-19 22:22:36 UTC (rev 6925)
+++ code/branches/presentation3/data/levels/empty_level.oxw	2010-05-20 08:23:22 UTC (rev 6926)
@@ -1,6 +1,7 @@
 <?lua
   include("stats.oxo")
   include("hudtemplates3.oxo")
+  include("templates/lodinformation.oxt")
 ?>
 
 <?lua
@@ -12,6 +13,10 @@
  name         = "Sample"
  description  = "Just a few tests"
 >
+  <templates>
+    <Template link=lodtemplate_default />
+  </templates>
+
   <Scene
     ambientlight = "0.8, 0.8, 0.8"
     skybox       = "Orxonox/Starbox"

Modified: code/branches/presentation3/data/levels/gametype_asteroids.oxw
===================================================================
--- code/branches/presentation3/data/levels/gametype_asteroids.oxw	2010-05-19 22:22:36 UTC (rev 6925)
+++ code/branches/presentation3/data/levels/gametype_asteroids.oxw	2010-05-20 08:23:22 UTC (rev 6926)
@@ -2,6 +2,7 @@
   include("hudtemplates3.oxo")
   include("stats.oxo")
   include("templates/spaceship_assff.oxt")
+  include("templates/lodinformation.oxt")
 ?>
 
 <Level
@@ -9,6 +10,10 @@
  description  = "testmap for gametype asteroid race"
  gametype     =  Asteroids
 >
+  <templates>
+    <Template link=lodtemplate_default />
+  </templates>
+
 <Scene
  ambientlight = "0.5, 0.5, 0.5"
  skybox       = "Orxonox/Starbox"

Modified: code/branches/presentation3/data/levels/gametype_underattack.oxw
===================================================================
--- code/branches/presentation3/data/levels/gametype_underattack.oxw	2010-05-19 22:22:36 UTC (rev 6925)
+++ code/branches/presentation3/data/levels/gametype_underattack.oxw	2010-05-20 08:23:22 UTC (rev 6926)
@@ -3,6 +3,7 @@
   include("stats.oxo")
   include("underattackhud.oxo")
   include("templates/spaceship_assff.oxt")
+  include("templates/lodinformation.oxt")
 ?>
 
 <Level
@@ -10,6 +11,10 @@
  description  = "A simple testlevel"
  gametype     = UnderAttack
 >
+  <templates>
+    <Template link=lodtemplate_default />
+  </templates>
+
   <Scene
    ambientlight = "0.5, 0.5, 0.5"
    skybox       = "Orxonox/skypanoramagen1"

Copied: code/branches/presentation3/data/levels/presentationLOD.oxw (from rev 6911, code/branches/lod/data/levels/presentationLOD.oxw)
===================================================================
--- code/branches/presentation3/data/levels/presentationLOD.oxw	                        (rev 0)
+++ code/branches/presentation3/data/levels/presentationLOD.oxw	2010-05-20 08:23:22 UTC (rev 6926)
@@ -0,0 +1,24 @@
+<?lua
+  include("stats.oxo")
+  include("hudtemplates3.oxo")
+?>
+
+<?lua
+  include("templates/spaceship_assff.oxt")
+  include("templates/spaceship_pirate.oxt")
+?>
+
+<Level
+ name         = "Sample"
+ description  = "Just a few tests"
+>
+  <Scene
+    ambientlight = "0.8, 0.8, 0.8"
+    skybox       = "Orxonox/Starbox"
+  >
+    <Model position="0,10,0" scale=3 mesh="ast3.mesh"/>
+    <Model position="0,-10,0" scale=3 mesh="ast3.mesh"/>
+    <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 position="0,0,100" spawnclass=SpaceShip pawndesign=spaceshipassff />
+  </Scene>
+</Level>

Copied: code/branches/presentation3/data/levels/presentationLODdif.oxw (from rev 6911, code/branches/lod/data/levels/presentationLODdif.oxw)
===================================================================
--- code/branches/presentation3/data/levels/presentationLODdif.oxw	                        (rev 0)
+++ code/branches/presentation3/data/levels/presentationLODdif.oxw	2010-05-20 08:23:22 UTC (rev 6926)
@@ -0,0 +1,35 @@
+<?lua
+  include("stats.oxo")
+  include("hudtemplates3.oxo")
+  include("lodinformation.oxt")
+?>
+
+<?lua
+  include("templates/spaceship_assff.oxt")
+  include("templates/spaceship_pirate.oxt")
+?>
+
+<Level
+ name         = "Sample"
+ description  = "Just a few tests"
+>
+  <lodinformation>
+	  <MeshLodInformation mesh=ast1.mesh lodQuality=4 />
+  </lodinformation>
+  <Scene
+    ambientlight = "0.8, 0.8, 0.8"
+    skybox       = "Orxonox/Starbox"
+  >
+    <Model position="0,10,0" scale=3 mesh="ast3.mesh"/>
+	<Model position="0,-10,0" scale=3 mesh="ast3.mesh" lodLevel="1"/>
+    <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 position="0,0,100" spawnclass=SpaceShip pawndesign=spaceshipassff />
+	
+  </Scene>
+
+  <templates>
+	<Template link=lodtemplate_default />
+  </templates>
+</Level>
+
+ 
\ No newline at end of file

Modified: code/branches/presentation3/data/levels/teambasematchlevel.oxw
===================================================================
--- code/branches/presentation3/data/levels/teambasematchlevel.oxw	2010-05-19 22:22:36 UTC (rev 6925)
+++ code/branches/presentation3/data/levels/teambasematchlevel.oxw	2010-05-20 08:23:22 UTC (rev 6926)
@@ -4,6 +4,7 @@
   include("teambasematchhud.oxo")
   include("templates/spaceship_assff.oxt")
   include("templates/spaceship_pirate.oxt")
+  include("templates/lodinformation.oxt")
 ?>
 
 <Level
@@ -11,6 +12,10 @@
  description  = "A simple testlevel"
  gametype     = TeamBaseMatch
 >
+  <templates>
+    <Template link=lodtemplate_default />
+  </templates>
+
   <Scene
    ambientlight = "0.5, 0.5, 0.5"
    skybox       = "Orxonox/skypanoramagen1"

Modified: code/branches/presentation3/data/levels/teamdeathmatch.oxw
===================================================================
--- code/branches/presentation3/data/levels/teamdeathmatch.oxw	2010-05-19 22:22:36 UTC (rev 6925)
+++ code/branches/presentation3/data/levels/teamdeathmatch.oxw	2010-05-20 08:23:22 UTC (rev 6926)
@@ -4,6 +4,7 @@
   include("templates/spaceship_assff.oxt")
   include("templates/spaceship_H2.oxt")
   include("templates/spaceship_pirate.oxt")
+  include("templates/lodinformation.oxt")
 ?>
 
 <Level
@@ -11,6 +12,10 @@
  description  = "Testing waypoings for AI controlled spaceships."
  gametype     = TeamDeathmatch
 >
+  <templates>
+    <Template link=lodtemplate_default />
+  </templates>
+
   <Scene
    ambientlight = "0.7, 0.6, 0.6"
    skybox       = "Orxonox/skypanoramagen1"

Copied: code/branches/presentation3/data/levels/templates/lodinformation.oxt (from rev 6911, code/branches/lod/data/levels/templates/lodinformation.oxt)
===================================================================
--- code/branches/presentation3/data/levels/templates/lodinformation.oxt	                        (rev 0)
+++ code/branches/presentation3/data/levels/templates/lodinformation.oxt	2010-05-20 08:23:22 UTC (rev 6926)
@@ -0,0 +1,8 @@
+<Template name=lodtemplate_default>
+  <Level>
+	<lodinformation>
+	  <MeshLodInformation mesh=Carrier.mesh lodQuality=1.8 />
+	  <MeshLodInformation mesh=assff.mesh lodQuality=3 />
+	</lodinformation>
+  </Level>
+</Template>
\ No newline at end of file

Modified: code/branches/presentation3/src/libraries/core/BaseObject.cc
===================================================================
--- code/branches/presentation3/src/libraries/core/BaseObject.cc	2010-05-19 22:22:36 UTC (rev 6925)
+++ code/branches/presentation3/src/libraries/core/BaseObject.cc	2010-05-20 08:23:22 UTC (rev 6926)
@@ -74,6 +74,7 @@
             this->setNamespace(this->creator_->getNamespace());
             this->setScene(this->creator_->getScene(), this->creator_->getSceneID());
             this->setGametype(this->creator_->getGametype());
+            this->setLevel(this->creator_->getLevel());
         }
         else
         {
@@ -82,6 +83,7 @@
             this->scene_ = 0;
             this->sceneID_ = OBJECTID_UNKNOWN;
             this->gametype_ = 0;
+            this->level_ = 0;
         }
     }
 

Modified: code/branches/presentation3/src/libraries/core/BaseObject.h
===================================================================
--- code/branches/presentation3/src/libraries/core/BaseObject.h	2010-05-19 22:22:36 UTC (rev 6925)
+++ code/branches/presentation3/src/libraries/core/BaseObject.h	2010-05-20 08:23:22 UTC (rev 6926)
@@ -50,6 +50,7 @@
 {
     class Scene;
     class Gametype;
+    class Level;
 
     //! The BaseObject is the parent of all classes representing an instance in the game.
     class _CoreExport BaseObject : virtual public OrxonoxClass
@@ -152,6 +153,17 @@
             inline const SmartPtr<Gametype>& getGametype() const { return this->gametype_; }
             inline Gametype* getOldGametype() const { return this->oldGametype_; }
             virtual void changedGametype() {}
+            
+            inline void setLevel(const SmartPtr<Level>& level)
+            {
+                if (level != this->level_)
+                {
+                    this->level_ = level;
+                    this->changedLevel();
+                }
+            }
+            inline const SmartPtr<Level>& getLevel() const { return this->level_; }
+            virtual void changedLevel() {}
 
             void addEventSource(BaseObject* source, const std::string& state);
             void removeEventSource(BaseObject* source);
@@ -208,6 +220,7 @@
             uint32_t               sceneID_;
             SmartPtr<Gametype>     gametype_;
             Gametype*              oldGametype_;
+            SmartPtr<Level>        level_;
             std::set<Template*>    templates_;
 
             std::map<BaseObject*, std::string>  eventSources_;           //!< List of objects which send events to this object, mapped to the state which they affect

Modified: code/branches/presentation3/src/orxonox/Level.cc
===================================================================
--- code/branches/presentation3/src/orxonox/Level.cc	2010-05-19 22:22:36 UTC (rev 6925)
+++ code/branches/presentation3/src/orxonox/Level.cc	2010-05-20 08:23:22 UTC (rev 6926)
@@ -48,6 +48,7 @@
     {
         RegisterObject(Level);
 
+        
         this->registerVariables();
         this->xmlfilename_ = this->getFilename();
         this->xmlfile_ = 0;
@@ -71,9 +72,10 @@
 
         XMLPortParam(Level, "description", setDescription, getDescription, xmlelement, mode);
         XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
-
+            
+        XMLPortObject(Level, MeshLodInformation, "lodinformation", addLodInfo, getLodInfo, xmlelement, mode);
         XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
-    }
+}
 
     void Level::registerVariables()
     {
@@ -124,6 +126,7 @@
     {
         this->objects_.push_back(object);
         object->setGametype(this->getGametype());
+    object->setLevel(this);
     }
 
     BaseObject* Level::getObject(unsigned int index) const
@@ -137,7 +140,21 @@
         }
         return 0;
     }
+    
+    void Level::addLodInfo(MeshLodInformation* lodInformation)
+    {
+        std::string meshName = lodInformation->getMeshName();
+        this->lodInformation_.insert(std::make_pair(meshName,lodInformation));
+    }
 
+    MeshLodInformation* Level::getLodInfo(std::string meshName) const
+    {
+        if(this->lodInformation_.find(meshName)!=this->lodInformation_.end())
+            return this->lodInformation_.find(meshName)->second;
+        
+        return 0;
+    }
+
     void Level::playerEntered(PlayerInfo* player)
     {
         COUT(3) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << std::endl;

Modified: code/branches/presentation3/src/orxonox/Level.h
===================================================================
--- code/branches/presentation3/src/orxonox/Level.h	2010-05-19 22:22:36 UTC (rev 6925)
+++ code/branches/presentation3/src/orxonox/Level.h	2010-05-20 08:23:22 UTC (rev 6926)
@@ -33,8 +33,10 @@
 
 #include <list>
 #include <string>
+#include <map>
 #include "core/BaseObject.h"
 #include "network/synchronisable/Synchronisable.h"
+#include "graphics/MeshLodInformation.h"
 
 namespace orxonox
 {
@@ -54,22 +56,30 @@
 
             void playerEntered(PlayerInfo* player);
             void playerLeft(PlayerInfo* player);
+			
+            MeshLodInformation* getLodInfo(std::string meshName) const;
 
+
         private:
             void addObject(BaseObject* object);
             BaseObject* getObject(unsigned int index) const;
 
+            void addLodInfo(MeshLodInformation* object);
+//            const MeshLodInformation* getLodInfo(std::string meshName) const;
+//            MeshLodInformation* getLodInfo(unsigned int index) const;
+
             void setGametypeString(const std::string& gametype);
             inline const std::string& getGametypeString() const
                 { return this->gametype_; }
 
             void networkcallback_applyXMLFile();
 
-            std::string            description_;
-            std::string            gametype_;
-            std::string            xmlfilename_;
-            XMLFile*               xmlfile_;
-            std::list<BaseObject*> objects_;
+            std::string                    description_;
+            std::string                    gametype_;
+            std::string                    xmlfilename_;
+            XMLFile*                       xmlfile_;
+            std::list<BaseObject*>         objects_;
+            std::map<std::string,MeshLodInformation*>  lodInformation_;
     };
 }
 

Modified: code/branches/presentation3/src/orxonox/LevelManager.cc
===================================================================
--- code/branches/presentation3/src/orxonox/LevelManager.cc	2010-05-19 22:22:36 UTC (rev 6925)
+++ code/branches/presentation3/src/orxonox/LevelManager.cc	2010-05-20 08:23:22 UTC (rev 6926)
@@ -69,6 +69,7 @@
 
     void LevelManager::requestActivity(Level* level)
     {
+        COUT(0) << "pushing level into level list: " << level << endl;
         this->levels_s.push_back(level);
         if (this->levels_s.size() == 1)
             this->activateNextLevel();
@@ -76,6 +77,7 @@
 
     void LevelManager::releaseActivity(Level* level)
     {
+        COUT(0) << "poping level from level list: " << level << endl;
         if (this->levels_s.size() > 0)
         {
             if (this->levels_s.front() == level)

Modified: code/branches/presentation3/src/orxonox/graphics/CMakeLists.txt
===================================================================
--- code/branches/presentation3/src/orxonox/graphics/CMakeLists.txt	2010-05-19 22:22:36 UTC (rev 6925)
+++ code/branches/presentation3/src/orxonox/graphics/CMakeLists.txt	2010-05-20 08:23:22 UTC (rev 6926)
@@ -3,6 +3,7 @@
   BlinkingBillboard.cc
   FadingBillboard.cc
   GlobalShader.cc
+  MeshLodInformation.cc
   Model.cc
   ParticleEmitter.cc
   ParticleSpawner.cc

Copied: code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.cc (from rev 6911, code/branches/lod/src/orxonox/graphics/MeshLodInformation.cc)
===================================================================
--- code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.cc	                        (rev 0)
+++ code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.cc	2010-05-20 08:23:22 UTC (rev 6926)
@@ -0,0 +1,82 @@
+/*
+ *   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:
+ *      Jan Bernegger
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "MeshLodInformation.h"
+
+#include <OgreEntity.h>
+
+#include "core/CoreIncludes.h"
+#include "core/GameMode.h"
+#include "core/XMLPort.h"
+#include "Scene.h"
+
+namespace orxonox
+{
+    CreateFactory(MeshLodInformation);
+
+    MeshLodInformation::MeshLodInformation(BaseObject* creator) 
+	: BaseObject(creator), lodLevel_(-1)
+    {
+        RegisterObject(MeshLodInformation);
+    }
+
+    MeshLodInformation::~MeshLodInformation()
+    {    }
+
+    void MeshLodInformation::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(MeshLodInformation, XMLPort, xmlelement, mode);
+
+        XMLPortParam(MeshLodInformation, "mesh", setMeshSource, getMeshSource, xmlelement, mode);
+        XMLPortParam(MeshLodInformation, "lodQuality", setLodLevel, getLodLevel, xmlelement, mode);
+    }
+    
+    std::string MeshLodInformation::getMeshName()
+    {
+		return MeshLodInformation::getMeshSource();
+    }
+	
+	void MeshLodInformation::setLodLevel(float lodLevel)
+	{
+        if(lodLevel>=0)
+		    lodLevel_=lodLevel;
+	}
+	float MeshLodInformation::getLodLevel()
+	{
+		return lodLevel_;
+	} 
+	void MeshLodInformation::setMeshSource(std::string meshSource)
+	{
+		meshSource_ = meshSource;
+	}
+	std::string MeshLodInformation::getMeshSource()
+	{
+		return meshSource_;
+	}
+ 
+}

Copied: code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.h (from rev 6911, code/branches/lod/src/orxonox/graphics/MeshLodInformation.h)
===================================================================
--- code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.h	                        (rev 0)
+++ code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.h	2010-05-20 08:23:22 UTC (rev 6926)
@@ -0,0 +1,60 @@
+/*
+ *   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:
+ *      Jan Bernegger
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _MeshLodInformation_H__
+#define _MeshLodInformation_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+#include "tools/Mesh.h"
+#include "worldentities/StaticEntity.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport MeshLodInformation : public BaseObject
+    {
+		private:
+			void setLodLevel(float lodLevel);
+			void setMeshSource(std::string meshSource);
+			std::string getMeshSource();
+			std::string meshSource_;
+			float lodLevel_;
+		
+        public:
+            MeshLodInformation(BaseObject* creator);
+            virtual ~MeshLodInformation();
+            
+			float getLodLevel();
+            std::string getMeshName();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+    };
+}
+
+#endif /* _MeshLodInformation_H__ */

Modified: code/branches/presentation3/src/orxonox/graphics/Model.cc
===================================================================
--- code/branches/presentation3/src/orxonox/graphics/Model.cc	2010-05-19 22:22:36 UTC (rev 6925)
+++ code/branches/presentation3/src/orxonox/graphics/Model.cc	2010-05-20 08:23:22 UTC (rev 6926)
@@ -34,6 +34,8 @@
 #include "core/GameMode.h"
 #include "core/XMLPort.h"
 #include "Scene.h"
+#include "graphics/MeshLodInformation.h"
+#include "Level.h"
 
 namespace orxonox
 {
@@ -46,6 +48,8 @@
         this->bCastShadows_ = true;
 
         this->registerVariables();
+        //LoD
+        this->lodLevel_=5;
     }
 
     Model::~Model()
@@ -57,7 +61,9 @@
     void Model::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
         SUPER(Model, XMLPort, xmlelement, mode);
-
+        
+        XMLPortParam(Model, "lodLevel", setLodLevel, getLodLevel, xmlelement, mode);
+        
         XMLPortParam(Model, "mesh", setMeshSource, getMeshSource, xmlelement, mode);
         XMLPortParam(Model, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true);
     }
@@ -68,13 +74,23 @@
         registerVariable(this->bCastShadows_, VariableDirection::ToClient, new NetworkCallback<Model>(this, &Model::changedShadows));
     }
 
+    float Model::getBiggestScale(Vector3 scale3d)
+    {
+        float scaleFactor = scale3d.x;
+        if(scale3d.y>scaleFactor)
+            scaleFactor = scale3d.y;
+        if(scale3d.z>scaleFactor)
+            scaleFactor = scale3d.z;
+        return scaleFactor;
+    }
+    
     void Model::changedMesh()
     {
         if (GameMode::showsGraphics())
         {
             if (this->mesh_.getEntity())
                 this->detachOgreObject(this->mesh_.getEntity());
-
+            
             this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
 
             if (this->mesh_.getEntity())
@@ -82,6 +98,69 @@
                 this->attachOgreObject(this->mesh_.getEntity());
                 this->mesh_.getEntity()->setCastShadows(this->bCastShadows_);
                 this->mesh_.setVisible(this->isVisible());
+                
+                //LOD
+                if(this->mesh_.getEntity()->getMesh()->getNumLodLevels()==1
+                    &&this->meshSrc_!="laserbeam.mesh")
+                {
+                    float scaleFactor = 1;
+                    BaseObject* creatorPtr = this;
+                    
+                    while(creatorPtr!=NULL&&orxonox_cast<WorldEntity*>(creatorPtr))
+                    {
+                        scaleFactor *= getBiggestScale(((WorldEntity*) creatorPtr)->getScale3D());
+                        creatorPtr = creatorPtr->getCreator();
+                    }
+                    
+                    Level* level_ = this->getLevel();
+                    
+                    MeshLodInformation* lodInfo = level_->getLodInfo(this->meshSrc_);
+                    
+                    if(lodInfo!=0)
+                        setLodLevel(lodInfo->getLodLevel());
+                    
+                    COUT(0) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and scale: "<< scaleFactor << ":" << std::endl;
+
+#if OGRE_VERSION >= 0x010700
+                    Ogre::Mesh::LodValueList distList;
+#else
+                    Ogre::Mesh::LodDistanceList distList;
+#endif
+
+                    if(lodLevel_>0&&lodLevel_<=5)
+                    {
+                        float factor = scaleFactor*5/lodLevel_;
+                        
+                        COUT(0)<<"LodLevel set with factor: "<<factor<<std::endl;
+
+                        distList.push_back(70.0f*factor);
+                        distList.push_back(140.0f*factor);
+                        distList.push_back(170.0f*factor);
+                        distList.push_back(200.0f*factor);
+                        distList.push_back(230.0f*factor);
+                        distList.push_back(250.0f*factor);
+                        distList.push_back(270.0f*factor);
+                        distList.push_back(290.0f*factor);
+                        distList.push_back(310.0f*factor);
+                        distList.push_back(330.0f*factor);
+
+                        float reductionValue = 0.15f;
+
+                        
+                        //Generiert LOD-Levels
+                        this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue);
+                    }
+                    else
+                    {
+                        std::string what;
+                        if(lodLevel_>5)
+                            what = ">5";
+                        else
+                            what = "<0";
+                        
+                        COUT(0)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was "<<what<<"."<<std::endl;
+                    }
+                }
             }
         }
     }

Modified: code/branches/presentation3/src/orxonox/graphics/Model.h
===================================================================
--- code/branches/presentation3/src/orxonox/graphics/Model.h	2010-05-19 22:22:36 UTC (rev 6925)
+++ code/branches/presentation3/src/orxonox/graphics/Model.h	2010-05-20 08:23:22 UTC (rev 6926)
@@ -60,14 +60,24 @@
                 { this->bCastShadows_ = bCastShadows; this->changedShadows(); }
             inline bool getCastShadows() const
                 { return this->bCastShadows_; }
-
+                
         private:
             void changedMesh();
             void changedShadows();
+            
+            //LoD
+            inline void setLodLevel(float lodLevel)
+                { this->lodLevel_ =  lodLevel; }
+            inline float getLodLevel() const
+                { return this->lodLevel_; }
+            float getBiggestScale(Vector3 scale3d);
 
             std::string meshSrc_;
             Mesh mesh_;
             bool bCastShadows_;
+            
+            //LoD
+            float lodLevel_;
     };
 }
 




More information about the Orxonox-commit mailing list