00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "CaelumPrecompiled.h"
00022 #include "CloudSystem.h"
00023 #include "FlatCloudLayer.h"
00024
00025 using namespace Ogre;
00026
00027 namespace Caelum
00028 {
00029 CloudSystem::CloudSystem(
00030 Ogre::SceneManager *sceneMgr,
00031 Ogre::SceneNode *cloudRoot)
00032 {
00033 mSceneMgr = sceneMgr;
00034 mCloudRoot = cloudRoot;
00035 }
00036
00037 FlatCloudLayer* CloudSystem::createLayerAtHeight(Ogre::Real height)
00038 {
00039 FlatCloudLayer* layer = this->createLayer ();
00040 layer->setHeight(height);
00041 return layer;
00042 }
00043
00044 FlatCloudLayer* CloudSystem::createLayer()
00045 {
00046 std::auto_ptr<FlatCloudLayer> layer(new FlatCloudLayer(mSceneMgr, mCloudRoot));
00047 mLayers.push_back(layer.get());
00048 return layer.release();
00049 }
00050
00051 void CloudSystem::addLayer(FlatCloudLayer* layer)
00052 {
00053 assert(layer != NULL);
00054 mLayers.push_back(layer);
00055 }
00056
00057 void CloudSystem::clearLayers()
00058 {
00059 for (unsigned i = 0; i < mLayers.size(); i++)
00060 {
00061 delete mLayers[i];
00062 mLayers[i] = 0;
00063 }
00064 }
00065
00066 CloudSystem::~CloudSystem()
00067 {
00068 clearLayers ();
00069 }
00070
00071 void CloudSystem::update(
00072 Ogre::Real timePassed,
00073 const Ogre::Vector3 &sunDirection,
00074 const Ogre::ColourValue &sunLightColour,
00075 const Ogre::ColourValue &fogColour,
00076 const Ogre::ColourValue &sunSphereColour)
00077 {
00078 for (uint i = 0; i < mLayers.size(); i++) {
00079 assert(mLayers[i] != NULL);
00080 mLayers[i]->update(timePassed, sunDirection, sunLightColour, fogColour, sunSphereColour);
00081 }
00082 }
00083
00084 void CloudSystem::forceLayerQueryFlags (uint flags) {
00085 for (uint i = 0; i < mLayers.size(); i++) {
00086 mLayers[i]->setQueryFlags (flags);
00087 }
00088 }
00089
00090 void CloudSystem::forceLayerVisibilityFlags (uint flags) {
00091 for (uint i = 0; i < mLayers.size(); i++) {
00092 mLayers[i]->setVisibilityFlags (flags);
00093 }
00094 }
00095 }