internal static W3dAdaptiveDeltaBlock Parse(BinaryReader reader, int vectorIndex, int numBits)
        {
            var result = new W3dAdaptiveDeltaBlock
            {
                VectorIndex = vectorIndex,
                BlockIndex  = reader.ReadByte()
            };

            var numDeltaBytes = numBits * 2;
            var deltaBytes    = new sbyte[numDeltaBytes];

            for (var k = 0; k < numDeltaBytes; k++)
            {
                deltaBytes[k] = reader.ReadSByte();
            }
            result.DeltaBytes = deltaBytes;

            return(result);
        }
示例#2
0
        internal static W3dAdaptiveDeltaData Parse(
            BinaryReader reader,
            uint numFrames,
            W3dAnimationChannelType type,
            int vectorLength,
            W3dAdaptiveDeltaBitCount bitCount)
        {
            var count = (numFrames + 15) >> 4;

            // First read all initial values
            var result = new W3dAdaptiveDeltaData
            {
                BitCount     = bitCount,
                VectorLength = vectorLength,
                InitialDatum = W3dAnimationChannelDatum.Parse(reader, type)
            };

            var numBits = (int)bitCount;

            // Then read the interleaved delta blocks
            var deltaBlocks = new W3dAdaptiveDeltaBlock[count * vectorLength];

            for (var i = 0; i < count; i++)
            {
                for (var j = 0; j < vectorLength; j++)
                {
                    deltaBlocks[(i * vectorLength) + j] = W3dAdaptiveDeltaBlock.Parse(
                        reader,
                        j,
                        numBits);
                }
            }
            result.DeltaBlocks = deltaBlocks;

            return(result);
        }