44SEnvironment::SEnvironment(
SScene* parent,
const std::string& environmentName) :
SData(environmentName)
61 observerLatitude = 45.0f;
62 observerLongitude = 0.0f;
66 windDirection = Ogre::Vector2::UNIT_X;
67 humidityFactor = 25.0f;
82 sun =
new SSun(
this,
"SO3/Internal/Environment/"+
name +
"/Sun");
83 moon =
new SMoon(
this,
"SO3/Internal/Environment/"+
name +
"/Moon");
92 sky =
new SSky(
this,
"SO3/Internal/Environment/"+
name +
"/Sky");
95 water =
new SWater(
this,
"SO3/Internal/Environment/"+
name +
"/Water");
98 Ogre::Root::getSingleton().addFrameListener(
this);
105SEnvironment::SEnvironment() :
SData(
"")
113 Ogre::Root::getSingleton().removeFrameListener(
this);
116 SO3_SAFE_DELETE(water);
117 SO3_SAFE_DELETE(sky);
118 SO3_SAFE_DELETE(moon);
119 SO3_SAFE_DELETE(sun);
120 SO3_SAFE_DELETE(universalClock);
130 ViewportList::iterator iSearchedViewport = viewportList.find(targetViewport);
131 if(iSearchedViewport == viewportList.end())
134 viewportList.insert(targetViewport);
144 RenderTargetList::iterator searchedRenderTarget = mRenderTargetList.find(parentRenderTarger);
145 if(searchedRenderTarget == mRenderTargetList.end())
148 parentRenderTarger->addListener(
this);
149 mRenderTargetList.insert(RenderTargetList::value_type(parentRenderTarger, 1));
154 mRenderTargetList[parentRenderTarger] += 1;
158 OGRE_EXCEPT(Ogre::Exception::ERR_DUPLICATE_ITEM,
"The viewport already exist in the list of associated viewports!",
"SEnvironment::RegisterViewport");
163 ViewportList::iterator iSearchedViewport = viewportList.find(targetViewport);
164 if(iSearchedViewport != viewportList.end())
168 mRenderTargetList[parentRenderTarger] -= 1;
169 if(mRenderTargetList[parentRenderTarger] == 0)
171 parentRenderTarger->removeListener(
this);
172 mRenderTargetList.erase(parentRenderTarger);
182 viewportList.erase(targetViewport);
201 ViewportList::iterator iSearchedViewport = viewportList.find(targetViewport);
202 if(iSearchedViewport != viewportList.end())
210 ViewportList::iterator iViewportList = viewportList.begin();
211 while(iViewportList != viewportList.end())
213 if ((*iViewportList)->GetOgreViewPortPointer() == targetViewport)
224 ViewportList::iterator iViewportList = viewportListCopy.begin();
225 while(iViewportList != viewportListCopy.end())
239 return universalClock;
269 enabled = enableEnvironment;
301 waterEnabled = enableWater;
314 skyEnabled = enableSky;
327 windSpeed = newWindSpeed;
332 return windDirection;
337 windDirection = newWindDirection.normalisedCopy();
342 return humidityFactor;
348 humidityFactor = newHumidity;
349 if(newHumidity < 0.0f)
350 humidityFactor = 0.0f;
351 if(newHumidity > 100.0f)
352 humidityFactor = 100.0f;
376 paused = pauseSimulation;
387 tempDateTime.
second =
static_cast<int> (second);
393 double second =
static_cast<double> (dateTime.
second);
400 return observerLongitude;
405 observerLongitude = newLongitude;
410 return observerLatitude;
415 observerLatitude = newLatitude;
422 Ogre::Real updateTime = 0.0f;
425 universalClock->
Update(evt.timeSinceLastFrame);
438 water->
Update(evt.timeSinceLastFrame);
442 sky->
Update(evt.timeSinceLastFrame);
450 Ogre::RenderTarget* parentRenderTarger = targetViewport->getTarget();
451 RenderTargetList::iterator searchedRenderTarget = mRenderTargetList.find(parentRenderTarger);
452 if(searchedRenderTarget != mRenderTargetList.end())
455 parentRenderTarger->removeListener(
this);
456 parentRenderTarger->addListener(
this);
463 Ogre::RenderTarget* parentRenderTarger = targetViewport->getTarget();
464 RenderTargetList::iterator searchedRenderTarget = mRenderTargetList.find(parentRenderTarger);
465 if(searchedRenderTarget != mRenderTargetList.end())
468 parentRenderTarger->removeListener(
this);
void RegisterViewport(SViewPort *viewport)
void UnregisterCamera(Ogre::Camera *cam)
void UnregisterViewport(SViewPort *viewport)
void SetEnable(const bool &enableComponent)
ViewportList GetRegisteredViewports()
SUniversalClock * GetUniversalClock()
Ogre::Degree GetLatitude()
virtual bool frameStarted(const Ogre::FrameEvent &evt)
float GetTimeSpeedFactor()
void SetEnable(const bool &enableEnvironment)
void UnregisterViewport(SViewPort *targetViewport)
void _NotifyEnvironmentComponentUnRegisterRenderTarget(Ogre::Viewport *targetViewport)
void SetPaused(const bool &pauseSimulation)
Ogre::Degree GetLongitude()
std::set< SViewPort * > ViewportList
void SetWaterEnable(const bool &enableWater)
void RegisterViewport(SViewPort *targetViewport)
void SetWindSpeed(const float &newWindSpeed)
void SetSkyEnable(const bool &enableSky)
void UnregisterCamera(Ogre::Camera *cam)
void UnregisterAllViewports()
void _NotifyEnvironmentComponentRegisterRenderTarget(Ogre::Viewport *targetViewport)
void SetDateTime(const SDateTime &newDateTime)
Ogre::Vector2 GetWindDirection()
void SetHumidity(const float &newHumidity)
void SetTimeSpeedFactor(const float &newTimeSpeedFactor)
void UpdateCamera(SViewPort *viewport)
bool IsRegisteredViewport(SViewPort *targetViewport)
void SetLongitude(const Ogre::Degree &newLongitude)
void SetWindDirection(const Ogre::Vector2 &newWindDirection)
void SetLatitude(const Ogre::Degree &newLatitude)
Ogre::SceneManager * GetOgreScenePointer()
virtual void Update(const Ogre::Real &updateTime)
virtual void UpdateCamera(SViewPort *viewport)
void UpdateShadowFarDistance(const float &distance)
void UpdateShadowFarClipDistance(const float &distance)
void SetEnable(const bool &enable)
void SetTimeScale(const float &scale)
void GetGregorianDateTime(int &year, int &month, int &day, int &hour, int &minute, double &second)
void Update(const float &time)
void SetGregorianDateTime(const int &year, const int &month, const int &day, const int &hour, const int &minute, const double &second)
float GetTimeScale() const
void RegisterStereoViewport()
void UnregisterStereoViewport()
bool IsStereoViewportRegistered()
Ogre::Viewport * GetOgreViewPortPointer()
virtual void UpdateCamera(SViewPort *viewport)
virtual void Update(const Ogre::Real &updateTime)