Beispiel #1
0
        /// <summary>
        /// adds a new key frame to the animation
        /// </summary>
        /// <param name="frame"></param>
        /// <param name="value"></param>
        /// <param name="type"></param>
        /// <param name="interpolationType"></param>
        public void AddKey(float frame, float value, SBTrackType type, InterpolationType interpolationType = InterpolationType.Linear)
        {
            var track = Tracks.Find(e => e.Type == type);

            if (track == null)
            {
                track = new SBTransformTrack(type);
                Tracks.Add(track);
            }
            track.AddKey(frame, value, interpolationType);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        public void ConvertRotationToEuler(int FrameCount)
        {
            if (!UseQuat)
            {
                return;
            }

            var xtrack = Tracks.Find(e => e.Type == SBTrackType.RotateX);
            var ytrack = Tracks.Find(e => e.Type == SBTrackType.RotateY);
            var ztrack = Tracks.Find(e => e.Type == SBTrackType.RotateZ);
            var wtrack = Tracks.Find(e => e.Type == SBTrackType.RotateW);

            SBTransformTrack eulX = new SBTransformTrack(SBTrackType.RotateX);
            SBTransformTrack eulY = new SBTransformTrack(SBTrackType.RotateY);
            SBTransformTrack eulZ = new SBTransformTrack(SBTrackType.RotateZ);

            var dummyBone = new SBBone();

            dummyBone.Transform = Matrix4.Identity;

            for (int i = 0; i < FrameCount; i++)
            {
                var key = GetTransformAt(i, dummyBone);
                var eul = Tools.CrossMath.ToEulerAngles(key.ExtractRotation().Inverted());

                eulX.AddKey(i, eul.X);
                eulY.AddKey(i, eul.Y);
                eulZ.AddKey(i, eul.Z);
            }

            Tracks.Remove(xtrack);
            Tracks.Remove(ytrack);
            Tracks.Remove(ztrack);
            Tracks.Remove(wtrack);

            Tracks.Add(eulX);
            Tracks.Add(eulY);
            Tracks.Add(eulZ);
        }