Example #1
0
float CBTFile::GetHeight(DWORD X, DWORD Z) const
{
	n_assert(Header);
	n_assert(X < Header->Width);
	n_assert(Z < Header->Height);
	if (IsFloatData()) return GetHeightF(X, Z);
	else
	{
		short Height = GetHeightS(X, Z);
		return (Height == NoDataS) ? NoDataF : Height * GetVerticalScale();
	}
}
Example #2
0
float TileMap::GetHeight(float x, float y)
{
	if(m_heightMap9F == NULL)
		return m_tileHeight;

	x = TERRAIN_MAP_RESOLUTION * (32 - x / TERRAIN_TILE_SIZE);
	y = TERRAIN_MAP_RESOLUTION * (32 - y / TERRAIN_TILE_SIZE);

	int x_int = (int)x;
	int y_int = (int)y;
	x -= x_int;
	y -= y_int;
	x_int &= (TERRAIN_MAP_RESOLUTION - 1);
	y_int &= (TERRAIN_MAP_RESOLUTION - 1);

	if(m_heightMapFlags & MAP_HEIGHT_AS_INT16)
		return GetHeightS(x, y, x_int, y_int);
	else if(m_heightMapFlags & MAP_HEIGHT_AS_INT8)
		return GetHeightB(x, y, x_int, y_int);
	return GetHeightF(x, y, x_int, y_int);
}