VR-Forces 4.7 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtSilverliningGroup.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2017 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 #include <vrvCore/DtCloudLayer.h>
33 
34 namespace SilverLining
35 {
36  class Atmosphere;
37  class CloudLayer;
38  class LocalTime;
39  class Location;
40 }
41 
42 namespace makVrv
43 {
44  class DtChannel;
45  class DtDe;
46  class DtOsgFogComponent;
47  class DtLightManagerGroup;
48  class DtOsgSkyObject;
49 
53  class DT_DLL_VRVOSG DtSilverliningGroup : public osg::Group
54  {
55  public:
56 
57  struct CloudLayer
58  {
59  unsigned int type;
60  unsigned int handle;
63  double density;
64  bool enabled;
65  bool realized;
66  bool infinite;
67  bool relative;
68  };
69  typedef std::vector<CloudLayer> CloudLayerList;
72 
74  virtual ~DtSilverliningGroup();
75 
76  DtDe& getDe() { return myDe; }
77 
79  virtual void setGenerateCubeMaps(bool enabled);
80 
82  void setCubeMapGenerationDistanceThreshold(double threshold);
83 
86  virtual unsigned int getCubeMap(const osg::ref_ptr<osg::Camera>& camera) const;
87 
90  virtual unsigned int getPrimaryCubeMap() const;
91 
92  virtual void installIntoChannel(DtChannel*);
93 
95  virtual void applyFog(osg::ref_ptr<osg::Camera> camera);
96 
98  virtual void deleteGeods();
99 
101  virtual void setGeocentricMode(bool mode);
102 
104  virtual bool geocentricMode() const;
105 
107  virtual void setHiResCumulus(bool enabled);
108 
110  virtual bool hiResCumulus() const;
111 
113  virtual void setLensFlare(bool enabled);
114 
116  virtual bool lensFlare() const;
117 
119  virtual void setCrepuscularRays(bool enabled);
120 
122  virtual bool crepuscularRays() const;
123 
125  virtual void setForcedMoonPhase(float phase);
126 
128  virtual void clearForcedMoonPhase();
129 
131  virtual bool moonPhaseIsForced() const;
132 
134  virtual float forcedMoonPhase() const;
135 
139  virtual void setForcedSunAndMoon(double sunLat, double sunLon, double moonLat,
140  double moonLon, bool horizonCoords = true);
141 
142  // Clear any forced sun & moon position set with ForceSunAndMoon()
143  virtual void clearForcedSunAndMoon();
144 
146  virtual bool sunAndMoonPositionIsForced() const;
147 
149  virtual void getForcedSunAndMoonPosition(double& sunLat, double& sunLon,
150  double& moonLat, double& moonLon, bool& horizonCoords) const;
151 
154  virtual void setLightPollution(double Wm2);
155 
157  virtual double lightPollution() const;
158 
160  virtual void setDateAndTime(unsigned short year, unsigned char month,
161  unsigned char day, unsigned char hour, unsigned char minutes,
162  double seconds, bool observeDaylightSavings);
163 
165  virtual void updateTime();
166 
169  virtual void setLocation(const DtVector& location);
170 
172  virtual void update(const osg::Matrix& m);
173 
175  virtual void update2D(const osg::Matrix& m);
176 
179  virtual void updateConditions(DtOsgSkyObject* skyObject);
180 
182  virtual int cloudLayerCount() const;
183 
185  virtual void removeCloudLayer(int index);
186 
189  virtual void setFogColor(const osg::Vec4f& rgbA);
190 
192  virtual void setFogHeight(float height);
193 
196  virtual void setFogBlend(const osg::Vec4f& rgbA, float density);
197 
199  virtual void setFogOverride(osg::ref_ptr<osg::Camera> camera, const osg::Vec4f& rgbA, float density);
200 
203  virtual void setFogThresholdDistance(float distance);
204 
206  virtual void setHorizonColor(const osg::Vec4f& rgbA);
207 
209  virtual void setCubeMapDirty();
210 
212  virtual void setUse16BitEnviroMap(bool flag);
213 
215  virtual bool getUse16BitEnviroMap();
216 
218  virtual void setUsingSensorFXShader(bool flag);
219 
221  virtual bool getUsingSensorFXShader();
222 
224  virtual void clearHorizonColor();
225 
227  virtual void clearFogOverride(osg::ref_ptr<osg::Camera> camera);
228 
229  virtual void clearFogOverrideForAllCameras(void);
230 
234  void setUseGlobalTimeZone(bool b);
235 
237  virtual bool useGlobalTimeZone() const;
238 
240  virtual float getSunAlpha() const;
241 
243  virtual void setDrawSunAndMoonIntoEnvMap(bool draw);
244 
246  virtual bool drawSunAndMoonIntoEnvMap() const;
247 
249  virtual float getSkyCoverage() const;
250 
252  virtual void addCirroCumulus(const DtVector& position, const DtVector& bounds, bool infinite, bool relative);
253  virtual void addCirrusFibratus(const DtVector& position, const DtVector& bounds, bool infinite, bool relative);
254  virtual void addNimbostratus(const DtVector& position, const DtVector& bounds, double density, bool infinite, bool relative);
255  virtual void addCumulusMediocris(const DtVector& position, const DtVector& bounds, double density, bool infinite, bool relative);
256  virtual void addCumulusCongestus(const DtVector& position, const DtVector& bounds, double density, bool infinite, bool relative);
257  virtual void addCumulonumbusCappilatus(const DtVector& position, const DtVector& bounds, double density, bool relative);
258  virtual void addStratocumulus(const DtVector& position, const DtVector& bounds, double density, bool infinite, bool relative);
259  virtual void setCloudLayerEnabled(int index, bool enabled);
260  virtual void setCloudLayerPosition(int index, double xCoord, double yCoord);
261 
262  virtual void setWind(double directionDEN, double minAltitude, double maxAltitude, double velocity);
263  virtual void setAirTurbidity(float turbidity);
264  virtual void setVisibleDistance(float distance);
265  virtual float getVisibleDistance() const;
266 
267  virtual void createAtmosphere();
268  virtual void destroyAtmosphere();
269 
270  // if create atmosphere failed this is set to true.
271  virtual bool getFailedInit() { return myFailedInit; }
272 
273  virtual void addRain(float mmPerHour, bool global);
274  virtual void addSleet(float mmPerHour, bool global);
275  virtual void addSnow(float mmPerHour, bool global, bool wet);
276  virtual void clearAllPrecipitation();
277 
278  virtual void realizeLayers();
279 
280  virtual SilverLining::Atmosphere* findAtmosphere();
281 
282  DtDe& getDtDe();
283 
284  //get the Julian Date and Time in the GMT time zone
285  virtual void getGMTDateTime(long &julianDate, double &GMTTod);
286 
287  //return the node that is the parent to the clouds
288  virtual osg::Node *getCloudsNode();
289 
290  //return the node that is the parent to the sky
291  virtual osg::Node *getSkyNode();
292 
293  //set the flag for drawing the silverlining sun/moon
294  virtual void setSunMoonEnabled(bool drawSunMoon);
295 
296  //get the flag for drawing the silverlining sun/moon
297  virtual bool getSunMoonEnabled();
298 
299  //set the flag for drawing the silverlining stars
300  virtual void setStarsEnabled(bool drawStars);
301 
302  //get the flag for drawing the silverlining stars
303  virtual bool getStarsEnabled();
304 
305  virtual void enableLighting(osg::ref_ptr<osg::Camera> camera, bool enable);
306 
309  void setEnableHDR(bool enable);
310 
312  virtual osg::LightSource *skyLight();
313 
314  virtual const CloudLayerList& cloudLayerList() const;
315 
316  virtual osg::Vec3f & getLastUpVector() { return myLastUpVector; }
317 
319  virtual bool updateVolumetricUniforms(osg::StateSet * stateSet);
320 
321  protected:
322 
324  virtual void addLayer(const CloudLayer& layer);
325 
327  virtual void realizeLayer(CloudLayer& layer);
328  virtual void destroyLayer(DtSilverliningGroup::CloudLayer& layer);
329 
330  virtual int CalculateZoneByLongitude(double longitude);
332  void SetTimeAndLocation();
333 
334  virtual void addPrecipitationToClouds(int type, float mmPerHour);
335 
336  virtual void updatePrecipitation();
337 
338  virtual void setCloudVisibility();
339 
341  virtual void traverse(osg::NodeVisitor& nv);
342  virtual void resetLayers();
343  virtual void forceResetLayers();
344 
345  virtual void generateCubeMap(const osg::Matrix& viewMatrix);
346 
348  virtual void slot_reloadShader();
349 
350 
351  protected:
352 
355 
356  DtReferenceEllipsoid myRefEllip;
357  DtGeodeticCoord myGeod;
358 
360  SilverLining::Atmosphere* myAtmosphere;
361  SilverLining::LocalTime* myLocalTime;
362  SilverLining::Location* myLocation;
363 
366 
367  osg::ref_ptr<osg::Geode> mySkyGeode;
368  osg::ref_ptr<osg::LightSource> mySkyLight;
369  osg::ref_ptr<osg::Geode> myCloudGeode;
370  osg::ref_ptr<DtLightManagerGroup> myLightManagerGroup;
371 
372  osg::Vec4f myFogColor, myBlendedFogColor, myHorizonColor;
373  osg::Vec3f myLastUpVector;
374 
377 
379  float myTurbidity;
397 
400 
401  typedef std::map<osg::ref_ptr<osg::Camera>, bool> FogOverrideMap;
402 
404  std::map<osg::ref_ptr<osg::Camera>, float> myFogOverrideDensityMap;
405  std::map<osg::ref_ptr<osg::Camera>, osg::Vec4f> myFogOverrideColorMap;
406 
407  osg::ref_ptr<osg::Uniform> myLightLevelUniform;
408  osg::ref_ptr<osg::Uniform> myLightAmbientUniform;
409 
410  float myFogHeight, myFogThresholdDistance;
411  float mySunAlpha;
413 
417 
419 
420  osg::ref_ptr<DtOsgFogComponent> myFogComponent;
422 
423  //default opengl compiled shaders needed for silver lining to work after sensorFX is installed
424  std::vector<unsigned int> myDefaultShaderVector;
425 
428 
430 
433 
436 
437 
438  };
439 
443  {
444 
445  public:
447  static DtSilverliningGroupCreator& instance(DtDe& theIG);
448 
450  static void registerInstance(DtDe& theIG, DtSilverliningGroupCreator* anInstance);
451 
453  virtual DtSilverliningGroup* create(DtDe&);
454  };
455 }
456 
457 

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)