24 #pragma warning(disable:4355)
31 :
Ogre::FrameListener()
32 ,
Ogre::RenderTargetListener()
43 , mLastCameraPosition(
Ogre::Vector3(0,0,0))
44 , mLastCameraFarClipDistance(-1)
45 , mInfiniteCameraFarClipDistance(100000)
47 , mLightingMode(LM_LDR)
49 , mTimeMultiplier(0.1f)
61 delete mAtmosphereManager;
64 delete mCloudsManager;
65 delete mVCloudsManager;
68 delete mCfgFileManager;
70 if (mController->getDeleteBySkyX())
83 mGPUManager->_notifySkydomeMaterialChanged();
85 mMeshManager->create();
86 mMeshManager->setMaterialName(mGPUManager->getSkydomeMaterialName());
88 mAtmosphereManager->_update(mAtmosphereManager->getOptions(),
true);
98 mMoonManager->create();
100 setVisible(mVisible);
102 mLastCameraPosition = Ogre::Vector3(0,0,0);
103 mLastCameraFarClipDistance = -1;
115 mCloudsManager->removeAll();
116 mMeshManager->remove();
117 mMoonManager->remove();
118 mVCloudsManager->remove();
125 void SkyX::update(
const Ogre::Real& timeSinceLastFrame)
132 if (mTimeMultiplier != 0)
134 float timemultiplied = timeSinceLastFrame * mTimeMultiplier;
136 mTimeOffset += timemultiplied;
138 mController->update(timemultiplied);
149 mMoonManager->updateMoonPhase(mController->getMoonPhase());
150 mCloudsManager->update();
151 mVCloudsManager->update(timeSinceLastFrame);
154 void SkyX::notifyCameraRender(Ogre::Camera* c)
163 if (mLastCameraPosition != c->getDerivedPosition())
165 mMeshManager->getSceneNode()->setPosition(mCamera->getDerivedPosition());
167 mLastCameraPosition = mCamera->getDerivedPosition();
170 if (mLastCameraFarClipDistance != c->getFarClipDistance())
172 mMeshManager->updateGeometry(c);
174 mLastCameraFarClipDistance = mCamera->getFarClipDistance();
177 mMoonManager->updateGeometry(c);
179 mVCloudsManager->notifyCameraRender(c);
182 void SkyX::setVisible(
const bool& visible)
191 mMeshManager->getSceneNode()->setVisible(mVisible);
192 mMoonManager->getMoonSceneNode()->setVisible(mVisible);
194 if (mVCloudsManager->isCreated())
196 mVCloudsManager->getVClouds()->setVisible(mVisible);
202 mRenderQueueGroups = rqg;
204 mVCloudsManager->getVClouds()->setRenderQueueGroups(
212 mMeshManager->getEntity()->setRenderQueueGroup(mRenderQueueGroups.skydome);
213 mMoonManager->getMoonBillboard()->setRenderQueueGroup(mRenderQueueGroups.skydome+1);
225 mGPUManager->_notifySkydomeMaterialChanged();
228 mMeshManager->setMaterialName(mGPUManager->getSkydomeMaterialName());
230 mCloudsManager->registerAll();
232 mGPUManager->_updateFP();
235 mAtmosphereManager->_update(mAtmosphereManager->getOptions(),
true);
238 void SkyX::setStarfieldEnabled(
const bool& Enabled)
240 mStarfield = Enabled;
247 mGPUManager->_notifySkydomeMaterialChanged();
250 mMeshManager->setMaterialName(mGPUManager->getSkydomeMaterialName());
253 mAtmosphereManager->_update(mAtmosphereManager->getOptions(),
true);
264 bool SkyX::frameStarted(
const Ogre::FrameEvent& e)
266 update(e.timeSinceLastFrame);
270 void SkyX::preViewportUpdate(
const Ogre::RenderTargetViewportEvent& evt)
272 notifyCameraRender(evt.source->getCamera());