VR-Forces 5.0.3 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) 2021 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 
15 #include <vrvOsg/DtGlVaoManager.h>
16 #include <vrvOsg/vrvOsg.h>
17 
20 
21 #include <matrix/vlVector.h>
22 
23 
24 namespace makVrv
25 {
26  // Forward declarations.
27  class DtJobSplitter;
28  class DtWeatherArea;
29  class DtWeatherAreaGroup;
30  class DtWeatherPrecipitationShaftFactory;
31 
40  {
42 
43  public:
44 
46  struct DrawData
47  {
49  : myRenderInfo(0)
50  , myCamPos(0, 0, 0)
51  , myParametersUnfmLoc(0)
52  , myTransformUnfmLoc(0)
53  , myBoxUnfmLoc(0)
54  , myWeatherAreaGroup(0)
55  , myState(0)
56  {
57  // intentional nop
58  }
59 
60  osg::RenderInfo* myRenderInfo;
61  osg::Vec3d myCamPos;
62  osg::Matrixd myViewMatrix;
67  osg::StateSet* myState;
68  };
69 
71  virtual ~DtWeatherPrecipitationShaft();
72 
74  DtWeatherPrecipitationShaft() = delete;
75 
78 
80  DtWeatherPrecipitationShaft &operator=(const DtWeatherPrecipitationShaft &other) = delete;
81 
82  protected:
83 
86 
87  public:
88 
90  virtual void init();
91 
93  virtual void releaseGLObjects(osg::State* state) const;
94 
99  virtual bool cullUpdate(const osg::Vec3d& camPos, const osg::Matrixd& viewMatrixI,
100  const std::vector<osg::Vec4d>& cullingPlanes, DtJobSplitter* jobSplitter);
101 
104  virtual bool isPositionAboveArea(const osg::Vec3d& position);
105 
107  virtual void draw(DtWeatherPrecipitationShaft::DrawData& drawData);
108 
112  virtual void setBounds(const DtVector& bounds, float cornerRadius);
113 
117  virtual void setTransform(const osg::Vec3d& position, const osg::Matrixd& rotation);
118 
121  virtual void setIntensity(const float intensity);
122 
125  virtual void setBaseColor(const DtVector& color);
126 
130  virtual void setWind(const float windDirectionRad, const float windSpeedMps);
131 
134  virtual void runSort(const osg::Vec3& localCamPos);
135 
138  virtual void setEnabled(bool enabled);
139 
141  virtual bool enabled() const;
142 
146  virtual bool culled() const;
147 
152  virtual void computeBounds(osg::Vec4& bounds, osg::Vec3d& position, osg::Matrixd& rotation) const;
153 
154  protected:
155 
157  struct MeshGroup
158  {
160  : myVboPositionArray(0)
161  , myVboTexCoords0Array(0)
162  , myVboIndicesArray(0)
163  , myIndices(0)
164  , myIndicesCount(0)
165  {
166  myPoints = new osg::Vec4Array;
167  myTexCoords0 = new osg::Vec2Array;
168  }
169 
172  unsigned short* myIndices;
173  unsigned int myIndicesCount;
174 
175  unsigned int myVboPositionArray;
176  unsigned int myVboTexCoords0Array;
177  unsigned int myVboIndicesArray;
178  };
179 
181  struct Particle
182  {
184  : mySortDepth(0)
185  , myPosition(0, 0, 0, 0)
186  {
187  //intentional nop
188  }
189 
190  float mySortDepth;
191  osg::Vec4 myPosition;
192  };
193 
199  virtual bool positionInBounds2D(const float x, const float y, const osg::Vec3& bounds);
200 
204  virtual float computeRandomMinMax(float fMin, float fMax);
205 
208  virtual void computeSortDepth(const osg::Vec3& reference);
209 
211  virtual void fillSortedParticles();
212 
216  virtual bool bindMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
217 
221  virtual bool bindDynamicMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
222 
227  virtual bool bindVaoToMeshGroup(GLuint vao, MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
228 
233  virtual bool isSphereVisible(const std::vector<osg::Vec4d>& planes, const osg::Vec3d& center, double radius) const;
234 
235  protected:
236 
238  static int theSortBackToFront(const void* arg0, const void* arg1);
239 
241  static void theSortJob(void* data);
242 
243  protected:
244 
246  struct SortJobData
247  {
249  : myWeatherPrecipitationShaft(0)
250  , myLocalCameraPos(0, 0, 0)
251  {
252  //intentional nop
253  }
254 
256  osg::Vec3 myLocalCameraPos;
257  };
258 
260 
261  bool myEnabled;
262  bool myCulled;
263 
266 
267  osg::Vec3d myPosition;
268  osg::Matrixd myRotation;
269 
270  float myBoundsX;
271  float myBoundsY;
272  float myBoundsZ;
274 
276 
277  float myIntensity;
278  osg::Vec3 myBaseColor;
279 
280  Particle* myParticles; // memory pool of particles
281  int myParticlePoolCount; // the number of particles in the memory pool
282  int myParticleActiveCount; // number of active particles
283 
286 
288  unsigned int myRandomSeed;
289 
292  };
293 
294 
295 
299  {
300  public:
303 
306 
309 
312 
315 
318  static DtWeatherPrecipitationShaftFactory& instance(DtDe& de);
319 
321  static const std::string& theClassName();
322 
324  virtual DtWeatherPrecipitationShaft* create() const;
325 
326  protected:
327 
329  };
330 
331 }
332 
333 
334 
335 
DT_DLL_EXAMPLESCENEROOTPLUGIN void init(DtDe &anIG)
osg::Matrixd myRotation
Definition: DtWeatherPrecipitationShaft.h:268
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:287
osg::Vec3d myPosition
Definition: DtWeatherPrecipitationShaft.h:267
float myBoundsCornerRadius
Definition: DtWeatherPrecipitationShaft.h:273
GLint myParametersUnfmLoc
Definition: DtWeatherPrecipitationShaft.h:63
osg::Vec3 myBaseColor
Definition: DtWeatherPrecipitationShaft.h:278
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Particle * myParticles
Definition: DtWeatherPrecipitationShaft.h:280
float myBoundsX
Definition: DtWeatherPrecipitationShaft.h:270
A structure to hold data for a sorting job.
Definition: DtWeatherPrecipitationShaft.h:246
GLint myBoxUnfmLoc
Definition: DtWeatherPrecipitationShaft.h:65
float myParticleWidth
Definition: DtWeatherPrecipitationShaft.h:275
unsigned int GLuint
Definition: DtGlTextureBufferObject.h:17
osg::ref_ptr< osg::Vec4Array > myPoints
Definition: DtWeatherPrecipitationShaft.h:170
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:39
unsigned short * myIndices
Definition: DtWeatherPrecipitationShaft.h:172
SortJobData mySortJobData
Definition: DtWeatherPrecipitationShaft.h:284
int myParticleActiveCount
Definition: DtWeatherPrecipitationShaft.h:282
A group node which serves as a root for weather areas, patchy ground fog areas and effects...
Definition: DtWeatherAreaGroup.h:72
float myIntensity
Definition: DtWeatherPrecipitationShaft.h:277
osg::RenderInfo * myRenderInfo
Definition: DtWeatherPrecipitationShaft.h:60
MeshGroup()
Definition: DtWeatherPrecipitationShaft.h:159
osg::Vec4 myPosition
Definition: DtWeatherPrecipitationShaft.h:191
GLint myTransformUnfmLoc
Definition: DtWeatherPrecipitationShaft.h:64
DtDe & myDe
Definition: DtWeatherPrecipitationShaft.h:259
int myParticlePoolCount
Definition: DtWeatherPrecipitationShaft.h:281
Factory that is used to create weather precipitation shaft areas.
Definition: DtWeatherPrecipitationShaft.h:298
Contains makVrv::DtVirtualBaseClass class.
Contains makVrv::DtRandomNumberGenerator class.
osg::StateSet * myState
Definition: DtWeatherPrecipitationShaft.h:67
unsigned int myIndicesCount
Definition: DtWeatherPrecipitationShaft.h:173
DrawData()
Definition: DtWeatherPrecipitationShaft.h:48
Contains makVrv::DtJobSplitter class.
float myWindDirectionRad
Definition: DtWeatherPrecipitationShaft.h:290
float myWindSpeedMps
Definition: DtWeatherPrecipitationShaft.h:291
SortJobData()
Definition: DtWeatherPrecipitationShaft.h:248
const DtWeatherAreaGroup * myWeatherAreaGroup
Definition: DtWeatherPrecipitationShaft.h:66
osg::Vec3 myLocalCameraPos
Definition: DtWeatherPrecipitationShaft.h:256
float myBoundsZ
Definition: DtWeatherPrecipitationShaft.h:272
float myBoundsY
Definition: DtWeatherPrecipitationShaft.h:271
A structure used to hold data for drawing.
Definition: DtWeatherPrecipitationShaft.h:46
bool myEnabled
Definition: DtWeatherPrecipitationShaft.h:261
unsigned int myVboPositionArray
Definition: DtWeatherPrecipitationShaft.h:175
unsigned int myVboTexCoords0Array
Definition: DtWeatherPrecipitationShaft.h:176
MeshGroup * myMeshGroup
Definition: DtWeatherPrecipitationShaft.h:264
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:171
This class is used to manage an opengl vertex array object (VAO) dealing with multiple opengl context...
Definition: DtGlVaoManager.h:65
bool myCulled
Definition: DtWeatherPrecipitationShaft.h:262
DtWeatherPrecipitationShaft * myWeatherPrecipitationShaft
Definition: DtWeatherPrecipitationShaft.h:255
Particle()
Definition: DtWeatherPrecipitationShaft.h:183
Contains DLL export macros.
DtJobSplitterJob mySortJob
Definition: DtWeatherPrecipitationShaft.h:285
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
unsigned int myRandomSeed
Definition: DtWeatherPrecipitationShaft.h:288
unsigned int myVboIndicesArray
Definition: DtWeatherPrecipitationShaft.h:177
Contains the DtGlVaoManager class declaration.
float mySortDepth
Definition: DtWeatherPrecipitationShaft.h:190
A structure used to define a particle.
Definition: DtWeatherPrecipitationShaft.h:181
DtDe & myDe
Definition: DtWeatherPrecipitationShaft.h:328
DtGlVaoManager * myVaoManager
Definition: DtWeatherPrecipitationShaft.h:265
osg::Vec3d myCamPos
Definition: DtWeatherPrecipitationShaft.h:61
osg::Matrixd myViewMatrix
Definition: DtWeatherPrecipitationShaft.h:62
A structure used to define a mesh group (voa, positions, coords).
Definition: DtWeatherPrecipitationShaft.h:157

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)