rendered paste bodyclass CHim
{
public:
CHim():_HeightMap(NULL){}
~CHim(){CleanUp();}
bool OpenHIM(char* path){
CleanUp();
CFile* fh = new CFile(path, "rb");
if(!fh->IsOpen()) return false;
_Width = fh->Read<dword>();
_Height = fh->Read<dword>();
fh->Skip(4);
_HeightMap = new float*[_Width];
for(dword x = 0; x < _Width; x++)
_HeightMap[x] = new float[_Height];
for(dword x = 0; x < _Width; x++){
for(dword z = 0; z < _Height; z++){
_HeightMap[x][z] = fh->Read<float>();
}
}
fh->Close();
delete fh;
return true;
}
float Height(dword x, dword z){
return _HeightMap[x][z];
}
private:
void CleanUp(){
if(_HeightMap != NULL){
for(dword x = 0; x < _Width; x++)
delete [] _HeightMap[x];
delete [] _HeightMap;
_HeightMap = NULL;
}
_Width = 0;
_Height = 0;
}
dword _Width;
dword _Height;
float** _HeightMap;
};