caelum::CaelumSystem Class Reference

#include <CaelumSystem.h>

List of all members.

Public Types

enum  CaelumComponent {
  CAELUM_COMPONENT_SKY_COLOUR_MODEL = 1 << 0, CAELUM_COMPONENT_SKY_DOME = 1 << 1, CAELUM_COMPONENT_SOLAR_SYSTEM_MODEL = 1 << 2, 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_GROUND_FOG = 1 << (16 + 0), CAELUM_COMPONENTS_NONE = 0, CAELUM_COMPONENTS_DEFAULT, CAELUM_COMPONENTS_ALL
}

Public Member Functions

 CaelumSystem (Ogre::Root *root, Ogre::SceneManager *sceneMgr, CaelumComponent componentsToCreate=CAELUM_COMPONENTS_DEFAULT, bool manageResGroup=true, const Ogre::String &resGroupName=RESOURCE_GROUP_NAME)
 ~CaelumSystem ()
void shutdown (bool cleanup)
UniversalClockgetUniversalClock () const
Ogre::SceneNode * getRootNode (void) const
void updateSubcomponents (double timeSinceLastFrame)
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.
BaseSkyLightgetMoon () 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.
LayeredCloudsgetClouds () const
 Get LayeredClouds, or null if disabled.
void setClouds (LayeredClouds *obj)
 Set LayeredClouds, or null to disable.
void setSkyColourModel (SkyColourModel *model)
SkyColourModelgetSkyColourModel () const
void setSolarSystemModel (SolarSystemModel *model)
 Set the solar system model to use, or null to disable.
SolarSystemModelgetSolarSystemModel () const
 Set the current solar system model.
void setGroundFog (GroundFog *model)
GroundFoggetGroundFog () const
void setManageSceneFog (bool value)
bool getManageSceneFog () const
void setSceneFogDensityMultiplier (double value)
double getSceneFogDensityMultiplier () const
void setSceneFogColourMultiplier (const Ogre::ColourValue &value)
Ogre::ColourValue getSceneFogColourMultiplier () const
 See setSceneFogColourMultiplier.
void setGroundFogDensityMultiplier (double value)
double getGroundFogDensityMultiplier () const
void setGroundFogColourMultiplier (const Ogre::ColourValue &value)
Ogre::ColourValue getGroundFogColourMultiplier () const
 See setGroundFogColourMultiplier.
void setGlobalFogDensityMultiplier (double value)
double getGlobalFogDensityMultiplier () const
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.

Protected Member Functions

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


Detailed Description

Root of the Caelum system.

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 the main CaelumSystem class. This class is responsible for tracking and updating sub-components. It "owns" all of the components, using std::auto_ptr members.

The constructor will create a standard set of components but you can disable some or change others. When you do something like setXxx(new Xxx()) CaelumSystem takes control of the object's lifetime.

This class is also reponsible for doing all per-frame and per-RenderTarget updates. It's better to keep that logic here instead of coupling components together.

It's difficult to build a CaelumSystem class which will work for any combination of sky elements. It might be a good idea to have different classes for vastly different sky systems. Alternatively the update logic from Caelum could be refactor to only transfer a number of "common sky parameter" around; but that is a lot harder and ultimately less flexible.

Author:
Jes˙s Alonso Abad

Definition at line 62 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).

Definition at line 144 of file CaelumSystem.h.


Constructor & Destructor Documentation

caelum::CaelumSystem::CaelumSystem ( Ogre::Root *  root,
Ogre::SceneManager *  sceneMgr,
CaelumComponent  componentsToCreate = CAELUM_COMPONENTS_DEFAULT,
bool  manageResGroup = true,
const Ogre::String &  resGroupName = RESOURCE_GROUP_NAME 
)

Constructor. Registers itself in the Ogre engine and initialises the system. It can also initialize a bunch of default components.

Parameters:
root The Ogre root.
scene The Ogre scene manager.
compoment The components to create.
manageResGroup Tells the system if the resource group has been created externally (true) or if it's to be managed by the system.
resGroupName The resource group name, if it's desired to use an existing one or just a different name.

Definition at line 32 of file CaelumSystem.cpp.

caelum::CaelumSystem::~CaelumSystem (  ) 

Destructor.

Definition at line 118 of file CaelumSystem.cpp.


Member Function Documentation

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 154 of file CaelumSystem.cpp.

UniversalClock * caelum::CaelumSystem::getUniversalClock (  )  const

Gets the universal clock.

Returns:
A reference to the universal clock attached to this system.

Definition at line 205 of file CaelumSystem.cpp.

Ogre::SceneNode* caelum::CaelumSystem::getRootNode ( void   )  const [inline]

Gets caelum root scene node.

Definition at line 214 of file CaelumSystem.h.

void caelum::CaelumSystem::updateSubcomponents ( double  timeSinceLastFrame  ) 

void caelum::CaelumSystem::setSkyColourModel ( SkyColourModel model  )  [inline]

Sets the sky colour model to be used.

Parameters:
model The sky colour model, or null to disable

Definition at line 255 of file CaelumSystem.h.

SkyColourModel* caelum::CaelumSystem::getSkyColourModel (  )  const [inline]

Get the current sky colour model.

Definition at line 261 of file CaelumSystem.h.

Referenced by updateSubcomponents().

void caelum::CaelumSystem::setGroundFog ( GroundFog model  )  [inline]

Sets ground fog system.

Parameters:
model The sky colour model, or null to disable

Definition at line 278 of file CaelumSystem.h.

GroundFog* caelum::CaelumSystem::getGroundFog (  )  const [inline]

Get ground fog; if any.

Definition at line 284 of file CaelumSystem.h.

Referenced by preViewportUpdate(), and updateSubcomponents().

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 349 of file CaelumSystem.cpp.

bool caelum::CaelumSystem::getManageSceneFog (  )  const

Tells if Caelum is managing the fog or not.

Returns:
The value set in setManageSceneFog.

Definition at line 357 of file CaelumSystem.cpp.

Referenced by updateSubcomponents().

void caelum::CaelumSystem::setSceneFogDensityMultiplier ( double  value  ) 

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

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

Definition at line 361 of file CaelumSystem.cpp.

double caelum::CaelumSystem::getSceneFogDensityMultiplier (  )  const

Get the value set by setSceneFogDensityMultiplier.

Definition at line 365 of file CaelumSystem.cpp.

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 323 of file CaelumSystem.h.

void caelum::CaelumSystem::setGroundFogDensityMultiplier ( double  value  ) 

Multiplier for ground fog density (default 1). This is an additional multiplier for Caelum::GroundFog density. This has no effect if GroundFog is not used.

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

Definition at line 369 of file CaelumSystem.cpp.

double caelum::CaelumSystem::getGroundFogDensityMultiplier (  )  const

Get the value set by setGroundFogDensityMultiplier.

Definition at line 373 of file CaelumSystem.cpp.

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 344 of file CaelumSystem.h.

void caelum::CaelumSystem::setGlobalFogDensityMultiplier ( double  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 377 of file CaelumSystem.cpp.

double caelum::CaelumSystem::getGlobalFogDensityMultiplier (  )  const

Get the value set by setSceneFogDensityMultiplier.

Definition at line 381 of file CaelumSystem.cpp.

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 365 of file CaelumSystem.h.

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 374 of file CaelumSystem.h.

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

See also:
setMinimumAmbientLight

Definition at line 377 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 385 of file CaelumSystem.h.

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

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

Definition at line 393 of file CaelumSystem.h.

bool caelum::CaelumSystem::frameStarted ( const Ogre::FrameEvent &  e  )  [protected, 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 209 of file CaelumSystem.cpp.

References updateSubcomponents().

void caelum::CaelumSystem::preViewportUpdate ( const Ogre::RenderTargetViewportEvent &  e  )  [protected, 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.

Parameters:
e The viewport event, containing the viewport (and camera) to be rendered right now.

Definition at line 169 of file CaelumSystem.cpp.

References getClouds(), getGroundFog(), getImageStarfield(), getMoon(), getPointStarfield(), getSkyDome(), getSun(), caelum::GroundFog::notifyCameraChanged(), caelum::LayeredClouds::notifyCameraChanged(), caelum::PointStarfield::notifyCameraChanged(), caelum::ImageStarfield::notifyCameraChanged(), caelum::CameraBoundElement::notifyCameraChanged(), and caelum::SkyDome::notifyCameraChanged().


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

Generated on Fri Jul 11 09:24:53 2008 for Caelum by  doxygen 1.5.6