[Orxonox-commit 2122] r6838 - in code/branches/lod/src/orxonox: . graphics
kolibri7 at orxonox.net
kolibri7 at orxonox.net
Mon May 3 14:29:27 CEST 2010
Author: kolibri7
Date: 2010-05-03 14:29:27 +0200 (Mon, 03 May 2010)
New Revision: 6838
Modified:
code/branches/lod/src/orxonox/Level.cc
code/branches/lod/src/orxonox/Level.h
code/branches/lod/src/orxonox/graphics/MeshLodInformation.h
code/branches/lod/src/orxonox/graphics/Model.cc
Log:
implemented the XMLPort for additional lod information.
Modified: code/branches/lod/src/orxonox/Level.cc
===================================================================
--- code/branches/lod/src/orxonox/Level.cc 2010-05-03 12:10:46 UTC (rev 6837)
+++ code/branches/lod/src/orxonox/Level.cc 2010-05-03 12:29:27 UTC (rev 6838)
@@ -125,7 +125,7 @@
{
this->objects_.push_back(object);
object->setGametype(this->getGametype());
- object->setLevel(this);
+ object->setLevel(this);
}
BaseObject* Level::getObject(unsigned int index) const
@@ -143,14 +143,14 @@
//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();
+// 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>);
+ //this->lodInformation_[std::make_pair<meshName,lodInformation>);
}
- const MeshLodInformation* Level::getLodInfo(std::string meshName) const
+ MeshLodInformation* Level::getLodInfo(std::string meshName) const
{
if(this->lodInformation_.find(meshName)!=this->lodInformation_.end())
return this->lodInformation_.find(meshName)->second;
Modified: code/branches/lod/src/orxonox/Level.h
===================================================================
--- code/branches/lod/src/orxonox/Level.h 2010-05-03 12:10:46 UTC (rev 6837)
+++ code/branches/lod/src/orxonox/Level.h 2010-05-03 12:29:27 UTC (rev 6838)
@@ -56,13 +56,16 @@
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;
+// const MeshLodInformation* getLodInfo(std::string meshName) const;
// MeshLodInformation* getLodInfo(unsigned int index) const;
void setGametypeString(const std::string& gametype);
Modified: code/branches/lod/src/orxonox/graphics/MeshLodInformation.h
===================================================================
--- code/branches/lod/src/orxonox/graphics/MeshLodInformation.h 2010-05-03 12:10:46 UTC (rev 6837)
+++ code/branches/lod/src/orxonox/graphics/MeshLodInformation.h 2010-05-03 12:29:27 UTC (rev 6838)
@@ -41,7 +41,6 @@
{
private:
void setLodLevel(unsigned int lodLevel);
- int getLodLevel();
void setMeshSource(std::string meshSource);
std::string getMeshSource();
std::string meshSource_;
@@ -51,6 +50,7 @@
MeshLodInformation(BaseObject* creator);
virtual ~MeshLodInformation();
+ int getLodLevel();
std::string getMeshName();
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
Modified: code/branches/lod/src/orxonox/graphics/Model.cc
===================================================================
--- code/branches/lod/src/orxonox/graphics/Model.cc 2010-05-03 12:10:46 UTC (rev 6837)
+++ code/branches/lod/src/orxonox/graphics/Model.cc 2010-05-03 12:29:27 UTC (rev 6838)
@@ -28,12 +28,16 @@
#include "Model.h"
-#include <OGRE/OgreEntity.h>
+// What's this? With the directory in front the filename, my compiler can't find the file...
+//#include <OGRE/OgreEntity.h>
+#include <OgreEntity.h>
#include "core/CoreIncludes.h"
#include "core/GameMode.h"
#include "core/XMLPort.h"
#include "Scene.h"
+#include "graphics/MeshLodInformation.h"
+#include "Level.h"
namespace orxonox
{
@@ -57,10 +61,10 @@
void Model::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(Model, XMLPort, xmlelement, mode);
-
- //LoD
+
+ //LoD
XMLPortParam(Model, "lodLevel", setLodLevel, getLodLevel, xmlelement, mode).defaultValues(5);
-
+
XMLPortParam(Model, "mesh", setMeshSource, getMeshSource, xmlelement, mode);
XMLPortParam(Model, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true);
}
@@ -97,7 +101,13 @@
scaleFactor = scale3d.y;
if(scale3d.z>scaleFactor)
scaleFactor = scale3d.z;
-
+
+ Level* level_ = this->getLevel();
+
+ MeshLodInformation* lodInfo = level_->getLodInfo(this->meshSrc_);
+ if(lodInfo!=0)
+ setLodLevel(lodInfo->getLodLevel());
+
COUT(0) << this->meshSrc_<< " lodLevel_: " << this->lodLevel_ <<" scale: "<< scaleFactor << std::endl;
//Fuer Asteroiden perfekt
More information about the Orxonox-commit
mailing list