VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtWaterOnScreenEffect.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2014 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 
17 #include <vrvOsg/DtPostProcessor.h>
18 
19 #include <osg/Texture2D>
20 #include <osg/Image>
21 
22 
23 // The dimension of the grid used to divide the screen into discrete
24 // locations for water drops.
25 #define GRID_DIMENSION 200
26 // The texture size of the normal map used for post processing. This has
27 // a big impact on performance, so don't make it bigger than necessary.
28 // Having it kind of low is also useful for blurring the drops a bit and
29 // giving a cheap depth of field effect on them.
30 #define TEXSIZE 768
31 
32 namespace makVrv
33 {
34  class DropParticle;
35  class RaindropParticle;
36  class SplashParticle;
37  class DtWindow;
38  class DtObserverObject;
39 
44  {
45  public:
47  DtWaterOnScreen(DtDe& de, const std::string& postProcessType, bool handles2D);
48 
50  virtual ~DtWaterOnScreen();
51 
53  void activateRaindrops(bool on);
54 
57  void activateSplashes(bool on);
58 
60  void activateSpray(bool on);
61 
63  void setIsUnderwater(bool underwater);
64 
67  void addRainDrop(float x, float y, float radius);
68 
71  void addOceanSplash(float intensity);
72 
74  void setSplashIntensity(float intensity);
75 
77  void setSprayIntensity(float intensity);
78 
80  virtual void update(DtChannel *channel);
81 
83  int getNumActiveDrops() const;
84 
86  class GridCell
87  {
88  public:
89  GridCell();
90 
91  DropParticle *drop;
93  };
94 
98  void addSplashEffects(const DtObserverObject *observer, bool hasWaveSplashEffect);
99 
103  void addSprayEffects(const DtObserverObject *observer, bool hasOceanSprayEffect);
104 
105  protected:
106  void initialize();
107 
108  void clearNormalMap();
109 
110  void updateAndDrawDrops(double elapsedTime);
111 
112  void addRaindrops(double time, float heading, float observerVelocity);
113 
114  void addSpray(double time, float heading);
115 
116  void clearDrops();
117 
118  void setActiveStatus();
119 
120  void slot_windowRemoved(DtWindow* window);
121 
122  osg::ref_ptr<osg::Texture2D> myNormalMap;
123  osg::ref_ptr<osg::Image> myNormalImage;
125 
127  double myLastDropEmissionTime, myLastSprayEmissionTime;
128 
129  bool myRaindropsActiveFlag, mySplashesActiveFlag, mySprayActiveFlag;
130  bool myActiveFlag, myUnderwaterFlag;
131 
132  float mySplashIntensity, mySprayIntensity;
133 
135 
137 
138  unsigned char normalMapClearData[TEXSIZE*TEXSIZE*4];
140  unsigned char normalImageData[TEXSIZE*TEXSIZE*4];
141  };
142 
143  //
144  // Creator
145  //
146 
151  : public DtPostProcessorCreator
152  {
153  public:
156 
159 
161  virtual ~DtWaterOnScreenCreator();
162 
163  protected:
165  virtual DtPostProcessor* create(DtDe& de, const std::string& postProcessType);
166  };
167 }

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)