예제 #1
0
파일: Animation.cs 프로젝트: HaKDMoDz/Psy
        /// <summary>
        /// Create a new keyframe.
        /// </summary>
        /// <param name="precedingFrame"></param>
        public Keyframe AddFrame(Keyframe precedingFrame = null)
        {
            float frameTime;

            if (precedingFrame == null || _keyframes.Contains(precedingFrame))
            {
                frameTime = 0;
            }
            else
            {
                var frameIndex = _keyframes.IndexOf(precedingFrame);

                if (frameIndex == _keyframes.Count - 1)
                {
                    frameTime = precedingFrame.Time + 0.1f;
                }
                else
                {
                    var frameAfterPrecedingFrame = _keyframes[frameIndex + 1];
                    var timeDifference = frameAfterPrecedingFrame.Time - precedingFrame.Time;
                    frameTime = precedingFrame.Time + (timeDifference / 2.0f);
                }
            }

            var newKeyFrame = new Keyframe(this, frameTime);

            _keyframes.Add(newKeyFrame);

            if (precedingFrame != null)
            {
                newKeyFrame.LoadFromKeyframe(precedingFrame);
            }
            else
            {
                newKeyFrame.LoadFromCurrentModelState(_epicModel);
            }

            SortFrames();

            return newKeyFrame;
        }
예제 #2
0
파일: Animation.cs 프로젝트: HaKDMoDz/Psy
 public Keyframe AddFrame(float time)
 {
     var frame = new Keyframe(this, time);
     _keyframes.Add(frame);
     SortFrames();
     return frame;
 }
예제 #3
0
파일: Keyframe.cs 프로젝트: HaKDMoDz/Psy
        public void LoadFromKeyframe(Keyframe precedingFrame)
        {
            ModelPartAnimStates = new List<ModelPartAnimState>(precedingFrame.ModelPartAnimStates.Count);
            foreach (var other in precedingFrame.ModelPartAnimStates)
            {
                if (_animation.Ignores(other.ModelPart))
                {
                    continue;
                }

                var modelPartAnimState = other.Clone();
                ModelPartAnimStates.Add(modelPartAnimState);
            }

            AnchorAnimStates = new List<AnchorAnimState>(precedingFrame.AnchorAnimStates.Count);
            foreach (var other in precedingFrame.AnchorAnimStates)
            {
                if (_animation.Ignores(other.Anchor))
                {
                    continue;
                }

                var anchorAnimState = other.Clone();
                AnchorAnimStates.Add(anchorAnimState);
            }
        }