VR-Forces 4.3.1 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 #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 addCirroCumulus(const DtVector& position, const DtVector& bounds, bool infinite, bool relative);
226  void addCirrusFibratus(const DtVector& position, const DtVector& bounds, bool infinite, bool relative);
227  void addNimbostratus(const DtVector& position, const DtVector& bounds,double density, bool infinite, bool relative);
228  void addCumulusMediocris(const DtVector& position, const DtVector& bounds,double density, bool infinite, bool relative);
229  void addCumulusCongestus(const DtVector& position, const DtVector& bounds,double density, bool infinite, bool relative);
230  void addCumulonumbusCappilatus(const DtVector& position, const DtVector& bounds,double density, bool relative);
231  void addStratocumulus(const DtVector& position, const DtVector& bounds, double density, bool infinite, bool relative);
232  void setCloudLayerEnabled(int index, bool enabled);
233  void setCloudLayerPosition(int index, double xCoord, double yCoord);
234 
235  void setWind(double directionDEN,double minAltitude, double maxAltitude,double velocity);
236  void setAirTurbidity( float turbidity );
237  void setVisibleDistance( float distance );
238  float getVisibleDistance() const;
239 
240  void createAtmosphere();
241  void destroyAtmosphere();
242 
243  void addRain(float mmPerHour, bool global);
244  void addSleet(float mmPerHour, bool global);
245  void addSnow(float mmPerHour, bool global, bool wet);
246  void clearAllPrecipitation();
247 
248  void realizeLayers();
249 
250  SilverLining::Atmosphere* findAtmosphere();
251 
252  DtDe& getDtDe();
253 
254  //get the Julian Date and Time in the GMT time zone
255  void getGMTDateTime(long &julianDate, double &GMTTod);
256 
257  //return the node that is the parent to the clouds
258  osg::Node *getCloudsNode();
259 
260  //return the node that is the parent to the sky
261  osg::Node *getSkyNode();
262 
263  //return the default shader vector being used for the atmosphere user functions
264  std::vector<unsigned int> getDefaultShaderVector();
265 
266  //set the flag for drawing the silverlining sun/moon
267  void setSunMoonEnabled(bool drawSunMoon);
268 
269  //get the flag for drawing the silverlining sun/moon
270  bool getSunMoonEnabled();
271 
272  //set the flag for drawing the silverlining stars
273  void setStarsEnabled(bool drawStars);
274 
275  //get the flag for drawing the silverlining stars
276  bool getStarsEnabled();
277 
278  void enableLighting(osg::ref_ptr<osg::Camera> camera, bool enable);
279 
280  protected:
281 
282  struct CloudLayer
283  {
284  unsigned int type;
285  unsigned int handle;
288  double density;
289  bool enabled;
290  bool realized;
291  bool infinite;
292  bool relative;
293  };
294 
296  void addLayer( const CloudLayer& layer );
297 
299  void realizeLayer( CloudLayer& layer );
300  void destroyLayer( DtSilverliningGroup::CloudLayer& layer );
301 
302  int CalculateZoneByLongitude(double longitude);
303  void SetTimeAndLocation();
304 
305  void addPrecipitationToClouds(int type, float mmPerHour);
306 
307  void updatePrecipitation();
308 
309  void setCloudVisibility();
310 
312  virtual void traverse(osg::NodeVisitor& nv);
313  void resetLayers();
314  void forceResetLayers();
315 
316  void generateCubeMap( const osg::Matrix& viewMatrix );
317 
318  protected:
319 
320  typedef std::vector<CloudLayer> CloudLayerList;
321 
323  mutable OpenThreads::Mutex myMutex;
324 
325  DtReferenceEllipsoid myRefEllip;
326  DtGeodeticCoord myGeod;
327 
329  SilverLining::Atmosphere* myAtmosphere;
330  SilverLining::LocalTime* myLocalTime;
331  SilverLining::Location* myLocation;
332 
335 
336  osg::ref_ptr<osg::Geode> mySkyGeod;
337  osg::ref_ptr<osg::LightSource> mySkyLight;
338  osg::ref_ptr<osg::Geode> myCloudGeod;
339  osg::ref_ptr<DtLightManagerGroup> myLightManagerGroup;
340 
341  osg::Vec4f myFogColor, myBlendedFogColor, myHorizonColor;
344 
346  float myTurbidity;
363 
366 
367  typedef std::map<osg::ref_ptr<osg::Camera>, bool> FogOverrideMap;
368 
370  std::map<osg::ref_ptr<osg::Camera>, float> myFogOverrideDensityMap;
371  std::map<osg::ref_ptr<osg::Camera>, osg::Vec4f> myFogOverrideColorMap;
372 
373  osg::ref_ptr<osg::Uniform> myLightLevelUniform;
374 
375  float myFogHeight, myFogThresholdDistance;
376  float mySunAlpha;
378 
382 
384 
385  osg::ref_ptr<DtOsgFogComponent> myFogComponent;
387 
388  //default opengl compiled shaders needed for silver lining to work after sensorFX is installed
389  std::vector<unsigned int> myDefaultShaderVector;
390 
393 
395 
397  };
398 
402  {
403 
404  public:
406  static DtSilverliningGroupCreator& instance(DtDe& theIG);
407 
409  static void registerInstance(DtDe& theIG,DtSilverliningGroupCreator* anInstance);
410 
412  virtual DtSilverliningGroup* create(DtDe&);
413  };
414 }
415 
416 

Document ID: Generated on Wed Jul 29 00:55:00 EDT 2015 from SVN revision 155257
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)