Пример #1
0
        protected override AnimationClip Read(ContentReader input, AnimationClip existingInstance)
        {
            AnimationClip clip = new AnimationClip();

            clip.Name     = input.ReadString();
            clip.Duration = input.ReadDouble();

            int boneCnt = input.ReadInt32();

            for (int i = 0; i < boneCnt; i++)
            {
                AnimationClip.Bone bone = new AnimationClip.Bone();
                clip.Bones.Add(bone);

                bone.Name = input.ReadString();

                int cnt = input.ReadInt32();

                for (int j = 0; j < cnt; j++)
                {
                    AnimationClip.Keyframe keyframe = new AnimationClip.Keyframe();
                    keyframe.Time        = input.ReadDouble();
                    keyframe.Scale       = input.ReadVector3();
                    keyframe.Rotation    = input.ReadQuaternion();
                    keyframe.Translation = input.ReadVector3();

                    bone.Keyframes.Add(keyframe);
                }
            }

            return(clip);
        }
Пример #2
0
            /// <summary>
            /// Set the keyframes to a valid value relative to
            /// the current keyframe
            /// </summary>
            private void SetKeyframes()
            {
                if (ClipBone.Keyframes.Count > 0)
                {
                    //if (currentKeyframe == 0 && ClipBone.Keyframes.Count > 1)
                    //    currentKeyframe = 1;

                    Keyframe1 = ClipBone.Keyframes[currentKeyframe];
                    if (currentKeyframe == ClipBone.Keyframes.Count - 1)
                    {
                        Keyframe2 = Keyframe1;
                    }
                    else
                    {
                        //if (currentKeyframe == ClipBone.Keyframes.Count - 1)
                        //{
                        //    if (ClipBone.Keyframes.Count > 1)
                        //        Keyframe2 = ClipBone.Keyframes[1];
                        //    else
                        //        Keyframe2 = ClipBone.Keyframes[0];
                        //}
                        //else
                        {
                            Keyframe2 = ClipBone.Keyframes[currentKeyframe + 1];
                        }
                    }
                }
                else
                {
                    // If there are no keyframes, set both to null
                    Keyframe1 = null;
                    Keyframe2 = null;
                }
            }
Пример #3
0
        public void MakeLoopBlend(float blendTime)
        {
            Duration += blendTime;

            foreach (Bone bone in bones)
            {
                //add loop blending (add first frame copy at the end)
                if (bone.Keyframes.Count > 2)
                {
                    AnimationClip.Keyframe keyframe = bone.Keyframes[1].Clone();
                    keyframe.Time = Duration;
                    bone.Keyframes.Add(keyframe);
                }
            }
        }