VR-Forces 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) 2023 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 #include <vrvOsg/DtGpuOperation.h>
15 
19 
20 #include <osg/ref_ptr>
21 #include <osg/OperationThread>
22 #include <osg/Matrix>
23 #include <osg/Vec4>
24 
25 #include <vector>
26 
27 namespace osg
28 {
29  class State;
30  class Texture3D;
31  class Object;
32 }
33 
34 namespace makVrv
35 {
36  // Forward declarations.
37  class DtGlProgram;
38  class DtWeatherFogFroxelGrid;
39  class DtIndirectTexturePrototype;
40  class DtIndirectGlTextureObject;
42 
45 
47  template <>
48  inline const char* creatorTypeName<DtWeatherFogFroxelGrid>(void) { return "DtWeatherFogFroxelGridCreator"; }
49 
57  {
58  public:
59 
61 
62  // Inner class for generating a 3d texture containing voxel information
64  {
65  public:
67  FroxelGenerationOp(DtWeatherFogFroxelGrid& weatherFogFroxelGrid, DtDe& de);
68 
70  virtual ~FroxelGenerationOp();
71 
73  FroxelGenerationOp() = delete;
74 
76  FroxelGenerationOp(const FroxelGenerationOp&) = delete;
77 
79  FroxelGenerationOp &operator=(const FroxelGenerationOp&) = delete;
80  public:
82  virtual void execute(void) override;
83  protected:
85  virtual DtGlProgram* genComputeProg();
86 
87  protected:
88 
91 
102  };
103 
104  public:
105 
107  virtual ~DtWeatherFogFroxelGrid();
108 
110  DtWeatherFogFroxelGrid() = delete;
111 
114 
116  DtWeatherFogFroxelGrid &operator=(const DtWeatherFogFroxelGrid&) = delete;
117 
118  protected:
119 
122 
123  public:
124 
126  // reload shaders is triggered reloads the shader changes if triggered from
127  // reload shaders but the texture is not reloaded off disk due to osgFileCache
128  virtual void initialize();
129 
131  virtual void releaseGLObjects(osg::State* state);
132 
138  virtual bool bindFogFroxelTexture(const int unit, const unsigned int renderContextId);
139 
142  virtual void resetVolumes();
143 
153  virtual void addVolume(const osg::Vec3d& position,
154  const osg::Matrixf& rotation, const float width, const float length,
155  const float height, const float density);
156 
158  virtual void updateForView(const osg::Matrixf& projMat, const osg::Matrixd& viewMat);
159 
161  virtual float maxGridDistance() const;
162 
163  protected:
164 
166  virtual FroxelGenerationOp* createOp();
167 
169  virtual void slot_reloadShaders();
170 
171  protected:
172 
174  struct Volume
175  {
177  : position(0,0,0)
178  , width(1)
179  , length(1)
180  , height(1)
181  , density(0)
182  {
183  // intentional noop
184  }
185 
186  osg::Vec3d position;
187  osg::Matrixf rotation;
188  float width;
189  float length;
190  float height;
191  float density;
192  };
193 
195 
197 
198  const DtIndirectTexturePrototype* myVoxelTexturePrototype = nullptr;
199  DtIndirectGlTextureObject* myVoxelTextureObject = nullptr;
200 
202 
203  FroxelGenerationOp* myFroxelGenerationOp = nullptr;
204 
205  osg::Matrixf myProjMat;
206  osg::Matrixd myViewMat;
207 
208  std::vector<Volume*> myVolumes;
210 
212 
214  };
215 
216 }
int myViewInvMatUniformLoc
Definition: DtWeatherFogFroxelGrid.h:97
const char * creatorTypeName< DtWeatherFogFroxelGrid >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtWeatherFogFroxelGrid.h:48
DtVirtualBaseClassCreator< DtWeatherFogFroxelGrid > DtWeatherFogFroxelGridCreator
creator
Definition: DtWeatherFogFroxelGrid.h:41
float width
Definition: DtWeatherFogFroxelGrid.h:188
The DtOsgRenderer is the component responsible for rendering 3D images onto the screen via OpenSceneG...
Definition: DtOsgRenderer.h:92
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:189
DtOsgRenderer & myOsgRenderer
Definition: DtWeatherFogFroxelGrid.h:196
osg::Matrixd myViewMat
Definition: DtWeatherFogFroxelGrid.h:206
double length(const dvec3 &theVec)
Definition: DtVecUtils.h:20
float height
Definition: DtWeatherFogFroxelGrid.h:190
int myProjMatUniformLoc
Definition: DtWeatherFogFroxelGrid.h:95
Encapsulate an OpenGL texture object that is created/used in indirect rendering.
Definition: DtIndirectGlTextureObject.h:36
Abstract base for any operation that runs on the GPU via DtGpuArena.
Definition: DtGpuOperation.h:30
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
DtIndirectGlTextureObjectManager & myIndirectGlTextureObjectManager
Definition: DtWeatherFogFroxelGrid.h:201
int myReverseZUniformLoc
Definition: DtWeatherFogFroxelGrid.h:94
DtDe & myDe
Definition: DtWeatherFogFroxelGrid.h:194
This manager manages the lifetime of the actual gl texture objects (gl unsigned ints) in the indirect...
Definition: DtIndirectGlTextureObjectManager.h:61
Volume()
Definition: DtWeatherFogFroxelGrid.h:176
osg::Matrixf rotation
Definition: DtWeatherFogFroxelGrid.h:187
A convenience class to represent an OpenGL Shader Program.
Definition: DtGlProgram.h:66
DtWeatherFogFroxelGrid & myWeatherFogFroxelGrid
Definition: DtWeatherFogFroxelGrid.h:90
Contains the DtGpuOperation class declaration.
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:23
float density
Definition: DtWeatherFogFroxelGrid.h:191
Contains makVrv::DtVirtualBaseClass class.
int myBoxSizeUniformLoc
Definition: DtWeatherFogFroxelGrid.h:100
Definition: DtWeatherFogFroxelGrid.h:63
DtSignalConnectionManager myConnections
Definition: DtWeatherFogFroxelGrid.h:213
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
int myOutputTextureUniformLoc
Definition: DtWeatherFogFroxelGrid.h:93
osg::Vec3d position
Definition: DtWeatherFogFroxelGrid.h:186
DtWeatherFogFroxelGrid uses a frustum voxel grid to compute density/translucency at voxel locations b...
Definition: DtWeatherFogFroxelGrid.h:56
std::vector< Volume * > myVolumes
Definition: DtWeatherFogFroxelGrid.h:208
Base class to provide boost signal/slot management.
int myActiveVolumes
Definition: DtWeatherFogFroxelGrid.h:209
int myBoxRotUniformLoc
Definition: DtWeatherFogFroxelGrid.h:99
A structure used to define a volume (bounds, transform, density).
Definition: DtWeatherFogFroxelGrid.h:174
Contains DLL export macros.
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:76
VRV/Indirect uses its own texture paradigm: DtIndirectTexturePrototype, which is a &#39;template&#39; for mak...
Definition: DtIndirectTexturePrototype.h:53
int myCubeDataUniformLoc
Definition: DtWeatherFogFroxelGrid.h:101
Contains makVrv::DtOsgRenderer class.
int myProjInvMatUniformLoc
Definition: DtWeatherFogFroxelGrid.h:96
int myBoxPosUniformLoc
Definition: DtWeatherFogFroxelGrid.h:98
float myMaxGridDistance
Definition: DtWeatherFogFroxelGrid.h:211
osg::Matrixf myProjMat
Definition: DtWeatherFogFroxelGrid.h:205
friend DtWeatherFogFroxelGridCreator
Definition: DtWeatherFogFroxelGrid.h:60
DtGlProgram * myComputeProgram
Definition: DtWeatherFogFroxelGrid.h:92
DtDe & myDe
Definition: DtWeatherFogFroxelGrid.h:89

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)