Esempio n. 1
0
 public void EndRotation(float fromRotation, float toRotation)
 {
     var endTransformState = new BoneState()
     {
         Translation = _bone.Translation,
         Rotation = _bone.Rotation
     };
     _context.AddAnimationFrameFor(_boneActor, _startTransformState, endTransformState);
 }
        public void AddAnimationFrame(BoneActor actor, double animationEndTimeInSeconds, BoneState fromState, BoneState toState)
        {
            var frameAtTime = GetFrameAt(actor, animationEndTimeInSeconds);
            if (frameAtTime == null)
            {
                AddNewAnimationFrame(actor, animationEndTimeInSeconds, fromState, toState);
                return;
            }

            if (frameAtTime.EndTime.TotalSeconds != animationEndTimeInSeconds)
            {
                return;
            }

            SetActorPropertiesToBoneEndState(frameAtTime, actor, toState);
        }
        private void SetActorPropertiesToBoneEndState(BoneAnimationTimeFrameModel frame, BoneActor actor, BoneState toState)
        {
            frame.EndState.Translation = toState.Translation;
            frame.EndState.Rotation = toState.Rotation;

            frame.AnimationFrame.EndTranslation = toState.Translation;
            frame.AnimationFrame.EndRotation = toState.Rotation;

            var items = GetCollectionBoundToActor(actor);
            var nextFrame = GetFrameAfter(items, frame);

            if (nextFrame == null) return;

            nextFrame.AnimationFrame.StartTranslation = toState.Translation;
            nextFrame.AnimationFrame.StartRotation = toState.Rotation;
        }
        private void AddNewAnimationFrame(BoneActor actor, double animationEndTimeInSeconds, BoneState fromState, BoneState toState)
        {
            var dataCollection = GetCollectionBoundToActor(actor);
            var frame = GetLastTimeFrame(dataCollection);

            BoneAnimationTimeFrameModel item = null;
            if (frame == null)
            {
                item = new BoneAnimationTimeFrameModel()
                {
                    StartTime = new TimeSpan(),
                    EndTime = TimeSpan.FromSeconds(animationEndTimeInSeconds),
                    StartState = new BoneState()
                    {
                        Rotation = fromState.Rotation,
                        Translation = fromState.Translation
                    },
                    EndState = new BoneState()
                    {
                        Rotation = toState.Rotation,
                        Translation = toState.Translation
                    }
                };
            }
            else
            {
                item = new BoneAnimationTimeFrameModel()
                {
                    StartTime = frame.EndTime,
                    EndTime = TimeSpan.FromSeconds(animationEndTimeInSeconds),
                    StartState = frame.EndState,
                    EndState = new BoneState()
                    {
                        Rotation = toState.Rotation,
                        Translation = toState.Translation
                    }
                };
            }

            var animationFrame = new BoneAnimationFrame()
                {
                    StartTime = item.StartTime,
                    EndTime = item.EndTime,
                    StartTranslation = item.StartState.Translation,
                    StartRotation = item.StartState.Rotation,
                    EndTranslation = item.EndState.Translation,
                    EndRotation = item.EndState.Rotation
                };
            item.AnimationFrame = animationFrame;
            Animation.AddAnimationFrame(actor.AssignedBone, animationFrame);

            dataCollection.Add(item);
        }
Esempio n. 5
0
 public void EndTranslation(Vector2 fromTranslation, Vector2 toTranslation)
 {
     var endTransformState = new BoneState()
     {
         Translation = _bone.Translation,
         Rotation = _bone.Rotation
     };
     _context.AddAnimationFrameFor(_boneActor, _startTransformState, endTransformState);
 }
Esempio n. 6
0
 public void StartTranslate(Vector2 position)
 {
     _startTransformState = new BoneState()
     {
         Translation = _bone.Translation,
         Rotation = _bone.Rotation
     };
 }
Esempio n. 7
0
 public void StartRotation(float originalRotation)
 {
     _startTransformState = new BoneState()
     {
         Translation = _bone.Translation,
         Rotation = _bone.Rotation
     };
 }