Changeset 6843 for code/branches/lod/src/orxonox/graphics
- Timestamp:
- May 3, 2010, 4:21:07 PM (15 years ago)
- Location:
- code/branches/lod/src/orxonox/graphics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/lod/src/orxonox/graphics/Model.cc
r6838 r6843 29 29 #include "Model.h" 30 30 31 // What's this? With the directory in front the filename, my compiler can't find the file...32 //#include <OGRE/OgreEntity.h>33 31 #include <OgreEntity.h> 34 32 … … 76 74 } 77 75 76 float Model::getBiggestScale(Vector3 scale3d) 77 { 78 float scaleFactor = scale3d.x; 79 if(scale3d.y>scaleFactor) 80 scaleFactor = scale3d.y; 81 if(scale3d.z>scaleFactor) 82 scaleFactor = scale3d.z; 83 return scaleFactor; 84 } 85 78 86 void Model::changedMesh() 79 87 { … … 93 101 //LOD 94 102 if(this->mesh_.getEntity()->getMesh()->getNumLodLevels()==1 95 &&this->meshSrc_!="laserbeam.mesh" 96 &&this->lodLevel_!=0) 103 &&this->meshSrc_!="laserbeam.mesh") 97 104 { 98 Vector3 scale3d = this->getScale3D(); 99 float scaleFactor = scale3d.x; 100 if(scale3d.y>scaleFactor) 101 scaleFactor = scale3d.y; 102 if(scale3d.z>scaleFactor) 103 scaleFactor = scale3d.z; 105 float scaleFactor = getBiggestScale(this->getScale3D()); 106 BaseObject* creatorPtr = this->getCreator(); 107 while(creatorPtr!=0) 108 { 109 // TODO Cannot cast to WorldEntity 110 scaleFactor *= getBiggestScale(((WorldEntity) creatorPtr)->getScale3D()); 111 creatorPtr = this->getCreator(); 112 } 104 113 105 114 Level* level_ = this->getLevel(); … … 109 118 setLodLevel(lodInfo->getLodLevel()); 110 119 111 COUT(0) << this->meshSrc_<< " lodLevel_: " << this->lodLevel_ <<" scale: "<< scaleFactor << std::endl; 112 //Fuer Asteroiden perfekt 120 COUT(0) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and scale: "<< scaleFactor << ":" << std::endl; 113 121 114 122 #if OGRE_VERSION >= 0x010700 … … 118 126 #endif 119 127 120 float factor = scaleFactor; 121 COUT(0)<<"scaleFactor:"<<scaleFactor<<std::endl; 128 if(lodLevel_>0) 129 { 130 float factor = scaleFactor*5/lodLevel_; 131 132 COUT(0)<<"LodLevel set with factor: "<<factor<<std::endl; 122 133 123 distList.push_back(70.0f*factor);124 distList.push_back(140.0f*factor);125 distList.push_back(170.0f*factor);126 distList.push_back(200.0f*factor);127 distList.push_back(230.0f*factor);128 distList.push_back(250.0f*factor);129 distList.push_back(270.0f*factor);130 distList.push_back(290.0f*factor);131 distList.push_back(310.0f*factor);132 distList.push_back(330.0f*factor);134 distList.push_back(70.0f*factor); 135 distList.push_back(140.0f*factor); 136 distList.push_back(170.0f*factor); 137 distList.push_back(200.0f*factor); 138 distList.push_back(230.0f*factor); 139 distList.push_back(250.0f*factor); 140 distList.push_back(270.0f*factor); 141 distList.push_back(290.0f*factor); 142 distList.push_back(310.0f*factor); 143 distList.push_back(330.0f*factor); 133 144 134 float reductionValue = 0.2f;145 float reductionValue = 0.2f; 135 146 136 137 //Generiert LOD-Levels 138 this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue); 147 148 //Generiert LOD-Levels 149 this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue); 150 } 151 else 152 { 153 COUT(0)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was < 0."<<std::endl; 154 } 139 155 } 140 156 } -
code/branches/lod/src/orxonox/graphics/Model.h
r6691 r6843 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(unsigned short lodLevel) 70 { this->lodLevel_ = lodLevel; } 71 inline unsigned short getLodLevel() const 72 { return this->lodLevel_; } 67 68 //LoD 69 inline void setLodLevel(unsigned short lodLevel) 70 { this->lodLevel_ = lodLevel; } 71 inline unsigned short getLodLevel() const 72 { return this->lodLevel_; } 73 float Model::getBiggestScale(Vector3 scale3d); 73 74 74 75 std::string meshSrc_; 75 76 Mesh mesh_; 76 77 bool bCastShadows_; 77 78 79 78 79 //LoD 80 unsigned short lodLevel_; 80 81 }; 81 82 }
Note: See TracChangeset
for help on using the changeset viewer.