Changeset 7166 for code/trunk
- Timestamp:
- Aug 16, 2010, 10:56:26 PM (14 years ago)
- Location:
- code/trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/core/ConfigValueIncludes.h
r6536 r7166 96 96 orxonox::setConfigValueGeneric(this, &variable, ConfigFileType::Settings, this->getIdentifier()->getName(), entryName, defaultValue) 97 97 98 /** Sets a runtime configurable value (simplified macro version of setConfigValueGeneric) 99 If the container for the value doesn't yet exist, a new one is created. 100 Also, the @a varname argument will be modified and set to the new value (default or from ini file). 101 @param variable 102 Variable name as C++ identifier. 103 @param sectionName 104 Name of the section in the ini file (e.g. [MySection]) 105 @param entryName 106 Name of the entry in the ini file (e.g. [MySection] myValue) 107 @param defaultValue 108 Value to be used if it cannot be read from the ini file 109 */ 110 #define SetConfigValueExternal(variable, sectionName, entryName, defaultValue) \ 111 orxonox::setConfigValueGeneric(this, &variable, ConfigFileType::Settings, sectionName, entryName, defaultValue) 112 98 113 99 114 namespace orxonox -
code/trunk/src/libraries/tools/ParticleInterface.cc
r6417 r7166 95 95 void ParticleInterface::setConfigValues() 96 96 { 97 SetConfigValue(globalDetailLevel_, 2) 98 .description("O: off, 1: low, 2: normal, 3: high").callback(this, &ParticleInterface::detailLevelChanged); 97 SetConfigValueExternal(globalDetailLevel_, "GraphicsSettings", "particlesDetailLevel", 2) 98 .description("O: off, 1: low, 2: normal, 3: high") 99 .callback(this, &ParticleInterface::detailLevelChanged); 99 100 } 100 101 -
code/trunk/src/orxonox/graphics/Model.cc
r7163 r7166 32 32 33 33 #include "core/CoreIncludes.h" 34 #include "core/ConfigValueIncludes.h" 34 35 #include "core/GameMode.h" 35 36 #include "core/XMLPort.h" … … 47 48 RegisterObject(Model); 48 49 50 this->setConfigValues(); 49 51 this->registerVariables(); 50 52 } … … 54 56 if (this->isInitialized() && this->mesh_.getEntity()) 55 57 this->detachOgreObject(this->mesh_.getEntity()); 58 } 59 60 void Model::setConfigValues() 61 { 62 SetConfigValueExternal(bGlobalEnableLod_, "GraphicsSettings", "enableModelLoD", true) 63 .description("Enable level of detail for models"); 56 64 } 57 65 … … 97 105 this->mesh_.setVisible(this->isVisible()); 98 106 99 100 //LOD 101 if( this->mesh_.getEntity()->getMesh()->getNumLodLevels()==1 ) 107 if (this->bGlobalEnableLod_) 108 this->enableLod(); 109 } 110 } 111 } 112 113 void Model::changedShadows() 114 { 115 this->mesh_.setCastShadows(this->bCastShadows_); 116 } 117 118 void Model::changedVisibility() 119 { 120 SUPER(Model, changedVisibility); 121 122 this->mesh_.setVisible(this->isVisible()); 123 } 124 125 void Model::enableLod() 126 { 127 //LOD 128 if( this->mesh_.getEntity()->getMesh()->getNumLodLevels()==1 ) 129 { 130 Level* level = this->getLevel(); 131 132 assert( level != 0 ); 133 134 MeshLodInformation* lodInfo = level->getLodInfo(this->meshSrc_); 135 if( lodInfo ) 136 { 137 setLodLevel(lodInfo->getLodLevel()); 138 this->bLodEnabled_ = lodInfo->getEnabled(); 139 this->numLodLevels_ = lodInfo->getNumLevels(); 140 this->lodReductionRate_ = lodInfo->getReductionRate(); 141 } 142 if( this->numLodLevels_>10 ) 143 { 144 CCOUT(2) << "More than 10 LoD levels requested. Creating only 10." << endl; 145 this->numLodLevels_ = 10; 146 } 147 if( this->bLodEnabled_ ) 148 { 149 float volume = this->mesh_.getEntity()->getBoundingBox().volume(); 150 /* 151 float scaleFactor = 1; 152 153 BaseObject* creatorPtr = this; 154 155 while(creatorPtr!=NULL&&orxonox_cast<WorldEntity*>(creatorPtr)) 102 156 { 103 Level* level = this->getLevel(); 104 105 assert( level != 0 ); 106 107 MeshLodInformation* lodInfo = level->getLodInfo(this->meshSrc_); 108 if( lodInfo ) 109 { 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 { 122 float volume = this->mesh_.getEntity()->getBoundingBox().volume(); 123 // float scaleFactor = 1; 124 125 // BaseObject* creatorPtr = this; 126 // 127 // while(creatorPtr!=NULL&&orxonox_cast<WorldEntity*>(creatorPtr)) 128 // { 129 // scaleFactor *= getBiggestScale(((WorldEntity*) creatorPtr)->getScale3D()); 130 // creatorPtr = creatorPtr->getCreator(); 131 // } 132 // COUT(0) << "name: " << this->meshSrc_ << "scaleFactor: " << scaleFactor << ", volume: " << volume << endl; 133 134 COUT(4) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and volume: "<< volume << ":" << std::endl; 157 scaleFactor *= getBiggestScale(((WorldEntity*) creatorPtr)->getScale3D()); 158 creatorPtr = creatorPtr->getCreator(); 159 } 160 COUT(0) << "name: " << this->meshSrc_ << "scaleFactor: " << scaleFactor << ", volume: " << volume << endl; 161 */ 162 COUT(4) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and volume: "<< volume << ":" << std::endl; 135 163 136 164 #if OGRE_VERSION >= 0x010700 137 165 Ogre::Mesh::LodValueList distList; 138 166 #else 139 167 Ogre::Mesh::LodDistanceList distList; 140 168 #endif 141 169 142 if( lodLevel_>0 ) 143 { 144 // float factor = scaleFactor*5/lodLevel_; 145 float factor = pow(volume, 2.0f / 3.0f) * 15.0f / lodLevel_; 146 147 COUT(4) << "LodLevel set with factor: " << factor << endl; 148 149 distList.push_back(70.0f*factor); 150 distList.push_back(140.0f*factor); 151 distList.push_back(170.0f*factor); 152 distList.push_back(200.0f*factor); 153 distList.push_back(230.0f*factor); 154 distList.push_back(250.0f*factor); 155 distList.push_back(270.0f*factor); 156 distList.push_back(290.0f*factor); 157 distList.push_back(310.0f*factor); 158 distList.push_back(330.0f*factor); 159 while(distList.size()>this->numLodLevels_) 160 distList.pop_back(); 161 162 163 //Generiert LOD-Levels 164 this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, this->lodReductionRate_); 165 } 166 else 167 { 168 std::string what; 169 if(lodLevel_>5) 170 what = ">5"; 171 else 172 what = "<0"; 173 174 COUT(4)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was "<<what<<"." << endl; 175 } 176 } 170 if( lodLevel_>0 ) 171 { 172 // float factor = scaleFactor*5/lodLevel_; 173 float factor = pow(volume, 2.0f / 3.0f) * 15.0f / lodLevel_; 174 175 COUT(4) << "LodLevel set with factor: " << factor << endl; 176 177 distList.push_back(70.0f*factor); 178 distList.push_back(140.0f*factor); 179 distList.push_back(170.0f*factor); 180 distList.push_back(200.0f*factor); 181 distList.push_back(230.0f*factor); 182 distList.push_back(250.0f*factor); 183 distList.push_back(270.0f*factor); 184 distList.push_back(290.0f*factor); 185 distList.push_back(310.0f*factor); 186 distList.push_back(330.0f*factor); 187 while(distList.size()>this->numLodLevels_) 188 distList.pop_back(); 189 190 191 //Generiert LOD-Levels 192 this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, this->lodReductionRate_); 193 } 194 else 195 { 196 std::string what; 197 if(lodLevel_>5) 198 what = ">5"; 177 199 else 178 COUT(4) << "LodLevel for " << this->meshSrc_ << " not set because is disabled." << endl; 200 what = "<0"; 201 202 COUT(4)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was "<<what<<"." << endl; 179 203 } 180 204 } 205 else 206 COUT(4) << "LodLevel for " << this->meshSrc_ << " not set because is disabled." << endl; 181 207 } 182 208 } 183 184 void Model::changedShadows()185 {186 this->mesh_.setCastShadows(this->bCastShadows_);187 }188 189 void Model::changedVisibility()190 {191 SUPER(Model, changedVisibility);192 193 this->mesh_.setVisible(this->isVisible());194 }195 209 } -
code/trunk/src/orxonox/graphics/Model.h
r7163 r7166 44 44 virtual ~Model(); 45 45 46 void setConfigValues(); 47 46 48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 47 49 … … 67 69 68 70 //LoD 71 void enableLod(); 72 69 73 inline void setLodLevel(float lodLevel) 70 74 { this->lodLevel_ = lodLevel; } … … 78 82 79 83 //LoD 84 bool bGlobalEnableLod_; 80 85 float lodLevel_; 81 86 bool bLodEnabled_;
Note: See TracChangeset
for help on using the changeset viewer.