Exemple #1
0
        /// <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;
        }
Exemple #2
0
 public Keyframe AddFrame(float time)
 {
     var frame = new Keyframe(this, time);
     _keyframes.Add(frame);
     SortFrames();
     return frame;
 }
Exemple #3
0
        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);
            }
        }