Exemplo n.º 1
0
        internal static W3dTimeCodedAnimationChannel Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var result = new W3dTimeCodedAnimationChannel
                {
                    NumTimeCodes = reader.ReadUInt32(),
                    Pivot = reader.ReadUInt16(),
                    VectorLength = reader.ReadByte(),
                    ChannelType = reader.ReadByteAsEnum <W3dAnimationChannelType>()
                };

                W3dAnimationChannel.ValidateChannelDataSize(result.ChannelType, result.VectorLength);

                var data = new W3dTimeCodedDatum[result.NumTimeCodes];
                for (var i = 0; i < result.NumTimeCodes; i++)
                {
                    data[i] = W3dTimeCodedDatum.Parse(reader, result.ChannelType);
                }

                result.Data = data;

                return result;
            }));
        }
Exemplo n.º 2
0
        internal static W3dTimeCodedDatum Parse(BinaryReader reader, W3dAnimationChannelType channelType)
        {
            var result = new W3dTimeCodedDatum();

            result.TimeCode = reader.ReadUInt32();

            // MSB is used to indicate a binary (non interpolated) movement
            if ((result.TimeCode >> 31) == 1)
            {
                result.NonInterpolatedMovement = true;
                // TODO: non-interpolated movement.

                result.TimeCode &= ~(1 << 31);
            }

            result.Value = W3dAnimationChannelDatum.Parse(reader, channelType);

            return(result);
        }
Exemplo n.º 3
0
        public static W3dTimeCodedAnimationChannel Parse(BinaryReader reader)
        {
            var startPosition = reader.BaseStream.Position;

            var result = new W3dTimeCodedAnimationChannel
            {
                NumTimeCodes = reader.ReadUInt32(),
                Pivot        = reader.ReadUInt16(),
                VectorLength = reader.ReadByte(),
                ChannelType  = (W3dAnimationChannelType)reader.ReadByte()
            };

            W3dAnimationChannel.ValidateChannelDataSize(result.ChannelType, result.VectorLength);

            var data = new W3dTimeCodedDatum[result.NumTimeCodes];

            for (var i = 0; i < result.NumTimeCodes; i++)
            {
                var datum = new W3dTimeCodedDatum();

                datum.TimeCode = reader.ReadUInt32();

                // MSB is used to indicate a binary (non interpolated) movement
                if ((datum.TimeCode >> 31) == 1)
                {
                    // TODO: non-interpolated movement.

                    datum.TimeCode &= ~(1 << 31);
                }

                datum.Value = W3dAnimationChannelDatum.Parse(reader, result.ChannelType);

                data[i] = datum;
            }

            result.Data = data;

            return(result);
        }