VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtWeatherLightning.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 DtLight;
29  class DtWeatherArea;
30  class DtWeatherAreaGroup;
31  class DtWeatherLightningFactory;
32 
40  {
42 
43  public:
44 
46  struct DrawData
47  {
49  : myRenderInfo(0)
50  , myCamPos(0, 0, 0)
51  , myParametersUnfmLoc(0)
52  , myTransformUnfmLoc(0)
53  , myWeatherAreaGroup(0)
54  , myState(0)
55  {
56  // intentional nop
57  }
58 
59  osg::RenderInfo* myRenderInfo;
60  osg::Vec3d myCamPos;
61  osg::Matrixd myViewMatrix;
65  osg::StateSet* myState;
66  };
67 
69  virtual ~DtWeatherLightning();
70 
72  DtWeatherLightning() = delete;
73 
75  DtWeatherLightning(const DtWeatherLightning &other) = delete;
76 
78  DtWeatherLightning &operator=(const DtWeatherLightning &other) = delete;
79 
80  protected:
81 
84 
85  public:
86 
88  virtual void init();
89 
91  virtual void releaseGLObjects(osg::State* state) const;
92 
97  virtual void simulationUpdate(float timeStep, double currentTime, DtJobSplitter* jobSplitter);
98 
103  virtual bool cullUpdate(const osg::Vec3d& camPos, const osg::Matrixd& viewMatrixI,
104  const std::vector<osg::Vec4d>& cullingPlanes, DtJobSplitter* jobSplitter);
105 
107  virtual void draw(DtWeatherLightning::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 
129  virtual void runSort(const osg::Vec3& localCamPos);
130 
133  virtual void setEnabled(bool enabled);
134 
136  virtual bool enabled() const;
137 
140  virtual bool culled() const;
141 
146  virtual void computeBounds(osg::Vec4& bounds, osg::Vec3d& position, osg::Matrixd& rotation) const;
147 
148  protected:
149 
151  struct MeshGroup
152  {
154  : myVboPositionArray(0)
155  , myVboNormalArray(0)
156  , myVboTexCoordArray(0)
157  , myVboIndiceArray(0)
158  , myIndices(0)
159  , myIndicesCount(0)
160  , myActivePointCount(0)
161  {
162  myPoints = new osg::Vec4Array;
163  myNormals = new osg::Vec4Array;
164  myTexCoords = new osg::Vec2Array;
165  }
166 
170  unsigned short* myIndices;
171  unsigned int myIndicesCount;
172  unsigned int myActivePointCount;
173 
174  unsigned int myVboPositionArray;
175  unsigned int myVboNormalArray;
176  unsigned int myVboTexCoordArray;
177  unsigned int myVboIndiceArray;
178  };
179 
182  {
184  : myDirection(1, 0, 0)
185  , myWidthScale(1.0f)
186  , myChildDepth(0)
187  {
188  // intentional noop
189  }
190 
191  osg::Vec3 myDirection;
194  osg::Vec3 myPoints[16];
195  std::vector<LightningFinger*> myChildren;
196  };
197 
200  {
202  : mySortDepth(0)
203  , myUnique(0.0f)
204  , myAliveTime(0)
205  , myTime(0)
206  , myStart(0,0,0)
207  , myEnd(0,0,0)
208  , myLightPosition(0,0,0)
209  , myActiveFingers(0)
210  , myRootFinger(0)
211  , myMeshGroup(0)
212  , myVaoManager(0)
213  , myMeshDirty(false)
214  {
215  // intentional noop
216  }
217 
218  float mySortDepth;
219  float myUnique;
220  float myAliveTime; // amount of time to stay alive
221  float myTime; // amount of time that has passed
222  osg::Vec3 myStart;
223  osg::Vec3 myEnd;
224  osg::Vec3d myLightPosition;
225  LightningFinger myLightningFingerPool[24]; // memory pool
231  };
232 
235  friend struct SortDistanceComparator;
236 
238  {
239  public:
240  bool operator()(const DtWeatherLightning::LightningBolt* lhs, const DtWeatherLightning::LightningBolt* rhs);
241  };
242 
245  virtual void initBoltMeshGroup(LightningBolt* bolt);
246 
250  virtual void createBolt(const osg::Vec3& start, const osg::Vec3& end);
251 
255  virtual void createFingerSegments(LightningBolt* bolt, LightningFinger* finger);
256 
262  virtual bool positionInBounds2D(const float x, const float y, const osg::Vec3& bounds);
263 
267  virtual float computeRandomMinMax(float fMin, float fMax);
268 
271  virtual void computeSortDepth(const osg::Vec3& reference);
272 
276  void fillMeshGroupFlashPoint(LightningBolt* bolt);
277 
282  virtual void fillMeshGroup(LightningBolt* bolt, LightningFinger* finger);
283 
287  virtual bool bindMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
288 
292  virtual bool bindDynamicMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
293 
298  virtual bool bindVaoToMeshGroup(GLuint vao, MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
299 
304  virtual bool isSphereVisible(const std::vector<osg::Vec4d>& planes, const osg::Vec3d& center, double radius) const;
305 
309  const osg::Vec3 crossProduct(const osg::Vec3& v0, const osg::Vec3& v1) const;
310 
311  protected:
312 
314  static void theSortJob(void* data);
315 
316  protected:
317 
319  struct SortJobData
320  {
322  : myWeatherLightning(0)
323  , myLocalCameraPos(0, 0, 0)
324  {
325  //intentional nop
326  }
327 
329  osg::Vec3 myLocalCameraPos;
330  };
331 
333 
334  bool myEnabled;
335  bool myCulled;
336 
337  osg::Vec3d myPosition;
338  osg::Matrixd myRotation;
339 
340  float myBoundsX;
341  float myBoundsY;
342  float myBoundsZ;
344 
345  float myBoltWidth;
346  float myIntensity;
347  osg::Vec3 myBaseColor;
348 
349  // These are mutable because they modified during releaseGLObjects.
350  mutable std::vector<LightningBolt*> myMutableLightningBoltsPool; // memory pool
351  mutable std::vector<LightningBolt*> myMutableLightningBoltsActive; // active list
352 
355 
357  unsigned int myRandomSeed;
358 
362 
364  };
365 
366 
367 
371  {
372  public:
375 
377  virtual ~DtWeatherLightningFactory();
378 
380  DtWeatherLightningFactory() = delete;
381 
384 
386  DtWeatherLightningFactory &operator=(const DtWeatherLightningFactory &other) = delete;
387 
390  static DtWeatherLightningFactory& instance(DtDe& de);
391 
393  static const std::string& theClassName();
394 
396  virtual DtWeatherLightning* create() const;
397 
398  protected:
399 
401  };
402 
403 }
404 
405 
406 
407 
const DtWeatherAreaGroup * myWeatherAreaGroup
Definition: DtWeatherLightning.h:64
float myIntensity
Definition: DtWeatherLightning.h:346
DT_DLL_EXAMPLESCENEROOTPLUGIN void init(DtDe &anIG)
int myActiveFingers
Definition: DtWeatherLightning.h:226
A structure to hold data for a sorting job.
Definition: DtWeatherLightning.h:319
std::vector< LightningFinger * > myChildren
Definition: DtWeatherLightning.h:195
osg::Vec3 myBaseColor
Definition: DtWeatherLightning.h:347
float myBoundsCornerRadius
Definition: DtWeatherLightning.h:343
GLint myParametersUnfmLoc
Definition: DtWeatherLightning.h:62
Virtual base class.
Definition: DtVirtualBaseClass.h:19
Implementation independent random number generator.
Definition: DtRandomNumberGenerator.h:20
osg::Vec3 myDirection
Definition: DtWeatherLightning.h:191
unsigned int myVboNormalArray
Definition: DtWeatherLightning.h:175
osg::Vec3d myCamPos
Definition: DtWeatherLightning.h:60
float myBoltWidth
Definition: DtWeatherLightning.h:345
osg::Vec3d myLightPosition
Definition: DtWeatherLightning.h:224
float myWidthScale
Definition: DtWeatherLightning.h:192
osg::Vec3 myEnd
Definition: DtWeatherLightning.h:223
bool myMeshDirty
Definition: DtWeatherLightning.h:230
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
osg::ref_ptr< osg::Vec2Array > myTexCoords
Definition: DtWeatherLightning.h:169
std::vector< LightningBolt * > myMutableLightningBoltsActive
Definition: DtWeatherLightning.h:351
unsigned int myVboIndiceArray
Definition: DtWeatherLightning.h:177
MeshGroup()
Definition: DtWeatherLightning.h:153
LightningBolt()
Definition: DtWeatherLightning.h:201
unsigned int GLuint
Definition: DtGlTextureBufferObject.h:17
A structure used to hold data for drawing.
Definition: DtWeatherLightning.h:46
Contains makVrv::DtDe class.
this class is used to split work up between threads.
Definition: DtJobSplitter.h:64
DtWeatherLightning * myWeatherLightning
Definition: DtWeatherLightning.h:328
A structure used to define a lightning bolt.
Definition: DtWeatherLightning.h:199
A group node which serves as a root for weather areas, patchy ground fog areas and effects...
Definition: DtWeatherAreaGroup.h:72
DtDe & myDe
Definition: DtWeatherLightning.h:332
unsigned int myIndicesCount
Definition: DtWeatherLightning.h:171
osg::Matrixd myViewMatrix
Definition: DtWeatherLightning.h:61
float myStrikeTimer
Definition: DtWeatherLightning.h:361
unsigned int myVboTexCoordArray
Definition: DtWeatherLightning.h:176
This class simulates and renders a lightning area.
Definition: DtWeatherLightning.h:39
float myBoundsZ
Definition: DtWeatherLightning.h:342
A structure used to define a lightning bolt finger.
Definition: DtWeatherLightning.h:181
osg::RenderInfo * myRenderInfo
Definition: DtWeatherLightning.h:59
float myBoundsX
Definition: DtWeatherLightning.h:340
DtDe & myDe
Definition: DtWeatherLightning.h:400
Contains makVrv::DtVirtualBaseClass class.
Contains makVrv::DtRandomNumberGenerator class.
osg::ref_ptr< osg::Vec4Array > myPoints
Definition: DtWeatherLightning.h:167
unsigned int myActivePointCount
Definition: DtWeatherLightning.h:172
Contains makVrv::DtJobSplitter class.
osg::ref_ptr< osg::Vec4Array > myNormals
Definition: DtWeatherLightning.h:168
DtGlVaoManager * myVaoManager
Definition: DtWeatherLightning.h:229
osg::StateSet * myState
Definition: DtWeatherLightning.h:65
float myTime
Definition: DtWeatherLightning.h:221
osg::Vec3 myStart
Definition: DtWeatherLightning.h:222
DrawData()
Definition: DtWeatherLightning.h:48
DtLight * myLight
Definition: DtWeatherLightning.h:363
osg::Matrixd myRotation
Definition: DtWeatherLightning.h:338
A structure used to define a mesh group (voa, positions, coords).
Definition: DtWeatherLightning.h:151
DtJobSplitterJob mySortJob
Definition: DtWeatherLightning.h:354
Definition: DtWeatherLightning.h:237
DtRandomNumberGenerator myRandomNumberGen
Definition: DtWeatherLightning.h:356
A generic structure to hold data for a job for use with DtJobSplitter.
Definition: DtJobSplitter.h:26
SortJobData()
Definition: DtWeatherLightning.h:321
LightningFinger()
Definition: DtWeatherLightning.h:183
SortJobData mySortJobData
Definition: DtWeatherLightning.h:353
std::vector< LightningBolt * > myMutableLightningBoltsPool
Definition: DtWeatherLightning.h:350
bool myEnabled
Definition: DtWeatherLightning.h:334
Class for generic lights This holds per-light data such as range, attenuation factors, colors, etc.
Definition: DtLight.h:52
Factory that is used to create weather lightning areas.
Definition: DtWeatherLightning.h:370
This class is used to manage an opengl vertex array object (VAO) dealing with multiple opengl context...
Definition: DtGlVaoManager.h:49
float myStrikeTimeMax
Definition: DtWeatherLightning.h:360
float myBoundsY
Definition: DtWeatherLightning.h:341
osg::Vec3d myPosition
Definition: DtWeatherLightning.h:337
float myUnique
Definition: DtWeatherLightning.h:219
int myChildDepth
Definition: DtWeatherLightning.h:193
Contains DLL export macros.
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
float myStrikeTimeMin
Definition: DtWeatherLightning.h:359
Contains the DtGlVaoManager class declaration.
unsigned short * myIndices
Definition: DtWeatherLightning.h:170
unsigned int myVboPositionArray
Definition: DtWeatherLightning.h:174
GLint myTransformUnfmLoc
Definition: DtWeatherLightning.h:63
float mySortDepth
Definition: DtWeatherLightning.h:218
bool myCulled
Definition: DtWeatherLightning.h:335
float myAliveTime
Definition: DtWeatherLightning.h:220
MeshGroup * myMeshGroup
Definition: DtWeatherLightning.h:228
LightningFinger * myRootFinger
Definition: DtWeatherLightning.h:227
osg::Vec3 myLocalCameraPos
Definition: DtWeatherLightning.h:329
unsigned int myRandomSeed
Definition: DtWeatherLightning.h:357

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)