VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtWeatherFogFroxelGrid.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2021 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 #include <vrvOsg/DtOsgRenderer.h>
14 
16 
18 
19 #include <osg/ref_ptr>
20 #include <osg/Texture3D>
21 #include <osg/Matrix>
22 #include <osg/OperationThread>
23 #include <osg/Vec4>
24 
25 #include <vector>
26 
27 namespace makVrv
28 {
29  // Forward declarations.
30  class DtGlProgram;
32 
35 
37  template <>
38  inline const char* creatorTypeName<DtWeatherFogFroxelGrid>(void) { return "DtWeatherFogFroxelGridCreator"; }
39 
47  {
48  public:
49 
51 
52  // Inner class for generating a 3d texture containing voxel information
53  class FroxelGenerationJob : public osg::Operation
54  {
55  public:
57  FroxelGenerationJob(DtWeatherFogFroxelGrid& weatherFogFroxelGrid, DtDe& de);
58 
60  virtual ~FroxelGenerationJob();
61 
63  FroxelGenerationJob() = delete;
64 
67 
69  FroxelGenerationJob &operator=(const FroxelGenerationJob&) = delete;
70 
71  protected:
72 
74  virtual void operator () (osg::Object* sv);
75 
77  virtual void release();
78 
80  virtual DtGlProgram* genComputeProg();
81 
82  protected:
83 
86 
97  };
98 
99  public:
100 
102  virtual ~DtWeatherFogFroxelGrid();
103 
105  DtWeatherFogFroxelGrid() = delete;
106 
109 
111  DtWeatherFogFroxelGrid &operator=(const DtWeatherFogFroxelGrid&) = delete;
112 
113  protected:
114 
117 
118  public:
119 
121  // reload shaders is triggered reloads the shader changes if triggered from
122  // reload shaders but the texture is not reloaded off disk due to osgFileCache
123  virtual void initialize();
124 
126  virtual void releaseGLObjects(osg::State* state);
127 
133  virtual bool bindFogFroxelTexture(const int unit, const unsigned int renderContextId);
134 
137  virtual void resetVolumes();
138 
148  virtual void addVolume(const osg::Vec3d& position,
149  const osg::Matrixf& rotation, const float width, const float length,
150  const float height, const float density);
151 
153  virtual void updateForView(const osg::Matrixf& projMat, const osg::Matrixd& viewMat);
154 
156  virtual float maxGridDistance() const;
157 
158  protected:
159 
161  virtual FroxelGenerationJob* createJob();
162 
164  virtual void slot_reloadShaders();
165 
166  protected:
167 
169  struct Volume
170  {
172  : position(0,0,0)
173  , width(1)
174  , length(1)
175  , height(1)
176  , density(0)
177  {
178  // intentional noop
179  }
180 
181  osg::Vec3d position;
182  osg::Matrixf rotation;
183  float width;
184  float length;
185  float height;
186  float density;
187  };
188 
190 
192 
195 
197 
198  osg::Matrixf myProjMat;
199  osg::Matrixd myViewMat;
200 
201  std::vector<Volume*> myVolumes;
203 
205  };
206 
207 }
int myCubeDataUniformLoc
Definition: DtWeatherFogFroxelGrid.h:96
const char * creatorTypeName< DtWeatherFogFroxelGrid >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtWeatherFogFroxelGrid.h:38
int myViewInvMatUniformLoc
Definition: DtWeatherFogFroxelGrid.h:92
DtVirtualBaseClassCreator< DtWeatherFogFroxelGrid > DtWeatherFogFroxelGridCreator
creator
Definition: DtWeatherFogFroxelGrid.h:31
float width
Definition: DtWeatherFogFroxelGrid.h:183
The DtOsgRenderer is the component responsible for rendering 3D images onto the screen via OpenSceneG...
Definition: DtOsgRenderer.h:90
Virtual base class.
Definition: DtVirtualBaseClass.h:19
float length
Definition: DtWeatherFogFroxelGrid.h:184
DtOsgRenderer & myOsgRenderer
Definition: DtWeatherFogFroxelGrid.h:191
Definition: DtWeatherFogFroxelGrid.h:53
osg::Matrixd myViewMat
Definition: DtWeatherFogFroxelGrid.h:199
float height
Definition: DtWeatherFogFroxelGrid.h:185
osg::ref_ptr< FroxelGenerationJob > myFroxelGenerationJob
Definition: DtWeatherFogFroxelGrid.h:196
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
osg::ref_ptr< osg::Texture3D > myVoxelTexture
Definition: DtWeatherFogFroxelGrid.h:194
DtDe & myDe
Definition: DtWeatherFogFroxelGrid.h:189
int myBoxPosUniformLoc
Definition: DtWeatherFogFroxelGrid.h:93
Volume()
Definition: DtWeatherFogFroxelGrid.h:171
osg::Matrixf rotation
Definition: DtWeatherFogFroxelGrid.h:182
unsigned int GLuint
Definition: DtGlTextureBufferObject.h:17
A convenience class to represent an OpenGL Shader Program.
Definition: DtGlProgram.h:65
int myReverseZUniformLoc
Definition: DtWeatherFogFroxelGrid.h:89
int myProjInvMatUniformLoc
Definition: DtWeatherFogFroxelGrid.h:91
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:22
int myBoxRotUniformLoc
Definition: DtWeatherFogFroxelGrid.h:94
float density
Definition: DtWeatherFogFroxelGrid.h:186
DtWeatherFogFroxelGrid & myWeatherFogFroxelGrid
Definition: DtWeatherFogFroxelGrid.h:85
Contains makVrv::DtVirtualBaseClass class.
DtGlProgram * myComputeProgram
Definition: DtWeatherFogFroxelGrid.h:87
osg::Vec3d position
Definition: DtWeatherFogFroxelGrid.h:181
DtWeatherFogFroxelGrid uses a frustum voxel grid to compute density/translucency at voxel locations b...
Definition: DtWeatherFogFroxelGrid.h:46
DtDe & myDe
Definition: DtWeatherFogFroxelGrid.h:84
std::vector< Volume * > myVolumes
Definition: DtWeatherFogFroxelGrid.h:201
GLuint myVoxelTextureId
Definition: DtWeatherFogFroxelGrid.h:193
int myActiveVolumes
Definition: DtWeatherFogFroxelGrid.h:202
int myOutputTextureUniformLoc
Definition: DtWeatherFogFroxelGrid.h:88
int myProjMatUniformLoc
Definition: DtWeatherFogFroxelGrid.h:90
A structure used to define a volume (bounds, transform, density).
Definition: DtWeatherFogFroxelGrid.h:169
Contains DLL export macros.
int myBoxSizeUniformLoc
Definition: DtWeatherFogFroxelGrid.h:95
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
Contains makVrv::DtOsgRenderer class.
float myMaxGridDistance
Definition: DtWeatherFogFroxelGrid.h:204
osg::Matrixf myProjMat
Definition: DtWeatherFogFroxelGrid.h:198
friend DtWeatherFogFroxelGridCreator
Definition: DtWeatherFogFroxelGrid.h:50

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)