36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
using Passer;
|
|
|
|
public class LowLevelMessages {
|
|
public static Spherical ReceiveSpherical(byte[] data, ref uint ix) {
|
|
float horizontal = ReceiveAngle8(data, ref ix);
|
|
float vertical = ReceiveAngle8(data, ref ix);
|
|
float distance = ReceiveFloat16(data, ref ix);
|
|
Spherical v = new(distance, horizontal, vertical);
|
|
return v;
|
|
}
|
|
|
|
public static Quat32 ReceiveQuat32(byte[] data, ref uint ix) {
|
|
Quat32 q = new(
|
|
(data[ix++] - 128.0F) / 127.0F,
|
|
(data[ix++] - 128.0F) / 127.0F,
|
|
(data[ix++] - 128.0F) / 127.0F,
|
|
data[ix++] / 255.0F);
|
|
return q;
|
|
}
|
|
|
|
public static float ReceiveAngle8(byte[] data, ref uint ix) {
|
|
float value = (data[ix++] * 180) / 128.0F;
|
|
return value;
|
|
}
|
|
|
|
public static float ReceiveFloat16(byte[] data, ref uint ix) {
|
|
ushort value = (ushort)(data[ix++] << 8 | data[ix++]);
|
|
float16 f16 = new();
|
|
f16.SetBinary(value);
|
|
float f = f16.toFloat();
|
|
return f;
|
|
}
|
|
|
|
|
|
}
|