- Timestamp:
- Dec 14, 2008, 1:42:17 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/orxonox/objects/worldentities/Planet.cc
r2420 r2435 27 27 */ 28 28 29 30 29 #include "OrxonoxStableHeaders.h" 31 30 #include "Planet.h" 32 31 33 #include "tinyxml/tinyxml.h"34 #include "core/CoreIncludes.h"35 #include "GraphicsEngine.h"36 #include "core/XMLPort.h"37 #include "CameraManager.h"38 #include "objects/Scene.h"39 #include "Camera.h"40 32 #include <math.h> 41 33 … … 45 37 #include <OgreMeshManager.h> 46 38 39 #include "core/CoreIncludes.h" 40 #include "core/XMLPort.h" 41 #include "objects/Scene.h" 42 #include "CameraManager.h" 43 #include "Camera.h" 44 #include "GraphicsEngine.h" 47 45 48 46 namespace orxonox … … 67 65 this->getNode()->detachObject(this->mesh_.getEntity()); 68 66 } 69 67 70 68 void Planet::tick(float dt) 71 69 { 72 70 if(!this->isVisible()) 73 71 return; 74 72 75 73 Camera* activeCamera = CameraManager::getInstance().getActiveCamera(); 76 77 74 if(activeCamera) 75 { 78 76 Real distance = this->getPosition().distance( activeCamera->getWorldPosition() ); 79 // COUT(2) << distance << std::endl;77 // COUT(2) << distance << std::endl; 80 78 Real planetRadius = this->getScale(); 81 79 82 80 Real newScale = 2 * distance / sqrt(distance*distance - planetRadius*planetRadius); 83 81 Real tempTest = newScale*(1+Real(this->atmosphereSize)/Real(this->imageSize)); 84 82 newScale = tempTest; 85 83 86 84 this->billboard_.getBillboardSet()->setDefaultDimensions(newScale, newScale); 87 88 85 } 86 89 87 SUPER(Planet, tick, dt); 90 88 } 91 92 void Planet::init() {93 89 90 void Planet::init() 91 { 94 92 Real scaleFactor = this->getScale(); 95 93 96 94 this->distList.push_back(10.0*scaleFactor); 97 95 this->distList.push_back(19.0*scaleFactor); … … 104 102 this->distList.push_back(54.0*scaleFactor); 105 103 this->distList.push_back(55.0*scaleFactor); 106 104 107 105 Real reductionValue = 0.2; 108 106 109 107 this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue); 110 108 billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->atmosphere_, Vector3(0,0,0)); 111 109 112 110 this->getNode()->attachObject(this->billboard_.getBillboardSet()); 113 111 this->billboard_.getBillboardSet()->setUseAccurateFacing(true); … … 116 114 this->mesh_.setCastShadows(true); 117 115 } 118 116 119 117 void Planet::changedMesh() 120 118 { … … 147 145 { 148 146 SUPER(Planet, XMLPort, xmlelement, mode); 149 147 150 148 XMLPortParam(Planet, "atmosphere", setAtmosphere, getAtmosphere, xmlelement, mode).defaultValues("planet/Atmosphere"); 151 149 XMLPortParam(Planet, "atmospheresize", setAtmosphereSize, getAtmosphereSize, xmlelement,mode); … … 153 151 XMLPortParam(Planet, "mesh", setMeshSource, getMeshSource, xmlelement, mode); 154 152 XMLPortParam(Planet, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true); 155 156 153 } 157 154 158 void Planet::registerVariables(){ 155 void Planet::registerVariables() 156 { 159 157 registerVariable(this->atmosphere_, variableDirection::toclient); 160 158 registerVariable(this->meshSrc_, variableDirection::toclient, new NetworkCallback<Planet>(this, &Planet::changedMesh)); … … 168 166 SUPER(Planet, changedVisibility); 169 167 if (this->isInitialized()) 168 { 170 169 this->mesh_.setVisible(this->isVisible()); 171 170 this->billboard_.setVisible(this->isVisible()); 171 } 172 172 } 173 173 }
Note: See TracChangeset
for help on using the changeset viewer.