[Orxonox-commit 2161] r6877 - in code/branches/lod: data/levels src/orxonox src/orxonox/graphics

kolibri7 at orxonox.net kolibri7 at orxonox.net
Mon May 10 15:35:48 CEST 2010


Author: kolibri7
Date: 2010-05-10 15:35:48 +0200 (Mon, 10 May 2010)
New Revision: 6877

Modified:
   code/branches/lod/data/levels/gametype_underattack.oxw
   code/branches/lod/src/orxonox/Level.cc
   code/branches/lod/src/orxonox/graphics/MeshLodInformation.cc
   code/branches/lod/src/orxonox/graphics/Model.cc
Log:
*everything works now; setting the lodlevels and also the XML-Port.
*added lod information for Carrier.mesh in gametype_underattack.oxw

Modified: code/branches/lod/data/levels/gametype_underattack.oxw
===================================================================
--- code/branches/lod/data/levels/gametype_underattack.oxw	2010-05-10 13:18:14 UTC (rev 6876)
+++ code/branches/lod/data/levels/gametype_underattack.oxw	2010-05-10 13:35:48 UTC (rev 6877)
@@ -10,6 +10,11 @@
  description  = "A simple testlevel"
  gametype     = UnderAttack
 >
+
+  <lodinformation>
+    <MeshLodInformation mesh=Carrier.mesh lodQuality=1 />
+  </lodinformation>
+  
   <Scene
    ambientlight = "0.5, 0.5, 0.5"
    skybox       = "Orxonox/skypanoramagen1"

Modified: code/branches/lod/src/orxonox/Level.cc
===================================================================
--- code/branches/lod/src/orxonox/Level.cc	2010-05-10 13:18:14 UTC (rev 6876)
+++ code/branches/lod/src/orxonox/Level.cc	2010-05-10 13:35:48 UTC (rev 6877)
@@ -71,9 +71,9 @@
 
         XMLPortParam(Level, "description", setDescription, getDescription, xmlelement, mode);
         XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
-
-        XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);            
+            
         XMLPortObject(Level, MeshLodInformation, "lodinformation", addLodInfo, getLodInfo, xmlelement, mode);
+        XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
 }
 
     void Level::registerVariables()
@@ -140,14 +140,10 @@
         return 0;
     }
     
-    //LoD
     void Level::addLodInfo(MeshLodInformation* lodInformation)
     {
-//        std::pair<std::map<std::string,MeshLodInformation*>::iterator,bool> it 
-//            = new std::pair<lodInformation->getMeshName(),lodInformation>;
         std::string meshName = lodInformation->getMeshName();
         this->lodInformation_.insert(std::make_pair(meshName,lodInformation));
-        //this->lodInformation_[std::make_pair<meshName,lodInformation>);
     }
 
     MeshLodInformation* Level::getLodInfo(std::string meshName) const
@@ -156,17 +152,6 @@
             return this->lodInformation_.find(meshName)->second;
         
         return 0;
-        
-        
-        /*
-        unsigned int i = 0;
-        for (std::map<MeshLodInformation*>::const_iterator it = this->lodInformation_.begin(); it != this->lodInformation_.end(); ++it)
-        {
-            if (i == index)
-                return (*it);
-            ++i;
-        }
-        return 0;*/
     }
 
     void Level::playerEntered(PlayerInfo* player)

Modified: code/branches/lod/src/orxonox/graphics/MeshLodInformation.cc
===================================================================
--- code/branches/lod/src/orxonox/graphics/MeshLodInformation.cc	2010-05-10 13:18:14 UTC (rev 6876)
+++ code/branches/lod/src/orxonox/graphics/MeshLodInformation.cc	2010-05-10 13:35:48 UTC (rev 6877)
@@ -52,8 +52,8 @@
     {
         SUPER(MeshLodInformation, XMLPort, xmlelement, mode);
 
-        XMLPortParam(MeshLodInformation, "lodQuality", setLodLevel, getLodLevel, xmlelement, mode).defaultValues(5);
         XMLPortParam(MeshLodInformation, "mesh", setMeshSource, getMeshSource, xmlelement, mode);
+        XMLPortParam(MeshLodInformation, "lodQuality", setLodLevel, getLodLevel, xmlelement, mode);
     }
     
     std::string MeshLodInformation::getMeshName()

Modified: code/branches/lod/src/orxonox/graphics/Model.cc
===================================================================
--- code/branches/lod/src/orxonox/graphics/Model.cc	2010-05-10 13:18:14 UTC (rev 6876)
+++ code/branches/lod/src/orxonox/graphics/Model.cc	2010-05-10 13:35:48 UTC (rev 6877)
@@ -60,7 +60,6 @@
     {
         SUPER(Model, XMLPort, xmlelement, mode);
         
-        //LoD
         XMLPortParam(Model, "lodLevel", setLodLevel, getLodLevel, xmlelement, mode).defaultValues(5);
         
         XMLPortParam(Model, "mesh", setMeshSource, getMeshSource, xmlelement, mode);
@@ -102,18 +101,19 @@
                 if(this->mesh_.getEntity()->getMesh()->getNumLodLevels()==1
                     &&this->meshSrc_!="laserbeam.mesh")
                 {
-                    float scaleFactor = getBiggestScale(this->getScale3D());
-                    BaseObject* creatorPtr = this->getCreator();
-					//TODO Doesn't work...
-                    while(creatorPtr!=0&&typeid(creatorPtr)!=typeid(new WorldEntity*))
+                    float scaleFactor = 1;
+                    BaseObject* creatorPtr = this;
+                    
+                    while(creatorPtr!=NULL&&orxonox_cast<WorldEntity*>(creatorPtr))
                     {
                         scaleFactor *= getBiggestScale(((WorldEntity*) creatorPtr)->getScale3D());
-                        creatorPtr = this->getCreator();
+                        creatorPtr = creatorPtr->getCreator();
                     }
                     
                     Level* level_ = this->getLevel();
                     
                     MeshLodInformation* lodInfo = level_->getLodInfo(this->meshSrc_);
+                    
                     if(lodInfo!=0)
                         setLodLevel(lodInfo->getLodLevel());
                     
@@ -125,7 +125,7 @@
                     Ogre::Mesh::LodDistanceList distList;
 #endif
 
-                    if(lodLevel_>0)
+                    if(lodLevel_>0&&lodLevel_<=5)
                     {
                         float factor = scaleFactor*5/lodLevel_;
                         
@@ -142,7 +142,7 @@
                         distList.push_back(310.0f*factor);
                         distList.push_back(330.0f*factor);
 
-                        float reductionValue = 0.2f;
+                        float reductionValue = 0.15f;
 
                         
                         //Generiert LOD-Levels
@@ -150,7 +150,13 @@
                     }
                     else
                     {
-                        COUT(0)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was < 0."<<std::endl;
+                        std::string what;
+                        if(lodLevel_>5)
+                            what = ">5";
+                        else
+                            what = "<0";
+                        
+                        COUT(0)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was "<<what<<"."<<std::endl;
                     }
                 }
             }




More information about the Orxonox-commit mailing list