Changeset 11128 for code/branches/ogre1.9/src/modules/objects
- Timestamp:
- Mar 6, 2016, 1:56:26 PM (9 years ago)
- Location:
- code/branches/ogre1.9/src/modules/objects
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ogre1.9/src/modules/objects/Planet.cc
r10624 r11128 47 47 * @brief Constructor 48 48 */ 49 Planet::Planet(Context* context) : Mo vableEntity(context)49 Planet::Planet(Context* context) : Model(context) 50 50 { 51 51 RegisterObject(Planet); 52 this->setLodEnabled(false); 52 53 this->registerVariables(); 53 54 } … … 58 59 Planet::~Planet() 59 60 { 60 if (this->isInitialized() && this->mesh_.getEntity())61 this->detachOgreObject(this->mesh_.getEntity());62 61 } 63 62 … … 87 86 } 88 87 89 void Planet::changed Mesh()88 void Planet::changedAtmosphere() 90 89 { 91 90 if( GameMode::showsGraphics() ) 92 91 { 93 if (this->mesh_.getEntity()) 94 this->detachOgreObject(this->mesh_.getEntity()); 95 96 this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_); 97 98 if (this->mesh_.getEntity()) 92 if (this->getMesh().getEntity()) 99 93 { 100 this->attachOgreObject(this->mesh_.getEntity()); 101 this->mesh_.getEntity()->setCastShadows(this->bCastShadows_); 102 this->mesh_.setVisible(this->isVisible()); 103 104 float scaleFactor = this->getScale(); 105 106 #if OGRE_VERSION >= 0x010800 107 Ogre::ProgressiveMesh::LodValueList distList; 108 #elif OGRE_VERSION >= 0x010700 109 Ogre::Mesh::LodValueList distList; 110 #else 111 Ogre::Mesh::LodDistanceList distList; 112 #endif 113 114 distList.push_back(10.0f*scaleFactor); 115 distList.push_back(19.0f*scaleFactor); 116 distList.push_back(27.0f*scaleFactor); 117 distList.push_back(34.0f*scaleFactor); 118 distList.push_back(40.0f*scaleFactor); 119 distList.push_back(45.0f*scaleFactor); 120 distList.push_back(49.0f*scaleFactor); 121 distList.push_back(52.0f*scaleFactor); 122 distList.push_back(54.0f*scaleFactor); 123 distList.push_back(55.0f*scaleFactor); 124 125 float reductionValue = 0.2f; 126 127 #if OGRE_VERSION >= 0x010800 128 Ogre::ProgressiveMesh::generateLodLevels(this->mesh_.getEntity()->getMesh().get(), distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, 129 reductionValue); 130 #else 131 this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue); 132 #endif 133 billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->atmosphere_, Vector3(0,0,0)); 94 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->atmosphere_, Vector3(0,0,0)); 134 95 135 96 this->attachOgreObject(this->billboard_.getBillboardSet()); 136 97 this->billboard_.getBillboardSet()->setUseAccurateFacing(true); 137 this->setCastShadows(true); 138 this->billboard_.getBillboardSet()->setRenderQueueGroup(this->mesh_.getEntity()->getRenderQueueGroup()); 139 this->mesh_.setCastShadows(true); 98 this->billboard_.getBillboardSet()->setRenderQueueGroup(this->getMesh().getEntity()->getRenderQueueGroup()); 140 99 } 141 100 } 142 }143 144 void Planet::changedShadows()145 {146 this->mesh_.setCastShadows(this->bCastShadows_);147 101 } 148 102 … … 154 108 XMLPortParam(Planet, "atmospheresize", setAtmosphereSize, getAtmosphereSize, xmlelement,mode); 155 109 XMLPortParam(Planet, "imagesize", setImageSize, getImageSize, xmlelement,mode); 156 XMLPortParam(Planet, "mesh", setMeshSource, getMeshSource, xmlelement, mode);157 XMLPortParam(Planet, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true);158 110 } 159 111 160 112 void Planet::registerVariables() 161 113 { 162 registerVariable(this->atmosphere_, VariableDirection::ToClient );114 registerVariable(this->atmosphere_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedAtmosphere)); 163 115 registerVariable(this->atmosphereSize, VariableDirection::ToClient); 164 116 registerVariable(this->imageSize, VariableDirection::ToClient); 165 // Note: the meshSrc should be synchronised after atmosphere and other values, because the meshSrc callback setts the atmosphere billboards166 registerVariable(this->meshSrc_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedMesh));167 registerVariable(this->bCastShadows_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedShadows));168 117 } 169 118 … … 171 120 { 172 121 SUPER(Planet, changedVisibility); 173 if (this->isInitialized()) 174 { 175 this->mesh_.setVisible(this->isVisible()); 176 this->billboard_.setVisible(this->isVisible()); 177 } 122 123 this->billboard_.setVisible(this->isVisible()); 178 124 } 179 125 } -
code/branches/ogre1.9/src/modules/objects/Planet.h
r11071 r11128 41 41 #include "tools/BillboardSet.h" 42 42 #include "tools/Mesh.h" 43 #include "worldentities/MovableEntity.h" 43 #include "tools/interfaces/Tickable.h" 44 #include "graphics/Model.h" 44 45 45 46 namespace orxonox 46 47 { 47 class _ObjectsExport Planet : public Mo vableEntity48 class _ObjectsExport Planet : public Model, public Tickable 48 49 { 49 50 public: … … 58 59 virtual void changedVisibility() override; 59 60 60 inline void setMeshSource(const std::string& meshname)61 { this->meshSrc_ = meshname; this->changedMesh(); }62 63 inline const std::string& getMeshSource() const64 { return this->meshSrc_; }65 66 inline void setCastShadows(bool bCastShadows)67 { this->bCastShadows_ = bCastShadows; this->changedShadows(); }68 69 inline bool getCastShadows() const70 { return this->bCastShadows_; }71 72 inline const std::string& getMesh() const{73 return this->meshSrc_;74 }75 76 61 inline void setAtmosphereSize(float size){ 77 62 this->atmosphereSize = size; … … 84 69 inline void setAtmosphere(const std::string& atmosphere){ 85 70 this->atmosphere_ = atmosphere; 71 this->changedAtmosphere(); 86 72 } 87 73 … … 103 89 void registerVariables(); 104 90 105 void changedMesh(); 106 void changedShadows(); 91 void changedAtmosphere(); 107 92 108 std::string meshSrc_;109 93 std::string atmosphere_; 110 Mesh mesh_;111 94 float atmosphereSize; 112 95 float imageSize; 113 96 BillboardSet billboard_; 114 bool bCastShadows_;115 97 116 98 };
Note: See TracChangeset
for help on using the changeset viewer.