示例#1
0
        public static IAnimation AddAnimation(
            IBone[] bones,
            IAnimationManager animationManager,
            IDcx dcx)
        {
            var isDck            = dcx is Dck;
            var dcxAnimationData = dcx.AnimationData;

            var animation = animationManager.AddAnimation();

            animation.Name       = dcx.Name;
            animation.FrameCount = (int)dcxAnimationData.FrameCount;
            animation.FrameRate  = 30;

            foreach (var jointData in dcxAnimationData.JointDataList)
            {
                var jointIndex = jointData.JointIndex;

                var jointKeyframes = animation.AddBoneTracks(bones[jointIndex]);

                Keyframe <float>[][] frames;

                frames = DcxHelpers.ReadKeyframes_(
                    isDck,
                    dcxAnimationData,
                    jointData.ScaleAxes,
                    dcxAnimationData.ScaleValues);
                DcxHelpers.MergeKeyframesToScaleTrack(
                    frames,
                    jointKeyframes.Scales);

                frames = DcxHelpers.ReadKeyframes_(
                    isDck,
                    dcxAnimationData,
                    jointData.RotationAxes,
                    dcxAnimationData.RotationValues);
                DcxHelpers.MergeKeyframesToRotationTrack(
                    frames,
                    jointKeyframes.Rotations);

                frames = DcxHelpers.ReadKeyframes_(
                    isDck,
                    dcxAnimationData,
                    jointData.PositionAxes,
                    dcxAnimationData.PositionValues);
                DcxHelpers.MergeKeyframesToPositionTrack(
                    frames,
                    jointKeyframes.Positions);

                animation.AddBoneTracks(bones[jointIndex]).Set(jointKeyframes);
            }

            return(animation);
        }