[Orxonox-commit 2389] r7104 - code/branches/presentation3/src/modules/objects
scheusso at orxonox.net
scheusso at orxonox.net
Thu Jun 3 02:21:26 CEST 2010
Author: scheusso
Date: 2010-06-03 02:21:26 +0200 (Thu, 03 Jun 2010)
New Revision: 7104
Modified:
code/branches/presentation3/src/modules/objects/Planet.cc
Log:
made planet synchronisable
Modified: code/branches/presentation3/src/modules/objects/Planet.cc
===================================================================
--- code/branches/presentation3/src/modules/objects/Planet.cc 2010-06-03 00:20:28 UTC (rev 7103)
+++ code/branches/presentation3/src/modules/objects/Planet.cc 2010-06-03 00:21:26 UTC (rev 7104)
@@ -69,7 +69,7 @@
if (GameMode::showsGraphics())
{
Camera* activeCamera = CameraManager::getInstance().getActiveCamera();
- if (activeCamera)
+ if (activeCamera && this->billboard_.getBillboardSet())
{
float distance = this->getPosition().distance( activeCamera->getWorldPosition() );
// COUT(2) << distance << std::endl;
@@ -88,51 +88,54 @@
void Planet::init()
{
- float scaleFactor = this->getScale();
-
-#if OGRE_VERSION >= 0x010700
- Ogre::Mesh::LodValueList distList;
-#else
- Ogre::Mesh::LodDistanceList distList;
-#endif
-
- distList.push_back(10.0f*scaleFactor);
- distList.push_back(19.0f*scaleFactor);
- distList.push_back(27.0f*scaleFactor);
- distList.push_back(34.0f*scaleFactor);
- distList.push_back(40.0f*scaleFactor);
- distList.push_back(45.0f*scaleFactor);
- distList.push_back(49.0f*scaleFactor);
- distList.push_back(52.0f*scaleFactor);
- distList.push_back(54.0f*scaleFactor);
- distList.push_back(55.0f*scaleFactor);
-
- float reductionValue = 0.2f;
-
- this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue);
- billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->atmosphere_, Vector3(0,0,0));
-
- this->attachOgreObject(this->billboard_.getBillboardSet());
- this->billboard_.getBillboardSet()->setUseAccurateFacing(true);
- this->setCastShadows(true);
- this->billboard_.getBillboardSet()->setRenderQueueGroup(this->mesh_.getEntity()->getRenderQueueGroup());
- this->mesh_.setCastShadows(true);
}
void Planet::changedMesh()
{
- if (this->mesh_.getEntity())
- this->detachOgreObject(this->mesh_.getEntity());
+ if( GameMode::showsGraphics() )
+ {
+ if (this->mesh_.getEntity())
+ this->detachOgreObject(this->mesh_.getEntity());
- this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
+ this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
- if (this->mesh_.getEntity())
- {
- this->attachOgreObject(this->mesh_.getEntity());
- this->mesh_.getEntity()->setCastShadows(this->bCastShadows_);
- this->mesh_.setVisible(this->isVisible());
+ if (this->mesh_.getEntity())
+ {
+ this->attachOgreObject(this->mesh_.getEntity());
+ this->mesh_.getEntity()->setCastShadows(this->bCastShadows_);
+ this->mesh_.setVisible(this->isVisible());
+
+ float scaleFactor = this->getScale();
+
+ #if OGRE_VERSION >= 0x010700
+ Ogre::Mesh::LodValueList distList;
+ #else
+ Ogre::Mesh::LodDistanceList distList;
+ #endif
+
+ distList.push_back(10.0f*scaleFactor);
+ distList.push_back(19.0f*scaleFactor);
+ distList.push_back(27.0f*scaleFactor);
+ distList.push_back(34.0f*scaleFactor);
+ distList.push_back(40.0f*scaleFactor);
+ distList.push_back(45.0f*scaleFactor);
+ distList.push_back(49.0f*scaleFactor);
+ distList.push_back(52.0f*scaleFactor);
+ distList.push_back(54.0f*scaleFactor);
+ distList.push_back(55.0f*scaleFactor);
+
+ float reductionValue = 0.2f;
+
+ this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue);
+ billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->atmosphere_, Vector3(0,0,0));
+
+ this->attachOgreObject(this->billboard_.getBillboardSet());
+ this->billboard_.getBillboardSet()->setUseAccurateFacing(true);
+ this->setCastShadows(true);
+ this->billboard_.getBillboardSet()->setRenderQueueGroup(this->mesh_.getEntity()->getRenderQueueGroup());
+ this->mesh_.setCastShadows(true);
+ }
}
- this->init();
}
void Planet::changedShadows()
@@ -150,23 +153,21 @@
{
SUPER(Planet, XMLPort, xmlelement, mode);
- if (GameMode::showsGraphics())
- {
- XMLPortParam(Planet, "atmosphere", setAtmosphere, getAtmosphere, xmlelement, mode).defaultValues("planet/Atmosphere");
- XMLPortParam(Planet, "atmospheresize", setAtmosphereSize, getAtmosphereSize, xmlelement,mode);
- XMLPortParam(Planet, "imagesize", setImageSize, getImageSize, xmlelement,mode);
- XMLPortParam(Planet, "mesh", setMeshSource, getMeshSource, xmlelement, mode);
- XMLPortParam(Planet, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true);
- }
+ XMLPortParam(Planet, "atmosphere", setAtmosphere, getAtmosphere, xmlelement, mode).defaultValues("planet/Atmosphere");
+ XMLPortParam(Planet, "atmospheresize", setAtmosphereSize, getAtmosphereSize, xmlelement,mode);
+ XMLPortParam(Planet, "imagesize", setImageSize, getImageSize, xmlelement,mode);
+ XMLPortParam(Planet, "mesh", setMeshSource, getMeshSource, xmlelement, mode);
+ XMLPortParam(Planet, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true);
}
void Planet::registerVariables()
{
registerVariable(this->atmosphere_, VariableDirection::ToClient);
+ registerVariable(this->atmosphereSize, VariableDirection::ToClient);
+ registerVariable(this->imageSize, VariableDirection::ToClient);
+ // Note: the meshSrc should be synchronised after atmosphere and other values, because the meshSrc callback setts the atmosphere billboards
registerVariable(this->meshSrc_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedMesh));
registerVariable(this->bCastShadows_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedShadows));
- registerVariable(this->atmosphereSize, VariableDirection::ToClient);
- registerVariable(this->imageSize, VariableDirection::ToClient);
}
void Planet::changedVisibility()
More information about the Orxonox-commit
mailing list