VR-Forces 5.0.1 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtGroundFogEffect.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 <vrvOsg/DtGlVaoManager.h>
13 #include <vrvOsg/vrvOsg.h>
14 
15 #include <vrvCore/DtJobSplitter.h>
16 
18 
19 #include <osg/RenderInfo>
20 #include <osg/Vec3d>
21 
22 
23 namespace makVrv
24 {
25  // Forward declarations.
26  class DtWeatherAreaGroup;
27 
28 
37  {
38  public:
39 
41  struct DrawData
42  {
44  : myRenderInfo(0)
45  , myCamPos(0, 0, 0)
46  , myParametersUnfmLoc(0)
47  , mySoftnessUnfmLoc(0)
48  , myWindDirectionRad(0)
49  , myWindSpeedMps(0)
50  , myWeatherAreaGroup(0)
51  , myState(0)
52  {
53  // intentional nop
54  }
55 
56  osg::RenderInfo* myRenderInfo;
57  osg::Vec3d myCamPos;
63  osg::StateSet* myState;
64  };
65 
68 
70  virtual ~DtGroundFogEffect();
71 
72  private:
73 
76 
79 
81  DtGroundFogEffect &operator=(const DtGroundFogEffect &other);
82 
83  public:
84 
86  // \param particleCount The maximum number of particles to simulate.
87  // \param particleSize The base particle size.
88  // \param radius The effect radius.
89  virtual void init(int particleCount, float particleSize, float radius);
90 
92  virtual void releaseGLObjects(osg::State* state) const;
93 
95  virtual void draw(DtGroundFogEffect::DrawData& drawData, const osg::Vec3& baseColor) const;
96 
100  virtual void cullUpdate(const osg::Vec3d& camPos, DtJobSplitter* jobSplitter);
101 
104  virtual void setEnable(bool enable);
105 
109  virtual void setWind(float windDirectionRad, float windSpeedMps);
110 
113  virtual void setWindSpeedMultiplier(float multiplier);
114 
117  virtual void setWindLiftMultiplier(float multiplier);
118 
121  virtual void setWindTurbulence(float multiplier);
122 
125  virtual void setDensity(float density);
126 
128  virtual void setEffectFade(float fade);
129 
133  virtual void setIntensityPerWindRamp(float start, float end);
134 
136  virtual float computeIntensityPerWind();
137 
139  virtual void setBasisRotation(const osg::Matrixd& rotation);
140 
143  virtual void setColorMult(float r, float g, float b);
144 
146  virtual float radius() const;
147 
150  virtual void runSort(const osg::Vec3& localCamPos);
151 
152  protected:
153 
155  struct MeshGroup
156  {
158  : myVboPositionArray(0)
159  , myVboTexCoords0Array(0)
160  {
161  myPoints = new osg::Vec4Array;
162  myTexCoords0 = new osg::Vec2Array;
163  }
164 
167 
168  unsigned int myVboPositionArray;
169  unsigned int myVboTexCoords0Array;
170  };
171 
173  struct Particle
174  {
176  : mySortDepth(0)
177  , myPosition(0, 0, 0, 0)
178  {
179  //intentional nop
180  }
181 
182  float mySortDepth;
183  osg::Vec4 myPosition;
184  };
185 
187  virtual void connectSignals();
188 
190  virtual void disconnectSignals();
191 
193  virtual void slot_simulationUpdate();
194 
196  virtual void computeSortDepth(const osg::Vec3& reference);
197 
199  virtual void fillSortedParticles();
200 
204  virtual bool bindMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
205 
209  virtual bool bindDynamicMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
210 
215  virtual bool bindVaoToMeshGroup(GLuint vao, MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
216 
220  virtual void simulateParticles(float timeStep, double currentTime);
221 
222  // non-virtual for maximum inner loop performance.
223 
228  void wrapPosition(float& posX, float& posY, float& posZ);
229 
230  private:
231 
233  static int theSortBackToFront(const void* arg0, const void* arg1);
234 
236  static void theSortJob(void* data);
237 
238  protected:
239 
241  struct SortJobData
242  {
244  : myEffect(0)
245  , myCameraPos(0, 0, 0)
246  {
247  //intentional nop
248  }
249 
251  osg::Vec3 myCameraPos;
252  };
253 
255 
256  osg::Matrixd myBasisRot;
257 
258  bool myEnable;
259  osg::Vec3 myScroll;
260  float myRadius;
266  double myLastTime;
269  osg::Vec3 myColorMult;
272  float myDensity;
273 
276 
279 
282  };
283 
284 
287  {
288  public:
291 
293  virtual ~DtGroundFogEffectCreator();
294 
295  private:
299  DtGroundFogEffectCreator &operator=(const DtGroundFogEffectCreator& other);
300 
301  public:
303  // \param particleCount The maximum number of particles to simulate.
304  // \param particleSize The base particle size.
305  // \param radius The effect radius.
306  virtual DtGroundFogEffect* create(int particleCount, float particleSize, float radius) const;
307 
310  static DtGroundFogEffectCreator& instance(DtDe& de);
311 
313  static const std::string& theClassName();
314 
315  protected:
317  };
318 }
319 
320 
321 
322 
DT_DLL_EXAMPLESCENEROOTPLUGIN void init(DtDe &anIG)
float myWindDirectionRad
Definition: DtGroundFogEffect.h:261
SortJobData mySortJobData
Definition: DtGroundFogEffect.h:280
bool myEnable
Definition: DtGroundFogEffect.h:258
Virtual base class. Allows for RTTI and proper virtual destruction. Used by Creators, Factories, Providers, Assemblers and User Interfaces.
Definition: DtVirtualBaseClass.h:19
DtDe & myDe
Definition: DtGroundFogEffect.h:316
A structure used to hold data for drawing.
Definition: DtGroundFogEffect.h:41
DrawData()
Definition: DtGroundFogEffect.h:43
osg::ref_ptr< osg::Vec2Array > myTexCoords0
Definition: DtGroundFogEffect.h:166
float myWindSpeedMps
Definition: DtGroundFogEffect.h:61
unsigned int myVboTexCoords0Array
Definition: DtGroundFogEffect.h:169
osg::ref_ptr< osg::Vec4Array > myPoints
Definition: DtGroundFogEffect.h:165
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
A structure used to define a simulation particle.
Definition: DtGroundFogEffect.h:173
MeshGroup()
Definition: DtGroundFogEffect.h:157
const DtWeatherAreaGroup * myWeatherAreaGroup
Definition: DtGroundFogEffect.h:62
osg::Vec3 myScroll
Definition: DtGroundFogEffect.h:259
osg::Vec3 myCameraPos
Definition: DtGroundFogEffect.h:251
unsigned int GLuint
Definition: DtGlTextureBufferObject.h:17
DtGroundFogEffect * myEffect
Definition: DtGroundFogEffect.h:250
DtJobSplitterJob mySortJob
Definition: DtGroundFogEffect.h:281
this class is used to split work up between threads.
Definition: DtJobSplitter.h:64
A group node which serves as a root for weather areas, patchy ground fog areas and effects...
Definition: DtWeatherAreaGroup.h:72
int myParticleCount
Definition: DtGroundFogEffect.h:278
float mfIntensityPerWindEnd
Definition: DtGroundFogEffect.h:271
osg::RenderInfo * myRenderInfo
Definition: DtGroundFogEffect.h:56
Particle * myParticles
Definition: DtGroundFogEffect.h:277
double myLastTime
Definition: DtGroundFogEffect.h:266
float mySortDepth
Definition: DtGroundFogEffect.h:182
float myWindTurbulence
Definition: DtGroundFogEffect.h:265
this class is used to create an effect around the eye to represent blowing particle effects such as s...
Definition: DtGroundFogEffect.h:36
SortJobData()
Definition: DtGroundFogEffect.h:243
unsigned int myVboPositionArray
Definition: DtGroundFogEffect.h:168
osg::Vec3d myCamPos
Definition: DtGroundFogEffect.h:57
Contains makVrv::DtVirtualBaseClass class.
DtGlVaoManager * myVaoManager
Definition: DtGroundFogEffect.h:275
Contains makVrv::DtJobSplitter class.
MeshGroup * myMeshGroup
Definition: DtGroundFogEffect.h:274
float mfIntensityPerWindStart
Definition: DtGroundFogEffect.h:270
osg::StateSet * myState
Definition: DtGroundFogEffect.h:63
GLint mySoftnessUnfmLoc
Definition: DtGroundFogEffect.h:59
float myEffectFade
Definition: DtGroundFogEffect.h:267
osg::Vec4 myPosition
Definition: DtGroundFogEffect.h:183
osg::Vec3 myColorMult
Definition: DtGroundFogEffect.h:269
float myParticleSize
Definition: DtGroundFogEffect.h:268
DtDe & myDe
Definition: DtGroundFogEffect.h:254
A generic structure to hold data for a job for use with DtJobSplitter.
Definition: DtJobSplitter.h:26
creator for DtGroundFogEffect
Definition: DtGroundFogEffect.h:286
float myRadius
Definition: DtGroundFogEffect.h:260
This class is used to manage an opengl vertex array object (VAO) dealing with multiple opengl context...
Definition: DtGlVaoManager.h:65
float myWindDirectionRad
Definition: DtGroundFogEffect.h:60
Particle()
Definition: DtGroundFogEffect.h:175
Contains DLL export macros.
a structure to hold data for a sorting job
Definition: DtGroundFogEffect.h:241
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
float myWindSpeedMps
Definition: DtGroundFogEffect.h:262
float myDensity
Definition: DtGroundFogEffect.h:272
GLint myParametersUnfmLoc
Definition: DtGroundFogEffect.h:58
osg::Matrixd myBasisRot
Definition: DtGroundFogEffect.h:256
A structure used to define a mesh group (voa, positions, coords).
Definition: DtGroundFogEffect.h:155
Contains the DtGlVaoManager class declaration.
float myWindSpeedMultiplier
Definition: DtGroundFogEffect.h:263
float myWindLiftMultiplier
Definition: DtGroundFogEffect.h:264

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)