[Orxonox-commit 1974] r6691 - in code/branches/lod: data/levels src/orxonox src/orxonox/graphics
kolibri7 at orxonox.net
kolibri7 at orxonox.net
Mon Apr 12 15:48:24 CEST 2010
Author: kolibri7
Date: 2010-04-12 15:48:24 +0200 (Mon, 12 Apr 2010)
New Revision: 6691
Added:
code/branches/lod/data/levels/presentationLOD.oxw
code/branches/lod/data/levels/presentationLODdif.oxw
code/branches/lod/src/orxonox/graphics/MeshLodInformation.cc
code/branches/lod/src/orxonox/graphics/MeshLodInformation.h
Modified:
code/branches/lod/src/orxonox/Level.cc
code/branches/lod/src/orxonox/Level.h
code/branches/lod/src/orxonox/graphics/CMakeLists.txt
code/branches/lod/src/orxonox/graphics/Model.cc
code/branches/lod/src/orxonox/graphics/Model.h
Log:
implementing the XMLPort function for LoD; getting some erreors from gcc...
Added: code/branches/lod/data/levels/presentationLOD.oxw
===================================================================
--- code/branches/lod/data/levels/presentationLOD.oxw (rev 0)
+++ code/branches/lod/data/levels/presentationLOD.oxw 2010-04-12 13:48:24 UTC (rev 6691)
@@ -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>
Added: code/branches/lod/data/levels/presentationLODdif.oxw
===================================================================
--- code/branches/lod/data/levels/presentationLODdif.oxw (rev 0)
+++ code/branches/lod/data/levels/presentationLODdif.oxw 2010-04-12 13:48:24 UTC (rev 6691)
@@ -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/lod/src/orxonox/Level.cc
===================================================================
--- code/branches/lod/src/orxonox/Level.cc 2010-04-12 13:30:51 UTC (rev 6690)
+++ code/branches/lod/src/orxonox/Level.cc 2010-04-12 13:48:24 UTC (rev 6691)
@@ -31,7 +31,7 @@
#include "util/Math.h"
#include "core/CoreIncludes.h"
#include "core/Loader.h"
-#include "core/Template.h"
+#include "core/template.h"
#include "core/XMLFile.h"
#include "core/XMLPort.h"
@@ -72,8 +72,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);
- }
+ XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
+ XMLPortObject(Level, MeshLodInformation, "lodinformation", addLodInfo, getLodInfo, xmlelement, mode);
+}
void Level::registerVariables()
{
@@ -137,7 +138,34 @@
}
return 0;
}
+
+ //LoD
+ void Level::addLodInfo(const MeshLodInformation* lodInformation)
+ {
+// std::pair<std::map<std::string,MeshLodInformation*>::iterator,bool> it
+// = new std::pair<lodInformation->getMeshName(),lodInformation>;
+ this->lodInformation_.insert(std::pair<lodInformation->getMeshName(),lodInformation>);
+ }
+ MeshLodInformation* Level::getLodInfo(string meshName) const
+ {
+ if(this->lodInformation_.find(meshName)!=std::map::end)
+ return this->lodInformation_.find(meshName);
+
+ 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)
{
COUT(3) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << std::endl;
Modified: code/branches/lod/src/orxonox/Level.h
===================================================================
--- code/branches/lod/src/orxonox/Level.h 2010-04-12 13:30:51 UTC (rev 6690)
+++ code/branches/lod/src/orxonox/Level.h 2010-04-12 13:48:24 UTC (rev 6691)
@@ -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
{
@@ -59,17 +61,21 @@
void addObject(BaseObject* object);
BaseObject* getObject(unsigned int index) const;
+ void addLodInfo(const MeshLodInformation* object);
+ 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/lod/src/orxonox/graphics/CMakeLists.txt
===================================================================
--- code/branches/lod/src/orxonox/graphics/CMakeLists.txt 2010-04-12 13:30:51 UTC (rev 6690)
+++ code/branches/lod/src/orxonox/graphics/CMakeLists.txt 2010-04-12 13:48:24 UTC (rev 6691)
@@ -3,6 +3,7 @@
BlinkingBillboard.cc
FadingBillboard.cc
GlobalShader.cc
+ MeshLodInformation.cc
Model.cc
ParticleEmitter.cc
ParticleSpawner.cc
Added: code/branches/lod/src/orxonox/graphics/MeshLodInformation.cc
===================================================================
--- code/branches/lod/src/orxonox/graphics/MeshLodInformation.cc (rev 0)
+++ code/branches/lod/src/orxonox/graphics/MeshLodInformation.cc 2010-04-12 13:48:24 UTC (rev 6691)
@@ -0,0 +1,66 @@
+/*
+ * 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) : StaticEntity(creator)
+ {
+ RegisterObject(MeshLodInformation);
+ }
+
+ MeshLodInformation::~MeshLodInformation()
+ { }
+
+ void MeshLodInformation::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(MeshLodInformation, XMLPort, xmlelement, mode);
+
+ XMLPortParam(MeshLodInformation, "lodQuality", setLodLevel, getLodLevel, xmlelement, mode).defaultValues(5);
+ XMLPortParam(MeshLodInformation, "mesh", setMeshSource, getMeshSource, xmlelement, mode);
+ }
+
+ std::string getMeshName()
+ {
+ if(mesh!=null)
+ return mesh;
+ return "";
+ }
+
+
+}
Added: code/branches/lod/src/orxonox/graphics/MeshLodInformation.h
===================================================================
--- code/branches/lod/src/orxonox/graphics/MeshLodInformation.h (rev 0)
+++ code/branches/lod/src/orxonox/graphics/MeshLodInformation.h 2010-04-12 13:48:24 UTC (rev 6691)
@@ -0,0 +1,52 @@
+/*
+ * 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
+ {
+ public:
+ MeshLodInformation(BaseObject* creator);
+ virtual ~MeshLodInformation();
+
+ std::string getMeshName();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ };
+}
+
+#endif /* _MeshLodInformation_H__ */
Modified: code/branches/lod/src/orxonox/graphics/Model.cc
===================================================================
--- code/branches/lod/src/orxonox/graphics/Model.cc 2010-04-12 13:30:51 UTC (rev 6690)
+++ code/branches/lod/src/orxonox/graphics/Model.cc 2010-04-12 13:48:24 UTC (rev 6691)
@@ -57,7 +57,10 @@
void Model::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(Model, XMLPort, xmlelement, mode);
-
+
+ //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);
}
@@ -74,7 +77,7 @@
{
if (this->mesh_.getEntity())
this->detachOgreObject(this->mesh_.getEntity());
-
+
this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
if (this->mesh_.getEntity())
@@ -82,6 +85,39 @@
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"
+ &&this->lodLevel_!=0)
+ {
+ float scaleFactor = this->getScale();
+ COUT(0) << this->meshSrc_<< " lodLevel_: " << this->lodLevel_ <<" scale: "<< scaleFactor << std::endl;
+ //Für Asteroiden perfekt
+
+#if OGRE_VERSION >= 0x010700
+ Ogre::Mesh::LodValueList distList;
+#else
+ Ogre::Mesh::LodDistanceList distList;
+#endif
+
+ distList.push_back(70.0f*scaleFactor);
+ distList.push_back(140.0f*scaleFactor);
+ distList.push_back(170.0f*scaleFactor);
+ distList.push_back(200.0f*scaleFactor);
+ distList.push_back(230.0f*scaleFactor);
+ distList.push_back(250.0f*scaleFactor);
+ distList.push_back(270.0f*scaleFactor);
+ distList.push_back(290.0f*scaleFactor);
+ distList.push_back(310.0f*scaleFactor);
+ distList.push_back(330.0f*scaleFactor);
+
+ float reductionValue = 0.2f;
+
+
+ //Generiert LOD-Levels
+ this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue);
+ }
}
}
}
Modified: code/branches/lod/src/orxonox/graphics/Model.h
===================================================================
--- code/branches/lod/src/orxonox/graphics/Model.h 2010-04-12 13:30:51 UTC (rev 6690)
+++ code/branches/lod/src/orxonox/graphics/Model.h 2010-04-12 13:48:24 UTC (rev 6691)
@@ -60,14 +60,23 @@
{ this->bCastShadows_ = bCastShadows; this->changedShadows(); }
inline bool getCastShadows() const
{ return this->bCastShadows_; }
-
+
private:
void changedMesh();
void changedShadows();
+
+ //LoD
+ inline void setLodLevel(unsigned short lodLevel)
+ { this->lodLevel_ = lodLevel; }
+ inline unsigned short getLodLevel() const
+ { return this->lodLevel_; }
std::string meshSrc_;
Mesh mesh_;
bool bCastShadows_;
+
+ //LoD
+ unsigned short lodLevel_;
};
}
More information about the Orxonox-commit
mailing list