VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtWeatherPrecipitationShaft.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2022 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvCore/DtDe.h>
13 #include <vrvCore/DtJobSplitter.h>
14 
16 
17 #include <vrvOsg/DtGlVaoManager.h>
18 #include <vrvOsg/vrvOsg.h>
19 
22 
23 #include <matrix/vlVector.h>
24 
25 #include <osg/Vec3d>
26 #include <osg/Vec4d>
27 #include <osg/Array>
28 #include <osg/Matrixd>
29 #include <osg/ref_ptr>
30 
31 namespace osg
32 {
33  class RenderInfo;
34  class StateSet;
35 }
36 
37 namespace makVrv
38 {
39  // Forward declarations.
40  class DtJobSplitter;
41  class DtWeatherArea;
42  class DtWeatherAreaGroup;
43  class DtGlBuffer;
44 
47 
50 
52  template <>
53  inline const char* creatorTypeName<DtWeatherPrecipitationShaft>(void) { return "DtWeatherPrecipitationShaftCreator"; }
54 
55 
64  {
66 
67  public:
68 
70  struct DrawData
71  {
73  : myRenderInfo(0)
74  , myCamPos(0, 0, 0)
75  , myParametersUnfmLoc(0)
76  , myTransformUnfmLoc(0)
77  , myBoxUnfmLoc(0)
78  , myWeatherAreaGroup(0)
79  , myState(0)
80  {
81  // intentional nop
82  }
83 
84  osg::RenderInfo* myRenderInfo;
85  osg::Vec3d myCamPos;
86  osg::Matrixd myViewMatrix;
91  osg::StateSet* myState;
92  };
93 
95  virtual ~DtWeatherPrecipitationShaft();
96 
98  DtWeatherPrecipitationShaft() = delete;
99 
102 
104  DtWeatherPrecipitationShaft &operator=(const DtWeatherPrecipitationShaft &other) = delete;
105 
106  protected:
107 
110 
111  public:
112 
114  virtual void init();
115 
117  virtual void releaseGLObjects(osg::State* state) const;
118 
125  virtual bool cullUpdate(const osg::Vec3d& camPos, const osg::Matrixd& viewMatrixI,
126  const Frustum_64& frustum, DtJobSplitter* jobSplitter);
127 
130  virtual bool isPositionAboveArea(const osg::Vec3d& position);
131 
133  virtual void draw(DtWeatherPrecipitationShaft::DrawData& drawData);
134 
138  virtual void setBounds(const DtVector& bounds, float cornerRadius);
139 
143  virtual void setTransform(const osg::Vec3d& position, const osg::Matrixd& rotation);
144 
147  virtual void setIntensity(const float intensity);
148 
151  virtual void setBaseColor(const DtVector& color);
152 
156  virtual void setWind(const float windDirectionRad, const float windSpeedMps);
157 
160  virtual void runSort(const osg::Vec3f& localCamPos);
161 
164  virtual void setEnabled(bool enabled);
165 
167  virtual bool enabled() const;
168 
172  virtual bool culled() const;
173 
178  virtual void computeBounds(osg::Vec4f& bounds, osg::Vec3d& position, osg::Matrixd& rotation) const;
179 
180  protected:
181 
183  struct MeshGroup
184  {
186  : myVboPositionArray(0)
187  , myVboTexCoords0Array(0)
188  , myVboIndicesArray(0)
189  , myIndices(0)
190  , myIndicesCount(0)
191  {
192  myPoints = new osg::Vec4Array;
193  myTexCoords0 = new osg::Vec2Array;
194  }
195 
198  unsigned short* myIndices;
199  unsigned int myIndicesCount;
200 
201  DtGlBuffer* myVboPositionArray = nullptr;
202  DtGlBuffer* myVboTexCoords0Array = nullptr;
203  DtGlBuffer* myVboIndicesArray = nullptr;
204  };
205 
207  struct Particle
208  {
210  : mySortDepth(0)
211  , myPosition(0, 0, 0, 0)
212  {
213  //intentional nop
214  }
215 
216  float mySortDepth;
217  osg::Vec4f myPosition;
218  };
219 
225  virtual bool positionInBounds2D(const float x, const float y, const osg::Vec3f& bounds);
226 
230  virtual float computeRandomMinMax(float fMin, float fMax);
231 
234  virtual void computeSortDepth(const osg::Vec3f& reference);
235 
237  virtual void fillSortedParticles();
238 
242  virtual bool bindMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
243 
247  virtual bool bindDynamicMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
248 
253  virtual bool bindVaoToMeshGroup(GLuint vao, MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
254 
255  protected:
256 
258  static int theSortBackToFront(const void* arg0, const void* arg1);
259 
261  static void theSortJob(void* data);
262 
263  protected:
264 
266  struct SortJobData
267  {
269  : myWeatherPrecipitationShaft(0)
270  , myLocalCameraPos(0, 0, 0)
271  {
272  //intentional nop
273  }
274 
276  osg::Vec3f myLocalCameraPos;
277  };
278 
280 
281  bool myEnabled;
282  bool myCulled;
283 
286 
287  osg::Vec3d myPosition;
288  osg::Matrixd myRotation;
289 
290  float myBoundsX;
291  float myBoundsY;
292  float myBoundsZ;
294 
296 
297  float myIntensity;
298  osg::Vec3f myBaseColor;
299 
300  Particle* myParticles; // memory pool of particles
301  int myParticlePoolCount; // the number of particles in the memory pool
302  int myParticleActiveCount; // number of active particles
303 
306 
308  unsigned int myRandomSeed;
309 
312  };
313 }
DT_DLL_EXAMPLESCENEROOTPLUGIN void init(DtDe &anIG)
osg::Matrixd myRotation
Definition: DtWeatherPrecipitationShaft.h:288
Virtual base class. Allows for RTTI and proper virtual destruction. Used by Creators, Factories, Providers, Assemblers and User Interfaces.
Definition: DtVirtualBaseClass.h:19
Implementation independent random number generator.
Definition: DtRandomNumberGenerator.h:20
DtRandomNumberGenerator myRandomNumberGen
Definition: DtWeatherPrecipitationShaft.h:307
osg::Vec3d myPosition
Definition: DtWeatherPrecipitationShaft.h:287
float myBoundsCornerRadius
Definition: DtWeatherPrecipitationShaft.h:293
GLint myParametersUnfmLoc
Definition: DtWeatherPrecipitationShaft.h:87
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Particle * myParticles
Definition: DtWeatherPrecipitationShaft.h:300
float myBoundsX
Definition: DtWeatherPrecipitationShaft.h:290
A structure to hold data for a sorting job.
Definition: DtWeatherPrecipitationShaft.h:266
GLint myBoxUnfmLoc
Definition: DtWeatherPrecipitationShaft.h:89
float myParticleWidth
Definition: DtWeatherPrecipitationShaft.h:295
unsigned int GLuint
Definition: DtGlTextureBufferObject.h:18
osg::ref_ptr< osg::Vec4Array > myPoints
Definition: DtWeatherPrecipitationShaft.h:196
Contains makVrv::DtDe class.
this class is used to split work up between threads.
Definition: DtJobSplitter.h:64
This class simulates and renders a precipitation shaft area. The area volume is filled with a density...
Definition: DtWeatherPrecipitationShaft.h:63
unsigned short * myIndices
Definition: DtWeatherPrecipitationShaft.h:198
SortJobData mySortJobData
Definition: DtWeatherPrecipitationShaft.h:304
int myParticleActiveCount
Definition: DtWeatherPrecipitationShaft.h:302
A group node which serves as a root for weather areas, patchy ground fog areas and effects...
Definition: DtWeatherAreaGroup.h:76
float myIntensity
Definition: DtWeatherPrecipitationShaft.h:297
osg::RenderInfo * myRenderInfo
Definition: DtWeatherPrecipitationShaft.h:84
friend DtWeatherPrecipitationShaftCreator
Definition: DtWeatherPrecipitationShaft.h:65
osg::Vec4f myPosition
Definition: DtWeatherPrecipitationShaft.h:217
MeshGroup()
Definition: DtWeatherPrecipitationShaft.h:185
Camera forward declarations.
GLint myTransformUnfmLoc
Definition: DtWeatherPrecipitationShaft.h:88
DtDe & myDe
Definition: DtWeatherPrecipitationShaft.h:279
int myParticlePoolCount
Definition: DtWeatherPrecipitationShaft.h:301
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:23
Contains makVrv::DtRandomNumberGenerator class.
osg::StateSet * myState
Definition: DtWeatherPrecipitationShaft.h:91
unsigned int myIndicesCount
Definition: DtWeatherPrecipitationShaft.h:199
DrawData()
Definition: DtWeatherPrecipitationShaft.h:72
Contains makVrv::DtJobSplitter class.
osg::Vec3f myLocalCameraPos
Definition: DtWeatherPrecipitationShaft.h:276
float myWindDirectionRad
Definition: DtWeatherPrecipitationShaft.h:310
float myWindSpeedMps
Definition: DtWeatherPrecipitationShaft.h:311
SortJobData()
Definition: DtWeatherPrecipitationShaft.h:268
const DtWeatherAreaGroup * myWeatherAreaGroup
Definition: DtWeatherPrecipitationShaft.h:90
float myBoundsZ
Definition: DtWeatherPrecipitationShaft.h:292
float myBoundsY
Definition: DtWeatherPrecipitationShaft.h:291
A structure used to hold data for drawing.
Definition: DtWeatherPrecipitationShaft.h:70
bool myEnabled
Definition: DtWeatherPrecipitationShaft.h:281
A generic OpenGL buffer. This can be: -&gt; a vertex buffer -&gt; an index buffer -&gt; a shader storage buffe...
Definition: DtGlBuffer.h:29
const char * creatorTypeName< DtWeatherPrecipitationShaft >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtWeatherPrecipitationShaft.h:53
MeshGroup * myMeshGroup
Definition: DtWeatherPrecipitationShaft.h:284
A generic structure to hold data for a job for use with DtJobSplitter.
Definition: DtJobSplitter.h:26
osg::ref_ptr< osg::Vec2Array > myTexCoords0
Definition: DtWeatherPrecipitationShaft.h:197
This class is used to manage an opengl vertex array object (VAO) dealing with multiple opengl context...
Definition: DtGlVaoManager.h:58
bool myCulled
Definition: DtWeatherPrecipitationShaft.h:282
DtWeatherPrecipitationShaft * myWeatherPrecipitationShaft
Definition: DtWeatherPrecipitationShaft.h:275
Particle()
Definition: DtWeatherPrecipitationShaft.h:209
Contains DLL export macros.
DtJobSplitterJob mySortJob
Definition: DtWeatherPrecipitationShaft.h:305
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
osg::Vec3f myBaseColor
Definition: DtWeatherPrecipitationShaft.h:298
unsigned int myRandomSeed
Definition: DtWeatherPrecipitationShaft.h:308
Contains the DtGlVaoManager class declaration.
float mySortDepth
Definition: DtWeatherPrecipitationShaft.h:216
A structure used to define a particle.
Definition: DtWeatherPrecipitationShaft.h:207
DtGlVaoManager * myVaoManager
Definition: DtWeatherPrecipitationShaft.h:285
DtVirtualBaseClassCreator< DtWeatherPrecipitationShaft > DtWeatherPrecipitationShaftCreator
creator
Definition: DtWeatherPrecipitationShaft.h:46
osg::Vec3d myCamPos
Definition: DtWeatherPrecipitationShaft.h:85
osg::Matrixd myViewMatrix
Definition: DtWeatherPrecipitationShaft.h:86
A structure used to define a mesh group (voa, positions, coords).
Definition: DtWeatherPrecipitationShaft.h:183

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)