Ejemplo n.º 1
0
        public void AddAnimationFrame(Bone bone, BoneAnimationFrame frame)
        {
            if (_framesMapping.ContainsKey(bone))
            {
                _framesMapping[bone].Add(frame);
            }
            else
            {
                var frames = new List<BoneAnimationFrame>() { frame };
                _framesMapping.Add(bone, frames);
            }

            if (_longestAnimationTime < frame.EndTime)
            {
                _longestAnimationTime = frame.EndTime;
            }
        }
        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);
        }