SO3Engine
SO3Environment.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
32#ifndef __SO3ENVIRONMENT_H__
33#define __SO3ENVIRONMENT_H__
34
38#include "SO3Water.h"
39#include "SO3Sky.h"
40
41namespace SO3
42{
43
44class _SO3_Export SEnvironment : public SData,
45 public Ogre::FrameListener,
46 public Ogre::RenderTargetListener
47{
48public:
49 typedef std::set<SViewPort*> ViewportList;
50protected:
51private:
52 ViewportList viewportList;
53 typedef std::map<Ogre::RenderTarget*, int> RenderTargetList;
54 RenderTargetList mRenderTargetList;
55 SScene* scene;
56 SWater* water;
57 SSky* sky;
58 SSun* sun;
59 SMoon* moon;
60 bool paused;
61 bool enabled;
62 bool skyEnabled;
63 bool waterEnabled;
64 SUniversalClock* universalClock;
65 Ogre::Degree observerLatitude;
66 Ogre::Degree observerLongitude;
67 float windSpeed;
68 Ogre::Vector2 windDirection;
69 float humidityFactor;
70
71public:
74 SEnvironment(SScene* parent, const std::string& environmentName);
75
80
83 SScene* GetScene();
84
87 void RegisterViewport(SViewPort* targetViewport);
88
91 void UnregisterViewport(SViewPort* targetViewport);
92
95 void UnregisterCamera(Ogre::Camera* cam);
96
99 bool IsRegisteredViewport(SViewPort* targetViewport);
100
103 bool IsRegisteredViewport(Ogre::Viewport* targetViewport);
104
107 void UnregisterAllViewports();
108
111 ViewportList GetRegisteredViewports();
112
115 SUniversalClock* GetUniversalClock();
116
119 SWater* GetWater();
120
123 SSky* GetSky();
124
127 SSun* GetSun();
128
131 SMoon* GetMoon();
132
135 bool GetEnable();
136
139 void SetEnable(const bool& enableEnvironment);
140
143 bool GetPaused();
144
147 void SetPaused(const bool& pauseSimulation);
148
151 bool GetWaterEnable();
152
155 void SetWaterEnable(const bool& enableWater);
156
159 bool GetSkyEnable();
160
163 void SetSkyEnable(const bool& enableSky);
164
167 float GetWindSpeed();
168
171 void SetWindSpeed(const float& newWindSpeed);
172
175 Ogre::Vector2 GetWindDirection();
176
179 void SetWindDirection(const Ogre::Vector2& newWindDirection);
180
183 float GetHumidity();
184
187 void SetHumidity(const float& newHumidity);
188
191 float GetTimeSpeedFactor();
192
195 void SetTimeSpeedFactor(const float& newTimeSpeedFactor);
196
199 SDateTime GetDateTime();
200
203 void SetDateTime(const SDateTime& newDateTime);
204
208 Ogre::Degree GetLongitude();
209
212 void SetLongitude(const Ogre::Degree& newLongitude);
213
217 Ogre::Degree GetLatitude();
218
221 void SetLatitude(const Ogre::Degree& newLatitude);
222
225 // TODO: sea level is important for sky too: offset on the altitude (in horinzontal coordinate terms) of sun for example
226
230 void _NotifyEnvironmentComponentRegisterRenderTarget(Ogre::Viewport* targetViewport);
231
232 void _NotifyEnvironmentComponentUnRegisterRenderTarget(Ogre::Viewport* targetViewport);
233
236 void UpdateCamera(SViewPort* viewport);
237
238protected:
242 virtual bool frameStarted(const Ogre::FrameEvent& evt);
243private:
247 SEnvironment();
248};
249
250}
251
252#endif
std::set< SViewPort * > ViewportList