#include <CaelumSystem.h>
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) |
UniversalClock * | getUniversalClock () const |
Ogre::SceneNode * | getRootNode (void) const |
void | updateSubcomponents (double timeSinceLastFrame) |
SkyDome * | getSkyDome () const |
Get the current sky dome, or null if disabled. | |
void | setSkyDome (SkyDome *obj) |
Set the skydome, or null to disable. | |
BaseSkyLight * | getSun () const |
Gets the current sun, or null if disabled. | |
void | setSun (BaseSkyLight *obj) |
Set the sun, or null to disable. | |
BaseSkyLight * | getMoon () const |
Gets the current moon, or null if disabled. | |
void | setMoon (Moon *obj) |
Set the moon, or null to disable. | |
ImageStarfield * | getImageStarfield () const |
Gets the current image starfield, or null if disabled. | |
void | setImageStarfield (ImageStarfield *obj) |
Set image starfield, or null to disable. | |
PointStarfield * | getPointStarfield () const |
Gets the current point starfield, or null if disabled. | |
void | setPointStarfield (PointStarfield *obj) |
Set image starfield, or null to disable. | |
LayeredClouds * | getClouds () const |
Get LayeredClouds, or null if disabled. | |
void | setClouds (LayeredClouds *obj) |
Set LayeredClouds, or null to disable. | |
void | setSkyColourModel (SkyColourModel *model) |
SkyColourModel * | getSkyColourModel () const |
void | setSolarSystemModel (SolarSystemModel *model) |
Set the solar system model to use, or null to disable. | |
SolarSystemModel * | getSolarSystemModel () const |
Set the current solar system model. | |
void | setGroundFog (GroundFog *model) |
GroundFog * | getGroundFog () 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) |
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.
Definition at line 62 of file CaelumSystem.h.
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.
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.
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.
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.
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.
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 | ) |
Update the whole system manually. You have to call this if you don't register CaelumSystem as an ogre frame listener.
timeSinceLastFrame,: | Time passed since last frame. |
Definition at line 222 of file CaelumSystem.cpp.
References caelum::PointStarfield::_update(), caelum::BaseSkyLight::getAmbientMultiplier(), getClouds(), getEnsureSingleLightSource(), getEnsureSingleShadowSource(), caelum::SkyColourModel::getFogDensity(), getGroundFog(), getImageStarfield(), caelum::UniversalClock::getJulianDay(), caelum::UniversalClock::getJulianSecondDifference(), caelum::BaseSkyLight::getLightColour(), caelum::BaseSkyLight::getMainLight(), getManageAmbientLight(), getManageSceneFog(), getMoon(), caelum::SkyColourModel::getMoonBodyColour(), caelum::SolarSystemModel::getMoonDirection(), caelum::SkyColourModel::getMoonLightColour(), caelum::SolarSystemModel::getMoonPhase(), getPointStarfield(), getSkyColourModel(), getSkyDome(), getSolarSystemModel(), getSun(), caelum::SolarSystemModel::getSunDirection(), caelum::SkyColourModel::getSunLightColour(), caelum::SkyColourModel::getSunSphereColour(), caelum::GroundFog::setColour(), caelum::GroundFog::setDensity(), caelum::BaseSkyLight::setForceDisable(), caelum::SkyDome::setHazeColour(), caelum::SkyDome::setSunDirection(), caelum::ImageStarfield::update(), and caelum::UniversalClock::update().
Referenced by frameStarted().
void caelum::CaelumSystem::setSkyColourModel | ( | SkyColourModel * | model | ) | [inline] |
Sets the sky colour model to be used.
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.
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).
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.
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] |
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.
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().