VR-Forces 5.0.1 Developer's Guide
 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/OperationThread>
21 #include <osg/Matrix>
22 #include <osg/Vec4>
23 
24 #include <vector>
25 
26 namespace osg
27 {
28  class State;
29  class Texture3D;
30  class Object;
31 }
32 
33 namespace makVrv
34 {
35  // Forward declarations.
36  class DtGlProgram;
38 
41 
43  template <>
44  inline const char* creatorTypeName<DtWeatherFogFroxelGrid>(void) { return "DtWeatherFogFroxelGridCreator"; }
45 
53  {
54  public:
55 
57 
58  // Inner class for generating a 3d texture containing voxel information
59  class FroxelGenerationJob : public osg::Operation
60  {
61  public:
63  FroxelGenerationJob(DtWeatherFogFroxelGrid& weatherFogFroxelGrid, DtDe& de);
64 
66  virtual ~FroxelGenerationJob();
67 
69  FroxelGenerationJob() = delete;
70 
73 
75  FroxelGenerationJob &operator=(const FroxelGenerationJob&) = delete;
76 
77  protected:
78 
80  virtual void operator () (osg::Object* sv);
81 
83  virtual void release();
84 
86  virtual DtGlProgram* genComputeProg();
87 
88  protected:
89 
92 
103  };
104 
105  public:
106 
108  virtual ~DtWeatherFogFroxelGrid();
109 
111  DtWeatherFogFroxelGrid() = delete;
112 
115 
117  DtWeatherFogFroxelGrid &operator=(const DtWeatherFogFroxelGrid&) = delete;
118 
119  protected:
120 
123 
124  public:
125 
127  // reload shaders is triggered reloads the shader changes if triggered from
128  // reload shaders but the texture is not reloaded off disk due to osgFileCache
129  virtual void initialize();
130 
132  virtual void releaseGLObjects(osg::State* state);
133 
139  virtual bool bindFogFroxelTexture(const int unit, const unsigned int renderContextId);
140 
143  virtual void resetVolumes();
144 
154  virtual void addVolume(const osg::Vec3d& position,
155  const osg::Matrixf& rotation, const float width, const float length,
156  const float height, const float density);
157 
159  virtual void updateForView(const osg::Matrixf& projMat, const osg::Matrixd& viewMat);
160 
162  virtual float maxGridDistance() const;
163 
164  protected:
165 
167  virtual FroxelGenerationJob* createJob();
168 
170  virtual void slot_reloadShaders();
171 
172  protected:
173 
175  struct Volume
176  {
178  : position(0,0,0)
179  , width(1)
180  , length(1)
181  , height(1)
182  , density(0)
183  {
184  // intentional noop
185  }
186 
187  osg::Vec3d position;
188  osg::Matrixf rotation;
189  float width;
190  float length;
191  float height;
192  float density;
193  };
194 
196 
198 
201 
203 
204  osg::Matrixf myProjMat;
205  osg::Matrixd myViewMat;
206 
207  std::vector<Volume*> myVolumes;
209 
211  };
212 
213 }
int myCubeDataUniformLoc
Definition: DtWeatherFogFroxelGrid.h:102
const char * creatorTypeName< DtWeatherFogFroxelGrid >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtWeatherFogFroxelGrid.h:44
int myViewInvMatUniformLoc
Definition: DtWeatherFogFroxelGrid.h:98
DtVirtualBaseClassCreator< DtWeatherFogFroxelGrid > DtWeatherFogFroxelGridCreator
creator
Definition: DtWeatherFogFroxelGrid.h:37
float width
Definition: DtWeatherFogFroxelGrid.h:189
The DtOsgRenderer is the component responsible for rendering 3D images onto the screen via OpenSceneG...
Definition: DtOsgRenderer.h:87
Virtual base class. Allows for RTTI and proper virtual destruction. Used by Creators, Factories, Providers, Assemblers and User Interfaces.
Definition: DtVirtualBaseClass.h:19
float length
Definition: DtWeatherFogFroxelGrid.h:190
DtOsgRenderer & myOsgRenderer
Definition: DtWeatherFogFroxelGrid.h:197
Definition: DtWeatherFogFroxelGrid.h:59
osg::Matrixd myViewMat
Definition: DtWeatherFogFroxelGrid.h:205
float height
Definition: DtWeatherFogFroxelGrid.h:191
osg::ref_ptr< FroxelGenerationJob > myFroxelGenerationJob
Definition: DtWeatherFogFroxelGrid.h:202
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
osg::ref_ptr< osg::Texture3D > myVoxelTexture
Definition: DtWeatherFogFroxelGrid.h:200
DtDe & myDe
Definition: DtWeatherFogFroxelGrid.h:195
int myBoxPosUniformLoc
Definition: DtWeatherFogFroxelGrid.h:99
Volume()
Definition: DtWeatherFogFroxelGrid.h:177
osg::Matrixf rotation
Definition: DtWeatherFogFroxelGrid.h:188
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:95
int myProjInvMatUniformLoc
Definition: DtWeatherFogFroxelGrid.h:97
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:22
int myBoxRotUniformLoc
Definition: DtWeatherFogFroxelGrid.h:100
float density
Definition: DtWeatherFogFroxelGrid.h:192
DtWeatherFogFroxelGrid & myWeatherFogFroxelGrid
Definition: DtWeatherFogFroxelGrid.h:91
Contains makVrv::DtVirtualBaseClass class.
DtGlProgram * myComputeProgram
Definition: DtWeatherFogFroxelGrid.h:93
osg::Vec3d position
Definition: DtWeatherFogFroxelGrid.h:187
DtWeatherFogFroxelGrid uses a frustum voxel grid to compute density/translucency at voxel locations b...
Definition: DtWeatherFogFroxelGrid.h:52
DtDe & myDe
Definition: DtWeatherFogFroxelGrid.h:90
std::vector< Volume * > myVolumes
Definition: DtWeatherFogFroxelGrid.h:207
GLuint myVoxelTextureId
Definition: DtWeatherFogFroxelGrid.h:199
int myActiveVolumes
Definition: DtWeatherFogFroxelGrid.h:208
int myOutputTextureUniformLoc
Definition: DtWeatherFogFroxelGrid.h:94
int myProjMatUniformLoc
Definition: DtWeatherFogFroxelGrid.h:96
A structure used to define a volume (bounds, transform, density).
Definition: DtWeatherFogFroxelGrid.h:175
Contains DLL export macros.
int myBoxSizeUniformLoc
Definition: DtWeatherFogFroxelGrid.h:101
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:70
Contains makVrv::DtOsgRenderer class.
float myMaxGridDistance
Definition: DtWeatherFogFroxelGrid.h:210
osg::Matrixf myProjMat
Definition: DtWeatherFogFroxelGrid.h:204
friend DtWeatherFogFroxelGridCreator
Definition: DtWeatherFogFroxelGrid.h:56

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)