VR-Forces 4.8 Class Documentation
 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) 2020 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 <vrvUtil/DtJobSplitter.h>
17 
18 #include <osg/RenderInfo>
19 #include <osg/Vec3d>
20 
21 
22 namespace makVrv
23 {
24  // Forward declarations.
25  class DtGroundFogEffectDrawable;
26 
27 
36  {
37  public:
38 
40  struct DrawData
41  {
43  : myRenderInfo(0)
44  , myCamPos(0, 0, 0)
45  , myParametersUnfmLoc(0)
46  , mySoftnessUnfmLoc(0)
47  , myWindDirectionRad(0)
48  , myWindSpeedMps(0)
49  , myStateDirty(true)
50  , myDrawable(0)
51  , mySensorState(0)
52  {
53  // intentional nop
54  }
55 
56  osg::RenderInfo* myRenderInfo;
57  osg::Vec3d myCamPos;
64  osg::StateSet* mySensorState;
65  };
66 
69 
71  virtual ~DtGroundFogEffect();
72 
73  private:
74 
77 
80 
82  DtGroundFogEffect &operator=(const DtGroundFogEffect &other);
83 
84  public:
85 
87  // \param particleCount The maximum number of particles to simulate.
88  // \param particleSize The base particle size.
89  // \param radius The effect radius.
90  virtual void init(int particleCount, float particleSize, float radius);
91 
93  virtual void releaseGLObjects(osg::State* state) const;
94 
96  virtual void draw(DtGroundFogEffect::DrawData& drawData, const osg::Vec3& baseColor) const;
97 
101  virtual void cullUpdate(const osg::Vec3d& camPos, DtJobSplitter* jobSplitter);
102 
105  virtual void setEnable(bool enable);
106 
110  virtual void setWind(float windDirectionRad, float windSpeedMps);
111 
114  virtual void setWindSpeedMultiplier(float multiplier);
115 
118  virtual void setWindLiftMultiplier(float multiplier);
119 
122  virtual void setWindTurbulence(float multiplier);
123 
126  virtual void setDensity(float density);
127 
129  virtual void setEffectFade(float fade);
130 
134  virtual void setIntensityPerWindRamp(float start, float end);
135 
137  virtual float computeIntensityPerWind();
138 
140  virtual void setBasisRotation(const osg::Matrixd& rotation);
141 
144  virtual void setColorMult(float r, float g, float b);
145 
147  virtual float radius() const;
148 
151  virtual void runSort(const osg::Vec3& localCamPos);
152 
153  protected:
154 
156  struct MeshGroup
157  {
159  : myVboPositionArray(0)
160  , myVboTexCoords0Array(0)
161  {
162  myPoints = new osg::Vec4Array;
163  myTexCoords0 = new osg::Vec2Array;
164  }
165 
168 
169  unsigned int myVboPositionArray;
170  unsigned int myVboTexCoords0Array;
171  };
172 
174  struct Particle
175  {
177  : mySortDepth(0)
178  , myPosition(0, 0, 0, 0)
179  {
180  //intentional nop
181  }
182 
183  float mySortDepth;
184  osg::Vec4 myPosition;
185  };
186 
188  virtual void connectSignals();
189 
191  virtual void disconnectSignals();
192 
194  virtual void slot_simulationUpdate();
195 
197  virtual void computeSortDepth(const osg::Vec3& reference);
198 
200  virtual void fillSortedParticles();
201 
205  virtual bool bindMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
206 
210  virtual bool bindDynamicMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
211 
216  virtual bool bindVaoToMeshGroup(GLuint vao, MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
217 
221  virtual void simulateParticles(float timeStep, double currentTime);
222 
223  // non-virtual for maximum inner loop performance.
224 
229  void wrapPosition(float& posX, float& posY, float& posZ);
230 
231  private:
232 
234  static int theSortBackToFront(const void* arg0, const void* arg1);
235 
237  static void theSortJob(void* data);
238 
239  protected:
240 
242  struct SortJobData
243  {
245  : myEffect(0)
246  , myCameraPos(0, 0, 0)
247  {
248  //intentional nop
249  }
250 
252  osg::Vec3 myCameraPos;
253  };
254 
256 
257  osg::Matrixd myBasisRot;
258 
259  bool myEnable;
260  osg::Vec3 myScroll;
261  float myRadius;
267  double myLastTime;
270  osg::Vec3 myColorMult;
273  float myDensity;
274 
277 
280 
283  };
284 
285 
288  {
289  public:
292 
294  virtual ~DtGroundFogEffectCreator();
295 
296  private:
300  DtGroundFogEffectCreator &operator=(const DtGroundFogEffectCreator& other);
301 
302  public:
304  // \param particleCount The maximum number of particles to simulate.
305  // \param particleSize The base particle size.
306  // \param radius The effect radius.
307  virtual DtGroundFogEffect* create(int particleCount, float particleSize, float radius) const;
308 
311  static DtGroundFogEffectCreator& instance(DtDe& de);
312 
314  static const std::string& theClassName();
315 
316  protected:
318  };
319 }
320 
321 
322 
323 
float myWindDirectionRad
Definition: DtGroundFogEffect.h:262
SortJobData mySortJobData
Definition: DtGroundFogEffect.h:281
bool myEnable
Definition: DtGroundFogEffect.h:259
Virtual base class.
Definition: DtVirtualBaseClass.h:22
const DtGroundFogEffectDrawable * myDrawable
Definition: DtGroundFogEffect.h:63
DtDe & myDe
Definition: DtGroundFogEffect.h:317
A structure used to hold data for drawing.
Definition: DtGroundFogEffect.h:40
DrawData()
Definition: DtGroundFogEffect.h:42
osg::ref_ptr< osg::Vec2Array > myTexCoords0
Definition: DtGroundFogEffect.h:167
float myWindSpeedMps
Definition: DtGroundFogEffect.h:61
unsigned int myVboTexCoords0Array
Definition: DtGroundFogEffect.h:170
osg::ref_ptr< osg::Vec4Array > myPoints
Definition: DtGroundFogEffect.h:166
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
A structure used to define a simulation particle.
Definition: DtGroundFogEffect.h:174
MeshGroup()
Definition: DtGroundFogEffect.h:158
osg::Vec3 myScroll
Definition: DtGroundFogEffect.h:260
osg::Vec3 myCameraPos
Definition: DtGroundFogEffect.h:252
unsigned int GLuint
Definition: DtGlTextureBufferObject.h:17
DtGroundFogEffect * myEffect
Definition: DtGroundFogEffect.h:251
DtJobSplitterJob mySortJob
Definition: DtGroundFogEffect.h:282
this class is used to split work up between threads.
Definition: DtJobSplitter.h:64
int myParticleCount
Definition: DtGroundFogEffect.h:279
float mfIntensityPerWindEnd
Definition: DtGroundFogEffect.h:272
osg::RenderInfo * myRenderInfo
Definition: DtGroundFogEffect.h:56
Particle * myParticles
Definition: DtGroundFogEffect.h:278
double myLastTime
Definition: DtGroundFogEffect.h:267
float mySortDepth
Definition: DtGroundFogEffect.h:183
float myWindTurbulence
Definition: DtGroundFogEffect.h:266
this class is used to create an effect around the eye to represent blowing particle effects such as s...
Definition: DtGroundFogEffect.h:35
SortJobData()
Definition: DtGroundFogEffect.h:244
unsigned int myVboPositionArray
Definition: DtGroundFogEffect.h:169
osg::Vec3d myCamPos
Definition: DtGroundFogEffect.h:57
Contains makVrv::DtVirtualBaseClass class.
DtGlVaoManager * myVaoManager
Definition: DtGroundFogEffect.h:276
Contains makVrv::DtJobSplitter class.
MeshGroup * myMeshGroup
Definition: DtGroundFogEffect.h:275
float mfIntensityPerWindStart
Definition: DtGroundFogEffect.h:271
GLint mySoftnessUnfmLoc
Definition: DtGroundFogEffect.h:59
float myEffectFade
Definition: DtGroundFogEffect.h:268
osg::Vec4 myPosition
Definition: DtGroundFogEffect.h:184
osg::Vec3 myColorMult
Definition: DtGroundFogEffect.h:270
float myParticleSize
Definition: DtGroundFogEffect.h:269
DtDe & myDe
Definition: DtGroundFogEffect.h:255
A generic structure to hold data for a job for use with DtJobSplitter.
Definition: DtJobSplitter.h:26
creator for DtGroundFogEffect
Definition: DtGroundFogEffect.h:287
float myRadius
Definition: DtGroundFogEffect.h:261
This class is used to manage an opengl vertex array object (VAO) dealing with multiple opengl context...
Definition: DtGlVaoManager.h:49
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
float myWindDirectionRad
Definition: DtGroundFogEffect.h:60
Particle()
Definition: DtGroundFogEffect.h:176
Contains DLL export macros.
a structure to hold data for a sorting job
Definition: DtGroundFogEffect.h:242
A drawable for drawing ground fog effects.
Definition: DtGroundFogEffectDrawable.h:35
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
float myWindSpeedMps
Definition: DtGroundFogEffect.h:263
float myDensity
Definition: DtGroundFogEffect.h:273
GLint myParametersUnfmLoc
Definition: DtGroundFogEffect.h:58
osg::Matrixd myBasisRot
Definition: DtGroundFogEffect.h:257
osg::StateSet * mySensorState
Definition: DtGroundFogEffect.h:64
A structure used to define a mesh group (voa, positions, coords).
Definition: DtGroundFogEffect.h:156
Contains the DtGlVaoManager class declaration.
float myWindSpeedMultiplier
Definition: DtGroundFogEffect.h:264
float myWindLiftMultiplier
Definition: DtGroundFogEffect.h:265
bool myStateDirty
Definition: DtGroundFogEffect.h:62

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)