VR-Forces 4.7 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtWaterOnScreenEffect.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2016 MAK Technologies, Inc.
3  * All rights reserved.
4  *****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvTriton/vrvTriton.h>
13 #include <matrix/vlVector.h>
14 
15 #include <vrvOsg/vrvOsg.h>
16 
18 
20 
21 #include <osg/Texture2D>
22 #include <osg/Image>
23 
24 
25 // The dimension of the grid used to divide the screen into discrete
26 // locations for water drops.
27 #define GRID_DIMENSION 200
28 // The texture size of the normal map used for post processing. This has
29 // a big impact on performance, so don't make it bigger than necessary.
30 // Having it kind of low is also useful for blurring the drops a bit and
31 // giving a cheap depth of field effect on them.
32 #define TEXSIZE 768
33 
34 namespace makVrv
35 {
36  class DropParticle;
37  class RaindropParticle;
38  class SplashParticle;
39  class DtWindow;
40  class DtObserverObject;
41 
46  {
47  public:
49  DtWaterOnScreen(DtDe& de, const std::string& postProcessType, bool handles2D);
50 
52  virtual ~DtWaterOnScreen();
53 
55  void activateRaindrops(bool on);
56 
59  void activateSplashes(bool on);
60 
62  void activateSpray(bool on);
63 
65  void setIsUnderwater(bool underwater);
66 
69  void addRainDrop(float x, float y, float radius);
70 
73  void addOceanSplash(float intensity);
74 
76  void setSplashIntensity(float intensity);
77 
79  void setSprayIntensity(float intensity);
80 
82  virtual bool update(DtChannel *channel);
83 
85  int getNumActiveDrops() const;
86 
88  void setWaterOnScreenSize(double size);
89 
91  static double waterOnScreenSize();
92 
94  class GridCell
95  {
96  public:
97  GridCell();
98 
99  DropParticle *drop;
101  };
102 
106  void addSplashEffects(const DtObserverObject *observer, bool hasWaveSplashEffect);
107 
111  void addSprayEffects(const DtObserverObject *observer, bool hasOceanSprayEffect);
112 
113  protected:
114  virtual void initialize();
115 
116  void clearNormalMap();
117 
118  void updateAndDrawDrops(double elapsedTime);
119 
120  void addRaindrops(double time, float heading, float observerVelocity);
121 
122  void addSpray(double time, float heading);
123 
124  void clearDrops();
125 
126  void reset();
127 
128  void setActiveStatus();
129 
130  void slot_windowRemoved(DtWindow* window);
131 
132  void slot_waterOnScreenSizeChanged(double value);
133 
134  osg::ref_ptr<osg::Texture2D> myNormalMap;
135  osg::ref_ptr<osg::Image> myNormalImage;
137 
139  double myLastDropEmissionTime, myLastSprayEmissionTime;
140 
141  bool myRaindropsActiveFlag, mySplashesActiveFlag, mySprayActiveFlag;
142  bool myActiveFlag, myUnderwaterFlag;
143 
144  float mySplashIntensity, mySprayIntensity;
145 
147 
148  static double myWaterOnScreenSize;
149 
151 
152  unsigned char myNormalMapClearData[TEXSIZE*TEXSIZE*4];
154  unsigned char myNormalImageData[TEXSIZE*TEXSIZE*4];
155 
157  };
158 
159  //
160  // Creator
161  //
162 
167  : public DtPostProcessorCreator
168  {
169  public:
171  friend class DtPostProcessManager;
172 
175 
177  virtual ~DtWaterOnScreenCreator();
178 
179  protected:
181  virtual DtPostProcessor* create(DtDe& de, const std::string& postProcessType);
182  };
183 }

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)