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 
124  virtual bool cullUpdate(const osg::Vec3d& camPos, const osg::Matrixd& viewMatrixI,
125  const Frustum_64& frustum, DtJobSplitter* jobSplitter);
126 
129  virtual bool isPositionAboveArea(const osg::Vec3d& position);
130 
132  virtual void draw(DtWeatherPrecipitationShaft::DrawData& drawData);
133 
137  virtual void setBounds(const DtVector& bounds, float cornerRadius);
138 
142  virtual void setTransform(const osg::Vec3d& position, const osg::Matrixd& rotation);
143 
146  virtual void setIntensity(const float intensity);
147 
150  virtual void setBaseColor(const DtVector& color);
151 
155  virtual void setWind(const float windDirectionRad, const float windSpeedMps);
156 
159  virtual void runSort(const osg::Vec3f& localCamPos);
160 
163  virtual void setEnabled(bool enabled);
164 
166  virtual bool enabled() const;
167 
171  virtual bool culled() const;
172 
177  virtual void computeBounds(osg::Vec4f& bounds, osg::Vec3d& position, osg::Matrixd& rotation) const;
178 
179  protected:
180 
182  struct MeshGroup
183  {
185  : myVboPositionArray(0)
186  , myVboTexCoords0Array(0)
187  , myVboIndicesArray(0)
188  , myIndices(0)
189  , myIndicesCount(0)
190  {
191  myPoints = new osg::Vec4Array;
192  myTexCoords0 = new osg::Vec2Array;
193  }
194 
197  unsigned short* myIndices;
198  unsigned int myIndicesCount;
199 
200  DtGlBuffer* myVboPositionArray = nullptr;
201  DtGlBuffer* myVboTexCoords0Array = nullptr;
202  DtGlBuffer* myVboIndicesArray = nullptr;
203  };
204 
206  struct Particle
207  {
209  : mySortDepth(0)
210  , myPosition(0, 0, 0, 0)
211  {
212  //intentional nop
213  }
214 
215  float mySortDepth;
216  osg::Vec4f myPosition;
217  };
218 
224  virtual bool positionInBounds2D(const float x, const float y, const osg::Vec3f& bounds);
225 
229  virtual float computeRandomMinMax(float fMin, float fMax);
230 
233  virtual void computeSortDepth(const osg::Vec3f& reference);
234 
236  virtual void fillSortedParticles();
237 
241  virtual bool bindMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
242 
246  virtual bool bindDynamicMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
247 
252  virtual bool bindVaoToMeshGroup(GLuint vao, MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
253 
254  protected:
255 
257  static int theSortBackToFront(const void* arg0, const void* arg1);
258 
260  static void theSortJob(void* data);
261 
262  protected:
263 
265  struct SortJobData
266  {
268  : myWeatherPrecipitationShaft(0)
269  , myLocalCameraPos(0, 0, 0)
270  {
271  //intentional nop
272  }
273 
275  osg::Vec3f myLocalCameraPos;
276  };
277 
279 
280  bool myEnabled;
281  bool myCulled;
282 
285 
286  osg::Vec3d myPosition;
287  osg::Matrixd myRotation;
288 
289  float myBoundsX;
290  float myBoundsY;
291  float myBoundsZ;
293 
295 
296  float myIntensity;
297  osg::Vec3f myBaseColor;
298 
299  Particle* myParticles; // memory pool of particles
300  int myParticlePoolCount; // the number of particles in the memory pool
301  int myParticleActiveCount; // number of active particles
302 
305 
307  unsigned int myRandomSeed;
308 
311  };
312 }
DT_DLL_EXAMPLESCENEROOTPLUGIN void init(DtDe &anIG)
osg::Matrixd myRotation
Definition: DtWeatherPrecipitationShaft.h:287
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:306
osg::Vec3d myPosition
Definition: DtWeatherPrecipitationShaft.h:286
float myBoundsCornerRadius
Definition: DtWeatherPrecipitationShaft.h:292
GLint myParametersUnfmLoc
Definition: DtWeatherPrecipitationShaft.h:87
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Particle * myParticles
Definition: DtWeatherPrecipitationShaft.h:299
float myBoundsX
Definition: DtWeatherPrecipitationShaft.h:289
A structure to hold data for a sorting job.
Definition: DtWeatherPrecipitationShaft.h:265
GLint myBoxUnfmLoc
Definition: DtWeatherPrecipitationShaft.h:89
float myParticleWidth
Definition: DtWeatherPrecipitationShaft.h:294
unsigned int GLuint
Definition: DtGlTextureBufferObject.h:18
osg::ref_ptr< osg::Vec4Array > myPoints
Definition: DtWeatherPrecipitationShaft.h:195
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:197
SortJobData mySortJobData
Definition: DtWeatherPrecipitationShaft.h:303
int myParticleActiveCount
Definition: DtWeatherPrecipitationShaft.h:301
A group node which serves as a root for weather areas, patchy ground fog areas and effects...
Definition: DtWeatherAreaGroup.h:75
float myIntensity
Definition: DtWeatherPrecipitationShaft.h:296
osg::RenderInfo * myRenderInfo
Definition: DtWeatherPrecipitationShaft.h:84
friend DtWeatherPrecipitationShaftCreator
Definition: DtWeatherPrecipitationShaft.h:65
osg::Vec4f myPosition
Definition: DtWeatherPrecipitationShaft.h:216
MeshGroup()
Definition: DtWeatherPrecipitationShaft.h:184
Camera forward declarations.
GLint myTransformUnfmLoc
Definition: DtWeatherPrecipitationShaft.h:88
DtDe & myDe
Definition: DtWeatherPrecipitationShaft.h:278
int myParticlePoolCount
Definition: DtWeatherPrecipitationShaft.h:300
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:198
DrawData()
Definition: DtWeatherPrecipitationShaft.h:72
Contains makVrv::DtJobSplitter class.
osg::Vec3f myLocalCameraPos
Definition: DtWeatherPrecipitationShaft.h:275
float myWindDirectionRad
Definition: DtWeatherPrecipitationShaft.h:309
float myWindSpeedMps
Definition: DtWeatherPrecipitationShaft.h:310
SortJobData()
Definition: DtWeatherPrecipitationShaft.h:267
const DtWeatherAreaGroup * myWeatherAreaGroup
Definition: DtWeatherPrecipitationShaft.h:90
float myBoundsZ
Definition: DtWeatherPrecipitationShaft.h:291
float myBoundsY
Definition: DtWeatherPrecipitationShaft.h:290
A structure used to hold data for drawing.
Definition: DtWeatherPrecipitationShaft.h:70
bool myEnabled
Definition: DtWeatherPrecipitationShaft.h:280
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:283
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:196
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:281
DtWeatherPrecipitationShaft * myWeatherPrecipitationShaft
Definition: DtWeatherPrecipitationShaft.h:274
Particle()
Definition: DtWeatherPrecipitationShaft.h:208
Contains DLL export macros.
DtJobSplitterJob mySortJob
Definition: DtWeatherPrecipitationShaft.h:304
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:297
unsigned int myRandomSeed
Definition: DtWeatherPrecipitationShaft.h:307
Contains the DtGlVaoManager class declaration.
float mySortDepth
Definition: DtWeatherPrecipitationShaft.h:215
A structure used to define a particle.
Definition: DtWeatherPrecipitationShaft.h:206
DtGlVaoManager * myVaoManager
Definition: DtWeatherPrecipitationShaft.h:284
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:182

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)