Caelum::CaelumSystem Class Reference

#include <CaelumSystem.h>

Inheritance diagram for Caelum::CaelumSystem:

Inheritance graph
[legend]
Collaboration diagram for Caelum::CaelumSystem:

Collaboration graph
[legend]

List of all members.

Public Types

enum  CaelumComponent {
  CAELUM_COMPONENT_SKY_DOME = 1 << 1, CAELUM_COMPONENT_MOON = 1 << 3, CAELUM_COMPONENT_SUN = 1 << 4, CAELUM_COMPONENT_IMAGE_STARFIELD = 1 << 5,
  CAELUM_COMPONENT_POINT_STARFIELD = 1 << 6, CAELUM_COMPONENT_CLOUDS = 1 << 7, CAELUM_COMPONENT_PRECIPITATION = 1 << 8, CAELUM_COMPONENT_SCREEN_SPACE_FOG = 1 << 9,
  CAELUM_COMPONENT_GROUND_FOG = 1 << (16 + 0), CAELUM_COMPONENTS_NONE = 0, CAELUM_COMPONENTS_DEFAULT, CAELUM_COMPONENTS_ALL
}
typedef std::set
< Ogre::Viewport * > 
AttachedViewportSet

Public Member Functions

 CaelumSystem (Ogre::Root *root, Ogre::SceneManager *sceneMgr, CaelumComponent componentsToCreate)
void clear ()
void autoConfigure (CaelumComponent componentsToCreate)
 ~CaelumSystem ()
void shutdown (bool cleanup)
void updateSubcomponents (Real timeSinceLastFrame)
void notifyCameraChanged (Ogre::Camera *cam)
Ogre::SceneManager * getSceneMgr () const
Ogre::SceneNode * getCaelumCameraNode (void) const
 Gets root scene node for camera-bound elements.
Ogre::SceneNode * getCaelumGroundNode (void) const
 Gets root scene node for ground-bound elements.
void setAutoNotifyCameraChanged (bool value)
bool getAutoNotifyCameraChanged () const
void setAutoAttachViewportsToComponents (bool value)
bool getAutoAttachViewportsToComponents () const
void setAutoMoveCameraNode (bool value)
bool getAutoMoveCameraNode ()
void setAutoViewportBackground (bool value)
bool getAutoViewportBackground () const
void setUpdateTimeout (Ogre::Real updateTimeout)
 LUGRE update rate.
Ogre::Real getUpdateTimeout ()
const Ogre::Degree getObserverLongitude () const
 Get the observer's longitude. East is positive, west is negative.
void setObserverLongitude (Ogre::Degree value)
 Set the observer's longitude. East is positive, west is negative.
const Ogre::Degree getObserverLatitude () const
 Get the observer's latitude. North is positive, south is negative.
void setObserverLatitude (Ogre::Degree value)
 Set the observer's latitude. North is positive, south is negative.
LongReal getJulianDay () const
void setJulianDay (LongReal value)
Real getTimeScale () const
void setTimeScale (Real value)
void attachViewport (Ogre::Viewport *rt)
void detachViewport (Ogre::Viewport *rt)
bool isViewportAttached (Ogre::Viewport *vp) const
void detachAllViewports ()
const AttachedViewportSet_getAttachedViewportSet ()
 Get a reference to the set of attached viewports.
UniversalClockgetUniversalClock () const
 Gets the universal clock.
SkyDomegetSkyDome () const
 Get the current sky dome, or null if disabled.
void setSkyDome (SkyDome *obj)
 Set the skydome, or null to disable.
BaseSkyLightgetSun () const
 Gets the current sun, or null if disabled.
void setSun (BaseSkyLight *obj)
 Set the sun, or null to disable.
MoongetMoon () const
 Gets the current moon, or null if disabled.
void setMoon (Moon *obj)
 Set the moon, or null to disable.
ImageStarfieldgetImageStarfield () const
 Gets the current image starfield, or null if disabled.
void setImageStarfield (ImageStarfield *obj)
 Set image starfield, or null to disable.
PointStarfieldgetPointStarfield () const
 Gets the current point starfield, or null if disabled.
void setPointStarfield (PointStarfield *obj)
 Set image starfield, or null to disable.
GroundFoggetGroundFog ()
 Get ground fog; if enabled.
void setGroundFog (GroundFog *obj)
 Sets ground fog system, or null to disable.
CloudSystemgetCloudSystem ()
 Get cloud system; or null if disabled.
void setCloudSystem (CloudSystem *obj)
 Set cloud system; or null to disable.
PrecipitationControllergetPrecipitationController ()
 Get precipitation controller; or null if disabled.
void setPrecipitationController (PrecipitationController *obj)
 Set precipitation controller; or null to disable.
DepthComposergetDepthComposer ()
 Get depth composer; or null if disabled.
void setDepthComposer (DepthComposer *obj)
 Set depth composer; or null to disable.
void setManageSceneFog (bool value)
bool getManageSceneFog () const
void setSceneFogDensityMultiplier (Real value)
Real getSceneFogDensityMultiplier () const
void setSceneFogColourMultiplier (const Ogre::ColourValue &value)
const Ogre::ColourValue getSceneFogColourMultiplier () const
 See setSceneFogColourMultiplier.
void setGroundFogDensityMultiplier (Real value)
Real getGroundFogDensityMultiplier () const
void setGroundFogColourMultiplier (const Ogre::ColourValue &value)
const Ogre::ColourValue getGroundFogColourMultiplier () const
 See setGroundFogColourMultiplier.
void setGlobalFogDensityMultiplier (Real value)
Real getGlobalFogDensityMultiplier () const
void setGlobalFogColourMultiplier (const Ogre::ColourValue &value)
const Ogre::ColourValue getGlobalFogColourMultiplier () const
 See setGlobalFogColourMultiplier.
void setManageAmbientLight (bool value)
bool getManageAmbientLight () const
 Check if CaelumSystem is managing ambient lighting.
void setMinimumAmbientLight (const Ogre::ColourValue &value)
const Ogre::ColourValue getMinimumAmbientLight () const
void setEnsureSingleLightSource (bool value)
bool getEnsureSingleLightSource () const
 See setEnsureSingleLightSource.
void setEnsureSingleShadowSource (bool value)
bool getEnsureSingleShadowSource () const
 See setEnsureSingleShadowSource.
Ogre::ColourValue getFogColour (Real time, const Ogre::Vector3 &sunDir)
Real getFogDensity (Real time, const Ogre::Vector3 &sunDir)
Ogre::ColourValue getSunSphereColour (Real time, const Ogre::Vector3 &sunDir)
Ogre::ColourValue getSunLightColour (Real time, const Ogre::Vector3 &sunDir)
Ogre::ColourValue getMoonBodyColour (const Ogre::Vector3 &moonDir)
 Gets the colour of moon's body.
Ogre::ColourValue getMoonLightColour (const Ogre::Vector3 &moonDir)
 Gets the colour of moon's light.
void setSkyGradientsImage (const Ogre::String &filename=DEFAULT_SKY_GRADIENTS_IMAGE)
 Set the sun gradients image.
void setSunColoursImage (const Ogre::String &filename=DEFAULT_SUN_COLOURS_IMAGE)
const Ogre::Vector3 getSunDirection (LongReal jday)
const Ogre::Vector3 getMoonDirection (LongReal jday)
const Ogre::Real getMoonPhase (LongReal jday)
void forceSubcomponentQueryFlags (uint mask)
void forceSubcomponentVisibilityFlags (uint mask)

Static Public Attributes

static const String DEFAULT_SKY_GRADIENTS_IMAGE = "EarthClearSky2.png"
static const String DEFAULT_SUN_COLOURS_IMAGE = "SunGradient.png"

Protected Member Functions

void attachViewportImpl (Ogre::Viewport *rt)
void detachViewportImpl (Ogre::Viewport *rt)

Private Member Functions

virtual bool frameStarted (const Ogre::FrameEvent &e)
virtual void preViewportUpdate (const Ogre::RenderTargetViewportEvent &e)
void destroySubcomponents (bool everything)

Static Private Member Functions

static const Ogre::Vector3 makeDirection (Ogre::Degree azimuth, Ogre::Degree altitude)

Private Attributes

Ogre::Root * mOgreRoot
 Root of the Ogre engine.
Ogre::SceneManager * mSceneMgr
 Scene manager.
SceneNodePtr mCaelumCameraNode
 Caelum scene node for camera-bound elements (most).
SceneNodePtr mCaelumGroundNode
 Caelum scene node for ground-bound elements (only clouds currently).
bool mCleanup
 Cleanup requested flag.
bool mAutoMoveCameraNode
 Automatically move the camera node.
bool mAutoNotifyCameraChanged
 Automatically call this->notifyCameraChanged.
bool mAutoAttachViewportsToComponents
 Automatically attach compositors to viewports.
bool mAutoViewportBackground
 Automatically set the viewport colour to black.
bool mManageSceneFog
 Flag to indicate if Caelum manages standard Ogre::Scene fog.
Real mGlobalFogDensityMultiplier
Ogre::ColourValue mGlobalFogColourMultiplier
Real mSceneFogDensityMultiplier
Ogre::ColourValue mSceneFogColourMultiplier
Real mGroundFogDensityMultiplier
Ogre::ColourValue mGroundFogColourMultiplier
bool mManageAmbientLight
 Flag for managing scene ambient light.
Ogre::ColourValue mMinimumAmbientLight
 Minimum ambient light; only useful if mManageAmbientLight.
bool mEnsureSingleLightSource
 If only one light source should enabled at a time.
bool mEnsureSingleShadowSource
 Ensure only one of the light sources casts shadows.
std::auto_ptr< Ogre::Image > mSkyGradientsImage
 The sky gradients image (for lookups).
std::auto_ptr< Ogre::Image > mSunColoursImage
 The sun gradients image (for lookups).
Ogre::Degree mObserverLatitude
 Observer Latitude (on the earth).
Ogre::Degree mObserverLongitude
 Observer Longitude (on the earth).
Ogre::Real mUpdateTimeout
 LUGRE update timeout.
Ogre::Real mTimeSinceLastUpdate
std::auto_ptr< UniversalClockmUniversalClock
std::auto_ptr< SkyDomemSkyDome
std::auto_ptr< BaseSkyLightmSun
std::auto_ptr< MoonmMoon
std::auto_ptr< ImageStarfieldmImageStarfield
std::auto_ptr< PointStarfieldmPointStarfield
std::auto_ptr< GroundFogmGroundFog
std::auto_ptr< CloudSystemmCloudSystem
std::auto_ptr
< PrecipitationController
mPrecipitationController
std::auto_ptr< DepthComposermDepthComposer
AttachedViewportSet mAttachedViewports


Detailed Description

This is the "root class" of caelum.

This class is created once for one SceneManager and will render the sky for that scene. CaelumSystem will be visible in all viewports on the scene and must be notified when those viewports are created and destroyed.

Components
Caelum is built from several classes for different sky elements (the sun, clouds, etc). Those classes know very little about each other and are connected through this class. This class is responsible for tracking and updating sub-components.

This class "owns" all of the subcomponents, using std::auto_ptr members. When you call functions like setXxx(new Xxx()) this class takes ownership of the object's lifetime and will try to update it as appropriate. All components are optional; disable one component should never cause a crash. When something is broken disabling components one by one is a very good way to find the source of the problem.

The constructor can create a bunch of components with default settings for you; based on the CaelumSystem::CaelumComponent flags passed.

Updating
This class is responsible for updating subcomponents. There are two update functions which must be get called to keep CaelumSystem functioning properly. One is per-frame and the other is per-camera.

CaelumSystem::updateSubcomponents must be called once per frame to advance world time and tie components together. That function will set certain properties on the subcomponents making up CaelumSystem If you want to force some properties beyond what CaelumSystem does by default you can do that AFTER the call to updateSubcompoments. For example you can override the moon's phase by calling Moon::setPhase.

CaelumSystem::notifyCameraChanged must be called for each camera before rendering with that camera. All viewport tweaks and camera movement must be done BEFORE calling this function. This method will recenter Caelum's domes on the camera. Also, some subcomponents can actually depend on field-of-view and viewport resolution (like PointStarfield).

You can register CaelumSystem as an Ogre::FrameListener and updateSubcomponents will be automatically called inside Ogre's rendering loop (inside frameStarted). If you want more control you should call updateSubcomponents in your own main loop. That way you can avoid potential issues with the ordering of multiple FrameListeners.

You can register CaelumSystem as an Ogre::RenderTargetListener and notifyCameraChanged will be automatically called inside preViewportUpdate. That behaviour can be disabled with setAutoNotifyCameraChanged(false). It is recommended that you call notifyCameraChanged manually before updating viewports.

RenderTargetListener::preViewportUpdate does not work as expected when compositors are involved (those inside Caelum or external). Compositors plug into preRenderTargetUpdate and render the scene to a texture BEFORE preViewportUpdate; this means that notifyCameraChanged will execute before the final compositor pass but after actual scene rendering.

If notifyCameraChanged is not called correctly the most likely result is "flickering" when moving the camera. If you move the camera AFTER notifyCameraChanged then the domes will not be positioned correctly and will appear to lag slightly after the camera. Since updates are always done every frame keeping the camera still will make problems disappear.

If you notice z-buffer issues while the camera is still update order is probably not the cause.

Definition at line 113 of file CaelumSystem.h.


Member Typedef Documentation

typedef std::set<Ogre::Viewport*> Caelum::CaelumSystem::AttachedViewportSet

Definition at line 202 of file CaelumSystem.h.


Member Enumeration Documentation

Flags enumeration for caelum components. This is an enumeration for the components to create by default in Caelum's constructor. You can still pass 0 and create everything by hand.

CaelumSystem's constructor used to take a number of bools but now there are too many components and this is nicer.

CAELUM_COMPONENT_ members are for individual components. CAELUM_COMPONENTS_ are standard bitmasks. CAELUM_COMPONENTS_DEFAULT picks elements that don't require modifications to external materials (right now it excludes ground fog).

Enumerator:
CAELUM_COMPONENT_SKY_DOME 
CAELUM_COMPONENT_MOON 
CAELUM_COMPONENT_SUN 
CAELUM_COMPONENT_IMAGE_STARFIELD 
CAELUM_COMPONENT_POINT_STARFIELD 
CAELUM_COMPONENT_CLOUDS 
CAELUM_COMPONENT_PRECIPITATION 
CAELUM_COMPONENT_SCREEN_SPACE_FOG 
CAELUM_COMPONENT_GROUND_FOG 
CAELUM_COMPONENTS_NONE 
CAELUM_COMPONENTS_DEFAULT 
CAELUM_COMPONENTS_ALL 

Definition at line 221 of file CaelumSystem.h.


Constructor & Destructor Documentation

Caelum::CaelumSystem::CaelumSystem ( Ogre::Root *  root,
Ogre::SceneManager *  sceneMgr,
CaelumComponent  componentsToCreate 
)

Constructor. Registers itself in the Ogre engine and initialises the system.

Parameters:
root The Ogre root.
scene The Ogre scene manager.
componentsToCreate Default components for
See also:
autoConfigure.

Definition at line 37 of file CaelumSystem.cpp.

References Caelum::CaelumPlugin::getSingletonPtr(), Caelum::CaelumPlugin::initialise(), Caelum::CaelumPlugin::install(), and Caelum::RESOURCE_GROUP_NAME.

Caelum::CaelumSystem::~CaelumSystem (  ) 

Destructor.

Definition at line 100 of file CaelumSystem.cpp.

References destroySubcomponents().


Member Function Documentation

const Ogre::Vector3 Caelum::CaelumSystem::makeDirection ( Ogre::Degree  azimuth,
Ogre::Degree  altitude 
) [static, private]

Definition at line 694 of file CaelumSystem.cpp.

Referenced by getMoonDirection(), and getSunDirection().

void Caelum::CaelumSystem::clear (  ) 

void Caelum::CaelumSystem::autoConfigure ( CaelumComponent  componentsToCreate  ) 

void Caelum::CaelumSystem::shutdown ( bool  cleanup  ) 

Shuts down the system and detaches itself from the Ogre engine.

shutdown(true) is equivalent to deleting CaelumSystem yourself. shutdown(false) delays destruction to the next time caelum is called as a frame listener. This makes it safe to shutdown Caelum from inside another frame listener.

Parameters:
cleanup If this is true then detach and destroy the CaelumSystem instantly.

Definition at line 246 of file CaelumSystem.cpp.

References destroySubcomponents(), mCleanup, and mOgreRoot.

void Caelum::CaelumSystem::updateSubcomponents ( Real  timeSinceLastFrame  ) 

Update the whole system manually. You have to call this yourself if you don't register CaelumSystem as an ogre frame listener. Otherwise it's called automatically.

Parameters:
timeSinceLastFrame,: Time passed since last frame.

Definition at line 444 of file CaelumSystem.cpp.

References Caelum::PointStarfield::_update(), Caelum::BaseSkyLight::getAmbientMultiplier(), getCloudSystem(), getDepthComposer(), getEnsureSingleLightSource(), getEnsureSingleShadowSource(), getFogColour(), getFogDensity(), getGroundFog(), getImageStarfield(), Caelum::BaseSkyLight::getLightColour(), Caelum::BaseSkyLight::getMainLight(), getManageAmbientLight(), getManageSceneFog(), getMoon(), getMoonBodyColour(), getMoonDirection(), getMoonLightColour(), getMoonPhase(), getObserverLatitude(), getObserverLongitude(), getPointStarfield(), getPrecipitationController(), getSkyDome(), getSun(), getSunDirection(), getSunLightColour(), getSunSphereColour(), mGlobalFogColourMultiplier, mGlobalFogDensityMultiplier, mGroundFogColourMultiplier, mGroundFogDensityMultiplier, mMinimumAmbientLight, mMoon, mSceneFogColourMultiplier, mSceneFogDensityMultiplier, mSceneMgr, mSun, mUniversalClock, Caelum::GroundFog::setColour(), Caelum::GroundFog::setDensity(), Caelum::BaseSkyLight::setForceDisable(), Caelum::DepthComposer::setGroundFogColour(), Caelum::DepthComposer::setGroundFogDensity(), Caelum::DepthComposer::setHazeColour(), Caelum::SkyDome::setHazeColour(), Caelum::ImageStarfield::setInclination(), Caelum::PointStarfield::setObserverLatitude(), Caelum::PointStarfield::setObserverLongitude(), Caelum::DepthComposer::setSunDirection(), Caelum::SkyDome::setSunDirection(), Caelum::DepthComposer::update(), Caelum::PrecipitationController::update(), Caelum::CloudSystem::update(), and Caelum::ImageStarfield::update().

Referenced by frameStarted().

void Caelum::CaelumSystem::notifyCameraChanged ( Ogre::Camera *  cam  ) 

Notify subcomponents of camera changes. This function must be called after camera changes but before rendering with that camera. If multiple cameras are used it must be called for each camera before the camera is rendered with.

This function will move caelum's camera node to the camera position, but only if getAutoMoveCameraNode. It will also call CameraBoundElement::notifyCameraChanged

Definition at line 393 of file CaelumSystem.cpp.

References getAutoMoveCameraNode(), getGroundFog(), getImageStarfield(), getMoon(), getPointStarfield(), getSkyDome(), getSun(), mCaelumCameraNode, Caelum::GroundFog::notifyCameraChanged(), Caelum::PointStarfield::notifyCameraChanged(), Caelum::ImageStarfield::notifyCameraChanged(), Caelum::Moon::notifyCameraChanged(), Caelum::CameraBoundElement::notifyCameraChanged(), and Caelum::SkyDome::notifyCameraChanged().

Referenced by preViewportUpdate().

Ogre::SceneManager* Caelum::CaelumSystem::getSceneMgr (  )  const [inline]

Get the scene manager for this caelum system. This is set in the constructor. CaelumSystem can't exist without a valid scene manager.

Definition at line 317 of file CaelumSystem.h.

Ogre::SceneNode* Caelum::CaelumSystem::getCaelumCameraNode ( void   )  const [inline]

Gets root scene node for camera-bound elements.

Definition at line 320 of file CaelumSystem.h.

Referenced by autoConfigure().

Ogre::SceneNode* Caelum::CaelumSystem::getCaelumGroundNode ( void   )  const [inline]

Gets root scene node for ground-bound elements.

Definition at line 323 of file CaelumSystem.h.

Referenced by autoConfigure().

void Caelum::CaelumSystem::setAutoNotifyCameraChanged ( bool  value  )  [inline]

If true; listen to preViewportUpdate and automatically notifyCameraChanged();

This is on by default; but does not work with compositors.

You must attach CaelumSystem as a RenderTargetListener manually for this to work; as in version 0.3.

Definition at line 332 of file CaelumSystem.h.

bool Caelum::CaelumSystem::getAutoNotifyCameraChanged (  )  const [inline]

See also:
setAutoNotifyCameraChanged

Definition at line 334 of file CaelumSystem.h.

Referenced by preViewportUpdate().

void Caelum::CaelumSystem::setAutoAttachViewportsToComponents ( bool  value  )  [inline]

If true; automatically attach viewports to subcomponents.

Some subcomponents use compositors and those compositors need to be attached to individual viewports. By default CaelumSystem will try take to take care of that automatically.

This property allows you to disable that behaviour. If set to false you must call functions like PrecipitationController::createViewportInstance manually.

See also:
attachViewport detachViewport

Definition at line 348 of file CaelumSystem.h.

bool Caelum::CaelumSystem::getAutoAttachViewportsToComponents (  )  const [inline]

void Caelum::CaelumSystem::setAutoMoveCameraNode ( bool  value  )  [inline]

If true (default); automatically move the camera node in notifyCameraChanged. If disable you get full control of the camera node; and in theory you can attach it to the scene graph however you please.

Definition at line 356 of file CaelumSystem.h.

bool Caelum::CaelumSystem::getAutoMoveCameraNode (  )  [inline]

See also:
setAutoMoveCameraNode

Definition at line 358 of file CaelumSystem.h.

Referenced by notifyCameraChanged().

void Caelum::CaelumSystem::setAutoViewportBackground ( bool  value  )  [inline]

If true; automatically set the viewport color to black. Caelum's domes relies on the viewport background being black. There's generally no reason to disable this and it's on by default.

Definition at line 364 of file CaelumSystem.h.

bool Caelum::CaelumSystem::getAutoViewportBackground (  )  const [inline]

See also:
setAutoViewportBackground

Definition at line 366 of file CaelumSystem.h.

Referenced by preViewportUpdate().

void Caelum::CaelumSystem::setUpdateTimeout ( Ogre::Real  updateTimeout  )  [inline]

LUGRE update rate.

Definition at line 369 of file CaelumSystem.h.

Ogre::Real Caelum::CaelumSystem::getUpdateTimeout (  )  [inline]

Definition at line 370 of file CaelumSystem.h.

const Ogre::Degree Caelum::CaelumSystem::getObserverLongitude (  )  const [inline]

Get the observer's longitude. East is positive, west is negative.

Definition at line 373 of file CaelumSystem.h.

Referenced by getMoonDirection(), getSunDirection(), and updateSubcomponents().

void Caelum::CaelumSystem::setObserverLongitude ( Ogre::Degree  value  )  [inline]

Set the observer's longitude. East is positive, west is negative.

Definition at line 376 of file CaelumSystem.h.

const Ogre::Degree Caelum::CaelumSystem::getObserverLatitude (  )  const [inline]

Get the observer's latitude. North is positive, south is negative.

Definition at line 379 of file CaelumSystem.h.

Referenced by getMoonDirection(), getSunDirection(), and updateSubcomponents().

void Caelum::CaelumSystem::setObserverLatitude ( Ogre::Degree  value  )  [inline]

Set the observer's latitude. North is positive, south is negative.

Definition at line 382 of file CaelumSystem.h.

LongReal Caelum::CaelumSystem::getJulianDay (  )  const [inline]

Definition at line 384 of file CaelumSystem.h.

void Caelum::CaelumSystem::setJulianDay ( LongReal  value  )  [inline]

Definition at line 385 of file CaelumSystem.h.

Real Caelum::CaelumSystem::getTimeScale (  )  const [inline]

Definition at line 386 of file CaelumSystem.h.

void Caelum::CaelumSystem::setTimeScale ( Real  value  )  [inline]

Definition at line 387 of file CaelumSystem.h.

void Caelum::CaelumSystem::attachViewport ( Ogre::Viewport *  rt  ) 

Attach CaelumSystem to a viewport. You should call this for every new viewport looking at the scene where CaelumSystem is created.

If the viewport is already attached then nothing happens.

If getAutoAttachViewportsToComponents() this will add Caelum's compositors.

Definition at line 293 of file CaelumSystem.cpp.

References attachViewportImpl(), and mAttachedViewports.

void Caelum::CaelumSystem::detachViewport ( Ogre::Viewport *  rt  ) 

Reverse of

See also:
attachViewport. You need to call this when you destroy a viewport.
If the viewport is not already attached nothing happens.

Definition at line 301 of file CaelumSystem.cpp.

References assert, detachViewportImpl(), and mAttachedViewports.

bool Caelum::CaelumSystem::isViewportAttached ( Ogre::Viewport *  vp  )  const

Check if one particular viewport is attached.

Definition at line 320 of file CaelumSystem.cpp.

References mAttachedViewports.

void Caelum::CaelumSystem::detachAllViewports (  ) 

Detach from all viewports.

Definition at line 311 of file CaelumSystem.cpp.

References detachViewportImpl(), and mAttachedViewports.

const AttachedViewportSet& Caelum::CaelumSystem::_getAttachedViewportSet (  )  [inline]

Get a reference to the set of attached viewports.

Definition at line 416 of file CaelumSystem.h.

void Caelum::CaelumSystem::attachViewportImpl ( Ogre::Viewport *  rt  )  [protected]

void Caelum::CaelumSystem::detachViewportImpl ( Ogre::Viewport *  rt  )  [protected]

UniversalClock* Caelum::CaelumSystem::getUniversalClock (  )  const [inline]

Gets the universal clock.

Definition at line 425 of file CaelumSystem.h.

SkyDome* Caelum::CaelumSystem::getSkyDome (  )  const [inline]

Get the current sky dome, or null if disabled.

Definition at line 428 of file CaelumSystem.h.

Referenced by forceSubcomponentQueryFlags(), forceSubcomponentVisibilityFlags(), notifyCameraChanged(), and updateSubcomponents().

void Caelum::CaelumSystem::setSkyDome ( SkyDome obj  ) 

Set the skydome, or null to disable.

Definition at line 324 of file CaelumSystem.cpp.

References mSkyDome.

Referenced by autoConfigure(), and destroySubcomponents().

BaseSkyLight* Caelum::CaelumSystem::getSun (  )  const [inline]

Gets the current sun, or null if disabled.

Definition at line 433 of file CaelumSystem.h.

Referenced by autoConfigure(), forceSubcomponentQueryFlags(), forceSubcomponentVisibilityFlags(), notifyCameraChanged(), and updateSubcomponents().

void Caelum::CaelumSystem::setSun ( BaseSkyLight obj  ) 

Set the sun, or null to disable.

Definition at line 328 of file CaelumSystem.cpp.

References mSun.

Referenced by autoConfigure(), and destroySubcomponents().

Moon* Caelum::CaelumSystem::getMoon (  )  const [inline]

Gets the current moon, or null if disabled.

Definition at line 438 of file CaelumSystem.h.

Referenced by autoConfigure(), forceSubcomponentQueryFlags(), forceSubcomponentVisibilityFlags(), notifyCameraChanged(), and updateSubcomponents().

void Caelum::CaelumSystem::setMoon ( Moon obj  ) 

Set the moon, or null to disable.

Definition at line 332 of file CaelumSystem.cpp.

References mMoon.

Referenced by autoConfigure(), and destroySubcomponents().

ImageStarfield* Caelum::CaelumSystem::getImageStarfield (  )  const [inline]

Gets the current image starfield, or null if disabled.

Definition at line 443 of file CaelumSystem.h.

Referenced by forceSubcomponentQueryFlags(), forceSubcomponentVisibilityFlags(), notifyCameraChanged(), and updateSubcomponents().

void Caelum::CaelumSystem::setImageStarfield ( ImageStarfield obj  ) 

Set image starfield, or null to disable.

Definition at line 336 of file CaelumSystem.cpp.

References mImageStarfield.

Referenced by autoConfigure(), and destroySubcomponents().

PointStarfield* Caelum::CaelumSystem::getPointStarfield (  )  const [inline]

Gets the current point starfield, or null if disabled.

Definition at line 448 of file CaelumSystem.h.

Referenced by forceSubcomponentQueryFlags(), forceSubcomponentVisibilityFlags(), notifyCameraChanged(), and updateSubcomponents().

void Caelum::CaelumSystem::setPointStarfield ( PointStarfield obj  ) 

Set image starfield, or null to disable.

Definition at line 340 of file CaelumSystem.cpp.

References mPointStarfield.

Referenced by autoConfigure(), and destroySubcomponents().

GroundFog* Caelum::CaelumSystem::getGroundFog (  )  [inline]

Get ground fog; if enabled.

Definition at line 453 of file CaelumSystem.h.

Referenced by forceSubcomponentQueryFlags(), forceSubcomponentVisibilityFlags(), notifyCameraChanged(), and updateSubcomponents().

void Caelum::CaelumSystem::setGroundFog ( GroundFog obj  ) 

Sets ground fog system, or null to disable.

Definition at line 344 of file CaelumSystem.cpp.

References mGroundFog.

Referenced by autoConfigure(), and destroySubcomponents().

CloudSystem* Caelum::CaelumSystem::getCloudSystem (  )  [inline]

Get cloud system; or null if disabled.

Definition at line 458 of file CaelumSystem.h.

Referenced by autoConfigure(), forceSubcomponentQueryFlags(), forceSubcomponentVisibilityFlags(), and updateSubcomponents().

void Caelum::CaelumSystem::setCloudSystem ( CloudSystem obj  ) 

Set cloud system; or null to disable.

Definition at line 348 of file CaelumSystem.cpp.

References mCloudSystem.

Referenced by autoConfigure(), and destroySubcomponents().

PrecipitationController* Caelum::CaelumSystem::getPrecipitationController (  )  [inline]

Get precipitation controller; or null if disabled.

Definition at line 463 of file CaelumSystem.h.

Referenced by attachViewportImpl(), detachViewportImpl(), setPrecipitationController(), and updateSubcomponents().

void Caelum::CaelumSystem::setPrecipitationController ( PrecipitationController obj  ) 

DepthComposer* Caelum::CaelumSystem::getDepthComposer (  )  [inline]

Get depth composer; or null if disabled.

Definition at line 468 of file CaelumSystem.h.

Referenced by attachViewportImpl(), detachViewportImpl(), setDepthComposer(), and updateSubcomponents().

void Caelum::CaelumSystem::setDepthComposer ( DepthComposer obj  ) 

void Caelum::CaelumSystem::setManageSceneFog ( bool  value  ) 

Enables/disables Caelum managing standard Ogre::Scene fog. This makes CaelumSystem control standard Ogre::Scene fogging. It will use EXP2 fog with density from SkyColourModel.

Fog density multipliers are used; final scene fog density is: SceneMultiplier * GlobalMultiplier * SkyColourModel.GetFogDensity

When this is set to false it also disables all scene fog (but you control it afterwards).

Parameters:
value New value

Definition at line 581 of file CaelumSystem.cpp.

References mManageSceneFog, and mSceneMgr.

Referenced by clear().

bool Caelum::CaelumSystem::getManageSceneFog (  )  const

Tells if Caelum is managing the fog or not.

Returns:
The value set in setManageSceneFog.

Definition at line 589 of file CaelumSystem.cpp.

References mManageSceneFog.

Referenced by updateSubcomponents().

void Caelum::CaelumSystem::setSceneFogDensityMultiplier ( Real  value  ) 

Multiplier for scene fog density (default 1). This is an additional multiplier for Ogre::Scene fog density. This has no effect if getManageSceneFog is false.

Final scene fog density is: SceneMultiplier * GlobalMultiplier * SkyColourModel.GetFogDensity

Definition at line 593 of file CaelumSystem.cpp.

References mSceneFogDensityMultiplier.

Real Caelum::CaelumSystem::getSceneFogDensityMultiplier (  )  const

Get the value set by setSceneFogDensityMultiplier.

Definition at line 597 of file CaelumSystem.cpp.

References mSceneFogDensityMultiplier.

void Caelum::CaelumSystem::setSceneFogColourMultiplier ( const Ogre::ColourValue &  value  )  [inline]

Set an additional multiplier for fog colour as it comes from SkyColourModel. This is 0.7 by default; to be compatible with previous versions.

Definition at line 507 of file CaelumSystem.h.

const Ogre::ColourValue Caelum::CaelumSystem::getSceneFogColourMultiplier (  )  const [inline]

See setSceneFogColourMultiplier.

Definition at line 510 of file CaelumSystem.h.

void Caelum::CaelumSystem::setGroundFogDensityMultiplier ( Real  value  ) 

Multiplier for ground fog density (default 1). This is an additional multiplier for Caelum::GroundFog DepthComposer ground fog density.

Final ground fog density is: GroundFogMultipler * GlobalMultiplier * SkyColourModel.GetFogDensity

Definition at line 601 of file CaelumSystem.cpp.

References mGroundFogDensityMultiplier.

Real Caelum::CaelumSystem::getGroundFogDensityMultiplier (  )  const

Get the value set by setGroundFogDensityMultiplier.

Definition at line 605 of file CaelumSystem.cpp.

References mGroundFogDensityMultiplier.

void Caelum::CaelumSystem::setGroundFogColourMultiplier ( const Ogre::ColourValue &  value  )  [inline]

Set an additional multiplier for ground fog colour as it comes from SkyColourModel. This is OgreColour::White by default; which has no effect.

Definition at line 527 of file CaelumSystem.h.

const Ogre::ColourValue Caelum::CaelumSystem::getGroundFogColourMultiplier (  )  const [inline]

See setGroundFogColourMultiplier.

Definition at line 530 of file CaelumSystem.h.

void Caelum::CaelumSystem::setGlobalFogDensityMultiplier ( Real  value  ) 

Multiplier for global fog density (default 1). This is an additional multiplier for fog density as received from SkyColourModel. There are other multipliers you can tweak for individual kinds of fog; but this is what you should change from whatever "game logic" you might have.

Definition at line 609 of file CaelumSystem.cpp.

References mGlobalFogDensityMultiplier.

Real Caelum::CaelumSystem::getGlobalFogDensityMultiplier (  )  const

Get the value set by setSceneFogDensityMultiplier.

Definition at line 613 of file CaelumSystem.cpp.

References mGlobalFogDensityMultiplier.

void Caelum::CaelumSystem::setGlobalFogColourMultiplier ( const Ogre::ColourValue &  value  )  [inline]

Set an additional multiplier for fog colour. This will also affect stuff like clouds or precipitation. Careful! This is OgreColour::White by default; which has no effect.

Definition at line 548 of file CaelumSystem.h.

const Ogre::ColourValue Caelum::CaelumSystem::getGlobalFogColourMultiplier (  )  const [inline]

See setGlobalFogColourMultiplier.

Definition at line 551 of file CaelumSystem.h.

void Caelum::CaelumSystem::setManageAmbientLight ( bool  value  )  [inline]

Set this to true to have CaelumSystem manage the scene's ambient light. The colour and AmbientMultiplier of the sun and moon are used. This is false by default.

Definition at line 557 of file CaelumSystem.h.

Referenced by clear().

bool Caelum::CaelumSystem::getManageAmbientLight (  )  const [inline]

Check if CaelumSystem is managing ambient lighting.

Definition at line 560 of file CaelumSystem.h.

Referenced by updateSubcomponents().

void Caelum::CaelumSystem::setMinimumAmbientLight ( const Ogre::ColourValue &  value  )  [inline]

Set the minimum value for scene ambient lighting, This is only used if getManageAmbientLight() is true. By default this value is Ogre::ColourValue::Black, so it has no effect.

Definition at line 566 of file CaelumSystem.h.

Referenced by clear().

const Ogre::ColourValue Caelum::CaelumSystem::getMinimumAmbientLight (  )  const [inline]

See also:
setMinimumAmbientLight

Definition at line 569 of file CaelumSystem.h.

void Caelum::CaelumSystem::setEnsureSingleLightSource ( bool  value  )  [inline]

Ensure only one of caelum's light sources is active at a time (the brightest). This uses SkyLight::setForceDisable to disable low-intensity lightsources. Their contribution to ambient lighting is not affected. This implies a single shadow caster. This is disabled by default; and you can tweak light disabling by yourself.

Definition at line 577 of file CaelumSystem.h.

bool Caelum::CaelumSystem::getEnsureSingleLightSource (  )  const [inline]

See setEnsureSingleLightSource.

Definition at line 580 of file CaelumSystem.h.

Referenced by updateSubcomponents().

void Caelum::CaelumSystem::setEnsureSingleShadowSource ( bool  value  )  [inline]

Ensure only one of caelum's light sources casts shadows (the brightest). Disabled by default.

Definition at line 585 of file CaelumSystem.h.

bool Caelum::CaelumSystem::getEnsureSingleShadowSource (  )  const [inline]

See setEnsureSingleShadowSource.

Definition at line 588 of file CaelumSystem.h.

Referenced by updateSubcomponents().

Ogre::ColourValue Caelum::CaelumSystem::getFogColour ( Real  time,
const Ogre::Vector3 &  sunDir 
)

Gets the fog colour for a certain daytime.

Parameters:
time The current time.
sunDir The sun direction.
Returns:
The fog colour.

Definition at line 627 of file CaelumSystem.cpp.

References Caelum::getInterpolatedColour(), and mSkyGradientsImage.

Referenced by updateSubcomponents().

Real Caelum::CaelumSystem::getFogDensity ( Real  time,
const Ogre::Vector3 &  sunDir 
)

Gets the fog density for a certain daytime.

Parameters:
time The current time.
sunDir The sun direction.
Returns:
The fog density.

Definition at line 637 of file CaelumSystem.cpp.

References Caelum::getInterpolatedColour(), and mSkyGradientsImage.

Referenced by updateSubcomponents().

Ogre::ColourValue Caelum::CaelumSystem::getSunSphereColour ( Real  time,
const Ogre::Vector3 &  sunDir 
)

Get the colour of the sun sphere. This colour is used to draw the sun sphere in the sky.

Returns:
The colour of the sun.

Definition at line 648 of file CaelumSystem.cpp.

References Caelum::getInterpolatedColour(), and mSunColoursImage.

Referenced by updateSubcomponents().

Ogre::ColourValue Caelum::CaelumSystem::getSunLightColour ( Real  time,
const Ogre::Vector3 &  sunDir 
)

Gets the colour of sun light. This color is used to illuminate the scene.

Returns:
The colour of the sun's light

Definition at line 659 of file CaelumSystem.cpp.

References assert, Caelum::getInterpolatedColour(), and mSkyGradientsImage.

Referenced by updateSubcomponents().

Ogre::ColourValue Caelum::CaelumSystem::getMoonBodyColour ( const Ogre::Vector3 &  moonDir  ) 

Gets the colour of moon's body.

Definition at line 676 of file CaelumSystem.cpp.

Referenced by updateSubcomponents().

Ogre::ColourValue Caelum::CaelumSystem::getMoonLightColour ( const Ogre::Vector3 &  moonDir  ) 

Gets the colour of moon's light.

Definition at line 680 of file CaelumSystem.cpp.

References assert, f(), Caelum::getInterpolatedColour(), and mSkyGradientsImage.

Referenced by updateSubcomponents().

void Caelum::CaelumSystem::setSkyGradientsImage ( const Ogre::String &  filename = DEFAULT_SKY_GRADIENTS_IMAGE  ) 

Set the sun gradients image.

Definition at line 617 of file CaelumSystem.cpp.

References mSkyGradientsImage, and Caelum::RESOURCE_GROUP_NAME.

Referenced by clear().

void Caelum::CaelumSystem::setSunColoursImage ( const Ogre::String &  filename = DEFAULT_SUN_COLOURS_IMAGE  ) 

Set the sun colours image. Sun colour is taken from this image.

Definition at line 622 of file CaelumSystem.cpp.

References mSunColoursImage, and Caelum::RESOURCE_GROUP_NAME.

Referenced by clear().

const Ogre::Vector3 Caelum::CaelumSystem::getSunDirection ( LongReal  jday  ) 

Get the sun's direction at a certain time.

Parameters:
jday astronomical julian day.
See also:
UniversalClock for julian day calculations.

Definition at line 704 of file CaelumSystem.cpp.

References Caelum::Astronomy::enterHighPrecissionFloatingPointMode(), Caelum::Astronomy::getHorizontalSunPosition(), getObserverLatitude(), getObserverLongitude(), makeDirection(), and Caelum::Astronomy::restoreFloatingPointMode().

Referenced by updateSubcomponents().

const Ogre::Vector3 Caelum::CaelumSystem::getMoonDirection ( LongReal  jday  ) 

const Ogre::Real Caelum::CaelumSystem::getMoonPhase ( LongReal  jday  ) 

Fake function to get the phase of the moon

Parameters:
jday Julian day
Returns:
the phase of the moon; ranging from 0(full moon) to 2(new moon). The calculations performed by this function are completely fake. It's a triangle wave with a period of 28.5 days.

Definition at line 733 of file CaelumSystem.cpp.

Referenced by updateSubcomponents().

bool Caelum::CaelumSystem::frameStarted ( const Ogre::FrameEvent &  e  )  [private, virtual]

Handle FrameListener::frameStarted to call updateSubcomponents every frame. If you don't register CaelumSystem as a an ogre frame listener you have to call updateSubcomponents yourself.

Definition at line 426 of file CaelumSystem.cpp.

References mCleanup, mOgreRoot, mTimeSinceLastUpdate, mUpdateTimeout, and updateSubcomponents().

void Caelum::CaelumSystem::preViewportUpdate ( const Ogre::RenderTargetViewportEvent &  e  )  [private, virtual]

Event trigger called just before rendering a viewport in a render target Caelum is attached to. Useful to make objects follow every camera that renders a viewport in a certain render target.

Definition at line 381 of file CaelumSystem.cpp.

References getAutoNotifyCameraChanged(), getAutoViewportBackground(), and notifyCameraChanged().

void Caelum::CaelumSystem::destroySubcomponents ( bool  everything  )  [private]

Free all subcomponents, but not CaelumSystem itself. Can be called multiple times.

Parameters:
everything To destroy things that can't be rebuilt.

Definition at line 76 of file CaelumSystem.cpp.

References mCaelumCameraNode, mCaelumGroundNode, mSkyGradientsImage, mSunColoursImage, mUniversalClock, Caelum::OwnedPtr< PointedT, TraitsT >::reset(), setCloudSystem(), setDepthComposer(), setGroundFog(), setImageStarfield(), setMoon(), setPointStarfield(), setPrecipitationController(), setSkyDome(), and setSun().

Referenced by clear(), shutdown(), and ~CaelumSystem().

void Caelum::CaelumSystem::forceSubcomponentQueryFlags ( uint  mask  ) 

Call setQueryFlags for all subcomponents now.

This is not persistent; you can adjust the query masks of individual objects afterwards. This also means you should call this only after you created all other objects.

Has no effect on compositor-based stuff (precipitation will still show up).

Definition at line 743 of file CaelumSystem.cpp.

References Caelum::CloudSystem::forceLayerQueryFlags(), getCloudSystem(), getGroundFog(), getImageStarfield(), getMoon(), getPointStarfield(), getSkyDome(), getSun(), Caelum::GroundFog::setQueryFlags(), Caelum::PointStarfield::setQueryFlags(), Caelum::ImageStarfield::setQueryFlags(), Caelum::Moon::setQueryFlags(), Caelum::BaseSkyLight::setQueryFlags(), and Caelum::SkyDome::setQueryFlags().

void Caelum::CaelumSystem::forceSubcomponentVisibilityFlags ( uint  mask  ) 


Member Data Documentation

Ogre::Root* Caelum::CaelumSystem::mOgreRoot [private]

Root of the Ogre engine.

Definition at line 120 of file CaelumSystem.h.

Referenced by frameStarted(), and shutdown().

Ogre::SceneManager* Caelum::CaelumSystem::mSceneMgr [private]

Scene manager.

Definition at line 123 of file CaelumSystem.h.

Referenced by autoConfigure(), setManageSceneFog(), and updateSubcomponents().

Caelum scene node for camera-bound elements (most).

Definition at line 126 of file CaelumSystem.h.

Referenced by destroySubcomponents(), and notifyCameraChanged().

Caelum scene node for ground-bound elements (only clouds currently).

Definition at line 129 of file CaelumSystem.h.

Referenced by destroySubcomponents().

Cleanup requested flag.

Definition at line 132 of file CaelumSystem.h.

Referenced by frameStarted(), and shutdown().

Automatically move the camera node.

Definition at line 135 of file CaelumSystem.h.

Referenced by clear().

Automatically call this->notifyCameraChanged.

Definition at line 138 of file CaelumSystem.h.

Referenced by clear().

Automatically attach compositors to viewports.

Definition at line 141 of file CaelumSystem.h.

Referenced by clear().

Automatically set the viewport colour to black.

Definition at line 144 of file CaelumSystem.h.

Referenced by clear().

Flag to indicate if Caelum manages standard Ogre::Scene fog.

Definition at line 147 of file CaelumSystem.h.

Referenced by getManageSceneFog(), and setManageSceneFog().

Definition at line 150 of file CaelumSystem.h.

Referenced by clear(), and updateSubcomponents().

Definition at line 153 of file CaelumSystem.h.

Referenced by clear(), and updateSubcomponents().

Definition at line 156 of file CaelumSystem.h.

Referenced by clear(), and updateSubcomponents().

Flag for managing scene ambient light.

Definition at line 159 of file CaelumSystem.h.

Ogre::ColourValue Caelum::CaelumSystem::mMinimumAmbientLight [private]

Minimum ambient light; only useful if mManageAmbientLight.

Definition at line 162 of file CaelumSystem.h.

Referenced by updateSubcomponents().

If only one light source should enabled at a time.

Definition at line 165 of file CaelumSystem.h.

Referenced by clear().

Ensure only one of the light sources casts shadows.

Definition at line 168 of file CaelumSystem.h.

Referenced by clear().

std::auto_ptr<Ogre::Image> Caelum::CaelumSystem::mSkyGradientsImage [private]

The sky gradients image (for lookups).

Definition at line 171 of file CaelumSystem.h.

Referenced by destroySubcomponents(), getFogColour(), getFogDensity(), getMoonLightColour(), getSunLightColour(), and setSkyGradientsImage().

std::auto_ptr<Ogre::Image> Caelum::CaelumSystem::mSunColoursImage [private]

The sun gradients image (for lookups).

Definition at line 174 of file CaelumSystem.h.

Referenced by destroySubcomponents(), getSunSphereColour(), and setSunColoursImage().

Observer Latitude (on the earth).

Definition at line 177 of file CaelumSystem.h.

Referenced by clear().

Observer Longitude (on the earth).

Definition at line 179 of file CaelumSystem.h.

Referenced by clear().

LUGRE update timeout.

Definition at line 183 of file CaelumSystem.h.

Referenced by frameStarted().

Definition at line 184 of file CaelumSystem.h.

Referenced by frameStarted().

Definition at line 190 of file CaelumSystem.h.

Referenced by clear(), destroySubcomponents(), and updateSubcomponents().

std::auto_ptr<SkyDome> Caelum::CaelumSystem::mSkyDome [private]

Definition at line 191 of file CaelumSystem.h.

Referenced by setSkyDome().

std::auto_ptr<BaseSkyLight> Caelum::CaelumSystem::mSun [private]

Definition at line 192 of file CaelumSystem.h.

Referenced by setSun(), and updateSubcomponents().

std::auto_ptr<Moon> Caelum::CaelumSystem::mMoon [private]

Definition at line 193 of file CaelumSystem.h.

Referenced by setMoon(), and updateSubcomponents().

Definition at line 194 of file CaelumSystem.h.

Referenced by setImageStarfield().

Definition at line 195 of file CaelumSystem.h.

Referenced by setPointStarfield().

std::auto_ptr<GroundFog> Caelum::CaelumSystem::mGroundFog [private]

Definition at line 196 of file CaelumSystem.h.

Referenced by setGroundFog().

Definition at line 197 of file CaelumSystem.h.

Referenced by setCloudSystem().

Definition at line 198 of file CaelumSystem.h.

Referenced by setPrecipitationController().

Definition at line 199 of file CaelumSystem.h.

Referenced by setDepthComposer().

const String Caelum::CaelumSystem::DEFAULT_SKY_GRADIENTS_IMAGE = "EarthClearSky2.png" [static]

Definition at line 250 of file CaelumSystem.h.

Referenced by clear().

const String Caelum::CaelumSystem::DEFAULT_SUN_COLOURS_IMAGE = "SunGradient.png" [static]

Definition at line 251 of file CaelumSystem.h.

Referenced by clear().


The documentation for this class was generated from the following files:

Generated on Sat May 19 05:40:50 2012 for cpp by  doxygen 1.5.6