#include <height_map.h>
Nevrax France
Definition at line 46 of file height_map.h.
Public Member Functions | |
void | buildFromBitmap (const NLMISC::CBitmap &bitmap) |
CHeightMap () | |
Constructor. | |
uint | getHeight () const |
uint | getWidth () const |
float | getZ (uint x, uint y) const |
return the ZValue, interval is: 0-MaxZ. nlassert(x,y). | |
void | resize (uint w, uint h) |
resize the heightmap. resize Heights too. | |
Data Fields | |
std::vector< uint8 > | Heights |
float | MaxZ |
The range of heights: 0 to MaxZ. | |
float | OriginX |
The origin of the bottom-left corner of this heightmap. | |
float | OriginY |
The origin of the bottom-left corner of this heightmap. | |
float | SizeX |
The size of one Element ot this HeightMap (eg: 160x160 for a zone). | |
float | SizeY |
The size of one Element ot this HeightMap (eg: 160x160 for a zone). | |
Private Attributes | |
uint | _Height |
The size of this array. Heights.size. | |
uint | _Width |
The size of this array. Heights.size. |
|
Constructor.
Definition at line 60 of file height_map.h. References MaxZ, and NL3D_MEM_HMAP.
|
|
This tool method build a HeightMap, from a bitmap, resize(), and fill Heights. value are read from bitmap luminance value. NB: Lines are inverted, because bitmap definition is left-right / top-bottom. Definition at line 49 of file height_map.cpp. References NLMISC::CBitmap::convertToType(), Heights, NL3D_MEM_HMAP, resize(), uint, uint8, v, w, x, and y.
00050 { 00051 NL3D_MEM_HMAP 00052 // copy bitmap. 00053 CBitmap bitmap= bitmap0; 00054 // convert to luminance. 00055 bitmap.convertToType(CBitmap::Luminance); 00056 00057 // resize array. 00058 uint w, h; 00059 w= bitmap.getWidth(); 00060 h= bitmap.getHeight(); 00061 resize(w,h); 00062 00063 // get luminance image. 00064 CObjectVector<uint8> &array= bitmap.getPixels(); 00065 // invert the image in Y. 00066 for(uint y=0;y<h;y++) 00067 { 00068 for(uint x=0;x<w;x++) 00069 { 00070 uint8 v= array[(h-1-y)*w+x]; 00071 Heights[y*w+x]= v; 00072 } 00073 } 00074 } |
|
Definition at line 72 of file height_map.h. References uint. Referenced by NL3D::CLandscape::setHeightField().
00072 {return _Height;} |
|
Definition at line 71 of file height_map.h. References uint. Referenced by NL3D::CLandscape::setHeightField().
00071 {return _Width;} |
|
return the ZValue, interval is: 0-MaxZ. nlassert(x,y).
Definition at line 78 of file height_map.cpp. References Heights, MaxZ, NL3D_MEM_HMAP, nlassert, uint, x, and y. Referenced by NL3D::CLandscape::setHeightField().
|
|
resize the heightmap. resize Heights too.
Definition at line 39 of file height_map.cpp. References Heights, NL3D_MEM_HMAP, uint, and w. Referenced by buildFromBitmap().
00040 { 00041 NL3D_MEM_HMAP 00042 _Width= w; 00043 _Height= h; 00044 Heights.resize(w*h); 00045 } |
|
The size of this array. Heights.size.
Definition at line 86 of file height_map.h. |
|
The size of this array. Heights.size.
Definition at line 86 of file height_map.h. |
|
Definition at line 49 of file height_map.h. Referenced by buildFromBitmap(), getZ(), and resize(). |
|
The range of heights: 0 to MaxZ.
Definition at line 56 of file height_map.h. Referenced by CHeightMap(), and getZ(). |
|
The origin of the bottom-left corner of this heightmap.
Definition at line 52 of file height_map.h. Referenced by NL3D::CLandscape::setHeightField(). |
|
The origin of the bottom-left corner of this heightmap.
Definition at line 52 of file height_map.h. Referenced by NL3D::CLandscape::setHeightField(). |
|
The size of one Element ot this HeightMap (eg: 160x160 for a zone).
Definition at line 54 of file height_map.h. Referenced by NL3D::CLandscape::setHeightField(). |
|
The size of one Element ot this HeightMap (eg: 160x160 for a zone).
Definition at line 54 of file height_map.h. Referenced by NL3D::CLandscape::setHeightField(). |