VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtWeatherRainShaft.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 DtWeatherRainShaftFactory;
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 ~DtWeatherRainShaft();
72 
74  DtWeatherRainShaft() = delete;
75 
77  DtWeatherRainShaft(const DtWeatherRainShaft &other) = delete;
78 
80  DtWeatherRainShaft &operator=(const DtWeatherRainShaft &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(DtWeatherRainShaft::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 
145  virtual bool culled() const;
146 
151  virtual void computeBounds(osg::Vec4& bounds, osg::Vec3d& position, osg::Matrixd& rotation) const;
152 
153  protected:
154 
156  struct MeshGroup
157  {
159  : myVboPositionArray(0)
160  , myVboTexCoords0Array(0)
161  , myVboIndicesArray(0)
162  , myIndices(0)
163  , myIndicesCount(0)
164  {
165  myPoints = new osg::Vec4Array;
166  myTexCoords0 = new osg::Vec2Array;
167  }
168 
171  unsigned short* myIndices;
172  unsigned int myIndicesCount;
173 
174  unsigned int myVboPositionArray;
175  unsigned int myVboTexCoords0Array;
176  unsigned int myVboIndicesArray;
177  };
178 
180  struct Particle
181  {
183  : mySortDepth(0)
184  , myPosition(0, 0, 0, 0)
185  {
186  //intentional nop
187  }
188 
189  float mySortDepth;
190  osg::Vec4 myPosition;
191  };
192 
198  virtual bool positionInBounds2D(const float x, const float y, const osg::Vec3& bounds);
199 
203  virtual float computeRandomMinMax(float fMin, float fMax);
204 
207  virtual void computeSortDepth(const osg::Vec3& reference);
208 
210  virtual void fillSortedParticles();
211 
215  virtual bool bindMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
216 
220  virtual bool bindDynamicMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
221 
226  virtual bool bindVaoToMeshGroup(GLuint vao, MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
227 
232  virtual bool isSphereVisible(const std::vector<osg::Vec4d>& planes, const osg::Vec3d& center, double radius) const;
233 
234  protected:
235 
237  static int theSortBackToFront(const void* arg0, const void* arg1);
238 
240  static void theSortJob(void* data);
241 
242  protected:
243 
245  struct SortJobData
246  {
248  : myWeatherRainShaft(0)
249  , myLocalCameraPos(0, 0, 0)
250  {
251  //intentional nop
252  }
253 
255  osg::Vec3 myLocalCameraPos;
256  };
257 
259 
260  bool myEnabled;
261  bool myCulled;
262 
265 
266  osg::Vec3d myPosition;
267  osg::Matrixd myRotation;
268 
269  float myBoundsX;
270  float myBoundsY;
271  float myBoundsZ;
273 
275 
276  float myIntensity;
277  osg::Vec3 myBaseColor;
278 
279  Particle* myParticles; // memory pool of particles
280  int myParticlePoolCount; // the number of particles in the memory pool
281  int myParticleActiveCount; // number of active particles
282 
285 
287  unsigned int myRandomSeed;
288 
291  };
292 
293 
294 
298  {
299  public:
302 
304  virtual ~DtWeatherRainShaftFactory();
305 
307  DtWeatherRainShaftFactory() = delete;
308 
311 
313  DtWeatherRainShaftFactory &operator=(const DtWeatherRainShaftFactory &other) = delete;
314 
317  static DtWeatherRainShaftFactory& instance(DtDe& de);
318 
320  static const std::string& theClassName();
321 
323  virtual DtWeatherRainShaft* create() const;
324 
325  protected:
326 
328  };
329 
330 }
331 
332 
333 
334 
DT_DLL_EXAMPLESCENEROOTPLUGIN void init(DtDe &anIG)
MeshGroup()
Definition: DtWeatherRainShaft.h:158
This class simulates and renders a rain shaft area.
Definition: DtWeatherRainShaft.h:39
osg::Vec3 myBaseColor
Definition: DtWeatherRainShaft.h:277
Virtual base class.
Definition: DtVirtualBaseClass.h:19
Implementation independent random number generator.
Definition: DtRandomNumberGenerator.h:20
float myWindDirectionRad
Definition: DtWeatherRainShaft.h:289
float myParticleWidth
Definition: DtWeatherRainShaft.h:274
GLint myTransformUnfmLoc
Definition: DtWeatherRainShaft.h:64
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Particle * myParticles
Definition: DtWeatherRainShaft.h:279
unsigned int myIndicesCount
Definition: DtWeatherRainShaft.h:172
GLint myBoxUnfmLoc
Definition: DtWeatherRainShaft.h:65
SortJobData mySortJobData
Definition: DtWeatherRainShaft.h:283
Factory that is used to create weather rain shaft areas.
Definition: DtWeatherRainShaft.h:297
unsigned int GLuint
Definition: DtGlTextureBufferObject.h:17
Contains makVrv::DtDe class.
this class is used to split work up between threads.
Definition: DtJobSplitter.h:64
unsigned int myVboIndicesArray
Definition: DtWeatherRainShaft.h:176
A group node which serves as a root for weather areas, patchy ground fog areas and effects...
Definition: DtWeatherAreaGroup.h:72
float myBoundsCornerRadius
Definition: DtWeatherRainShaft.h:272
osg::ref_ptr< osg::Vec4Array > myPoints
Definition: DtWeatherRainShaft.h:169
A structure used to define a particle.
Definition: DtWeatherRainShaft.h:180
A structure used to hold data for drawing.
Definition: DtWeatherRainShaft.h:46
Contains makVrv::DtVirtualBaseClass class.
DtRandomNumberGenerator myRandomNumberGen
Definition: DtWeatherRainShaft.h:286
bool myCulled
Definition: DtWeatherRainShaft.h:261
Contains makVrv::DtRandomNumberGenerator class.
unsigned int myVboPositionArray
Definition: DtWeatherRainShaft.h:174
DtDe & myDe
Definition: DtWeatherRainShaft.h:258
osg::Matrixd myRotation
Definition: DtWeatherRainShaft.h:267
osg::Vec3d myCamPos
Definition: DtWeatherRainShaft.h:61
Contains makVrv::DtJobSplitter class.
float myBoundsZ
Definition: DtWeatherRainShaft.h:271
unsigned short * myIndices
Definition: DtWeatherRainShaft.h:171
DtJobSplitterJob mySortJob
Definition: DtWeatherRainShaft.h:284
DtGlVaoManager * myVaoManager
Definition: DtWeatherRainShaft.h:264
float myIntensity
Definition: DtWeatherRainShaft.h:276
float myBoundsX
Definition: DtWeatherRainShaft.h:269
DtWeatherRainShaft * myWeatherRainShaft
Definition: DtWeatherRainShaft.h:254
int myParticleActiveCount
Definition: DtWeatherRainShaft.h:281
osg::ref_ptr< osg::Vec2Array > myTexCoords0
Definition: DtWeatherRainShaft.h:170
GLint myParametersUnfmLoc
Definition: DtWeatherRainShaft.h:63
float myBoundsY
Definition: DtWeatherRainShaft.h:270
Particle()
Definition: DtWeatherRainShaft.h:182
osg::RenderInfo * myRenderInfo
Definition: DtWeatherRainShaft.h:60
osg::Matrixd myViewMatrix
Definition: DtWeatherRainShaft.h:62
A generic structure to hold data for a job for use with DtJobSplitter.
Definition: DtJobSplitter.h:26
osg::StateSet * myState
Definition: DtWeatherRainShaft.h:67
This class is used to manage an opengl vertex array object (VAO) dealing with multiple opengl context...
Definition: DtGlVaoManager.h:49
Contains DLL export macros.
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
A structure used to define a mesh group (voa, positions, coords).
Definition: DtWeatherRainShaft.h:156
SortJobData()
Definition: DtWeatherRainShaft.h:247
DtDe & myDe
Definition: DtWeatherRainShaft.h:327
const DtWeatherAreaGroup * myWeatherAreaGroup
Definition: DtWeatherRainShaft.h:66
osg::Vec3d myPosition
Definition: DtWeatherRainShaft.h:266
float mySortDepth
Definition: DtWeatherRainShaft.h:189
Contains the DtGlVaoManager class declaration.
unsigned int myRandomSeed
Definition: DtWeatherRainShaft.h:287
DrawData()
Definition: DtWeatherRainShaft.h:48
MeshGroup * myMeshGroup
Definition: DtWeatherRainShaft.h:263
osg::Vec3 myLocalCameraPos
Definition: DtWeatherRainShaft.h:255
unsigned int myVboTexCoords0Array
Definition: DtWeatherRainShaft.h:175
osg::Vec4 myPosition
Definition: DtWeatherRainShaft.h:190
int myParticlePoolCount
Definition: DtWeatherRainShaft.h:280
bool myEnabled
Definition: DtWeatherRainShaft.h:260
A structure to hold data for a sorting job.
Definition: DtWeatherRainShaft.h:245
float myWindSpeedMps
Definition: DtWeatherRainShaft.h:290

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)