Project

General

Profile

SO3Engine
SO3Sky.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 __SO3SKY_H__
33#define __SO3SKY_H__
34
38#include "SkyX.h"
39
40namespace SO3
41{
42
43#define SO3_SKY_DEFAULT_TIME_MULTIPLIER 10000.0f
44
45class _SO3_Export SSky : public SEnvironmentComponent,
46 public Ogre::RenderTargetListener
47{
48public:
52 {
55 SO3_SKY_COMPONENT_VOLUMETRIC_CLOUD
56 };
57
61 {
62 SO3_SKY_LDR = 0,
63 SO3_SKY_HDR = 1
64 };
65
71 {
72 public:
73 protected:
75 private:
76 bool skyComponentEnable;
77 const SkyComponentType componentType;
78
79 public:
82 SkyComponent(SSky* parentSkyInstance, const SkyComponentType& component);
83
86 virtual ~SkyComponent();
87
91 bool GetEnabled();
92
96 void SetEnabled(const bool& enable);
97
100 virtual void SetEnableImpl(const bool& enableComponent);
101
105 virtual void UnregisterCamera(Ogre::Camera* cam);
106
109 SkyComponentType GetType();
110
113 virtual void Update(const Ogre::Real& updateTime)=0;
114 protected:
115 private:
119 SkyComponent();
120 };
121
126 {
127 public:
128 protected:
129 private:
130 typedef std::map<unsigned int, SkyX::CloudLayer::Options*> CloudLayerOptionsMap;
131 CloudLayerOptionsMap cloudLayerOptionsMap;
132 typedef std::map<unsigned int, SkyX::CloudLayer*> CloudLayerMap;
133 CloudLayerMap cloudLayerMap;
134
135 public:
138 CloudLayered(SSky* parentSkyInstance);
139
143
146 virtual void Update(const Ogre::Real& updateTime);
147
151 unsigned int AddLayer(const Ogre::Real& heightFromCloudCeiling=0.0f, const Ogre::Real& scale=0.001f, const Ogre::Real& distanceAttenuation=0.05f, const Ogre::Real& detailAttenuation=1.0f, const Ogre::Real& heightVolume=0.25f, const Ogre::Real& volumetricDisplacement=0.01f);
152
156 void RemoveLayer(const unsigned int& index);
157
160 void RemoveAllLayers();
161
164 std::vector<int> GetLayerIndexes();
165
168 void SetParameters(const unsigned int& index, const float& heightFromCloudCeiling, const float& scale, const float& attenuationDistance, const float& attenuationDetail, const float& heightVolume, const float& volumetricDisplacement);
169
172 Ogre::Real GetHeightFromCloudCeiling(const unsigned int& index);
173
176 void SetHeightFromCloudCeiling(const unsigned int& index, const Ogre::Real& newHeightFromCloudCeiling);
177
180 Ogre::Real GetScale(const unsigned int& index);
181
184 void SetScale(const unsigned int& index, const Ogre::Real& newScale);
185
188 Ogre::Real GetAttenuationDistance(const unsigned int& index);
189
192 void SetAttenuationDistance(const unsigned int& index, const Ogre::Real& newAttenuationDistance);
193
196 Ogre::Real GetAttenuationDetail(const unsigned int& index);
197
200 void SetAttenuationDetail(const unsigned int& index, const Ogre::Real& newAttenuationDetail);
201
204 Ogre::Real GetHeightVolume(const unsigned int& index);
205
208 void SetHeightVolume(const unsigned int& index, const Ogre::Real& newHeightVolume);
209
212 Ogre::Real GetVolumetricDisplacement(const unsigned int& index);
213
216 void SetVolumetricDisplacement(const unsigned int& index, const Ogre::Real& newVolumetricDisplacement);
217
220 virtual void SetEnableImpl(const bool& enableComponent);
221 protected:
222 private:
226 CloudLayered();
227
231 SkyX::CloudLayer::Options* GetLayerOptions(const unsigned int& index);
232
235 void ApplyLayerOptions(const unsigned int& index);
236 };
237
242 {
243 public:
244 protected:
245 private:
246 float cachedHumidity;
247 SkyX::ColorGradient sunGradient;
248 Ogre::ColourValue cachedMoonLightColour;
249 Ogre::ColourValue cachedSunLightColour;
250 float cachedCloudCeiling;
251 float cachedWindSpeed;
252 Ogre::Vector2 cachedWindDirection;
253
254 public:
257 CloudVolumetric(SSky* parentSkyInstance);
258
262
265 virtual void Update(const Ogre::Real& updateTime);
266
270 virtual void UnregisterCamera(Ogre::Camera* cam);
271
274 virtual void SetEnableImpl(const bool& enableComponent);
275 protected:
276 private:
281
284 void CheckSunColourGradient(const bool& force = false);
285 };
286protected:
287private:
288 SScene* parentScene;
289 SkyX::SkyX* skyxManager;
290 SkyX::AtmosphereManager::Options skyxOptions;
291 SSkyAstronomicalModel* astronomicalModel;
292 CloudVolumetric* volumetricClouds;
293 CloudLayered* layeredClouds;
294 float cloudsAnimationSpeed;
295 float cloudsCeilingHeight;
296 std::string cachedMoonTextureName;
297 SkyLightingMode skyLightingMode;
298 bool skyLightningEnable;
299
300public:
303 SSky(SEnvironment* parent, const std::string& skyName);
304
308 ~SSky();
309
313 SkyX::SkyX* GetSkyX();
314
317 SSky::CloudVolumetric* GetCloudVolumetric();
318
321 SkyComponent* GetComponent(const SkyComponentType& componentType);
322
325 SSky::CloudLayered* GetCloudLayered();
326
330 virtual void Update(const Ogre::Real& updateTime);
331
334 virtual void UpdateCamera(SViewPort* viewport);
335
339 float GetAnimationSpeed();
340
344 void SetAnimationSpeed(const float& animationSpeed);
345
348 float GetCloudCeiling();
349
352 void SetCloudCeiling(const float& newCloudCeiling);
353
356 bool GetHDREnable();
357
360 void SetHDREnable(const bool& enable);
361
364 bool GetLightningEnable();
365
368 void SetLightningEnable(const bool& enable);
369
370 void AddLightning(const Ogre::Vector3 from, const Ogre::Vector3 dir, const Ogre::Real length);
371
372 void AddViewport(Ogre::Viewport* viewport);
373
374 void RemoveViewport(Ogre::Viewport* viewport);
375protected:
379 virtual void SetEnableImpl(const bool& enableComponent);
380
384 virtual void RegisterViewportImpl(SViewPort* viewport);
385
389 virtual void UnregisterViewportImpl(SViewPort* viewport);
390
391 virtual void UnregisterCameraImpl(Ogre::Camera* cam);
392private:
396 SSky();
397};
398
399}
400
401#endif
librairies include
virtual void Update(const Ogre::Real &updateTime)=0
SkyLightingMode
Definition SO3Sky.h:61
SkyComponentType
Definition SO3Sky.h:52
@ SO3_SKY_COMPONENT_LAYERER_CLOUD
Definition SO3Sky.h:54
@ SO3_SKY_COMPONENT_NONE
Definition SO3Sky.h:53