1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
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/>.
19 #include "nel/3d/height_map.h"
22 using namespace NLMISC
;
32 // ***************************************************************************
33 void CHeightMap::resize(uint w
, uint h
)
41 // ***************************************************************************
42 void CHeightMap::buildFromBitmap(const NLMISC::CBitmap
&bitmap0
)
45 CBitmap bitmap
= bitmap0
;
46 // convert to luminance.
47 bitmap
.convertToType(CBitmap::Luminance
);
52 h
= bitmap
.getHeight();
55 // get luminance image.
56 CObjectVector
<uint8
> &array
= bitmap
.getPixels();
57 // invert the image in Y.
62 uint8 v
= array
[(h
-1-y
)*w
+x
];
69 // ***************************************************************************
70 float CHeightMap::getZ(uint x
, uint y
) const
72 nlassert(x
<_Width
&& y
<_Height
);
73 return Heights
[y
*_Width
+x
]*MaxZ
/255;