Exemple #1
0
        public static float GetHeightAt(this Heightmap heightmap, int x, int y)
        {
            if (!IsValidCoordinate(heightmap, x, y) || x == 0 || y == 0 || x == heightmap.Size.X - 1 || y == heightmap.Size.Y - 1)
            {
                return(-heightmap.HeightRange.Y);
            }

            var index      = GetHeightIndex(heightmap, x, y);
            var heightData = heightmap.Shorts[index];

            var height = HeightmapUtils.ConvertToFloatHeight(short.MinValue, short.MaxValue, heightData);

            height *= heightmap.HeightRange.Y;

            return(height);
        }
Exemple #2
0
        public static float GetTerrainHeight(this Heightmap heightmap, int x, int y)
        {
            if (!IsValidCoordinate(heightmap, x, y))
            {
                return(0.0f);
            }

            var index      = GetHeightIndex(heightmap, x, y);
            var heightData = heightmap.Shorts[index];

            var height = HeightmapUtils.ConvertToFloatHeight(short.MinValue, short.MaxValue, heightData);

            height *= heightmap.HeightRange.Y;

            return(height);
        }