Código
GetPointZPos(Float: point_X, Float: point_Y, &Float: point_Z)
{
if(!(-3000.0 < point_X < 3000.0 || -3000.0 < point_Y < 3000.0))
return 0;
static
File: z_Map_File
;
if(!z_Map_File)
{
z_Map_File = fopen("SAfull.hmap", io_read);
if(!z_Map_File)
return 0;
}
new
z_Data[2 char]
;
fseek(z_Map_File, (-6000 * (floatround(point_Y, point_Y <= 0.0 ? floatround_ceil : floatround_floor) - 3000) + floatround(point_X, point_X <= 0.0 ? floatround_ceil : floatround_floor) + 3000) * 2);
fblockread(z_Map_File, z_Data, 2 char);
point_Z = (z_Data[1 / 2] & 0x0000FFFF) * 0.01;
return 1;
}
Código
Public Function GetZFromXY(ByVal X As Single, ByVal Y As Single) As Single
If Not (-3000.0 < X < 3000.0 Or -3000.0 < Y < 3000.0) Then Return 0.0
Static Reader As New IO.BinaryReader(New IO.FileStream(My.Application.Info.DirectoryPath & "\SAfull.hmap", IO.FileMode.Open))
Dim Z(2) As Byte
Reader.BaseStream.Seek(((-6000 * (Math.Round(Y, If(Y <= 0.0, MidpointRounding.AwayFromZero, MidpointRounding.ToEven)) - 3000) + Math.Round(X, If(X <= 0.0, MidpointRounding.AwayFromZero, MidpointRounding.ToEven)) + 3000)) * 2, IO.SeekOrigin.Begin)
Reader.Read(Z, 0, 2)
Reader.Close()
return ((Z(1 / 2) And &HFFFF) * 0.01)
End Function
codigo actualizado










Autor



En línea





