38SkyManager::SkyManager() : m_caelum_system(nullptr), m_last_clock(0.0)
41 m_caelum_system =
new Caelum::CaelumSystem(
43 App::GetGfxScene()->GetSceneManager(),
44 Caelum::CaelumSystem::CAELUM_COMPONENTS_DEFAULT
54SkyManager::~SkyManager()
57 m_caelum_system->shutdown(
false);
58 m_caelum_system =
nullptr;
61void SkyManager::NotifySkyCameraChanged(Ogre::Camera* cam)
64 m_caelum_system->notifyCameraChanged(cam);
67void SkyManager::DetectSkyUpdate()
69 if (!m_caelum_system || !App::GetGameContext()->GetTerrain())
74 Caelum::LongReal c = m_caelum_system->getUniversalClock()->getJulianDay();
76 if (c - m_last_clock > 0.001f)
86void SkyManager::LoadCaelumScript(std::string script,
int fogStart,
int fogEnd)
91 Caelum::CaelumPlugin::getSingleton().loadCaelumSystemFromScript(m_caelum_system, script);
94#ifdef CAELUM_VERSION_SEC
96 if (fogStart != -1 && fogEnd != -1 && fogStart < fogEnd)
99 App::GetCameraManager()->GetCamera()->setFarClipDistance(fogEnd / 0.8);
101 m_caelum_system->setManageSceneFog(Ogre::FOG_LINEAR);
102 m_caelum_system->setManageSceneFogStart(fogStart);
103 m_caelum_system->setManageSceneFogEnd(fogEnd);
105 else if (App::GetCameraManager()->GetCamera()->getFarClipDistance() > 0)
107 if (fogStart != -1 && fogEnd != -1)
109 LOG(
"CaelumFogStart must be smaller then CaelumFogEnd. Ignoring boundaries.");
111 else if (fogStart != -1 || fogEnd != -1)
113 LOG(
"You always need to define both boundaries (CaelumFogStart AND CaelumFogEnd). Ignoring boundaries.");
116 float farclip = App::GetCameraManager()->GetCamera()->getFarClipDistance();
117 m_caelum_system->setManageSceneFog(Ogre::FOG_LINEAR);
118 m_caelum_system->setManageSceneFogStart(farclip * 0.7);
119 m_caelum_system->setManageSceneFogEnd(farclip * 0.9);
124 m_caelum_system->setManageSceneFog(Ogre::FOG_NONE);
127#error please use a recent Caelum version, see http:
130 if (m_caelum_system->getMoon())
132 m_caelum_system->getMoon()->setAutoDisable(
true);
134 m_caelum_system->getMoon()->setForceDisable(
true);
135 m_caelum_system->getMoon()->getMainLight()->setCastShadows(
false);
138 m_caelum_system->setEnsureSingleShadowSource(
true);
139 m_caelum_system->setEnsureSingleLightSource(
true);
142 m_caelum_system->updateSubcomponents(0.1);
144 catch (Ogre::Exception& e)
146 RoR::LogFormat(
"[RoR] Exception while loading sky script: %s", e.getFullDescription().c_str());
148 Ogre::Vector3 lightsrc = m_caelum_system->getSun()->getMainLight()->getDirection();
149 m_caelum_system->getSun()->getMainLight()->setDirection(lightsrc.normalisedCopy());
152void SkyManager::SetSkyTimeFactor(
float factor)
154 m_caelum_system->getUniversalClock()->setTimeScale(factor);
157Ogre::Light* SkyManager::GetSkyMainLight()
159 if (m_caelum_system && m_caelum_system->getSun())
161 return m_caelum_system->getSun()->getMainLight();
166float SkyManager::GetSkyTimeFactor()
168 return m_caelum_system->getUniversalClock()->getTimeScale();
171std::string SkyManager::GetPrettyTime()
176 Caelum::LongReal second;
177 Caelum::Astronomy::getGregorianDateTimeFromJulianDay(m_caelum_system->getJulianDay()
178 , ignore, ignore, ignore, hour, minute, second);
181 snprintf(buf, 100,
"%02d:%02d:%02d", hour, minute,
static_cast<int>(second));
System integration layer; inspired by OgreBites::ApplicationContext.
void LOG(const char *msg)
Legacy alias - formerly a macro.
Game state manager and message-queue provider.
Ogre::Root * GetOgreRoot()
Ogre::RenderWindow * GetRenderWindow()
this class handles all interactions with the Ogre Terrain system
AppContext * GetAppContext()
void LogFormat(const char *format,...)
Improved logging utility. Uses fixed 2Kb buffer.