1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef CL_WATER_MAP_H
18 #define CL_WATER_MAP_H
21 #include "nel/3d/u_scene.h"
23 #include "nel/misc/polygon.h"
24 #include "nel/misc/vector_2f.h"
28 /** Provides an easy way to know is there's water at a given point, and what is it height
29 * NB : for now, only water surfaces that have been instanciated once yet are taken in account
30 * so this is useful only for testing if a visible point is in water
33 * \author Nicolas Vizerie
34 * \author Nevrax France
37 class CWaterMap
: public NL3D::IWaterSurfaceAddedCallback
42 /** Init the map with its corners coordinates.
43 * NB : This register callback to the main scene to know when a water surface is added
45 void init(const NLMISC::CVector2f
&minCorner
, const NLMISC::CVector2f
&maxCorner
, float cellSize
= 20.f
);
47 /** Test if there's water at the given position
48 * if so, 'height' is filled with the water height
50 bool getWaterHeight(const NLMISC::CVector2f
&pos
, float &height
, bool &splashEnabled
);
51 // Dump water map as a tga file. For debug.
52 void dump(const std::string
&filename
);
53 // render water map on screen with boxes (for debug)
54 void render(const NLMISC::CVector2f
&camPos
, float maxDist
= 100.f
);
58 float Height
; // height of surface
59 NLMISC::CPolygon2D Shape
;
62 NLMISC::CVector2f _MinCorner
;
63 NLMISC::CVector2f _MaxCorner
;
64 typedef std::vector
<CWaterInfo
> TWaterInfoVect
; // a vector of water surfaces overlapping at the same point.
65 TWaterInfoVect _WaterInfoVect
; // list of surfaces that have been added yet.
66 typedef std::vector
<uint16
> TWaterInfoIndexVect
; // a vector of water surface that overlap at the same point
67 std::vector
<TWaterInfoIndexVect
> _WaterInfoIndexVectVect
; // a vector of vector of surface infos (if the list of referenced water surface for a given cell are the same, then the list is shared between the two cells
68 // so this contains the possible lists of surfaces contained by a cell)
69 std::vector
<uint16
> _Grid
; // for each point in space, gives an ID into _WaterInfoVectVect. This gives access to a water surfaces list.
75 virtual void waterSurfaceAdded(const NLMISC::CPolygon2D
&shape
, const NLMISC::CMatrix
&worldMatrix
, bool splashEnabled
, bool usesSceneWaterenvmap
);
76 virtual void waterSurfaceRemoved(bool usesSceneWaterenvmap
);
81 extern bool DisplayWaterMap
;