Changeset 7127 for code/branches/presentation3/src/orxonox/graphics
- Timestamp:
- Jun 9, 2010, 9:32:58 PM (15 years ago)
- Location:
- code/branches/presentation3/src/orxonox/graphics
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.cc
r7039 r7127 40 40 CreateFactory(MeshLodInformation); 41 41 42 MeshLodInformation::MeshLodInformation(BaseObject* creator) 42 MeshLodInformation::MeshLodInformation(BaseObject* creator) 43 43 : BaseObject(creator), lodLevel_(5), bEnabled_(true), numLevels_(10), reductionRate_(0.15) 44 44 { … … 59 59 XMLPortParam(MeshLodInformation, "reductionRate", setReductionRate, getReductionRate, xmlelement, mode); 60 60 } 61 61 62 62 std::string MeshLodInformation::getMeshName() 63 63 { 64 64 return MeshLodInformation::getMeshSource(); 65 65 } 66 66 67 67 void MeshLodInformation::setLodLevel(float lodLevel) 68 68 { … … 73 73 { 74 74 return lodLevel_; 75 } 75 } 76 76 void MeshLodInformation::setMeshSource(std::string meshSource) 77 77 { … … 82 82 return meshSource_; 83 83 } 84 84 85 85 } -
code/branches/presentation3/src/orxonox/graphics/MeshLodInformation.h
r7036 r7127 43 43 MeshLodInformation(BaseObject* creator); 44 44 virtual ~MeshLodInformation(); 45 45 46 46 float getLodLevel(); 47 47 std::string getMeshName(); … … 49 49 unsigned int getNumLevels(){ return this->numLevels_; } 50 50 float getReductionRate(){ return this->reductionRate_; } 51 51 52 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 53 53 -
code/branches/presentation3/src/orxonox/graphics/Model.cc
r7111 r7127 42 42 CreateFactory(Model); 43 43 44 Model::Model(BaseObject* creator) : 44 Model::Model(BaseObject* creator) : 45 45 StaticEntity(creator), bCastShadows_(true), lodLevel_(5), bLodEnabled_(true), numLodLevels_(10), lodReductionRate_(.15) 46 46 { … … 59 59 { 60 60 SUPER(Model, XMLPort, xmlelement, mode); 61 61 62 62 XMLPortParam(Model, "lodLevel", setLodLevel, getLodLevel, xmlelement, mode); 63 63 64 64 XMLPortParam(Model, "mesh", setMeshSource, getMeshSource, xmlelement, mode); 65 65 XMLPortParam(Model, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true); … … 81 81 return scaleFactor; 82 82 } 83 83 84 84 void Model::changedMesh() 85 85 { … … 88 88 if (this->mesh_.getEntity()) 89 89 this->detachOgreObject(this->mesh_.getEntity()); 90 90 91 91 this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_); 92 92 … … 96 96 this->mesh_.getEntity()->setCastShadows(this->bCastShadows_); 97 97 this->mesh_.setVisible(this->isVisible()); 98 99 98 99 100 100 //LOD 101 101 if( this->mesh_.getEntity()->getMesh()->getNumLodLevels()==1 ) 102 102 { 103 103 Level* level = this->getLevel(); 104 104 105 105 assert( level != 0 ); 106 106 107 107 MeshLodInformation* lodInfo = level->getLodInfo(this->meshSrc_); 108 108 if( lodInfo ) … … 122 122 float volume = this->mesh_.getEntity()->getBoundingBox().volume(); 123 123 // float scaleFactor = 1; 124 124 125 125 // BaseObject* creatorPtr = this; 126 // 126 // 127 127 // while(creatorPtr!=NULL&&orxonox_cast<WorldEntity*>(creatorPtr)) 128 128 // { … … 131 131 // } 132 132 // COUT(0) << "name: " << this->meshSrc_ << "scaleFactor: " << scaleFactor << ", volume: " << volume << endl; 133 133 134 134 COUT(4) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and volume: "<< volume << ":" << std::endl; 135 135 … … 144 144 // float factor = scaleFactor*5/lodLevel_; 145 145 float factor = pow(volume, 2.0f / 3.0f) * 15.0f / lodLevel_; 146 146 147 147 COUT(4) << "LodLevel set with factor: " << factor << endl; 148 148 … … 160 160 distList.pop_back(); 161 161 162 162 163 163 //Generiert LOD-Levels 164 164 this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, this->lodReductionRate_); … … 171 171 else 172 172 what = "<0"; 173 173 174 174 COUT(4)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was "<<what<<"." << endl; 175 175 } -
code/branches/presentation3/src/orxonox/graphics/Model.h
r7036 r7127 61 61 inline bool getCastShadows() const 62 62 { return this->bCastShadows_; } 63 63 64 64 protected: 65 65 void changedMesh(); 66 66 void changedShadows(); 67 67 68 68 //LoD 69 69 inline void setLodLevel(float lodLevel) … … 76 76 Mesh mesh_; 77 77 bool bCastShadows_; 78 78 79 79 //LoD 80 80 float lodLevel_; … … 82 82 unsigned int numLodLevels_; 83 83 float lodReductionRate_; 84 84 85 85 }; 86 86 }
Note: See TracChangeset
for help on using the changeset viewer.