//--------------------------------------------------------------------------------- bool CCaelumEditor::_setCloudsEnable(OgitorsPropertyBase* property, const bool& value) { Caelum::CloudSystem *clouds = mHandle->getCloudSystem(); Caelum::FlatCloudLayer *layer = clouds->getLayer(property->getTag()); layer->setVisibilityFlags(value == true?0xFFFFFFFF:0); return true; }
//--------------------------------------------------------------------------------- bool CCaelumEditor::_setCloudsSpeed(OgitorsPropertyBase* property, const Ogre::Vector2& value) { Caelum::CloudSystem *clouds = mHandle->getCloudSystem(); Caelum::FlatCloudLayer *layer = clouds->getLayer(property->getTag()); layer->setCloudSpeed(value); return true; }
//-------------------------------------------------------------------------------------------------- bool CCaelumEditor::_createSky(Ogre::SceneManager *mngr, Ogre::Camera *cam) { Caelum::CaelumSystem::CaelumComponent componentMask; componentMask = static_cast<Caelum::CaelumSystem::CaelumComponent> ( Caelum::CaelumSystem::CAELUM_COMPONENT_SUN | Caelum::CaelumSystem::CAELUM_COMPONENT_MOON | Caelum::CaelumSystem::CAELUM_COMPONENT_SKY_DOME | Caelum::CaelumSystem::CAELUM_COMPONENT_POINT_STARFIELD | Caelum::CaelumSystem::CAELUM_COMPONENT_CLOUDS | 0); mSceneManager = mngr; mHandle = new Caelum::CaelumSystem(Ogre::Root::getSingletonPtr(), mngr,componentMask); mHandle->setManageSceneFog(false); mHandle->notifyCameraChanged(cam); mHandle->getSkyDome()->setQueryFlags(0); mHandle->getSkyDome()->setVisibilityFlags(0x80000000); mHandle->forceSubcomponentQueryFlags(0); mHandle->forceSubcomponentVisibilityFlags(0x80000000); mHandle->getUniversalClock()->setGregorianDateTime(mClockYear->get(),mClockMonth->get(),mClockDay->get(),mClockHour->get(),mClockMinute->get(),mClockSecond->get()); mHandle->getUniversalClock()->setTimeScale(mClockSpeed->get()); mHandle->setObserverLongitude(Ogre::Degree(mLongitude->get())); mHandle->setObserverLatitude(Ogre::Degree(mLatitude->get())); mHandle->setManageSceneFog(mFogManage->get()); mHandle->setGlobalFogDensityMultiplier(mFogDensityMultiplier->get()); Caelum::BaseSkyLight *sun = mHandle->getSun(); sun->setAmbientMultiplier(mSunAmbientMultiplier->get()); sun->setDiffuseMultiplier(mSunDiffuseMultiplier->get()); sun->setSpecularMultiplier(mSunSpecularMultiplier->get()); mHandle->getSun()->setAutoDisable(mSunAutoDisable->get()); mHandle->getSun()->getMainLight()->setCastShadows(mSunCastShadow->get()); mHandle->getSun()->getMainLight()->setAttenuation(mSunAttenuationDistance->get(),mSunAttenuationConstantMultiplier->get(),mSunAttenuationLinearMultiplier->get(),mSunAttenuationConstantMultiplier->get()); Caelum::BaseSkyLight *moon = mHandle->getMoon(); moon->setAmbientMultiplier(mMoonAmbientMultiplier->get()); moon->setDiffuseMultiplier(mMoonDiffuseMultiplier->get()); moon->setSpecularMultiplier(mMoonSpecularMultiplier->get()); mHandle->getMoon()->setAutoDisable(mMoonAutoDisable->get()); mHandle->getMoon()->getMainLight()->setCastShadows(mMoonCastShadow->get()); mHandle->getMoon()->getMainLight()->setAttenuation(mMoonAttenuationDistance->get(),mMoonAttenuationConstantMultiplier->get(),mMoonAttenuationLinearMultiplier->get(),mMoonAttenuationConstantMultiplier->get()); Caelum::PointStarfield *stars = mHandle->getPointStarfield(); stars->setMagnitudeScale( mStarsMagnitudeScale->get() ); stars->setMag0PixelSize( mStarsMag0PixelSize->get() ); stars->setMinPixelSize( mStarsMinPixelSize->get() ); stars->setMaxPixelSize( mStarsMaxPixelSize->get() ); mHandle->setEnsureSingleLightSource( mLightingSingleLightSource->get() ); mHandle->setEnsureSingleShadowSource( mLightingSingleShadowSource->get() ); mHandle->setManageAmbientLight( mLightingManageAmbientLight->get() ); mHandle->setMinimumAmbientLight( mLightingMinimumAmbientLight->get() ); Caelum::CloudSystem *clouds = mHandle->getCloudSystem(); if(!clouds) { clouds = new Caelum::CloudSystem(mSceneManager,mHandle->getCaelumCameraNode()); mHandle->setCloudSystem(clouds); } clouds->clearLayers(); clouds->getLayerVector().clear(); for(int i = 0;i < 3;i++) { Caelum::FlatCloudLayer *layer = clouds->createLayer(); layer->setVisibilityFlags(mCloudsEnabled[i]->get() == true?0xFFFFFFFF:0); layer->setQueryFlags(0); layer->setCloudCover(mCloudsCoverage[i]->get()); layer->setHeight(mCloudsHeight[i]->get()); layer->setCloudSpeed(mCloudsSpeed[0]->get()); } return true; }
CaelumSky::CaelumSky(CaelumEnvironment& environment) : CaelumEnvironmentComponent(environment) { // Setup cloud options. if (mCaelumSystem->getCloudSystem()) { Caelum::CloudSystem* cloudSystem = mCaelumSystem->getCloudSystem(); Caelum::FlatCloudLayer* cloudLayer = cloudSystem->createLayerAtHeight(1500); cloudLayer->setCloudSpeed(Ogre::Vector2(0.0005, -0.0009)); cloudLayer->setCloudBlendTime(3600 * 24); cloudLayer->setCloudCover(0.3); cloudLayer->setFadeDistances(5000, 9000); cloudLayer->setFadeDistMeasurementVector(Ogre::Vector3(1, 0, 1)); cloudLayer = cloudSystem->createLayerAtHeight(2000); cloudLayer->setCloudSpeed(Ogre::Vector2(0.00045, -0.00075)); cloudLayer->setCloudBlendTime(3600 * 24); cloudLayer->setCloudCover(0.4); cloudLayer->setFadeDistances(5000, 9000); cloudLayer->setFadeDistMeasurementVector(Ogre::Vector3(1, 0, 1)); } registerConfigListener("caelum", "cloudspeed", sigc::mem_fun(*this, &CaelumSky::Config_CloudSpeed)); registerConfigListener("caelum", "cloudblendtime", sigc::mem_fun(*this, &CaelumSky::Config_CloudBlendTime)); registerConfigListener("caelum", "cloudcover", sigc::mem_fun(*this, &CaelumSky::Config_CloudCover)); }