Changeset 7104
- Timestamp:
- Jun 3, 2010, 2:21:26 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/src/modules/objects/Planet.cc
r6501 r7104 70 70 { 71 71 Camera* activeCamera = CameraManager::getInstance().getActiveCamera(); 72 if (activeCamera )72 if (activeCamera && this->billboard_.getBillboardSet()) 73 73 { 74 74 float distance = this->getPosition().distance( activeCamera->getWorldPosition() ); … … 89 89 void Planet::init() 90 90 { 91 float scaleFactor = this->getScale();92 93 #if OGRE_VERSION >= 0x01070094 Ogre::Mesh::LodValueList distList;95 #else96 Ogre::Mesh::LodDistanceList distList;97 #endif98 99 distList.push_back(10.0f*scaleFactor);100 distList.push_back(19.0f*scaleFactor);101 distList.push_back(27.0f*scaleFactor);102 distList.push_back(34.0f*scaleFactor);103 distList.push_back(40.0f*scaleFactor);104 distList.push_back(45.0f*scaleFactor);105 distList.push_back(49.0f*scaleFactor);106 distList.push_back(52.0f*scaleFactor);107 distList.push_back(54.0f*scaleFactor);108 distList.push_back(55.0f*scaleFactor);109 110 float reductionValue = 0.2f;111 112 this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue);113 billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->atmosphere_, Vector3(0,0,0));114 115 this->attachOgreObject(this->billboard_.getBillboardSet());116 this->billboard_.getBillboardSet()->setUseAccurateFacing(true);117 this->setCastShadows(true);118 this->billboard_.getBillboardSet()->setRenderQueueGroup(this->mesh_.getEntity()->getRenderQueueGroup());119 this->mesh_.setCastShadows(true);120 91 } 121 92 122 93 void Planet::changedMesh() 123 94 { 124 if (this->mesh_.getEntity()) 125 this->detachOgreObject(this->mesh_.getEntity()); 95 if( GameMode::showsGraphics() ) 96 { 97 if (this->mesh_.getEntity()) 98 this->detachOgreObject(this->mesh_.getEntity()); 126 99 127 this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);100 this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_); 128 101 129 if (this->mesh_.getEntity()) 130 { 131 this->attachOgreObject(this->mesh_.getEntity()); 132 this->mesh_.getEntity()->setCastShadows(this->bCastShadows_); 133 this->mesh_.setVisible(this->isVisible()); 102 if (this->mesh_.getEntity()) 103 { 104 this->attachOgreObject(this->mesh_.getEntity()); 105 this->mesh_.getEntity()->setCastShadows(this->bCastShadows_); 106 this->mesh_.setVisible(this->isVisible()); 107 108 float scaleFactor = this->getScale(); 109 110 #if OGRE_VERSION >= 0x010700 111 Ogre::Mesh::LodValueList distList; 112 #else 113 Ogre::Mesh::LodDistanceList distList; 114 #endif 115 116 distList.push_back(10.0f*scaleFactor); 117 distList.push_back(19.0f*scaleFactor); 118 distList.push_back(27.0f*scaleFactor); 119 distList.push_back(34.0f*scaleFactor); 120 distList.push_back(40.0f*scaleFactor); 121 distList.push_back(45.0f*scaleFactor); 122 distList.push_back(49.0f*scaleFactor); 123 distList.push_back(52.0f*scaleFactor); 124 distList.push_back(54.0f*scaleFactor); 125 distList.push_back(55.0f*scaleFactor); 126 127 float reductionValue = 0.2f; 128 129 this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue); 130 billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->atmosphere_, Vector3(0,0,0)); 131 132 this->attachOgreObject(this->billboard_.getBillboardSet()); 133 this->billboard_.getBillboardSet()->setUseAccurateFacing(true); 134 this->setCastShadows(true); 135 this->billboard_.getBillboardSet()->setRenderQueueGroup(this->mesh_.getEntity()->getRenderQueueGroup()); 136 this->mesh_.setCastShadows(true); 137 } 134 138 } 135 this->init();136 139 } 137 140 … … 151 154 SUPER(Planet, XMLPort, xmlelement, mode); 152 155 153 if (GameMode::showsGraphics()) 154 { 155 XMLPortParam(Planet, "atmosphere", setAtmosphere, getAtmosphere, xmlelement, mode).defaultValues("planet/Atmosphere"); 156 XMLPortParam(Planet, "atmospheresize", setAtmosphereSize, getAtmosphereSize, xmlelement,mode); 157 XMLPortParam(Planet, "imagesize", setImageSize, getImageSize, xmlelement,mode); 158 XMLPortParam(Planet, "mesh", setMeshSource, getMeshSource, xmlelement, mode); 159 XMLPortParam(Planet, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true); 160 } 156 XMLPortParam(Planet, "atmosphere", setAtmosphere, getAtmosphere, xmlelement, mode).defaultValues("planet/Atmosphere"); 157 XMLPortParam(Planet, "atmospheresize", setAtmosphereSize, getAtmosphereSize, xmlelement,mode); 158 XMLPortParam(Planet, "imagesize", setImageSize, getImageSize, xmlelement,mode); 159 XMLPortParam(Planet, "mesh", setMeshSource, getMeshSource, xmlelement, mode); 160 XMLPortParam(Planet, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true); 161 161 } 162 162 … … 164 164 { 165 165 registerVariable(this->atmosphere_, VariableDirection::ToClient); 166 registerVariable(this->atmosphereSize, VariableDirection::ToClient); 167 registerVariable(this->imageSize, VariableDirection::ToClient); 168 // Note: the meshSrc should be synchronised after atmosphere and other values, because the meshSrc callback setts the atmosphere billboards 166 169 registerVariable(this->meshSrc_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedMesh)); 167 170 registerVariable(this->bCastShadows_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedShadows)); 168 registerVariable(this->atmosphereSize, VariableDirection::ToClient);169 registerVariable(this->imageSize, VariableDirection::ToClient);170 171 } 171 172
Note: See TracChangeset
for help on using the changeset viewer.