public void TraitsTest()
        {
            var animationEx = new SingleKeyFrameAnimation();

            Assert.AreEqual(SingleTraits.Instance, animationEx.Traits);
        }
Ejemplo n.º 2
0
 public void TraitsTest()
 {
     var animationEx = new SingleKeyFrameAnimation();
       Assert.AreEqual(SingleTraits.Instance, animationEx.Traits);
 }
Ejemplo n.º 3
0
        // Create morph target animation in code.
        private static ITimeline CreateMorphingAnimation()
        {
            // The weight of each morph target is controlled by a keyframe animation.
            var browMad = new SingleKeyFrameAnimation {
                TargetProperty = "BROW-mad"
            };

            browMad.KeyFrames.Add(new KeyFrame <float>(FrameToTime(15), 0));
            browMad.KeyFrames.Add(new KeyFrame <float>(FrameToTime(30), 1));
            browMad.KeyFrames.Add(new KeyFrame <float>(FrameToTime(65), 1));
            browMad.KeyFrames.Add(new KeyFrame <float>(FrameToTime(80), 0));

            var browSurp = new SingleKeyFrameAnimation {
                TargetProperty = "BROW-surp"
            };

            browSurp.KeyFrames.Add(new KeyFrame <float>(FrameToTime(0), 0));
            browSurp.KeyFrames.Add(new KeyFrame <float>(FrameToTime(15), 0.5f));
            browSurp.KeyFrames.Add(new KeyFrame <float>(FrameToTime(30), 0));
            browSurp.KeyFrames.Add(new KeyFrame <float>(FrameToTime(210), 0));
            browSurp.KeyFrames.Add(new KeyFrame <float>(FrameToTime(220), 0.5f));
            browSurp.KeyFrames.Add(new KeyFrame <float>(FrameToTime(230), 0.5f));
            browSurp.KeyFrames.Add(new KeyFrame <float>(FrameToTime(250), 0));

            var cheekIn = new SingleKeyFrameAnimation {
                TargetProperty = "CHEEK-in"
            };

            cheekIn.KeyFrames.Add(new KeyFrame <float>(FrameToTime(0), 0));
            cheekIn.KeyFrames.Add(new KeyFrame <float>(FrameToTime(15), 1));
            cheekIn.KeyFrames.Add(new KeyFrame <float>(FrameToTime(30), 0));

            var cheekOut = new SingleKeyFrameAnimation {
                TargetProperty = "CHEEK-out"
            };

            cheekOut.KeyFrames.Add(new KeyFrame <float>(FrameToTime(25), 0));
            cheekOut.KeyFrames.Add(new KeyFrame <float>(FrameToTime(35), 1));
            cheekOut.KeyFrames.Add(new KeyFrame <float>(FrameToTime(65), 1));
            cheekOut.KeyFrames.Add(new KeyFrame <float>(FrameToTime(80), 0));

            var eyeClosed = new SingleKeyFrameAnimation {
                TargetProperty = "EYE-closed"
            };

            eyeClosed.KeyFrames.Add(new KeyFrame <float>(FrameToTime(20), 0));
            eyeClosed.KeyFrames.Add(new KeyFrame <float>(FrameToTime(25), 1));
            eyeClosed.KeyFrames.Add(new KeyFrame <float>(FrameToTime(55), 0.2f));
            eyeClosed.KeyFrames.Add(new KeyFrame <float>(FrameToTime(65), 0.2f));
            eyeClosed.KeyFrames.Add(new KeyFrame <float>(FrameToTime(80), 0));
            eyeClosed.KeyFrames.Add(new KeyFrame <float>(FrameToTime(230), 0));
            eyeClosed.KeyFrames.Add(new KeyFrame <float>(FrameToTime(235), 1));
            eyeClosed.KeyFrames.Add(new KeyFrame <float>(FrameToTime(240), 0));

            var mouthE = new SingleKeyFrameAnimation {
                TargetProperty = "MOUTH-e"
            };

            mouthE.KeyFrames.Add(new KeyFrame <float>(FrameToTime(115), 0));
            mouthE.KeyFrames.Add(new KeyFrame <float>(FrameToTime(125), 0.7f));
            mouthE.KeyFrames.Add(new KeyFrame <float>(FrameToTime(130), 0.7f));
            mouthE.KeyFrames.Add(new KeyFrame <float>(FrameToTime(140), 0.9f));
            mouthE.KeyFrames.Add(new KeyFrame <float>(FrameToTime(145), 0.9f));
            mouthE.KeyFrames.Add(new KeyFrame <float>(FrameToTime(155), 0.0f));

            var mouthU = new SingleKeyFrameAnimation {
                TargetProperty = "MOUTH-u"
            };

            mouthU.KeyFrames.Add(new KeyFrame <float>(FrameToTime(25), 0));
            mouthU.KeyFrames.Add(new KeyFrame <float>(FrameToTime(35), 0.5f));
            mouthU.KeyFrames.Add(new KeyFrame <float>(FrameToTime(55), 0));
            mouthU.KeyFrames.Add(new KeyFrame <float>(FrameToTime(145), 0));
            mouthU.KeyFrames.Add(new KeyFrame <float>(FrameToTime(155), 0.5f));
            mouthU.KeyFrames.Add(new KeyFrame <float>(FrameToTime(160), 0.5f));
            mouthU.KeyFrames.Add(new KeyFrame <float>(FrameToTime(170), 0.9f));
            mouthU.KeyFrames.Add(new KeyFrame <float>(FrameToTime(175), 0.9f));
            mouthU.KeyFrames.Add(new KeyFrame <float>(FrameToTime(170), 0.9f));
            mouthU.KeyFrames.Add(new KeyFrame <float>(FrameToTime(190), 0.0f));

            var mouthSmile = new SingleKeyFrameAnimation {
                TargetProperty = "MOUTH-smile"
            };

            mouthSmile.KeyFrames.Add(new KeyFrame <float>(FrameToTime(210), 0));
            mouthSmile.KeyFrames.Add(new KeyFrame <float>(FrameToTime(220), 1));
            mouthSmile.KeyFrames.Add(new KeyFrame <float>(FrameToTime(230), 1));
            mouthSmile.KeyFrames.Add(new KeyFrame <float>(FrameToTime(250), 0));

            // Combine the key frame animations into a single animation.
            var timelineGroup = new TimelineGroup();

            timelineGroup.Add(browMad);
            timelineGroup.Add(browSurp);
            timelineGroup.Add(cheekIn);
            timelineGroup.Add(cheekOut);
            timelineGroup.Add(eyeClosed);
            timelineGroup.Add(mouthE);
            timelineGroup.Add(mouthU);
            timelineGroup.Add(mouthSmile);

            // Make an endless loop.
            return(new TimelineClip(timelineGroup)
            {
                Duration = TimeSpan.MaxValue,
                LoopBehavior = LoopBehavior.Cycle
            });
        }
Ejemplo n.º 4
0
    // Create morph target animation in code.
    private static ITimeline CreateMorphingAnimation()
    {
      // The weight of each morph target is controlled by a keyframe animation.
      var browMad = new SingleKeyFrameAnimation { TargetProperty = "BROW-mad" };
      browMad.KeyFrames.Add(new KeyFrame<float>(FrameToTime(15), 0));
      browMad.KeyFrames.Add(new KeyFrame<float>(FrameToTime(30), 1));
      browMad.KeyFrames.Add(new KeyFrame<float>(FrameToTime(65), 1));
      browMad.KeyFrames.Add(new KeyFrame<float>(FrameToTime(80), 0));

      var browSurp = new SingleKeyFrameAnimation { TargetProperty = "BROW-surp" };
      browSurp.KeyFrames.Add(new KeyFrame<float>(FrameToTime(0), 0));
      browSurp.KeyFrames.Add(new KeyFrame<float>(FrameToTime(15), 0.5f));
      browSurp.KeyFrames.Add(new KeyFrame<float>(FrameToTime(30), 0));
      browSurp.KeyFrames.Add(new KeyFrame<float>(FrameToTime(210), 0));
      browSurp.KeyFrames.Add(new KeyFrame<float>(FrameToTime(220), 0.5f));
      browSurp.KeyFrames.Add(new KeyFrame<float>(FrameToTime(230), 0.5f));
      browSurp.KeyFrames.Add(new KeyFrame<float>(FrameToTime(250), 0));

      var cheekIn = new SingleKeyFrameAnimation { TargetProperty = "CHEEK-in" };
      cheekIn.KeyFrames.Add(new KeyFrame<float>(FrameToTime(0), 0));
      cheekIn.KeyFrames.Add(new KeyFrame<float>(FrameToTime(15), 1));
      cheekIn.KeyFrames.Add(new KeyFrame<float>(FrameToTime(30), 0));

      var cheekOut = new SingleKeyFrameAnimation { TargetProperty = "CHEEK-out" };
      cheekOut.KeyFrames.Add(new KeyFrame<float>(FrameToTime(25), 0));
      cheekOut.KeyFrames.Add(new KeyFrame<float>(FrameToTime(35), 1));
      cheekOut.KeyFrames.Add(new KeyFrame<float>(FrameToTime(65), 1));
      cheekOut.KeyFrames.Add(new KeyFrame<float>(FrameToTime(80), 0));

      var eyeClosed = new SingleKeyFrameAnimation { TargetProperty = "EYE-closed" };
      eyeClosed.KeyFrames.Add(new KeyFrame<float>(FrameToTime(20), 0));
      eyeClosed.KeyFrames.Add(new KeyFrame<float>(FrameToTime(25), 1));
      eyeClosed.KeyFrames.Add(new KeyFrame<float>(FrameToTime(55), 0.2f));
      eyeClosed.KeyFrames.Add(new KeyFrame<float>(FrameToTime(65), 0.2f));
      eyeClosed.KeyFrames.Add(new KeyFrame<float>(FrameToTime(80), 0));
      eyeClosed.KeyFrames.Add(new KeyFrame<float>(FrameToTime(230), 0));
      eyeClosed.KeyFrames.Add(new KeyFrame<float>(FrameToTime(235), 1));
      eyeClosed.KeyFrames.Add(new KeyFrame<float>(FrameToTime(240), 0));

      var mouthE = new SingleKeyFrameAnimation { TargetProperty = "MOUTH-e" };
      mouthE.KeyFrames.Add(new KeyFrame<float>(FrameToTime(115), 0));
      mouthE.KeyFrames.Add(new KeyFrame<float>(FrameToTime(125), 0.7f));
      mouthE.KeyFrames.Add(new KeyFrame<float>(FrameToTime(130), 0.7f));
      mouthE.KeyFrames.Add(new KeyFrame<float>(FrameToTime(140), 0.9f));
      mouthE.KeyFrames.Add(new KeyFrame<float>(FrameToTime(145), 0.9f));
      mouthE.KeyFrames.Add(new KeyFrame<float>(FrameToTime(155), 0.0f));

      var mouthU = new SingleKeyFrameAnimation { TargetProperty = "MOUTH-u" };
      mouthU.KeyFrames.Add(new KeyFrame<float>(FrameToTime(25), 0));
      mouthU.KeyFrames.Add(new KeyFrame<float>(FrameToTime(35), 0.5f));
      mouthU.KeyFrames.Add(new KeyFrame<float>(FrameToTime(55), 0));
      mouthU.KeyFrames.Add(new KeyFrame<float>(FrameToTime(145), 0));
      mouthU.KeyFrames.Add(new KeyFrame<float>(FrameToTime(155), 0.5f));
      mouthU.KeyFrames.Add(new KeyFrame<float>(FrameToTime(160), 0.5f));
      mouthU.KeyFrames.Add(new KeyFrame<float>(FrameToTime(170), 0.9f));
      mouthU.KeyFrames.Add(new KeyFrame<float>(FrameToTime(175), 0.9f));
      mouthU.KeyFrames.Add(new KeyFrame<float>(FrameToTime(170), 0.9f));
      mouthU.KeyFrames.Add(new KeyFrame<float>(FrameToTime(190), 0.0f));

      var mouthSmile = new SingleKeyFrameAnimation { TargetProperty = "MOUTH-smile" };
      mouthSmile.KeyFrames.Add(new KeyFrame<float>(FrameToTime(210), 0));
      mouthSmile.KeyFrames.Add(new KeyFrame<float>(FrameToTime(220), 1));
      mouthSmile.KeyFrames.Add(new KeyFrame<float>(FrameToTime(230), 1));
      mouthSmile.KeyFrames.Add(new KeyFrame<float>(FrameToTime(250), 0));

      // Combine the key frame animations into a single animation.
      var timelineGroup = new TimelineGroup();
      timelineGroup.Add(browMad);
      timelineGroup.Add(browSurp);
      timelineGroup.Add(cheekIn);
      timelineGroup.Add(cheekOut);
      timelineGroup.Add(eyeClosed);
      timelineGroup.Add(mouthE);
      timelineGroup.Add(mouthU);
      timelineGroup.Add(mouthSmile);

      // Make an endless loop.
      return new TimelineClip(timelineGroup)
      {
        Duration = TimeSpan.MaxValue,
        LoopBehavior = LoopBehavior.Cycle
      };
    }