Changeset 6926 for code/branches/presentation3
- Timestamp:
- May 20, 2010, 10:23:22 AM (15 years ago)
- Location:
- code/branches/presentation3
- Files:
-
- 14 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3
- Property svn:mergeinfo changed
/code/branches/lod (added) merged: 6691,6724,6786-6787,6794,6828-6829,6838-6839,6843,6852,6877,6881,6909,6911
- Property svn:mergeinfo changed
-
code/branches/presentation3/data/levels/empty_level.oxw
r6560 r6926 2 2 include("stats.oxo") 3 3 include("hudtemplates3.oxo") 4 include("templates/lodinformation.oxt") 4 5 ?> 5 6 … … 13 14 description = "Just a few tests" 14 15 > 16 <templates> 17 <Template link=lodtemplate_default /> 18 </templates> 19 15 20 <Scene 16 21 ambientlight = "0.8, 0.8, 0.8" -
code/branches/presentation3/data/levels/gametype_asteroids.oxw
r6417 r6926 3 3 include("stats.oxo") 4 4 include("templates/spaceship_assff.oxt") 5 include("templates/lodinformation.oxt") 5 6 ?> 6 7 … … 10 11 gametype = Asteroids 11 12 > 13 <templates> 14 <Template link=lodtemplate_default /> 15 </templates> 16 12 17 <Scene 13 18 ambientlight = "0.5, 0.5, 0.5" -
code/branches/presentation3/data/levels/gametype_underattack.oxw
r5781 r6926 4 4 include("underattackhud.oxo") 5 5 include("templates/spaceship_assff.oxt") 6 include("templates/lodinformation.oxt") 6 7 ?> 7 8 … … 11 12 gametype = UnderAttack 12 13 > 14 <templates> 15 <Template link=lodtemplate_default /> 16 </templates> 17 13 18 <Scene 14 19 ambientlight = "0.5, 0.5, 0.5" -
code/branches/presentation3/data/levels/teambasematchlevel.oxw
r6417 r6926 5 5 include("templates/spaceship_assff.oxt") 6 6 include("templates/spaceship_pirate.oxt") 7 include("templates/lodinformation.oxt") 7 8 ?> 8 9 … … 12 13 gametype = TeamBaseMatch 13 14 > 15 <templates> 16 <Template link=lodtemplate_default /> 17 </templates> 18 14 19 <Scene 15 20 ambientlight = "0.5, 0.5, 0.5" -
code/branches/presentation3/data/levels/teamdeathmatch.oxw
r5781 r6926 5 5 include("templates/spaceship_H2.oxt") 6 6 include("templates/spaceship_pirate.oxt") 7 include("templates/lodinformation.oxt") 7 8 ?> 8 9 … … 12 13 gametype = TeamDeathmatch 13 14 > 15 <templates> 16 <Template link=lodtemplate_default /> 17 </templates> 18 14 19 <Scene 15 20 ambientlight = "0.7, 0.6, 0.6" -
code/branches/presentation3/src/libraries/core/BaseObject.cc
r6800 r6926 75 75 this->setScene(this->creator_->getScene(), this->creator_->getSceneID()); 76 76 this->setGametype(this->creator_->getGametype()); 77 this->setLevel(this->creator_->getLevel()); 77 78 } 78 79 else … … 83 84 this->sceneID_ = OBJECTID_UNKNOWN; 84 85 this->gametype_ = 0; 86 this->level_ = 0; 85 87 } 86 88 } -
code/branches/presentation3/src/libraries/core/BaseObject.h
r6800 r6926 51 51 class Scene; 52 52 class Gametype; 53 class Level; 53 54 54 55 //! The BaseObject is the parent of all classes representing an instance in the game. … … 153 154 inline Gametype* getOldGametype() const { return this->oldGametype_; } 154 155 virtual void changedGametype() {} 156 157 inline void setLevel(const SmartPtr<Level>& level) 158 { 159 if (level != this->level_) 160 { 161 this->level_ = level; 162 this->changedLevel(); 163 } 164 } 165 inline const SmartPtr<Level>& getLevel() const { return this->level_; } 166 virtual void changedLevel() {} 155 167 156 168 void addEventSource(BaseObject* source, const std::string& state); … … 209 221 SmartPtr<Gametype> gametype_; 210 222 Gametype* oldGametype_; 223 SmartPtr<Level> level_; 211 224 std::set<Template*> templates_; 212 225 -
code/branches/presentation3/src/orxonox/Level.cc
r6746 r6926 49 49 RegisterObject(Level); 50 50 51 51 52 this->registerVariables(); 52 53 this->xmlfilename_ = this->getFilename(); … … 72 73 XMLPortParam(Level, "description", setDescription, getDescription, xmlelement, mode); 73 74 XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype"); 74 75 76 XMLPortObject(Level, MeshLodInformation, "lodinformation", addLodInfo, getLodInfo, xmlelement, mode); 75 77 XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false); 76 78 } 77 79 78 80 void Level::registerVariables() … … 125 127 this->objects_.push_back(object); 126 128 object->setGametype(this->getGametype()); 129 object->setLevel(this); 127 130 } 128 131 … … 136 139 ++i; 137 140 } 141 return 0; 142 } 143 144 void Level::addLodInfo(MeshLodInformation* lodInformation) 145 { 146 std::string meshName = lodInformation->getMeshName(); 147 this->lodInformation_.insert(std::make_pair(meshName,lodInformation)); 148 } 149 150 MeshLodInformation* Level::getLodInfo(std::string meshName) const 151 { 152 if(this->lodInformation_.find(meshName)!=this->lodInformation_.end()) 153 return this->lodInformation_.find(meshName)->second; 154 138 155 return 0; 139 156 } -
code/branches/presentation3/src/orxonox/Level.h
r5929 r6926 34 34 #include <list> 35 35 #include <string> 36 #include <map> 36 37 #include "core/BaseObject.h" 37 38 #include "network/synchronisable/Synchronisable.h" 39 #include "graphics/MeshLodInformation.h" 38 40 39 41 namespace orxonox … … 55 57 void playerEntered(PlayerInfo* player); 56 58 void playerLeft(PlayerInfo* player); 59 60 MeshLodInformation* getLodInfo(std::string meshName) const; 61 57 62 58 63 private: 59 64 void addObject(BaseObject* object); 60 65 BaseObject* getObject(unsigned int index) const; 66 67 void addLodInfo(MeshLodInformation* object); 68 // const MeshLodInformation* getLodInfo(std::string meshName) const; 69 // MeshLodInformation* getLodInfo(unsigned int index) const; 61 70 62 71 void setGametypeString(const std::string& gametype); … … 66 75 void networkcallback_applyXMLFile(); 67 76 68 std::string description_; 69 std::string gametype_; 70 std::string xmlfilename_; 71 XMLFile* xmlfile_; 72 std::list<BaseObject*> objects_; 77 std::string description_; 78 std::string gametype_; 79 std::string xmlfilename_; 80 XMLFile* xmlfile_; 81 std::list<BaseObject*> objects_; 82 std::map<std::string,MeshLodInformation*> lodInformation_; 73 83 }; 74 84 } -
code/branches/presentation3/src/orxonox/LevelManager.cc
r6501 r6926 70 70 void LevelManager::requestActivity(Level* level) 71 71 { 72 COUT(0) << "pushing level into level list: " << level << endl; 72 73 this->levels_s.push_back(level); 73 74 if (this->levels_s.size() == 1) … … 77 78 void LevelManager::releaseActivity(Level* level) 78 79 { 80 COUT(0) << "poping level from level list: " << level << endl; 79 81 if (this->levels_s.size() > 0) 80 82 { -
code/branches/presentation3/src/orxonox/graphics/CMakeLists.txt
r5929 r6926 4 4 FadingBillboard.cc 5 5 GlobalShader.cc 6 MeshLodInformation.cc 6 7 Model.cc 7 8 ParticleEmitter.cc -
code/branches/presentation3/src/orxonox/graphics/Model.cc
r5781 r6926 35 35 #include "core/XMLPort.h" 36 36 #include "Scene.h" 37 #include "graphics/MeshLodInformation.h" 38 #include "Level.h" 37 39 38 40 namespace orxonox … … 47 49 48 50 this->registerVariables(); 51 //LoD 52 this->lodLevel_=5; 49 53 } 50 54 … … 58 62 { 59 63 SUPER(Model, XMLPort, xmlelement, mode); 60 64 65 XMLPortParam(Model, "lodLevel", setLodLevel, getLodLevel, xmlelement, mode); 66 61 67 XMLPortParam(Model, "mesh", setMeshSource, getMeshSource, xmlelement, mode); 62 68 XMLPortParam(Model, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true); … … 69 75 } 70 76 77 float Model::getBiggestScale(Vector3 scale3d) 78 { 79 float scaleFactor = scale3d.x; 80 if(scale3d.y>scaleFactor) 81 scaleFactor = scale3d.y; 82 if(scale3d.z>scaleFactor) 83 scaleFactor = scale3d.z; 84 return scaleFactor; 85 } 86 71 87 void Model::changedMesh() 72 88 { … … 75 91 if (this->mesh_.getEntity()) 76 92 this->detachOgreObject(this->mesh_.getEntity()); 77 93 78 94 this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_); 79 95 … … 83 99 this->mesh_.getEntity()->setCastShadows(this->bCastShadows_); 84 100 this->mesh_.setVisible(this->isVisible()); 101 102 //LOD 103 if(this->mesh_.getEntity()->getMesh()->getNumLodLevels()==1 104 &&this->meshSrc_!="laserbeam.mesh") 105 { 106 float scaleFactor = 1; 107 BaseObject* creatorPtr = this; 108 109 while(creatorPtr!=NULL&&orxonox_cast<WorldEntity*>(creatorPtr)) 110 { 111 scaleFactor *= getBiggestScale(((WorldEntity*) creatorPtr)->getScale3D()); 112 creatorPtr = creatorPtr->getCreator(); 113 } 114 115 Level* level_ = this->getLevel(); 116 117 MeshLodInformation* lodInfo = level_->getLodInfo(this->meshSrc_); 118 119 if(lodInfo!=0) 120 setLodLevel(lodInfo->getLodLevel()); 121 122 COUT(0) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and scale: "<< scaleFactor << ":" << std::endl; 123 124 #if OGRE_VERSION >= 0x010700 125 Ogre::Mesh::LodValueList distList; 126 #else 127 Ogre::Mesh::LodDistanceList distList; 128 #endif 129 130 if(lodLevel_>0&&lodLevel_<=5) 131 { 132 float factor = scaleFactor*5/lodLevel_; 133 134 COUT(0)<<"LodLevel set with factor: "<<factor<<std::endl; 135 136 distList.push_back(70.0f*factor); 137 distList.push_back(140.0f*factor); 138 distList.push_back(170.0f*factor); 139 distList.push_back(200.0f*factor); 140 distList.push_back(230.0f*factor); 141 distList.push_back(250.0f*factor); 142 distList.push_back(270.0f*factor); 143 distList.push_back(290.0f*factor); 144 distList.push_back(310.0f*factor); 145 distList.push_back(330.0f*factor); 146 147 float reductionValue = 0.15f; 148 149 150 //Generiert LOD-Levels 151 this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue); 152 } 153 else 154 { 155 std::string what; 156 if(lodLevel_>5) 157 what = ">5"; 158 else 159 what = "<0"; 160 161 COUT(0)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was "<<what<<"."<<std::endl; 162 } 163 } 85 164 } 86 165 } -
code/branches/presentation3/src/orxonox/graphics/Model.h
r5781 r6926 61 61 inline bool getCastShadows() const 62 62 { return this->bCastShadows_; } 63 63 64 64 private: 65 65 void changedMesh(); 66 66 void changedShadows(); 67 68 //LoD 69 inline void setLodLevel(float lodLevel) 70 { this->lodLevel_ = lodLevel; } 71 inline float getLodLevel() const 72 { return this->lodLevel_; } 73 float getBiggestScale(Vector3 scale3d); 67 74 68 75 std::string meshSrc_; 69 76 Mesh mesh_; 70 77 bool bCastShadows_; 78 79 //LoD 80 float lodLevel_; 71 81 }; 72 82 }
Note: See TracChangeset
for help on using the changeset viewer.