Changeset 7036 for code/branches/presentation3/src
- Timestamp:
- May 31, 2010, 9:02:48 AM (14 years ago)
- Location:
- code/branches/presentation3/src/orxonox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/src/orxonox/Level.cc
r6961 r7036 145 145 { 146 146 std::string meshName = lodInformation->getMeshName(); 147 this->lodInformation_.insert(std::make_pair(meshName,lodInformation)); 147 // this->lodInformation_.insert(std::make_pair(meshName,lodInformation)); 148 if( this->lodInformation_.find(meshName) != this->lodInformation_.end()) 149 CCOUT(4) << "replacing lod information for " << meshName << endl; 150 this->lodInformation_[meshName] = lodInformation; 148 151 } 149 152 -
code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.cc
r7020 r7036 41 41 42 42 MeshLodInformation::MeshLodInformation(BaseObject* creator) 43 : BaseObject(creator), lodLevel_( -1), bEnabled_(true)43 : BaseObject(creator), lodLevel_(5), bEnabled_(true), numLevels_(10), reductionRate_(0.15) 44 44 { 45 45 RegisterObject(MeshLodInformation); … … 56 56 XMLPortParam(MeshLodInformation, "lodQuality", setLodLevel, getLodLevel, xmlelement, mode); 57 57 XMLPortParam(MeshLodInformation, "enabled", setEnabled, getEnabled, xmlelement, mode); 58 XMLPortParam(MeshLodInformation, "numLevels", setNumLevels, getNumLevels, xmlelement, mode); 59 XMLPortParam(MeshLodInformation, "reductionRate", setReductionRate, getReductionRate, xmlelement, mode); 58 60 } 59 61 -
code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.h
r7020 r7036 47 47 std::string getMeshName(); 48 48 bool getEnabled(){ return this->bEnabled_; } 49 unsigned int getNumLevels(){ return this->numLevels_; } 50 float getReductionRate(){ return this->reductionRate_; } 49 51 50 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); … … 53 55 void setLodLevel(float lodLevel); 54 56 void setMeshSource(std::string meshSource); 55 void setEnabled( bool enabled ){ this->bEnabled_ = true; } 57 void setEnabled( bool enabled ){ this->bEnabled_ = enabled; } 58 void setNumLevels( unsigned int num ){ this->numLevels_ = num; } 59 void setReductionRate( float rate ){ this->reductionRate_ = rate; } 56 60 std::string getMeshSource(); 57 61 std::string meshSource_; 58 62 float lodLevel_; 59 63 bool bEnabled_; 64 unsigned int numLevels_; 65 float reductionRate_; 60 66 61 67 }; -
code/branches/presentation3/src/orxonox/graphics/Model.cc
r7024 r7036 42 42 CreateFactory(Model); 43 43 44 Model::Model(BaseObject* creator) : StaticEntity(creator) 44 Model::Model(BaseObject* creator) : 45 StaticEntity(creator), bCastShadows_(true), lodLevel_(5), bLodEnabled_(true), numLodLevels_(10), lodReductionRate_(.15) 45 46 { 46 47 RegisterObject(Model); 47 48 48 this->bCastShadows_ = true;49 50 49 this->registerVariables(); 51 //LoD52 this->lodLevel_=5;53 50 } 54 51 … … 102 99 103 100 //LOD 104 if(this->mesh_.getEntity()->getMesh()->getNumLodLevels()==1 105 &&this->meshSrc_!="laserbeam.mesh") 101 if( this->mesh_.getEntity()->getMesh()->getNumLodLevels()==1 ) 106 102 { 107 103 Level* level = this->getLevel(); … … 109 105 assert( level != 0 ); 110 106 111 if( level->getLodInfo(this->meshSrc_)!=0 ) 112 setLodLevel(level->getLodInfo(this->meshSrc_)->getLodLevel()); 113 if( level->getLodInfo(this->meshSrc_)==0 || level->getLodInfo(this->meshSrc_)->getEnabled() ) 107 MeshLodInformation* lodInfo = level->getLodInfo(this->meshSrc_); 108 if( lodInfo ) 114 109 { 115 110 setLodLevel(lodInfo->getLodLevel()); 111 this->bLodEnabled_ = lodInfo->getEnabled(); 112 this->numLodLevels_ = lodInfo->getNumLevels(); 113 this->lodReductionRate_ = lodInfo->getReductionRate(); 114 } 115 if( this->numLodLevels_>10 ) 116 { 117 CCOUT(2) << "More than 10 LoD levels requested. Creating only 10." << endl; 118 this->numLodLevels_ = 10; 119 } 120 if( this->bLodEnabled_ ) 121 { 116 122 float volume = this->mesh_.getEntity()->getBoundingBox().volume(); 117 123 // float scaleFactor = 1; … … 139 145 float factor = volume/3/lodLevel_; 140 146 141 COUT(4) <<"LodLevel set with factor: "<<factor<<std::endl;147 COUT(4) << "LodLevel set with factor: " << factor << endl; 142 148 143 149 distList.push_back(70.0f*factor); … … 151 157 distList.push_back(310.0f*factor); 152 158 distList.push_back(330.0f*factor); 153 154 float reductionValue = 0.15f;159 while(distList.size()>this->numLodLevels_) 160 distList.pop_back(); 155 161 156 162 157 163 //Generiert LOD-Levels 158 this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue);164 this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, this->lodReductionRate_); 159 165 } 160 166 else … … 166 172 what = "<0"; 167 173 168 COUT(4)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was "<<what<<"." <<std::endl;174 COUT(4)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was "<<what<<"." << endl; 169 175 } 170 176 } 177 else 178 COUT(4) << "LodLevel for " << this->meshSrc_ << " not set because is disabled." << endl; 171 179 } 172 180 } -
code/branches/presentation3/src/orxonox/graphics/Model.h
r6937 r7036 79 79 //LoD 80 80 float lodLevel_; 81 bool bLodEnabled_; 82 unsigned int numLodLevels_; 83 float lodReductionRate_; 84 81 85 }; 82 86 }
Note: See TracChangeset
for help on using the changeset viewer.