00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef WATER_HEIGHT_MAP_H
00028 #define WATER_HEIGHT_MAP_H
00029
00030
00031 #include "nel/misc/types_nl.h"
00032 #include "nel/misc/vector_2f.h"
00033 #include "nel/3d/u_water.h"
00034 #include "nel/3d/animation_time.h"
00035
00036
00037 #include <vector>
00038 #include <string>
00039
00040
00041
00042
00043 namespace NL3D
00044 {
00045
00046
00047 class CWaterPoolManager;
00048
00049
00065 const uint NumWaterMap = 3;
00066
00067 class CWaterHeightMap : public UWaterHeightMap
00068 {
00069 public:
00070
00074 void animate(float deltaT);
00075
00079 void setSize(uint32 size);
00080
00082 uint32 getSize(void) const { return _Size; }
00083
00085
00091 void setUserPos(sint x, sint y);
00092
00093
00097 void getUserPos(sint &x, sint &y) const;
00098
00099
00100
00102 void perturbate(sint x, sint y, sint radius, float intensity);
00103
00106 virtual void perturbate(const NLMISC::CVector2f &pos, float strenght, float radius) ;
00107
00108
00110 void perturbatePoint(sint x, sint y, float intensity);
00111
00114 virtual void perturbatePoint(const NLMISC::CVector2f &pos, float strenght);
00115
00118 virtual float getHeight(const NLMISC::CVector2f &pos);
00119
00120
00122 float *getPointer(void) { return &(_Map[_CurrMap][0]); }
00123
00125 float *getPrevPointer(void) { return &(_Map[(_CurrMap + (NumWaterMap - 1)) % NumWaterMap][0]); }
00126
00128 float getBufferRatio() const { return _PropagationTime != 0 ? _PropagateEllapsedTime / _PropagationTime : 0.f; }
00129
00131
00132
00133
00135 void enableWaves(bool enabled = true) { _WavesEnabled = enabled; }
00136
00138 bool areWavesEnabled() const { return _WavesEnabled; }
00139
00147 void setWaves(float intensity, float period, uint radius, bool border);
00148
00150 float getWaveIntensity() const { return _WaveIntensity; }
00151
00153 float getWavePeriod() const { return _WavePeriod; }
00154
00156 uint32 getWaveImpulsionRadius() const { return _WaveImpulsionRadius; }
00157
00159 bool getBorderWaves() const { return _BorderWaves; }
00160
00162 void setDamping(float damping) { nlassert(damping >= 0 && damping < 1); _Damping = damping; }
00163 float getDamping() const { return _Damping; }
00164
00166 void setFilterWeight(float filterWeight) { _FilterWeight = filterWeight; }
00167 float getFilterWeight() const { return _FilterWeight; }
00168
00170 void setUnitSize(float unitSize) { _UnitSize = unitSize; }
00171 float getUnitSize() const { return _UnitSize; }
00172
00174 sint64 Date;
00175
00177 void serial(NLMISC::IStream &f) throw(NLMISC::EStream);
00178
00180 void setName(const std::string &name) { _Name = name; }
00181
00183 const std::string &getName() const { return _Name; }
00184
00185
00186 CWaterHeightMap();
00187
00188 virtual ~CWaterHeightMap() {}
00189
00191 void setPropagationTime(float time);
00192
00194 TAnimationTime getPropagationTime() const { return _PropagationTime; }
00195
00196
00197 private:
00198 void animateWaves(float deltaT);
00199
00200 void updateUserPos();
00201
00202 void animatePart(float startTime, float endTime);
00203
00208 void propagate(uint startLine, uint endLine);
00209
00210
00212 void filter(uint startLine, uint endLine);
00213
00215 void swapBuffers(float deltaT);
00216
00217
00218 friend class CWaterPoolManager;
00219
00220 std::string _Name;
00221 bool _WavesEnabled;
00222 float _Damping;
00223 float _FilterWeight;
00224 float _UnitSize;
00225 float _WaveIntensity;
00226 float _WavePeriod;
00227 uint32 _WaveImpulsionRadius;
00228 bool _BorderWaves;
00229 float _EmitEllapsedTime;
00230 float _PropagateEllapsedTime;
00231 TAnimationTime _PropagationTime;
00232
00233
00234 uint _X, _Y;
00235 uint _NewX, _NewY;
00236 typedef std::vector<float> TFloatVect;
00237 typedef std::vector<NLMISC::CVector2f > TFloat2Vect;
00238
00239 TFloatVect _Map[NumWaterMap];
00240
00241 uint8 _CurrMap;
00242 uint32 _Size;
00243
00245 void clearArea(uint8 currMap, sint x, sint y, sint width, sint height);
00246
00247 void clearZone(sint x, sint y, sint width, sint height);
00249 void makeCpy(uint buffer, uint dX, uint dY, uint sX, uint sY, uint width, uint height);
00250
00252 void clearBorder(uint currMap);
00253
00254
00255 };
00256
00257 }
00258
00259 #endif