VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtCloudDrawable.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvCore/DtDe.h>
13 #include <vrvOsg/vrvOsg.h>
14 
16 
17 #include <osg/Camera>
18 #include <osg/Drawable>
19 #include <map>
20 
21 namespace SilverLining
22 {
23  class Atmosphere;
24  class CloudLayer;
25 }
26 
27 namespace makVrv
28 {
29  class DtSilverliningGroup;
30  class DtGlRenderTexture;
31  class DtChannelManager;
32  class DtChannel;
33 
36  class DT_DLL_VRVOSG DtCloudDrawable : public osg::Drawable
37  {
38  public:
39 
41  {
42  CUBEMAP_CLEAN = 0
43  , CUBEMAP_RENDER = 1
44  , CUBEMAP_MIPMAP = 2
45  };
46 
47  struct CubeMapData
48  {
49  osg::Vec3d myLastUpdatePos;
50  unsigned int myID;
51  unsigned int myCurrentUpdateFace;
54  };
55 
56 
57  public:
58 
61 
63  DtCloudDrawable(const DtCloudDrawable& copy,const osg::CopyOp& op);
64 
66  virtual ~DtCloudDrawable();
67  public:
68 
70  META_Object(vrvOsg,DtCloudDrawable)
71 
72  virtual void releaseGLObjects(osg::State* state) const;
73 
75  virtual void slot_channelDestroyed(DtChannelManager* channelManager, DtChannel* channel);
76 
78  void setCrepuscularRays(bool enabled);
79 
81  void updateCubeMaps(bool fullRegenerate);
82 
84  unsigned int getCubeMap(const osg::ref_ptr<const osg::Camera> camera) const;
85 
87  unsigned int getPrimaryCubeMap() const;
88 
90  virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
91 
93  void setGeocentricMode(bool mode);
94 
97  virtual void cleanupCloudLayer(SilverLining::Atmosphere* atm, unsigned int layerHandle);
98 
99  protected:
100 
101  void fadeCloudsWithAltitude(double altitudeMSL, SilverLining::CloudLayer * layer);
102  void updateCloudAltitudes(const osg::Vec3d& localPosition, SilverLining::Atmosphere *atm);
103 
104  //helper functions for seting up the virtual program shaders and uniforms.
105  void updateShader(osg::Node *node, osg::State& state, SilverLining::Atmosphere *atm) const;
106  void updateOpenGLState(osg::State &state, SilverLining::Atmosphere *atm, osg::Camera *cam) const;
107  void setIsReflectionUniform(osg::State &state, SilverLining::Atmosphere* atm, bool isReflection) const;
108 
110  void connectSingals();
111 
113  void initUniforms();
114 
116  virtual void disconnectSignals();
117 
120  virtual void slot_environmentChanged(const std::string& name);
121 
122  bool computeHeightAboveTerrain(const osg::Vec3d& localPosition, double& heightOfGround);
123  void updateCloudLayerAltitudes(SilverLining::Atmosphere* atm);
124 
125  protected:
126 
129  virtual void updateDepthTexture(osg::RenderInfo& renderInfo) const;
130 
132  virtual void unbindDepthTexture(osg::RenderInfo& renderInfo) const;
133 
134  virtual void updateSoftnessAndSmoothCloudsFromImGui() const;
135 
136  virtual CubeMapData* getOrCreateCubeMapData(osg::Camera* camera, const osg::Vec3d& camPos) const;
137 
138  //variable for keeping the user shader list around so it can be deleted after new shaders are loaded.
139  mutable std::vector<unsigned int> myUserShaderVector;
140 
142  DtDe& myDe;
143 
144  bool myCrepuscularRays;
145  bool myGeocentricFlag;
146 
147  osg::Vec3d myLastHOTUpdatePos;
148  bool myForceHOTUpdate;
149  double myHOT;
150 
153  bool mySkipUpdateAltitudes;
154  std::map<SilverLining::CloudLayer *, double> myOriginalAltitudesMap;
155 
156  typedef std::map<osg::observer_ptr<const osg::Camera>, CubeMapData *> MapCameraToCubeMapData;
157  mutable MapCameraToCubeMapData myCubeMapDataMap;
158  virtual void flushInvalidCamerasForCubeMap(void);
159 
160  mutable unsigned int myMutableLastFrameNum;
161  mutable unsigned int myMutablePrimaryCubeMap;
162 
165  mutable osg::ref_ptr<osg::Uniform> myMutableSoftnessUniform;
166  mutable osg::ref_ptr<osg::Uniform> myMutableInvPersMatrixUniform;
167  mutable osg::ref_ptr<osg::Uniform> myMutablePersMatrixUniform;
168  mutable osg::ref_ptr<osg::Uniform> myMutableViewportUniform;
169  mutable osg::ref_ptr<osg::Uniform> myMutableIsReflectionUniform;
170  mutable osg::ref_ptr<osg::Uniform> myMutableViewMatrixInverseUniform;
171  mutable osg::ref_ptr<osg::Uniform> myMutableIsSunMoonDiskUniform;
172  mutable osg::ref_ptr<osg::Uniform> myMutableIsStarUniform;
173 
174  //cached pointer to stateset for this drawable
175  osg::ref_ptr<osg::StateSet> myStateSet;
176 
178  mutable bool myEnableSmoothClouds;
179  mutable float mySmoothCloudsDist;
180  mutable double myLastImGuiSimTime;
181 
182  unsigned long int myNextCameraID;
183  typedef std::map< osg::observer_ptr<const osg::Camera>, unsigned long int > MapOsgCamerasToEnvMapCameraIDs;
184  MapOsgCamerasToEnvMapCameraIDs myMapOsgCamerasToEnvMapCameraIDs;
185  virtual void flushInvalidCamerasForEnvMap(void);
186  virtual unsigned long int getOrCreateCameraHandleForEnvMap(const osg::RenderInfo& renderInfo);
187 
189  };
190 }
191 
192 
A drawable for drawing the cloud layer.
Definition: DtCloudDrawable.h:36
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Contains makVrv::DtDe class.
bool myNeedsFullRegen
Definition: DtCloudDrawable.h:53
A group node which adds a silver-lining sky and will light all Children with the proper lighting para...
Definition: DtSilverliningGroup.h:63
unsigned int myID
Definition: DtCloudDrawable.h:50
The abstract Channel Class.
Definition: DtChannel.h:29
unsigned int myCurrentUpdateFace
Definition: DtCloudDrawable.h:51
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:24
osg::Vec3d myLastUpdatePos
Definition: DtCloudDrawable.h:49
Definition: DtCloudDrawable.h:47
std::map< osg::observer_ptr< const osg::Camera >, unsigned long int > MapOsgCamerasToEnvMapCameraIDs
Definition: DtCloudDrawable.h:183
Base class for handling DtChannels.
Definition: DtChannelManager.h:35
std::map< osg::observer_ptr< const osg::Camera >, CubeMapData * > MapCameraToCubeMapData
Definition: DtCloudDrawable.h:156
Base class to provide boost signal/slot management.
CubeMapUpdateState myUpdateState
Definition: DtCloudDrawable.h:52
const char int mode
Definition: ioapi.h:38
Contains DLL export macros.
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
CubeMapUpdateState
Definition: DtCloudDrawable.h:40
Definition: vrfObjectManipulationHandlerBaseClass.h:67

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)