00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef CAELUMSYSTEM_H
00022 #define CAELUMSYSTEM_H
00023
00024 #include "CaelumPrerequisites.h"
00025
00026 #include "UniversalClock.h"
00027 #include "SkyColourModel.h"
00028 #include "SkyDome.h"
00029 #include "ImageStarfield.h"
00030 #include "LayeredClouds.h"
00031 #include "SolarSystemModel.h"
00032 #include "GroundFog.h"
00033 #include "Sun.h"
00034 #include "Moon.h"
00035
00036 namespace caelum {
00037
00062 class CAELUM_EXPORT CaelumSystem : public Ogre::FrameListener, public Ogre::RenderTargetListener {
00063
00064 private:
00067 Ogre::Root *mOgreRoot;
00068
00071 Ogre::SceneManager *mSceneMgr;
00072
00075 Ogre::SceneNode *mCaelumRootNode;
00076
00079 bool mCleanup;
00080
00083 bool mManageResourceGroup;
00084
00086 UniversalClock *mUniversalClock;
00087
00089 bool mManageSceneFog;
00090
00092 double mGlobalFogDensityMultiplier;
00093
00095 double mSceneFogDensityMultiplier;
00096
00098 Ogre::ColourValue mSceneFogColourMultiplier;
00099
00101 double mGroundFogDensityMultiplier;
00102
00104 Ogre::ColourValue mGroundFogColourMultiplier;
00105
00107 bool mManageAmbientLight;
00108
00110 Ogre::ColourValue mMinimumAmbientLight;
00111
00113 bool mEnsureSingleLightSource;
00114
00116 bool mEnsureSingleShadowSource;
00117
00118
00119 std::auto_ptr<SkyColourModel> mSkyColourModel;
00120 std::auto_ptr<SkyDome> mSkyDome;
00121 std::auto_ptr<SolarSystemModel> mSolarSystemModel;
00122 std::auto_ptr<BaseSkyLight> mSun;
00123 std::auto_ptr<Moon> mMoon;
00124 std::auto_ptr<ImageStarfield> mImageStarfield;
00125 std::auto_ptr<PointStarfield> mPointStarfield;
00126 std::auto_ptr<LayeredClouds> mClouds;
00127 std::auto_ptr<GroundFog> mGroundFog;
00128
00129
00130 public:
00144 enum CaelumComponent
00145 {
00146 CAELUM_COMPONENT_SKY_COLOUR_MODEL = 1 << 0,
00147 CAELUM_COMPONENT_SKY_DOME = 1 << 1,
00148 CAELUM_COMPONENT_SOLAR_SYSTEM_MODEL = 1 << 2,
00149 CAELUM_COMPONENT_MOON = 1 << 3,
00150 CAELUM_COMPONENT_SUN = 1 << 4,
00151 CAELUM_COMPONENT_IMAGE_STARFIELD = 1 << 5,
00152 CAELUM_COMPONENT_POINT_STARFIELD = 1 << 6,
00153 CAELUM_COMPONENT_CLOUDS = 1 << 7,
00154
00155
00156 CAELUM_COMPONENT_GROUND_FOG = 1 << (16 + 0),
00157
00158
00159 CAELUM_COMPONENTS_NONE = 0,
00160 CAELUM_COMPONENTS_DEFAULT = 0
00161 | CAELUM_COMPONENT_SKY_COLOUR_MODEL
00162 | CAELUM_COMPONENT_SKY_DOME
00163 | CAELUM_COMPONENT_SOLAR_SYSTEM_MODEL
00164 | CAELUM_COMPONENT_MOON
00165 | CAELUM_COMPONENT_SUN
00166 | CAELUM_COMPONENT_POINT_STARFIELD
00167 | CAELUM_COMPONENT_CLOUDS,
00168 CAELUM_COMPONENTS_ALL =
00169 CAELUM_COMPONENTS_DEFAULT | CAELUM_COMPONENT_GROUND_FOG,
00170 };
00171
00184 CaelumSystem (
00185 Ogre::Root *root,
00186 Ogre::SceneManager *sceneMgr,
00187 CaelumComponent componentsToCreate = CAELUM_COMPONENTS_DEFAULT,
00188 bool manageResGroup = true,
00189 const Ogre::String &resGroupName = RESOURCE_GROUP_NAME
00190 );
00191
00194 ~CaelumSystem ();
00195
00205 void shutdown (bool cleanup);
00206
00210 UniversalClock *getUniversalClock () const;
00211
00214 Ogre::SceneNode* getRootNode(void) const { return mCaelumRootNode; }
00215
00220 void updateSubcomponents (double timeSinceLastFrame);
00221
00223 inline SkyDome* getSkyDome () const { return mSkyDome.get (); }
00225 inline void setSkyDome (SkyDome *obj) { mSkyDome.reset (obj); }
00226
00228 inline BaseSkyLight* getSun () const { return mSun.get (); }
00230 inline void setSun (BaseSkyLight* obj) { mSun.reset (obj); }
00231
00233 BaseSkyLight* getMoon () const { return mMoon.get (); }
00235 inline void setMoon (Moon* obj) { mMoon.reset (obj); }
00236
00238 inline ImageStarfield* getImageStarfield () const { return mImageStarfield.get (); }
00240 inline void setImageStarfield (ImageStarfield* obj) { mImageStarfield.reset (obj); }
00241
00243 inline PointStarfield* getPointStarfield () const { return mPointStarfield.get (); }
00245 inline void setPointStarfield (PointStarfield* obj) { mPointStarfield.reset (obj); }
00246
00248 inline LayeredClouds* getClouds () const { return mClouds.get (); }
00250 inline void setClouds (LayeredClouds* obj) { mClouds.reset (obj); }
00251
00255 inline void setSkyColourModel (SkyColourModel *model) {
00256 mSkyColourModel.reset(model);
00257 }
00258
00261 inline SkyColourModel* getSkyColourModel () const {
00262 return mSkyColourModel.get();
00263 }
00264
00266 inline void setSolarSystemModel (SolarSystemModel *model) {
00267 mSolarSystemModel.reset(model);
00268 }
00269
00271 inline SolarSystemModel* getSolarSystemModel () const {
00272 return mSolarSystemModel.get();
00273 }
00274
00278 inline void setGroundFog (GroundFog *model) {
00279 mGroundFog.reset(model);
00280 }
00281
00284 inline GroundFog* getGroundFog () const {
00285 return mGroundFog.get();
00286 }
00287
00300 void setManageSceneFog (bool value);
00301
00305 bool getManageSceneFog () const;
00306
00314 void setSceneFogDensityMultiplier (double value);
00315
00318 double getSceneFogDensityMultiplier () const;
00319
00323 inline void setSceneFogColourMultiplier (const Ogre::ColourValue& value) { mSceneFogColourMultiplier = value; }
00324
00326 inline Ogre::ColourValue getSceneFogColourMultiplier () const { return mSceneFogColourMultiplier; }
00327
00335 void setGroundFogDensityMultiplier (double value);
00336
00339 double getGroundFogDensityMultiplier () const;
00340
00344 inline void setGroundFogColourMultiplier (const Ogre::ColourValue& value) { mGroundFogColourMultiplier = value; }
00345
00347 inline Ogre::ColourValue getGroundFogColourMultiplier () const { return mGroundFogColourMultiplier; }
00348
00355 void setGlobalFogDensityMultiplier (double value);
00356
00359 double getGlobalFogDensityMultiplier () const;
00360
00365 inline void setManageAmbientLight (bool value) { mManageAmbientLight = value; }
00366
00368 inline bool getManageAmbientLight () const { return mManageAmbientLight; }
00369
00374 inline void setMinimumAmbientLight (const Ogre::ColourValue &value) { mMinimumAmbientLight = value; }
00375
00377 inline const Ogre::ColourValue getMinimumAmbientLight () const { return mMinimumAmbientLight; }
00378
00385 inline void setEnsureSingleLightSource (bool value) { mEnsureSingleLightSource = value; }
00386
00388 inline bool getEnsureSingleLightSource () const { return mEnsureSingleLightSource; }
00389
00393 inline void setEnsureSingleShadowSource (bool value) { mEnsureSingleShadowSource = value; }
00394
00396 inline bool getEnsureSingleShadowSource () const { return mEnsureSingleShadowSource; }
00397
00398 protected:
00403 virtual bool frameStarted (const Ogre::FrameEvent &e);
00404
00409 virtual void preViewportUpdate (const Ogre::RenderTargetViewportEvent &e);
00410
00411 private:
00413 void destroySubcomponents();
00414 };
00415 }
00416
00417 #endif //CAELUMSYSTEM_H