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/>.
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"
35 // Fog state, can be setup in a driver
38 CFogState() : FogEnabled(false)
42 NLMISC::CRGBA FogColor
;
45 void setupInDriver(NL3D::UDriver
&drv
);
49 // A class that encodes fog color and distances
53 typedef CFogMapBuild::TMapType TMapType
; // enumeration of various fog map
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
);
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;
79 NLMISC::CVector2f _MinCoord
;
80 NLMISC::CVector2f _MaxCoord
;
81 NLMISC::CBitmap _Map
[CFogMapBuild::NumMap
];
83 void load(NLMISC::CBitmap
&bm
, const std::string
&filename
);
84 NLMISC::CRGBAF
getMapValueFromMapCoord(TMapType type
, float x
, float y
, NLMISC::CRGBAF defaultValue
) const;