Caelum
CloudSystem.cpp
1 /*
2 This file is part of Caelum.
3 See http://www.ogre3d.org/wiki/index.php/Caelum
4 
5 Copyright (c) 2008 Caelum team. See Contributors.txt for details.
6 
7 Caelum is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published
9 by the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Caelum is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License
18 along with Caelum. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #include "CaelumPrecompiled.h"
22 #include "CloudSystem.h"
23 #include "FlatCloudLayer.h"
24 
25 using namespace Ogre;
26 
27 namespace Caelum
28 {
29  CloudSystem::CloudSystem(
30  Ogre::SceneManager *sceneMgr,
31  Ogre::SceneNode *cloudRoot)
32  {
33  mSceneMgr = sceneMgr;
34  mCloudRoot = cloudRoot;
35  }
36 
37  FlatCloudLayer* CloudSystem::createLayerAtHeight(Ogre::Real height)
38  {
39  FlatCloudLayer* layer = this->createLayer ();
40  layer->setHeight(height);
41  return layer;
42  }
43 
44  FlatCloudLayer* CloudSystem::createLayer()
45  {
46  std::auto_ptr<FlatCloudLayer> layer(new FlatCloudLayer(mSceneMgr, mCloudRoot));
47  mLayers.push_back(layer.get());
48  return layer.release();
49  }
50 
51  void CloudSystem::addLayer(FlatCloudLayer* layer)
52  {
53  assert(layer != NULL);
54  mLayers.push_back(layer);
55  }
56 
57  void CloudSystem::clearLayers()
58  {
59  for (unsigned i = 0; i < mLayers.size(); i++)
60  {
61  delete mLayers[i];
62  mLayers[i] = 0;
63  }
64  }
65 
66  CloudSystem::~CloudSystem()
67  {
68  clearLayers ();
69  }
70 
71  void CloudSystem::update(
72  Ogre::Real timePassed,
73  const Ogre::Vector3 &sunDirection,
74  const Ogre::ColourValue &sunLightColour,
75  const Ogre::ColourValue &fogColour,
76  const Ogre::ColourValue &sunSphereColour)
77  {
78  for (uint i = 0; i < mLayers.size(); i++) {
79  assert(mLayers[i] != NULL);
80  mLayers[i]->update(timePassed, sunDirection, sunLightColour, fogColour, sunSphereColour);
81  }
82  }
83 
84  void CloudSystem::forceLayerQueryFlags (uint flags) {
85  for (uint i = 0; i < mLayers.size(); i++) {
86  mLayers[i]->setQueryFlags (flags);
87  }
88  }
89 
90  void CloudSystem::forceLayerVisibilityFlags (uint flags) {
91  for (uint i = 0; i < mLayers.size(); i++) {
92  mLayers[i]->setVisibilityFlags (flags);
93  }
94  }
95 }
void setHeight(Ogre::Real height)
Set the height of the cloud layer.
A flat cloud layer; drawn as a simple plane.
Caelum namespace.
Definition: Astronomy.cpp:24