VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtGroundFogPatchArea.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 <osg/Camera>
13 #include <osg/Drawable>
14 
15 #include <vrvCore/DtDe.h>
16 
18 #include <vrvOsg/DtGlVaoManager.h>
20 #include <vrvOsg/vrvOsg.h>
21 
22 #include <matrix/vlVector.h>
23 
24 #include <osg/Matrixd>
25 #include <osg/ref_ptr>
26 #include <osg/RenderInfo>
27 #include <osg/State>
28 #include <osg/Vec3d>
29 #include <osg/Vec4d>
30 #include <osg/Array>
31 
32 
33 namespace makVrv
34 {
35  // Forward declarations.
36  class DtGroundFogPatch;
37  class DtGroundFogPatchDrawable;
38  class DtJobSplitter;
39 
40 
57  {
58  public:
59 
62  enum AREA_TYPE
63  {
65  AREA_TYPE_SANDSTORM
66  };
67 
69  struct DrawData
70  {
72  : myRenderInfo(0)
73  , myCamPos(0, 0, 0)
74  , myGroundFogUnfmLoc(0)
75  , myInstanceParamsUnfmLoc(0)
76  , myInstanceMatrixUnfmLoc(0)
77  , myPatternedUnfmLoc(0)
78  , mySkeletonUnfmLoc(0)
79  , mySoftnessUnfmLoc(0)
80  , myPatternSize(512.0f)
81  , myWindDirectionRad(0)
82  , myWindSpeedMps(0)
83  , myStateDirty(true)
84  , myDrawable(0)
85  , mySensorState(0)
86  {
87  // intentional nop
88  }
89 
90  osg::RenderInfo* myRenderInfo;
91  osg::Vec3d myCamPos;
103  osg::StateSet* mySensorState;
104  };
105 
108 
110  virtual ~DtGroundFogPatchArea();
111 
112  private:
113 
116 
119 
121  DtGroundFogPatchArea &operator=(const DtGroundFogPatchArea &other);
122 
123  public:
124 
128  virtual void init(float worldSize, float thickness);
129 
132  virtual void addEffect(DtGroundFogEffect* effect);
133 
135  virtual void releaseFogPatchGLObjects(osg::State* state) const;
136 
138  virtual void releaseFogEffectGLObjects(osg::State* state) const;
139 
143  virtual void cullUpdate(const osg::Vec3d& camPos, const osg::Matrixd& viewMatrixI, const std::vector<osg::Vec4d>& cullingPlanes, DtJobSplitter* jobSplitter);
144 
146  virtual bool shouldDrawFogPatches();
147 
149  virtual void drawFogPatches(DtGroundFogPatchArea::DrawData& drawData);
150 
152  virtual void drawFogEffects(DtGroundFogEffect::DrawData& drawData);
153 
156  virtual void setDensity(float density);
157 
159  virtual float density() const;
160 
165  virtual void setTransform(const DtVector& position, float orientation, bool relativeToCamera = false);
166 
169  virtual void setEnabled(bool enabled);
170 
172  virtual bool enabled() const;
173 
176  virtual void setClampingEnabled(bool enabled);
177 
179  virtual bool clampingEnabled() const;
180 
182  virtual float worldSize() const;
183 
187  virtual void setBounds(const DtVector& bounds, float cornerRadius);
188 
191  virtual bool isPositionAboveArea(const osg::Vec3d& position);
192 
197  virtual void setBaseColor(float red, float green, float blue);
198 
201  virtual void setParticleSizeVariation(float variation);
202 
207  virtual void setPatternedLook(bool patternedEnable);
208 
212  virtual void setAreaType(DtGroundFogPatchArea::AREA_TYPE areaType);
213 
216  virtual DtGroundFogPatchArea::AREA_TYPE areaType() const;
217 
218  protected:
219 
221  struct MeshGroup
222  {
224  : myVboPositionArray(0)
225  , myVboTexCoords0Array(0)
226  , myVboBonesArray(0)
227  , myVboWeightsArray(0)
228  {
229  myPoints = new osg::Vec3Array;
230  myTexCoords0 = new osg::Vec2Array;
231  myBones = new osg::Vec4Array;
232  myWeights = new osg::Vec4Array;
233  }
234 
239 
240  unsigned int myVboPositionArray;
241  unsigned int myVboTexCoords0Array;
242  unsigned int myVboBonesArray;
243  unsigned int myVboWeightsArray;
244  };
245 
247  struct BoneWeight
248  {
250  : myIndex(0)
251  , myWeight(0)
252  {
253  // intentional nop
254  }
255 
256  int myIndex;
257  double myWeight;
258  };
259 
261  virtual void freeData(void);
262 
269  virtual void computeWeights(float x, float y, float patchSize, float* bones, float* weights);
270 
274  virtual void initLod(int gridSize, float patchSize);
275 
279  virtual bool bindMeshGroupData(MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
280 
285  virtual bool bindVaoToMeshGroup(GLuint vao, MeshGroup* meshGroup, osg::RenderInfo& renderInfo) const;
286 
290  virtual void computeBasis(const osg::Vec3d& inGeocentricPos, osg::Matrixd& rotOut);
291 
294  virtual void computeSortDepth(const osg::Vec3& camPos);
295 
300  virtual void inverseTransformPlane(osg::Vec4d& plane, const osg::Vec3d& position, const osg::Matrixd& rotation);
301 
306  virtual bool isSphereVisible(const std::vector<osg::Vec4d>& planes, const osg::Vec3d& center, double radius);
307 
309  virtual void computeBoundsCulling();
310 
312  virtual float computeEffectFade(const osg::Vec3& localCam);
313 
315  virtual double clampDistance() const;
316 
319  virtual bool clampPosition(osg::Vec3d& position);
320 
322  virtual float computeParticleSize();
323 
325  virtual float computePatchCellSize();
326 
328  static int theSortWeights(const void* arg0, const void* arg1);
329 
331  static int theSortBackToFront(const void* arg0, const void* arg1);
332 
333  protected:
334 
336 
337  float myDensity;
338  bool myEnabled;
339 
340  float myWindU; // current pattern texture U offset for wind
341  float myWindV; // current pattern texture V offset for wind
342  double myLastWindTime; // last time wind was computed
343 
344  bool myCameraBasisDirty; // true if the basis needs computed from the camera
349  float myMaxClampOffset; // the maximum computed abs(clamp offset)
350 
351  float myBaseColorR; // the red component of the base color
352  float myBaseColorG; // the green component of the base color
353  float myBaseColorB; // the blue component of the base color
354 
355  float myParticleSizeVariation; // particle size variation
356  // base size + random(-myParticleSizeVariation, myParticleSizeVariation) * base size
357 
358  float myPatternedLook; // (-1 or 1) passed to shader to indicate patterned look or not
360 
363 
364  osg::Vec3d myPosition;
366  osg::Vec3d myBasisPos;
367  osg::Matrixd myBasisRot;
368 
369  float myBoundsX;
370  float myBoundsY;
372 
373  static const double DT_GFP_CLAMP_DISTANCE; // the skeletal terrain clamping distance (affects culling too)
374  static const int DT_GFP_CELL_SIZE; // the number of cells in 1 row of a patch
375 
376  int myGridSize; // the number of patches in 1 row of a ground fog system
377  float myPatchWorldSize; // the world size of a patch: dimensions are (myPatchWorldSize x myPatchWorldSize x patchWorldHeight)
378  std::vector<DtGroundFogPatch*> myPatches;
379  int myPatchCount; // the total number of patches (myGridSize x myGridSize)
380  DtGroundFogPatch** myRenderPatches; // pointer to dynamically allocated array of pointers used for draw queue
382 
383  std::vector<DtGroundFogEffect*> myEffects;
384  };
385 
386 
389  {
390  public:
393 
395  virtual ~DtGroundFogPatchAreaCreator();
396 
397  private:
402 
403  public:
407  virtual DtGroundFogPatchArea* create(float worldSize, float thickness) const;
408 
411  static DtGroundFogPatchAreaCreator& instance(DtDe& de);
412 
414  static const std::string& theClassName();
415 
416  protected:
418  };
419 }
420 
421 
422 
int myIndex
Definition: DtGroundFogPatchArea.h:256
Virtual base class.
Definition: DtVirtualBaseClass.h:22
A structure used to hold data for drawing.
Definition: DtGroundFogEffect.h:40
DtGroundFogPatch ** myRenderPatches
Definition: DtGroundFogPatchArea.h:380
float myPatchWorldSize
Definition: DtGroundFogPatchArea.h:377
bool myEnabled
Definition: DtGroundFogPatchArea.h:338
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
AREA_TYPE
brief Area type enumerations.
Definition: DtGroundFogPatchArea.h:62
DtDe & myDe
Definition: DtGroundFogPatchArea.h:335
osg::RenderInfo * myRenderInfo
Definition: DtGroundFogPatchArea.h:90
double myLastWindTime
Definition: DtGroundFogPatchArea.h:342
osg::ref_ptr< osg::Vec4Array > myBones
Definition: DtGroundFogPatchArea.h:237
creator for DtGroundFogPatchArea
Definition: DtGroundFogPatchArea.h:388
unsigned int GLuint
Definition: DtGlTextureBufferObject.h:17
float myBoundsX
Definition: DtGroundFogPatchArea.h:369
Contains makVrv::DtDe class.
this class is used to split work up between threads.
Definition: DtJobSplitter.h:64
float myBaseColorR
Definition: DtGroundFogPatchArea.h:351
double myWeight
Definition: DtGroundFogPatchArea.h:257
GLint myPatternedUnfmLoc
Definition: DtGroundFogPatchArea.h:95
DrawData()
Definition: DtGroundFogPatchArea.h:71
BoneWeight()
Definition: DtGroundFogPatchArea.h:249
GLint myGroundFogUnfmLoc
Definition: DtGroundFogPatchArea.h:92
MeshGroup()
Definition: DtGroundFogPatchArea.h:223
AREA_TYPE myAreaType
Definition: DtGroundFogPatchArea.h:359
DtDe & myDe
Definition: DtGroundFogPatchArea.h:417
std::vector< DtGroundFogEffect * > myEffects
Definition: DtGroundFogPatchArea.h:383
int myClampBoneIndex
Definition: DtGroundFogPatchArea.h:348
osg::Vec3d myCamPos
Definition: DtGroundFogPatchArea.h:91
this class is used to create an effect around the eye to represent blowing particle effects such as s...
Definition: DtGroundFogEffect.h:35
std::vector< DtGroundFogPatch * > myPatches
Definition: DtGroundFogPatchArea.h:378
DtGlVaoManager * myVaoManager
Definition: DtGroundFogPatchArea.h:362
static const double DT_GFP_CLAMP_DISTANCE
Definition: DtGroundFogPatchArea.h:373
osg::Vec3d myBasisPos
Definition: DtGroundFogPatchArea.h:366
float myMaxClampOffset
Definition: DtGroundFogPatchArea.h:349
an object used to represent 1 patch of a patchy ground fog system.
Definition: DtGroundFogPatch.h:32
unsigned int myVboTexCoords0Array
Definition: DtGroundFogPatchArea.h:241
Contains makVrv::DtOsgCullVisitor class.
float myWindV
Definition: DtGroundFogPatchArea.h:341
unsigned int myVboWeightsArray
Definition: DtGroundFogPatchArea.h:243
GLint mySoftnessUnfmLoc
Definition: DtGroundFogPatchArea.h:97
bool myCameraBasisDirty
Definition: DtGroundFogPatchArea.h:344
int myRenderPatchCount
Definition: DtGroundFogPatchArea.h:381
float myPatternSize
Definition: DtGroundFogPatchArea.h:98
unsigned int myVboBonesArray
Definition: DtGroundFogPatchArea.h:242
float myPatternedLook
Definition: DtGroundFogPatchArea.h:358
float myParticleSizeVariation
Definition: DtGroundFogPatchArea.h:355
const DtGroundFogPatchDrawable * myDrawable
Definition: DtGroundFogPatchArea.h:102
float myWindU
Definition: DtGroundFogPatchArea.h:340
bool myInitialized
Definition: DtGroundFogPatchArea.h:345
float myWindDirectionRad
Definition: DtGroundFogPatchArea.h:99
A structure used to define a mesh group (voa, positions, coords).
Definition: DtGroundFogPatchArea.h:221
float myBaseColorB
Definition: DtGroundFogPatchArea.h:353
GLint myInstanceParamsUnfmLoc
Definition: DtGroundFogPatchArea.h:93
float myBaseColorG
Definition: DtGroundFogPatchArea.h:352
An area of ground fog patch items and effects.
Definition: DtGroundFogPatchArea.h:56
bool myClampingEnabled
Definition: DtGroundFogPatchArea.h:346
float myWindSpeedMps
Definition: DtGroundFogPatchArea.h:100
float myOrientation
Definition: DtGroundFogPatchArea.h:365
osg::ref_ptr< osg::Vec4Array > myWeights
Definition: DtGroundFogPatchArea.h:238
int myGridSize
Definition: DtGroundFogPatchArea.h:376
GLint myInstanceMatrixUnfmLoc
Definition: DtGroundFogPatchArea.h:94
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 myBoundsCornerRadius
Definition: DtGroundFogPatchArea.h:371
int myClampIndex
Definition: DtGroundFogPatchArea.h:347
Contains makVrv::DtGroundFogEffect class.
Contains DLL export macros.
float myDensity
Definition: DtGroundFogPatchArea.h:337
osg::ref_ptr< osg::Vec3Array > myPoints
Definition: DtGroundFogPatchArea.h:235
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
MeshGroup * myMeshGroup
Definition: DtGroundFogPatchArea.h:361
GLint mySkeletonUnfmLoc
Definition: DtGroundFogPatchArea.h:96
unsigned int myVboPositionArray
Definition: DtGroundFogPatchArea.h:240
Contains the DtGlVaoManager class declaration.
A drawable used for drawing patchy ground fog objects.
Definition: DtGroundFogPatchDrawable.h:35
int myPatchCount
Definition: DtGroundFogPatchArea.h:379
osg::StateSet * mySensorState
Definition: DtGroundFogPatchArea.h:103
float myBoundsY
Definition: DtGroundFogPatchArea.h:370
osg::Matrixd myBasisRot
Definition: DtGroundFogPatchArea.h:367
A structure used to hold data for drawing.
Definition: DtGroundFogPatchArea.h:69
osg::Vec3d myPosition
Definition: DtGroundFogPatchArea.h:364
osg::ref_ptr< osg::Vec2Array > myTexCoords0
Definition: DtGroundFogPatchArea.h:236
static const int DT_GFP_CELL_SIZE
Definition: DtGroundFogPatchArea.h:374
A structure used to define a skeleton bone weight.
Definition: DtGroundFogPatchArea.h:247
bool myStateDirty
Definition: DtGroundFogPatchArea.h:101

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)