VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtSilverliningGroup.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2014 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
14 #include <osg/Camera>
15 #include <osg/Group>
16 #include <osg/Geode>
17 #include <osg/LightSource>
18 
19 #include <list>
20 #include <map>
21 
22 #include <matrix/vlVector.h>
23 #include <matrix/referenceEllipsoid.h>
24 #include <matrix/geodeticCoord.h>
25 #include <OpenThreads/Mutex>
26 
29 
30 namespace SilverLining
31 {
32  class Atmosphere;
33  class CloudLayer;
34  class LocalTime;
35  class Location;
36 }
37 
38 namespace makVrv
39 {
40  class DtChannel;
41  class DtDe;
42  class DtOsgFogComponent;
43  class DtLightManagerGroup;
44  class DtOsgSkyObject;
45 
49  class DT_DLL_VRVOSG DtSilverliningGroup : public osg::Group
50  {
51  public:
52 
55 
57  virtual ~DtSilverliningGroup();
58 
60  void setGenerateCubeMaps(bool enabled);
61 
63  void setCubeMapGenerationDistanceThreshold(double threshold);
64 
67  unsigned int getCubeMap(const osg::ref_ptr<osg::Camera> camera) const;
68 
71  unsigned int getPrimaryCubeMap() const;
72 
73  void installIntoChannel(DtChannel*);
74 
76  void applyFog(osg::ref_ptr<osg::Camera> camera);
77 
79  void deleteGeods();
80 
82  void setGeocentricMode(bool mode);
83 
85  bool geocentricMode() const;
86 
88  void setHiResCumulus(bool enabled);
89 
91  bool hiResCumulus() const;
92 
94  void setLensFlare(bool enabled);
95 
97  bool lensFlare() const;
98 
100  void setCrepuscularRays(bool enabled);
101 
103  bool crepuscularRays() const;
104 
106  void setForcedMoonPhase(float phase);
107 
109  void clearForcedMoonPhase();
110 
112  bool moonPhaseIsForced() const;
113 
115  float forcedMoonPhase() const;
116 
120  void setForcedSunAndMoon(double sunLat, double sunLon, double moonLat,
121  double moonLon, bool horizonCoords=true);
122 
123  // Clear any forced sun & moon position set with ForceSunAndMoon()
124  void clearForcedSunAndMoon();
125 
127  bool sunAndMoonPositionIsForced() const;
128 
130  void getForcedSunAndMoonPosition( double& sunLat, double& sunLon,
131  double& moonLat, double& moonLon, bool& horizonCoords ) const;
132 
135  void setLightPollution(double Wm2);
136 
138  double lightPollution() const;
139 
141  virtual void setDateAndTime( unsigned short year, unsigned char month,
142  unsigned char day, unsigned char hour, unsigned char minutes,
143  double seconds, bool observeDaylightSavings );
144 
146  virtual void updateTime();
147 
150  virtual void setLocation(const DtVector& location);
151 
153  virtual void update(const osg::Matrix& m);
154 
156  virtual void update2D(const osg::Matrix& m);
157 
160  virtual void updateConditions(DtOsgSkyObject* skyObject);
161 
163  int cloudLayerCount() const;
164 
166  void removeCloudLayer(int index);
167 
170  void setFogColor(const osg::Vec4f& rgbA);
171 
173  void setFogHeight(float height);
174 
177  void setFogBlend(const osg::Vec4f& rgbA,float density);
178 
180  void setFogOverride(osg::ref_ptr<osg::Camera> camera, const osg::Vec4f& rgbA, float density);
181 
184  void setFogThresholdDistance(float distance);
185 
187  void setHorizonColor(const osg::Vec4f& rgbA);
188 
190  void setCubeMapDirty();
191 
193  void setUse16BitEnviroMap(bool flag);
194 
196  bool getUse16BitEnviroMap();
197 
199  void setUsingSensorFXShader(bool flag);
200 
202  bool getUsingSensorFXShader();
203 
205  void clearHorizonColor();
206 
208  void clearFogOverride(osg::ref_ptr<osg::Camera> camera);
209 
210  void clearFogOverrideForAllCameras(void);
211 
214  virtual void setUseGlobalTimeZone(bool b);
215 
217  virtual bool useGlobalTimeZone() const;
218 
220  float getSunAlpha() const;
221 
223  void addCirroCumulus(const DtVector& position, const DtVector& bounds, bool infinite, bool relative);
224  void addCirrusFibratus(const DtVector& position, const DtVector& bounds, bool infinite, bool relative);
225  void addNimbostratus(const DtVector& position, const DtVector& bounds,double density, bool infinite, bool relative);
226  void addCumulusMediocris(const DtVector& position, const DtVector& bounds,double density, bool infinite, bool relative);
227  void addCumulusCongestus(const DtVector& position, const DtVector& bounds,double density, bool infinite, bool relative);
228  void addCumulonumbusCappilatus(const DtVector& position, const DtVector& bounds,double density, bool relative);
229  void addStratocumulus(const DtVector& position, const DtVector& bounds, double density, bool infinite, bool relative);
230  void setCloudLayerEnabled(int index, bool enabled);
231  void setCloudLayerPosition(int index, double xCoord, double yCoord);
232 
233  void setWind(double directionDEN,double minAltitude, double maxAltitude,double velocity);
234  void setAirTurbidity( float turbidity );
235  void setVisibleDistance( float distance );
236  float getVisibleDistance() const;
237 
238  void createAtmosphere();
239  void destroyAtmosphere();
240 
241  void addRain(float mmPerHour, bool global);
242  void addSleet(float mmPerHour, bool global);
243  void addSnow(float mmPerHour, bool global, bool wet);
244  void clearAllPrecipitation();
245 
246  void realizeLayers();
247 
248  SilverLining::Atmosphere* findAtmosphere();
249 
250  DtDe& getDtDe();
251 
252  //get the Julian Date and Time in the GMT time zone
253  void getGMTDateTime(long &julianDate, double &GMTTod);
254 
255  //return the node that is the parent to the clouds
256  osg::Node *getCloudsNode();
257 
258  //return the node that is the parent to the sky
259  osg::Node *getSkyNode();
260 
261  //return the default shader vector being used for the atmosphere user functions
262  std::vector<unsigned int> getDefaultShaderVector();
263 
264  //set the flag for drawing the silverlining sun/moon
265  void setSunMoonEnabled(bool drawSunMoon);
266 
267  //get the flag for drawing the silverlining sun/moon
268  bool getSunMoonEnabled();
269 
270  //set the flag for drawing the silverlining stars
271  void setStarsEnabled(bool drawStars);
272 
273  //get the flag for drawing the silverlining stars
274  bool getStarsEnabled();
275 
276  void enableLighting(osg::ref_ptr<osg::Camera> camera, bool enable);
277 
278  protected:
279 
280  struct CloudLayer
281  {
282  unsigned int type;
283  unsigned int handle;
286  double density;
287  bool enabled;
288  bool realized;
289  bool infinite;
290  bool relative;
291  };
292 
294  void addLayer( const CloudLayer& layer );
295 
297  void realizeLayer( CloudLayer& layer );
298  void destroyLayer( DtSilverliningGroup::CloudLayer& layer );
299 
300  int CalculateZoneByLongitude(double longitude);
301  void SetTimeAndLocation();
302 
303  void addPrecipitationToClouds(int type, float mmPerHour);
304 
305  void updatePrecipitation();
306 
307  void setCloudVisibility();
308 
310  virtual void traverse(osg::NodeVisitor& nv);
311  void resetLayers();
312  void forceResetLayers();
313 
314  void generateCubeMap( const osg::Matrix& viewMatrix );
315 
316  protected:
317 
318  typedef std::vector<CloudLayer> CloudLayerList;
319 
321  mutable OpenThreads::Mutex myMutex;
322 
323  DtReferenceEllipsoid myRefEllip;
324  DtGeodeticCoord myGeod;
325 
327  SilverLining::Atmosphere* myAtmosphere;
328  SilverLining::LocalTime* myLocalTime;
329  SilverLining::Location* myLocation;
330 
333 
334  osg::ref_ptr<osg::Geode> mySkyGeod;
335  osg::ref_ptr<osg::LightSource> mySkyLight;
336  osg::ref_ptr<osg::Geode> myCloudGeod;
337  osg::ref_ptr<DtLightManagerGroup> myLightManagerGroup;
338 
339  osg::Vec4f myFogColor, myBlendedFogColor, myHorizonColor;
342 
344  float myTurbidity;
360 
363 
364  typedef std::map<osg::ref_ptr<osg::Camera>, bool> FogOverrideMap;
365 
367  std::map<osg::ref_ptr<osg::Camera>, float> myFogOverrideDensityMap;
368  std::map<osg::ref_ptr<osg::Camera>, osg::Vec4f> myFogOverrideColorMap;
369 
370  float myFogHeight, myFogThresholdDistance;
371  float mySunAlpha;
373 
377 
379 
380  osg::ref_ptr<DtOsgFogComponent> myFogComponent;
382 
383  //default opengl compiled shaders needed for silver lining to work after sensorFX is installed
384  std::vector<unsigned int> myDefaultShaderVector;
385 
388 
390 
392  };
393 
397  {
398 
399  public:
401  static DtSilverliningGroupCreator& instance(DtDe& theIG);
402 
404  static void registerInstance(DtDe& theIG,DtSilverliningGroupCreator* anInstance);
405 
407  virtual DtSilverliningGroup* create(DtDe&);
408  };
409 }
410 
411 

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)