VR-Forces Development_Version 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) 2016 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 #include <osg/Uniform>
19 
20 #include <OpenThreads/Mutex>
21 
22 #include <list>
23 #include <map>
24 
25 #include <matrix/vlVector.h>
26 #include <matrix/referenceEllipsoid.h>
27 #include <matrix/geodeticCoord.h>
28 
31 
32 namespace SilverLining
33 {
34  class Atmosphere;
35  class CloudLayer;
36  class LocalTime;
37  class Location;
38 }
39 
40 namespace makVrv
41 {
42  class DtChannel;
43  class DtDe;
44  class DtOsgFogComponent;
45  class DtLightManagerGroup;
46  class DtOsgSkyObject;
47 
51  class DT_DLL_VRVOSG DtSilverliningGroup : public osg::Group
52  {
53  public:
54 
57 
59  virtual ~DtSilverliningGroup();
60 
62  void setGenerateCubeMaps(bool enabled);
63 
65  void setCubeMapGenerationDistanceThreshold(double threshold);
66 
69  unsigned int getCubeMap(const osg::ref_ptr<osg::Camera> camera) const;
70 
73  unsigned int getPrimaryCubeMap() const;
74 
75  void installIntoChannel(DtChannel*);
76 
78  void applyFog(osg::ref_ptr<osg::Camera> camera);
79 
81  void deleteGeods();
82 
84  void setGeocentricMode(bool mode);
85 
87  bool geocentricMode() const;
88 
90  void setHiResCumulus(bool enabled);
91 
93  bool hiResCumulus() const;
94 
96  void setLensFlare(bool enabled);
97 
99  bool lensFlare() const;
100 
102  void setCrepuscularRays(bool enabled);
103 
105  bool crepuscularRays() const;
106 
108  void setForcedMoonPhase(float phase);
109 
111  void clearForcedMoonPhase();
112 
114  bool moonPhaseIsForced() const;
115 
117  float forcedMoonPhase() const;
118 
122  void setForcedSunAndMoon(double sunLat, double sunLon, double moonLat,
123  double moonLon, bool horizonCoords=true);
124 
125  // Clear any forced sun & moon position set with ForceSunAndMoon()
126  void clearForcedSunAndMoon();
127 
129  bool sunAndMoonPositionIsForced() const;
130 
132  void getForcedSunAndMoonPosition( double& sunLat, double& sunLon,
133  double& moonLat, double& moonLon, bool& horizonCoords ) const;
134 
137  void setLightPollution(double Wm2);
138 
140  double lightPollution() const;
141 
143  virtual void setDateAndTime( unsigned short year, unsigned char month,
144  unsigned char day, unsigned char hour, unsigned char minutes,
145  double seconds, bool observeDaylightSavings );
146 
148  virtual void updateTime();
149 
152  virtual void setLocation(const DtVector& location);
153 
155  virtual void update(const osg::Matrix& m);
156 
158  virtual void update2D(const osg::Matrix& m);
159 
162  virtual void updateConditions(DtOsgSkyObject* skyObject);
163 
165  int cloudLayerCount() const;
166 
168  void removeCloudLayer(int index);
169 
172  void setFogColor(const osg::Vec4f& rgbA);
173 
175  void setFogHeight(float height);
176 
179  void setFogBlend(const osg::Vec4f& rgbA,float density);
180 
182  void setFogOverride(osg::ref_ptr<osg::Camera> camera, const osg::Vec4f& rgbA, float density);
183 
186  void setFogThresholdDistance(float distance);
187 
189  void setHorizonColor(const osg::Vec4f& rgbA);
190 
192  void setCubeMapDirty();
193 
195  void setUse16BitEnviroMap(bool flag);
196 
198  bool getUse16BitEnviroMap();
199 
201  void setUsingSensorFXShader(bool flag);
202 
204  bool getUsingSensorFXShader();
205 
207  void clearHorizonColor();
208 
210  void clearFogOverride(osg::ref_ptr<osg::Camera> camera);
211 
212  void clearFogOverrideForAllCameras(void);
213 
216  virtual void setUseGlobalTimeZone(bool b);
217 
219  virtual bool useGlobalTimeZone() const;
220 
222  float getSunAlpha() const;
223 
225  void setDrawSunAndMoonIntoEnvMap(bool draw);
226 
228  bool drawSunAndMoonIntoEnvMap() const;
229 
231  void addCirroCumulus(const DtVector& position, const DtVector& bounds, bool infinite, bool relative);
232  void addCirrusFibratus(const DtVector& position, const DtVector& bounds, bool infinite, bool relative);
233  void addNimbostratus(const DtVector& position, const DtVector& bounds,double density, bool infinite, bool relative);
234  void addCumulusMediocris(const DtVector& position, const DtVector& bounds,double density, bool infinite, bool relative);
235  void addCumulusCongestus(const DtVector& position, const DtVector& bounds,double density, bool infinite, bool relative);
236  void addCumulonumbusCappilatus(const DtVector& position, const DtVector& bounds,double density, bool relative);
237  void addStratocumulus(const DtVector& position, const DtVector& bounds, double density, bool infinite, bool relative);
238  void setCloudLayerEnabled(int index, bool enabled);
239  void setCloudLayerPosition(int index, double xCoord, double yCoord);
240 
241  void setWind(double directionDEN,double minAltitude, double maxAltitude,double velocity);
242  void setAirTurbidity( float turbidity );
243  void setVisibleDistance( float distance );
244  float getVisibleDistance() const;
245 
246  void createAtmosphere();
247  void destroyAtmosphere();
248 
249  // if create atmosphere failed this is set to true.
250  bool getFailedInit(){ return myFailedInit; }
251 
252  void addRain(float mmPerHour, bool global);
253  void addSleet(float mmPerHour, bool global);
254  void addSnow(float mmPerHour, bool global, bool wet);
255  void clearAllPrecipitation();
256 
257  void realizeLayers();
258 
259  SilverLining::Atmosphere* findAtmosphere();
260 
261  DtDe& getDtDe();
262 
263  //get the Julian Date and Time in the GMT time zone
264  void getGMTDateTime(long &julianDate, double &GMTTod);
265 
266  //return the node that is the parent to the clouds
267  osg::Node *getCloudsNode();
268 
269  //return the node that is the parent to the sky
270  osg::Node *getSkyNode();
271 
272  //return the default shader vector being used for the atmosphere user functions
273  std::vector<unsigned int> getDefaultShaderVector();
274 
275  //set the flag for drawing the silverlining sun/moon
276  void setSunMoonEnabled(bool drawSunMoon);
277 
278  //get the flag for drawing the silverlining sun/moon
279  bool getSunMoonEnabled();
280 
281  //set the flag for drawing the silverlining stars
282  void setStarsEnabled(bool drawStars);
283 
284  //get the flag for drawing the silverlining stars
285  bool getStarsEnabled();
286 
287  void enableLighting(osg::ref_ptr<osg::Camera> camera, bool enable);
288 
290  virtual void setEnableHDR(bool enable);
291 
292 
293  protected:
294 
295  struct CloudLayer
296  {
297  unsigned int type;
298  unsigned int handle;
301  double density;
302  bool enabled;
303  bool realized;
304  bool infinite;
305  bool relative;
306  };
307 
309  void addLayer( const CloudLayer& layer );
310 
312  void realizeLayer( CloudLayer& layer );
313  void destroyLayer( DtSilverliningGroup::CloudLayer& layer );
314 
315  int CalculateZoneByLongitude(double longitude);
316  void SetTimeAndLocation();
317 
318  void addPrecipitationToClouds(int type, float mmPerHour);
319 
320  void updatePrecipitation();
321 
322  void setCloudVisibility();
323 
325  virtual void traverse(osg::NodeVisitor& nv);
326  void resetLayers();
327  void forceResetLayers();
328 
329  void generateCubeMap( const osg::Matrix& viewMatrix );
330 
331 
332  protected:
333 
334  typedef std::vector<CloudLayer> CloudLayerList;
335 
337  mutable OpenThreads::Mutex myMutex;
338 
339  DtReferenceEllipsoid myRefEllip;
340  DtGeodeticCoord myGeod;
341 
343  SilverLining::Atmosphere* myAtmosphere;
344  SilverLining::LocalTime* myLocalTime;
345  SilverLining::Location* myLocation;
346 
349 
350  osg::ref_ptr<osg::Geode> mySkyGeod;
351  osg::ref_ptr<osg::LightSource> mySkyLight;
352  osg::ref_ptr<osg::Geode> myCloudGeod;
353  osg::ref_ptr<DtLightManagerGroup> myLightManagerGroup;
354 
355  osg::Vec4f myFogColor, myBlendedFogColor, myHorizonColor;
358 
360  float myTurbidity;
378 
381 
382  typedef std::map<osg::ref_ptr<osg::Camera>, bool> FogOverrideMap;
383 
385  std::map<osg::ref_ptr<osg::Camera>, float> myFogOverrideDensityMap;
386  std::map<osg::ref_ptr<osg::Camera>, osg::Vec4f> myFogOverrideColorMap;
387 
388  osg::ref_ptr<osg::Uniform> myLightLevelUniform;
389 
390  float myFogHeight, myFogThresholdDistance;
391  float mySunAlpha;
393 
397 
399 
400  osg::ref_ptr<DtOsgFogComponent> myFogComponent;
402 
403  //default opengl compiled shaders needed for silver lining to work after sensorFX is installed
404  std::vector<unsigned int> myDefaultShaderVector;
405 
408 
410 
413  };
414 
418  {
419 
420  public:
422  static DtSilverliningGroupCreator& instance(DtDe& theIG);
423 
425  static void registerInstance(DtDe& theIG,DtSilverliningGroupCreator* anInstance);
426 
428  virtual DtSilverliningGroup* create(DtDe&);
429  };
430 }
431 
432 

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)