Beispiel #1
0
 public override IEnumerable <W3dKeyframeWithValue> GetKeyframesWithValues(W3dMotionChannel channel)
 {
     for (var i = 0; i < TimeCodes.Length; i++)
     {
         yield return(new W3dKeyframeWithValue(TimeCodes[i], Values[i]));
     }
 }
Beispiel #2
0
        public override IEnumerable <W3dKeyframeWithValue> GetKeyframesWithValues(W3dMotionChannel channel)
        {
            var decodedData = W3dAdaptiveDeltaCodec.Decode(
                Data,
                channel.NumTimeCodes,
                Scale);

            for (var i = (ushort)0; i < decodedData.Length; i++)
            {
                yield return(new W3dKeyframeWithValue(
                                 i,
                                 decodedData[i]));
            }
        }
Beispiel #3
0
        internal static W3dMotionChannel Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var zero = reader.ReadByte();
                if (zero != 0)
                {
                    throw new InvalidDataException();
                }

                var result = new W3dMotionChannel
                {
                    DeltaType = reader.ReadByteAsEnum <W3dMotionChannelDeltaType>(),
                    VectorLength = reader.ReadByte(),
                    ChannelType = reader.ReadByteAsEnum <W3dAnimationChannelType>(),
                    NumTimeCodes = reader.ReadUInt16(),
                    Pivot = reader.ReadUInt16()
                };

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

                switch (result.DeltaType)
                {
                case W3dMotionChannelDeltaType.TimeCoded:
                    result.Data = W3dMotionChannelTimeCodedData.Parse(reader, result.NumTimeCodes, result.ChannelType);
                    break;

                case W3dMotionChannelDeltaType.Delta4:
                    result.Data = W3dMotionChannelAdaptiveDeltaData.Parse(reader, result.NumTimeCodes, result.ChannelType, result.VectorLength, W3dAdaptiveDeltaBitCount.FourBits);
                    break;

                case W3dMotionChannelDeltaType.Delta8:
                    result.Data = W3dMotionChannelAdaptiveDeltaData.Parse(reader, result.NumTimeCodes, result.ChannelType, result.VectorLength, W3dAdaptiveDeltaBitCount.EightBits);
                    break;

                default:
                    throw new InvalidDataException();
                }

                return result;
            }));
        }
Beispiel #4
0
        internal static W3dCompressedAnimation Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var result = new W3dCompressedAnimation();

                ParseChunks(reader, context.CurrentEndPosition, chunkType =>
                {
                    switch (chunkType)
                    {
                    case W3dChunkType.W3D_CHUNK_COMPRESSED_ANIMATION_HEADER:
                        result.Header = W3dCompressedAnimationHeader.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_COMPRESSED_ANIMATION_CHANNEL:
                        switch (result.Header.Flavor)
                        {
                        case W3dCompressedAnimationFlavor.TimeCoded:
                            result.TimeCodedChannels.Add(W3dTimeCodedAnimationChannel.Parse(reader, context));
                            break;

                        case W3dCompressedAnimationFlavor.AdaptiveDelta4:
                            result.AdaptiveDeltaChannels.Add(W3dAdaptiveDeltaAnimationChannel.Parse(reader, context, W3dAdaptiveDeltaBitCount.FourBits));
                            break;

                        default:
                            throw new InvalidDataException();
                        }
                        break;

                    case W3dChunkType.W3D_CHUNK_COMPRESSED_BIT_CHANNEL:
                        switch (result.Header.Flavor)
                        {
                        case W3dCompressedAnimationFlavor.TimeCoded:
                            result.TimeCodedBitChannels.Add(W3dTimeCodedBitChannel.Parse(reader, context));
                            break;

                        default:
                            throw new InvalidDataException();
                        }
                        break;

                    case W3dChunkType.W3D_CHUNK_COMPRESSED_ANIMATION_MOTION_CHANNEL:
                        switch (result.Header.Flavor)
                        {
                        case W3dCompressedAnimationFlavor.TimeCoded:
                            result.MotionChannels.Add(W3dMotionChannel.Parse(reader, context));
                            break;

                        default:
                            throw new InvalidDataException();
                        }
                        break;

                    default:
                        throw CreateUnknownChunkException(chunkType);
                    }
                });

                return result;
            }));
        }
Beispiel #5
0
 public abstract IEnumerable <W3dKeyframeWithValue> GetKeyframesWithValues(W3dMotionChannel channel);