Changeset 7020 for code/branches/presentation3/src/orxonox
- Timestamp:
- May 30, 2010, 3:46:08 PM (14 years ago)
- Location:
- code/branches/presentation3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3
- Property svn:mergeinfo changed
/code/branches/rocket2 (added) merged: 6956,6966,6969-6970
- Property svn:mergeinfo changed
-
code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.cc
r6926 r7020 41 41 42 42 MeshLodInformation::MeshLodInformation(BaseObject* creator) 43 : BaseObject(creator), lodLevel_(-1) 43 : BaseObject(creator), lodLevel_(-1), bEnabled_(true) 44 44 { 45 45 RegisterObject(MeshLodInformation); … … 55 55 XMLPortParam(MeshLodInformation, "mesh", setMeshSource, getMeshSource, xmlelement, mode); 56 56 XMLPortParam(MeshLodInformation, "lodQuality", setLodLevel, getLodLevel, xmlelement, mode); 57 XMLPortParam(MeshLodInformation, "enabled", setEnabled, getEnabled, xmlelement, mode); 57 58 } 58 59 -
code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.h
r6926 r7020 40 40 class _OrxonoxExport MeshLodInformation : public BaseObject 41 41 { 42 private:43 void setLodLevel(float lodLevel);44 void setMeshSource(std::string meshSource);45 std::string getMeshSource();46 std::string meshSource_;47 float lodLevel_;48 49 42 public: 50 43 MeshLodInformation(BaseObject* creator); 51 44 virtual ~MeshLodInformation(); 52 45 53 46 float getLodLevel(); 54 47 std::string getMeshName(); 48 bool getEnabled(){ return this->bEnabled_; } 49 50 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 55 51 56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 52 private: 53 void setLodLevel(float lodLevel); 54 void setMeshSource(std::string meshSource); 55 void setEnabled( bool enabled ){ this->bEnabled_ = true; } 56 std::string getMeshSource(); 57 std::string meshSource_; 58 float lodLevel_; 59 bool bEnabled_; 60 57 61 }; 58 62 } -
code/branches/presentation3/src/orxonox/graphics/Model.cc
r7016 r7020 105 105 &&this->meshSrc_!="laserbeam.mesh") 106 106 { 107 float volume = this->mesh_.getEntity()->getBoundingBox().volume(); 108 float scaleFactor = 1; 109 110 BaseObject* creatorPtr = this; 111 112 while(creatorPtr!=NULL&&orxonox_cast<WorldEntity*>(creatorPtr)) 107 Level* level = this->getLevel(); 108 109 assert( level != 0 ); 110 if( level->getLodInfo(this->meshSrc_)!=0 && level->getLodInfo(this->meshSrc_)->getEnabled() ) 113 111 { 114 scaleFactor *= getBiggestScale(((WorldEntity*) creatorPtr)->getScale3D());115 creatorPtr = creatorPtr->getCreator();116 }117 // COUT(0) << "name: " << this->meshSrc_ << "scaleFactor: " << scaleFactor << ", volume: " << volume << endl;118 119 Level* level = this->getLevel();120 121 assert( level != 0 );122 if( level->getLodInfo(this->meshSrc_)!=0 )123 112 setLodLevel(level->getLodInfo(this->meshSrc_)->getLodLevel()); 124 125 COUT(4) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and scale: "<< scaleFactor << ":" << std::endl; 113 114 float volume = this->mesh_.getEntity()->getBoundingBox().volume(); 115 // float scaleFactor = 1; 116 117 // BaseObject* creatorPtr = this; 118 // 119 // while(creatorPtr!=NULL&&orxonox_cast<WorldEntity*>(creatorPtr)) 120 // { 121 // scaleFactor *= getBiggestScale(((WorldEntity*) creatorPtr)->getScale3D()); 122 // creatorPtr = creatorPtr->getCreator(); 123 // } 124 // COUT(0) << "name: " << this->meshSrc_ << "scaleFactor: " << scaleFactor << ", volume: " << volume << endl; 125 126 COUT(4) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and volume: "<< volume << ":" << std::endl; 126 127 127 128 #if OGRE_VERSION >= 0x010700 128 Ogre::Mesh::LodValueList distList;129 Ogre::Mesh::LodValueList distList; 129 130 #else 130 Ogre::Mesh::LodDistanceList distList;131 Ogre::Mesh::LodDistanceList distList; 131 132 #endif 132 133 133 if( lodLevel_>0 )134 {135 // float factor = scaleFactor*5/lodLevel_;136 float factor = volume/3/lodLevel_;137 138 COUT(4)<<"LodLevel set with factor: "<<factor<<std::endl;134 if( lodLevel_>0 ) 135 { 136 // float factor = scaleFactor*5/lodLevel_; 137 float factor = volume/3/lodLevel_; 138 139 COUT(4)<<"LodLevel set with factor: "<<factor<<std::endl; 139 140 140 distList.push_back(70.0f*factor);141 distList.push_back(140.0f*factor);142 distList.push_back(170.0f*factor);143 distList.push_back(200.0f*factor);144 distList.push_back(230.0f*factor);145 distList.push_back(250.0f*factor);146 distList.push_back(270.0f*factor);147 distList.push_back(290.0f*factor);148 distList.push_back(310.0f*factor);149 distList.push_back(330.0f*factor);141 distList.push_back(70.0f*factor); 142 distList.push_back(140.0f*factor); 143 distList.push_back(170.0f*factor); 144 distList.push_back(200.0f*factor); 145 distList.push_back(230.0f*factor); 146 distList.push_back(250.0f*factor); 147 distList.push_back(270.0f*factor); 148 distList.push_back(290.0f*factor); 149 distList.push_back(310.0f*factor); 150 distList.push_back(330.0f*factor); 150 151 151 float reductionValue = 0.15f;152 float reductionValue = 0.15f; 152 153 153 154 //Generiert LOD-Levels 155 this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue); 156 } 157 else 158 { 159 std::string what; 160 if(lodLevel_>5) 161 what = ">5"; 154 155 //Generiert LOD-Levels 156 this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue); 157 } 162 158 else 163 what = "<0"; 164 165 COUT(4)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was "<<what<<"."<<std::endl; 159 { 160 std::string what; 161 if(lodLevel_>5) 162 what = ">5"; 163 else 164 what = "<0"; 165 166 COUT(4)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was "<<what<<"."<<std::endl; 167 } 166 168 } 167 169 }
Note: See TracChangeset
for help on using the changeset viewer.