Changeset 6926 for code/branches/presentation3/src/orxonox/graphics
- Timestamp:
- May 20, 2010, 10:23:22 AM (15 years ago)
- Location:
- code/branches/presentation3
- Files:
-
- 4 edited
- 2 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/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.