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) 2026 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  , myWeatherAreaGroup(0)
61  , myState(0)
62  {
63  // intentional nop
64  }
65 
66  osg::RenderInfo* myRenderInfo;
67  osg::Vec3d myCamPos;
71  osg::StateSet* myState;
72  };
73 
75  DtGroundFogEffect(makVrv::DtDe& de, const int& particleCount, const float& particleSize, const float& radius);
76 
78  virtual ~DtGroundFogEffect();
79 
80  private:
81 
84 
87 
89  DtGroundFogEffect &operator=(const DtGroundFogEffect &other);
90 
91  public:
92 
94  // \param particleCount The maximum number of particles to simulate.
95  // \param particleSize The base particle size.
96  // \param radius The effect radius.
97  virtual void init(int particleCount, float particleSize, float radius);
98 
100  virtual void releaseGLObjects(osg::State* state) const;
101 
103  virtual void draw(DtGroundFogEffect::DrawData& drawData, const osg::Vec3& baseColor) const;
104 
108  virtual void cullUpdate(const osg::Vec3d& camPos, DtJobSplitter* jobSplitter);
109 
112  virtual void setEnable(bool enable);
113 
117  virtual void setWind(float windDirectionRad, float windSpeedMps);
118 
121  virtual void setWindSpeedMultiplier(float multiplier);
122 
125  virtual void setWindLiftMultiplier(float multiplier);
126 
129  virtual void setWindTurbulence(float multiplier);
130 
133  virtual void setDensity(float density);
134 
136  virtual void setEffectFade(float fade);
137 
141  virtual void setIntensityPerWindRamp(float start, float end);
142 
144  virtual float computeIntensityPerWind();
145 
147  virtual void setBasisRotation(const osg::Matrixd& rotation);
148 
151  virtual void setColorMult(float r, float g, float b);
152 
154  virtual float radius() const;
155 
158  virtual void runSort(const osg::Vec3& localCamPos);
159 
160  protected:
161 
163  struct MeshGroup
164  {
166  : myVboPositionArray(0)
167  , myVboTexCoords0Array(0)
168  {
169  myPoints = new osg::Vec4Array;
170  myTexCoords0 = new osg::Vec2Array;
171  }
172 
175 
176  DtGlBuffer* myVboPositionArray = nullptr;
177  DtGlBuffer* myVboTexCoords0Array = nullptr;
178  };
179 
181  struct Particle
182  {
184  : mySortDepth(0)
185  , myPosition(0, 0, 0, 0)
186  {
187  //intentional nop
188  }
189 
190  float mySortDepth;
191  osg::Vec4 myPosition;
192  };
193 
195  virtual void connectSignals();
196 
198  virtual void slot_simulationUpdate();
199 
201  virtual void computeSortDepth(const osg::Vec3& reference);
202 
204  virtual void fillSortedParticles();
205 
209  virtual bool bindMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
210 
214  virtual bool bindDynamicMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
215 
220  virtual bool bindVaoToMeshGroup(GLuint vao, MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
221 
225  virtual void simulateParticles(float timeStep, double currentTime);
226 
227  // non-virtual for maximum inner loop performance.
228 
233  void wrapPosition(float& posX, float& posY, float& posZ);
234 
235  private:
236 
238  static int theSortBackToFront(const void* arg0, const void* arg1);
239 
241  static void theSortJob(void* data);
242 
243  protected:
244 
246  struct SortJobData
247  {
249  : myEffect(0)
250  , myCameraPos(0, 0, 0)
251  {
252  //intentional nop
253  }
254 
256  osg::Vec3 myCameraPos;
257  };
258 
260 
261  osg::Matrixd myBasisRot;
262 
263  bool myEnable;
264  osg::Vec3 myScroll;
265  float myRadius;
271  double myLastTime;
274  osg::Vec3 myColorMult;
277  float myDensity;
278 
281 
284 
287 
289  };
290 }
291 
292 
293 
294 
DT_DLL_EXAMPLESCENEROOTPLUGIN void init(DtDe &anIG)
float myWindDirectionRad
Definition: DtGroundFogEffect.h:266
SortJobData mySortJobData
Definition: DtGroundFogEffect.h:285
bool myEnable
Definition: DtGroundFogEffect.h:263
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:174
osg::ref_ptr< osg::Vec4Array > myPoints
Definition: DtGroundFogEffect.h:173
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
A structure used to define a simulation particle.
Definition: DtGroundFogEffect.h:181
MeshGroup()
Definition: DtGroundFogEffect.h:165
const DtWeatherAreaGroup * myWeatherAreaGroup
Definition: DtGroundFogEffect.h:70
osg::Vec3 myScroll
Definition: DtGroundFogEffect.h:264
osg::Vec3 myCameraPos
Definition: DtGroundFogEffect.h:256
unsigned int GLuint
Definition: DtGlTextureBufferObject.h:18
DtGroundFogEffect * myEffect
Definition: DtGroundFogEffect.h:255
DtJobSplitterJob mySortJob
Definition: DtGroundFogEffect.h:286
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:76
int myParticleCount
Definition: DtGroundFogEffect.h:283
float mfIntensityPerWindEnd
Definition: DtGroundFogEffect.h:276
osg::RenderInfo * myRenderInfo
Definition: DtGroundFogEffect.h:66
Particle * myParticles
Definition: DtGroundFogEffect.h:282
double myLastTime
Definition: DtGroundFogEffect.h:271
float mySortDepth
Definition: DtGroundFogEffect.h:190
float myWindTurbulence
Definition: DtGroundFogEffect.h:270
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:23
SortJobData()
Definition: DtGroundFogEffect.h:248
osg::Vec3d myCamPos
Definition: DtGroundFogEffect.h:67
DtGlVaoManager * myVaoManager
Definition: DtGroundFogEffect.h:280
DtSignalConnectionManager myConnections
Definition: DtGroundFogEffect.h:288
Contains makVrv::DtJobSplitter class.
MeshGroup * myMeshGroup
Definition: DtGroundFogEffect.h:279
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
float mfIntensityPerWindStart
Definition: DtGroundFogEffect.h:275
osg::StateSet * myState
Definition: DtGroundFogEffect.h:71
GLint mySoftnessUnfmLoc
Definition: DtGroundFogEffect.h:69
float myEffectFade
Definition: DtGroundFogEffect.h:272
osg::Vec4 myPosition
Definition: DtGroundFogEffect.h:191
osg::Vec3 myColorMult
Definition: DtGroundFogEffect.h:274
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:273
DtDe & myDe
Definition: DtGroundFogEffect.h:259
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:265
This class is used to manage an opengl vertex array object (VAO) dealing with multiple opengl context...
Definition: DtGlVaoManager.h:58
Particle()
Definition: DtGroundFogEffect.h:183
Contains DLL export macros.
a structure to hold data for a sorting job
Definition: DtGroundFogEffect.h:246
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:76
float myWindSpeedMps
Definition: DtGroundFogEffect.h:267
float myDensity
Definition: DtGroundFogEffect.h:277
GLint myParametersUnfmLoc
Definition: DtGroundFogEffect.h:68
osg::Matrixd myBasisRot
Definition: DtGroundFogEffect.h:261
A structure used to define a mesh group (voa, positions, coords).
Definition: DtGroundFogEffect.h:163
Contains the DtGlVaoManager class declaration.
float myWindSpeedMultiplier
Definition: DtGroundFogEffect.h:268
float myWindLiftMultiplier
Definition: DtGroundFogEffect.h:269
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 Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)