Index: code/branches/presentation3/src/orxonox/graphics/CMakeLists.txt
===================================================================
--- code/branches/presentation3/src/orxonox/graphics/CMakeLists.txt	(revision 6912)
+++ code/branches/presentation3/src/orxonox/graphics/CMakeLists.txt	(revision 6926)
@@ -4,4 +4,5 @@
   FadingBillboard.cc
   GlobalShader.cc
+  MeshLodInformation.cc
   Model.cc
   ParticleEmitter.cc
Index: code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.cc
===================================================================
--- code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.cc	(revision 6926)
+++ code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.cc	(revision 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_;
+	}
+ 
+}
Index: code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.h
===================================================================
--- code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.h	(revision 6926)
+++ code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.h	(revision 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__ */
Index: code/branches/presentation3/src/orxonox/graphics/Model.cc
===================================================================
--- code/branches/presentation3/src/orxonox/graphics/Model.cc	(revision 6912)
+++ code/branches/presentation3/src/orxonox/graphics/Model.cc	(revision 6926)
@@ -35,4 +35,6 @@
 #include "core/XMLPort.h"
 #include "Scene.h"
+#include "graphics/MeshLodInformation.h"
+#include "Level.h"
 
 namespace orxonox
@@ -47,4 +49,6 @@
 
         this->registerVariables();
+        //LoD
+        this->lodLevel_=5;
     }
 
@@ -58,5 +62,7 @@
     {
         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);
@@ -69,4 +75,14 @@
     }
 
+    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()
     {
@@ -75,5 +91,5 @@
             if (this->mesh_.getEntity())
                 this->detachOgreObject(this->mesh_.getEntity());
-
+            
             this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
 
@@ -83,4 +99,67 @@
                 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;
+                    }
+                }
             }
         }
Index: code/branches/presentation3/src/orxonox/graphics/Model.h
===================================================================
--- code/branches/presentation3/src/orxonox/graphics/Model.h	(revision 6912)
+++ code/branches/presentation3/src/orxonox/graphics/Model.h	(revision 6926)
@@ -61,12 +61,22 @@
             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_;
     };
 }
