public static short Compress(float raw, Bounds bounds) { const float Max = short.MaxValue; return (short)(((raw - bounds.Min) / (bounds.Max - bounds.Min)) * Max); }
public CompressionInfo(Stream stream) { BinaryReader br = new BinaryReader(stream); X = new Bounds(br.ReadSingle(), br.ReadSingle()); Y = new Bounds(br.ReadSingle(), br.ReadSingle()); Z = new Bounds(br.ReadSingle(), br.ReadSingle()); U = new Bounds(br.ReadSingle(), br.ReadSingle()); V = new Bounds(br.ReadSingle(), br.ReadSingle()); U2 = new Bounds(br.ReadSingle(), br.ReadSingle()); V2 = new Bounds(br.ReadSingle(), br.ReadSingle()); }
public static float Decompress(short value, Bounds bounds) { const float Max = 1.0f / ushort.MaxValue; const float Half = short.MaxValue; return ((((float)value + Half) * Max ) * (bounds.Max - bounds.Min)) + bounds.Min; }