Use configured resolution for login/outgame/ingame
[ryzomcore.git] / ryzom / client / src / fog_map.h
blobc164348db6c742f89991f5229f8320ae60eb1785
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
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.
8 //
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/>.
19 #ifndef CL_FOG_MAP_H
20 #define CL_FOG_MAP_H
22 #include "nel/misc/bitmap.h"
23 #include "nel/misc/vector_2f.h"
25 #include "light_cycle_manager.h"
27 #include "game_share/fog_map_build.h"
30 namespace NL3D
32 class UDriver;
35 // Fog state, can be setup in a driver
36 struct CFogState
38 CFogState() : FogEnabled(false)
41 bool FogEnabled;
42 NLMISC::CRGBA FogColor;
43 float FogStartDist;
44 float FogEndDist;
45 void setupInDriver(NL3D::UDriver &drv);
49 // A class that encodes fog color and distances
50 class CFogMap
52 public:
53 typedef CFogMapBuild::TMapType TMapType; // enumeration of various fog map
54 public:
55 // default ctor
56 CFogMap();
57 /** Init the fog map from a descriptor, and load the maps
58 * NB : lookup are performed on file names
59 * \return true if the initialisation succeed
61 bool init(const CFogMapBuild &desc);
62 // init with explicit corners
63 bool init(const CFogMapBuild &desc, const NLMISC::CVector &minCoord, const NLMISC::CVector &maxCoord);
64 // Release datas
65 void release();
66 /// Compute the fog parameters at the given position.
67 void getFogParams(float referenceStartDist, float referenceEndDist, float x, float y, float dayNight, float duskRatio, CLightCycleManager::TLightState lightState, CFogState &result);
68 /** Get a map value with a world (x, y) position
69 * Default value is returned if no map was specified or if map wasn't loaded
71 NLMISC::CRGBAF getMapValue(TMapType type, float x, float y, NLMISC::CRGBAF defaultValue) const;
73 NLMISC::CBitmap &getMap(TMapType type) { nlassert(type < CFogMapBuild::NumMap); return _Map[type]; }
74 const NLMISC::CVector2f &getMinCoord() const { return _MinCoord; }
75 const NLMISC::CVector2f &getMaxCoord() const { return _MaxCoord; }
76 // convert a wortld pos into a map pos
77 void worldPosToMapPos(float inX, float inY, float &outX, float &outY) const;
78 private:
79 NLMISC::CVector2f _MinCoord;
80 NLMISC::CVector2f _MaxCoord;
81 NLMISC::CBitmap _Map[CFogMapBuild::NumMap];
82 private:
83 void load(NLMISC::CBitmap &bm, const std::string &filename);
84 NLMISC::CRGBAF getMapValueFromMapCoord(TMapType type, float x, float y, NLMISC::CRGBAF defaultValue) const;
87 #endif