本文整理汇总了C#中OpenMetaverse.BitPack.UnpackFloat方法的典型用法代码示例。如果您正苦于以下问题:C# BitPack.UnpackFloat方法的具体用法?C# BitPack.UnpackFloat怎么用?C# BitPack.UnpackFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenMetaverse.BitPack
的用法示例。
在下文中一共展示了BitPack.UnpackFloat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BitPacking
public void BitPacking()
{
byte[] packedBytes = new byte[12];
BitPack bitpacker = new BitPack(packedBytes, 0);
bitpacker.PackBits(0x0ABBCCDD, 32);
bitpacker.PackBits(25, 5);
bitpacker.PackFloat(123.321f);
bitpacker.PackBits(1000, 16);
bitpacker = new BitPack(packedBytes, 0);
int b = bitpacker.UnpackBits(32);
Assert.IsTrue(b == 0x0ABBCCDD, "Unpacked " + b + " instead of 2864434397");
b = bitpacker.UnpackBits(5);
Assert.IsTrue(b == 25, "Unpacked " + b + " instead of 25");
float f = bitpacker.UnpackFloat();
Assert.IsTrue(f == 123.321f, "Unpacked " + f + " instead of 123.321");
b = bitpacker.UnpackBits(16);
Assert.IsTrue(b == 1000, "Unpacked " + b + " instead of 1000");
packedBytes = new byte[1];
bitpacker = new BitPack(packedBytes, 0);
bitpacker.PackBit(true);
bitpacker = new BitPack(packedBytes, 0);
b = bitpacker.UnpackBits(1);
Assert.IsTrue(b == 1, "Unpacked " + b + " instead of 1");
packedBytes = new byte[1] { Byte.MaxValue };
bitpacker = new BitPack(packedBytes, 0);
bitpacker.PackBit(false);
bitpacker = new BitPack(packedBytes, 0);
b = bitpacker.UnpackBits(1);
Assert.IsTrue(b == 0, "Unpacked " + b + " instead of 0");
}
示例2: DecodePatchHeader
public static TerrainPatch.Header DecodePatchHeader(BitPack bitpack)
{
TerrainPatch.Header header = new TerrainPatch.Header {QuantWBits = bitpack.UnpackBits(8)};
// Quantized word bits
if (header.QuantWBits == END_OF_PATCHES)
return header;
// DC offset
header.DCOffset = bitpack.UnpackFloat();
// Range
header.Range = bitpack.UnpackBits(16);
// Patch IDs (10 bits)
header.PatchIDs = bitpack.UnpackBits(10);
// Word bits
header.WordBits = (uint) ((header.QuantWBits & 0x0f) + 2);
return header;
}