VR-Forces 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) 2022 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 
19 
20 #include <osg/RenderInfo>
21 #include <osg/Vec3d>
22 
23 
24 namespace makVrv
25 {
26  // Forward declarations.
27  class DtWeatherAreaGroup;
28  class DtGlBuffer;
29 
32 
35 
37  template <>
38  inline const char* creatorTypeName<DtGroundFogEffect>(void) { return "DtGroundFogEffectCreator"; }
39 
40 
49  {
50  public:
51 
53  struct DrawData
54  {
56  : myRenderInfo(0)
57  , myCamPos(0, 0, 0)
58  , myParametersUnfmLoc(0)
59  , mySoftnessUnfmLoc(0)
60  , myWindDirectionRad(0)
61  , myWindSpeedMps(0)
62  , myWeatherAreaGroup(0)
63  , myState(0)
64  {
65  // intentional nop
66  }
67 
68  osg::RenderInfo* myRenderInfo;
69  osg::Vec3d myCamPos;
75  osg::StateSet* myState;
76  };
77 
79  DtGroundFogEffect(makVrv::DtDe& de, const int& particleCount, const float& particleSize, const float& radius);
80 
82  virtual ~DtGroundFogEffect();
83 
84  private:
85 
88 
91 
93  DtGroundFogEffect &operator=(const DtGroundFogEffect &other);
94 
95  public:
96 
98  // \param particleCount The maximum number of particles to simulate.
99  // \param particleSize The base particle size.
100  // \param radius The effect radius.
101  virtual void init(int particleCount, float particleSize, float radius);
102 
104  virtual void releaseGLObjects(osg::State* state) const;
105 
107  virtual void draw(DtGroundFogEffect::DrawData& drawData, const osg::Vec3& baseColor) const;
108 
112  virtual void cullUpdate(const osg::Vec3d& camPos, DtJobSplitter* jobSplitter);
113 
116  virtual void setEnable(bool enable);
117 
121  virtual void setWind(float windDirectionRad, float windSpeedMps);
122 
125  virtual void setWindSpeedMultiplier(float multiplier);
126 
129  virtual void setWindLiftMultiplier(float multiplier);
130 
133  virtual void setWindTurbulence(float multiplier);
134 
137  virtual void setDensity(float density);
138 
140  virtual void setEffectFade(float fade);
141 
145  virtual void setIntensityPerWindRamp(float start, float end);
146 
148  virtual float computeIntensityPerWind();
149 
151  virtual void setBasisRotation(const osg::Matrixd& rotation);
152 
155  virtual void setColorMult(float r, float g, float b);
156 
158  virtual float radius() const;
159 
162  virtual void runSort(const osg::Vec3& localCamPos);
163 
164  protected:
165 
167  struct MeshGroup
168  {
170  : myVboPositionArray(0)
171  , myVboTexCoords0Array(0)
172  {
173  myPoints = new osg::Vec4Array;
174  myTexCoords0 = new osg::Vec2Array;
175  }
176 
179 
180  DtGlBuffer* myVboPositionArray = nullptr;
181  DtGlBuffer* myVboTexCoords0Array = nullptr;
182  };
183 
185  struct Particle
186  {
188  : mySortDepth(0)
189  , myPosition(0, 0, 0, 0)
190  {
191  //intentional nop
192  }
193 
194  float mySortDepth;
195  osg::Vec4 myPosition;
196  };
197 
199  virtual void connectSignals();
200 
202  virtual void slot_simulationUpdate();
203 
205  virtual void computeSortDepth(const osg::Vec3& reference);
206 
208  virtual void fillSortedParticles();
209 
213  virtual bool bindMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
214 
218  virtual bool bindDynamicMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
219 
224  virtual bool bindVaoToMeshGroup(GLuint vao, MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
225 
229  virtual void simulateParticles(float timeStep, double currentTime);
230 
231  // non-virtual for maximum inner loop performance.
232 
237  void wrapPosition(float& posX, float& posY, float& posZ);
238 
239  private:
240 
242  static int theSortBackToFront(const void* arg0, const void* arg1);
243 
245  static void theSortJob(void* data);
246 
247  protected:
248 
250  struct SortJobData
251  {
253  : myEffect(0)
254  , myCameraPos(0, 0, 0)
255  {
256  //intentional nop
257  }
258 
260  osg::Vec3 myCameraPos;
261  };
262 
264 
265  osg::Matrixd myBasisRot;
266 
267  bool myEnable;
268  osg::Vec3 myScroll;
269  float myRadius;
275  double myLastTime;
278  osg::Vec3 myColorMult;
281  float myDensity;
282 
285 
288 
291 
293  };
294 }
295 
296 
297 
298 
DT_DLL_EXAMPLESCENEROOTPLUGIN void init(DtDe &anIG)
float myWindDirectionRad
Definition: DtGroundFogEffect.h:270
SortJobData mySortJobData
Definition: DtGroundFogEffect.h:289
bool myEnable
Definition: DtGroundFogEffect.h:267
A structure used to hold data for drawing.
Definition: DtGroundFogEffect.h:53
DrawData()
Definition: DtGroundFogEffect.h:55
osg::ref_ptr< osg::Vec2Array > myTexCoords0
Definition: DtGroundFogEffect.h:178
float myWindSpeedMps
Definition: DtGroundFogEffect.h:73
osg::ref_ptr< osg::Vec4Array > myPoints
Definition: DtGroundFogEffect.h:177
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
A structure used to define a simulation particle.
Definition: DtGroundFogEffect.h:185
MeshGroup()
Definition: DtGroundFogEffect.h:169
const DtWeatherAreaGroup * myWeatherAreaGroup
Definition: DtGroundFogEffect.h:74
osg::Vec3 myScroll
Definition: DtGroundFogEffect.h:268
osg::Vec3 myCameraPos
Definition: DtGroundFogEffect.h:260
unsigned int GLuint
Definition: DtGlTextureBufferObject.h:18
DtGroundFogEffect * myEffect
Definition: DtGroundFogEffect.h:259
DtJobSplitterJob mySortJob
Definition: DtGroundFogEffect.h:290
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:75
int myParticleCount
Definition: DtGroundFogEffect.h:287
float mfIntensityPerWindEnd
Definition: DtGroundFogEffect.h:280
osg::RenderInfo * myRenderInfo
Definition: DtGroundFogEffect.h:68
Particle * myParticles
Definition: DtGroundFogEffect.h:286
double myLastTime
Definition: DtGroundFogEffect.h:275
float mySortDepth
Definition: DtGroundFogEffect.h:194
float myWindTurbulence
Definition: DtGroundFogEffect.h:274
this class is used to create an effect around the eye to represent blowing particle effects such as s...
Definition: DtGroundFogEffect.h:48
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:22
SortJobData()
Definition: DtGroundFogEffect.h:252
osg::Vec3d myCamPos
Definition: DtGroundFogEffect.h:69
DtGlVaoManager * myVaoManager
Definition: DtGroundFogEffect.h:284
DtSignalConnectionManager myConnections
Definition: DtGroundFogEffect.h:292
Contains makVrv::DtJobSplitter class.
MeshGroup * myMeshGroup
Definition: DtGroundFogEffect.h:283
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
float mfIntensityPerWindStart
Definition: DtGroundFogEffect.h:279
osg::StateSet * myState
Definition: DtGroundFogEffect.h:75
GLint mySoftnessUnfmLoc
Definition: DtGroundFogEffect.h:71
float myEffectFade
Definition: DtGroundFogEffect.h:276
osg::Vec4 myPosition
Definition: DtGroundFogEffect.h:195
osg::Vec3 myColorMult
Definition: DtGroundFogEffect.h:278
A generic OpenGL buffer. This can be: -&gt; a vertex buffer -&gt; an index buffer -&gt; a shader storage buffe...
Definition: DtGlBuffer.h:29
float myParticleSize
Definition: DtGroundFogEffect.h:277
DtDe & myDe
Definition: DtGroundFogEffect.h:263
Base class to provide boost signal/slot management.
A generic structure to hold data for a job for use with DtJobSplitter.
Definition: DtJobSplitter.h:26
DtVirtualBaseClassCreator< DtGroundFogEffect, const int &, const float &, const float & > DtGroundFogEffectCreator
creator
Definition: DtGroundFogEffect.h:31
float myRadius
Definition: DtGroundFogEffect.h:269
This class is used to manage an opengl vertex array object (VAO) dealing with multiple opengl context...
Definition: DtGlVaoManager.h:58
float myWindDirectionRad
Definition: DtGroundFogEffect.h:72
Particle()
Definition: DtGroundFogEffect.h:187
Contains DLL export macros.
a structure to hold data for a sorting job
Definition: DtGroundFogEffect.h:250
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:72
float myWindSpeedMps
Definition: DtGroundFogEffect.h:271
float myDensity
Definition: DtGroundFogEffect.h:281
GLint myParametersUnfmLoc
Definition: DtGroundFogEffect.h:70
osg::Matrixd myBasisRot
Definition: DtGroundFogEffect.h:265
A structure used to define a mesh group (voa, positions, coords).
Definition: DtGroundFogEffect.h:167
Contains the DtGlVaoManager class declaration.
float myWindSpeedMultiplier
Definition: DtGroundFogEffect.h:272
float myWindLiftMultiplier
Definition: DtGroundFogEffect.h:273
const char * creatorTypeName< DtGroundFogEffect >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtGroundFogEffect.h:38

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)