VR-Forces 4.5 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  float getSkyCoverage() const;
232 
234  void addCirroCumulus(const DtVector& position, const DtVector& bounds, bool infinite, bool relative);
235  void addCirrusFibratus(const DtVector& position, const DtVector& bounds, bool infinite, bool relative);
236  void addNimbostratus(const DtVector& position, const DtVector& bounds,double density, bool infinite, bool relative);
237  void addCumulusMediocris(const DtVector& position, const DtVector& bounds,double density, bool infinite, bool relative);
238  void addCumulusCongestus(const DtVector& position, const DtVector& bounds,double density, bool infinite, bool relative);
239  void addCumulonumbusCappilatus(const DtVector& position, const DtVector& bounds,double density, bool relative);
240  void addStratocumulus(const DtVector& position, const DtVector& bounds, double density, bool infinite, bool relative);
241  void setCloudLayerEnabled(int index, bool enabled);
242  void setCloudLayerPosition(int index, double xCoord, double yCoord);
243 
244  void setWind(double directionDEN,double minAltitude, double maxAltitude,double velocity);
245  void setAirTurbidity( float turbidity );
246  void setVisibleDistance( float distance );
247  float getVisibleDistance() const;
248 
249  void createAtmosphere();
250  void destroyAtmosphere();
251 
252  // if create atmosphere failed this is set to true.
253  bool getFailedInit(){ return myFailedInit; }
254 
255  void addRain(float mmPerHour, bool global);
256  void addSleet(float mmPerHour, bool global);
257  void addSnow(float mmPerHour, bool global, bool wet);
258  void clearAllPrecipitation();
259 
260  void realizeLayers();
261 
262  SilverLining::Atmosphere* findAtmosphere();
263 
264  DtDe& getDtDe();
265 
266  //get the Julian Date and Time in the GMT time zone
267  void getGMTDateTime(long &julianDate, double &GMTTod);
268 
269  //return the node that is the parent to the clouds
270  osg::Node *getCloudsNode();
271 
272  //return the node that is the parent to the sky
273  osg::Node *getSkyNode();
274 
275  //return the default shader vector being used for the atmosphere user functions
276  std::vector<unsigned int> getDefaultShaderVector();
277 
278  //set the flag for drawing the silverlining sun/moon
279  void setSunMoonEnabled(bool drawSunMoon);
280 
281  //get the flag for drawing the silverlining sun/moon
282  bool getSunMoonEnabled();
283 
284  //set the flag for drawing the silverlining stars
285  void setStarsEnabled(bool drawStars);
286 
287  //get the flag for drawing the silverlining stars
288  bool getStarsEnabled();
289 
290  void enableLighting(osg::ref_ptr<osg::Camera> camera, bool enable);
291 
293  virtual void setEnableHDR(bool enable);
294 
296  virtual osg::LightSource *skyLight();
297 
298  protected:
299 
300  struct CloudLayer
301  {
302  unsigned int type;
303  unsigned int handle;
306  double density;
307  bool enabled;
308  bool realized;
309  bool infinite;
310  bool relative;
311  };
312 
314  void addLayer( const CloudLayer& layer );
315 
317  void realizeLayer( CloudLayer& layer );
318  void destroyLayer( DtSilverliningGroup::CloudLayer& layer );
319 
320  int CalculateZoneByLongitude(double longitude);
321  void SetTimeAndLocation();
322 
323  void addPrecipitationToClouds(int type, float mmPerHour);
324 
325  void updatePrecipitation();
326 
327  void setCloudVisibility();
328 
330  virtual void traverse(osg::NodeVisitor& nv);
331  void resetLayers();
332  void forceResetLayers();
333 
334  void generateCubeMap( const osg::Matrix& viewMatrix );
335 
337  virtual void slot_reloadShader();
338 
339  protected:
340 
341  typedef std::vector<CloudLayer> CloudLayerList;
342 
344  mutable OpenThreads::Mutex myMutex;
345 
346  DtReferenceEllipsoid myRefEllip;
347  DtGeodeticCoord myGeod;
348 
350  SilverLining::Atmosphere* myAtmosphere;
351  SilverLining::LocalTime* myLocalTime;
352  SilverLining::Location* myLocation;
353 
356 
357  osg::ref_ptr<osg::Geode> mySkyGeod;
358  osg::ref_ptr<osg::LightSource> mySkyLight;
359  osg::ref_ptr<osg::Geode> myCloudGeod;
360  osg::ref_ptr<DtLightManagerGroup> myLightManagerGroup;
361 
362  osg::Vec4f myFogColor, myBlendedFogColor, myHorizonColor;
365 
367  float myTurbidity;
385 
388 
389  typedef std::map<osg::ref_ptr<osg::Camera>, bool> FogOverrideMap;
390 
392  std::map<osg::ref_ptr<osg::Camera>, float> myFogOverrideDensityMap;
393  std::map<osg::ref_ptr<osg::Camera>, osg::Vec4f> myFogOverrideColorMap;
394 
395  osg::ref_ptr<osg::Uniform> myLightLevelUniform;
396  osg::ref_ptr<osg::Uniform> myLightAmbientUniform;
397 
398  float myFogHeight, myFogThresholdDistance;
399  float mySunAlpha;
401 
405 
407 
408  osg::ref_ptr<DtOsgFogComponent> myFogComponent;
410 
411  //default opengl compiled shaders needed for silver lining to work after sensorFX is installed
412  std::vector<unsigned int> myDefaultShaderVector;
413 
416 
418 
421 
423  };
424 
428  {
429 
430  public:
432  static DtSilverliningGroupCreator& instance(DtDe& theIG);
433 
435  static void registerInstance(DtDe& theIG,DtSilverliningGroupCreator* anInstance);
436 
438  virtual DtSilverliningGroup* create(DtDe&);
439  };
440 }
441 
442 

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)