예제 #1
0
        public GFMotBoneTransform(BinaryReader Reader, string Name, uint FramesCount) : this()
        {
            this.Name = Name;

            uint Flags  = Reader.ReadUInt32();
            uint Length = Reader.ReadUInt32();

            IsAxisAngle = (Flags >> 31) == 0;

            for (int ElemIndex = 0; ElemIndex < 9; ElemIndex++)
            {
                switch (ElemIndex)
                {
                case 0: GFMotKeyFrame.SetList(ScaleX, Reader, Flags, FramesCount); break;

                case 1: GFMotKeyFrame.SetList(ScaleY, Reader, Flags, FramesCount); break;

                case 2: GFMotKeyFrame.SetList(ScaleZ, Reader, Flags, FramesCount); break;

                case 3: GFMotKeyFrame.SetList(RotationX, Reader, Flags, FramesCount); break;

                case 4: GFMotKeyFrame.SetList(RotationY, Reader, Flags, FramesCount); break;

                case 5: GFMotKeyFrame.SetList(RotationZ, Reader, Flags, FramesCount); break;

                case 6: GFMotKeyFrame.SetList(TranslationX, Reader, Flags, FramesCount); break;

                case 7: GFMotKeyFrame.SetList(TranslationY, Reader, Flags, FramesCount); break;

                case 8: GFMotKeyFrame.SetList(TranslationZ, Reader, Flags, FramesCount); break;
                }

                Flags >>= 3;
            }
        }
예제 #2
0
        public static void SetFrameValue(List <GFMotKeyFrame> KeyFrames, float Frame, ref float Value)
        {
            if (KeyFrames.Count == 1)
            {
                Value = KeyFrames[0].Value;
            }
            if (KeyFrames.Count < 2)
            {
                return;
            }

            GFMotKeyFrame LHS = KeyFrames.Last(x => x.Frame <= Frame);
            GFMotKeyFrame RHS = KeyFrames.First(x => x.Frame >= Frame);

            if (LHS.Frame != RHS.Frame)
            {
                float FrameDiff = Frame - LHS.Frame;
                float Weight    = FrameDiff / (RHS.Frame - LHS.Frame);

                Value = Interpolation.Herp(
                    LHS.Value, RHS.Value,
                    LHS.Slope, RHS.Slope,
                    FrameDiff,
                    Weight);
            }
            else
            {
                Value = LHS.Value;
            }
        }
예제 #3
0
        public GFMotUVTransform(BinaryReader Reader, string Name, uint FramesCount) : this()
        {
            this.Name = Name;

            UnitIndex = Reader.ReadUInt32();

            uint Flags  = Reader.ReadUInt32();
            uint Length = Reader.ReadUInt32();

            for (int ElemIndex = 0; ElemIndex < 5; ElemIndex++)
            {
                switch (ElemIndex)
                {
                case 0: GFMotKeyFrame.SetList(ScaleX, Reader, Flags, FramesCount); break;

                case 1: GFMotKeyFrame.SetList(ScaleY, Reader, Flags, FramesCount); break;

                case 2: GFMotKeyFrame.SetList(Rotation, Reader, Flags, FramesCount); break;

                case 3: GFMotKeyFrame.SetList(TranslationX, Reader, Flags, FramesCount); break;

                case 4: GFMotKeyFrame.SetList(TranslationY, Reader, Flags, FramesCount); break;
                }

                Flags >>= 3;
            }
        }