コード例 #1
0
        public static void TestRotateFrom()
        {
            Quaternion       quatStart = Quaternion.Euler(10.0f, 20.0f, 30.0f);
            Quaternion       quatEnd   = Quaternion.Euler(30.0f, 20.0f, 10.0f);
            Quaternion       quatVal   = quatStart;
            Ref <Quaternion> quatRef   = new Ref <Quaternion>(
                () => quatVal,
                t => quatVal = t
                );

            CommandQueue queue = new CommandQueue();

            queue.Enqueue(
                Cmd.Repeat(2,
                           Cmd.Sequence(
                               Cmd.RotateFrom(quatRef, quatEnd, 1.0),
                               Cmd.WaitForFrames(1)
                               )
                           )
                );

            queue.Update(0.5);
            AreEqual(quatVal, Quaternion.Slerp(quatEnd, quatStart, 0.5f), 0.000001f);

            quatVal = Quaternion.identity;
            queue.Update(0.5);
            AreEqual(quatVal, quatStart, 0.000001f);
            queue.Update(0.0);
            queue.Update(0.5);
            AreEqual(quatVal, Quaternion.Slerp(quatEnd, quatStart, 0.5f), 0.000001f);

            // Make sure the rotation ends in the correct position when given a complex easing function.
            queue = new CommandQueue();

            quatVal = quatStart;
            queue.Enqueue(
                Cmd.RotateFrom(quatRef, quatEnd, 1f, Ease.OutElastic())
                );

            while (!queue.Update(1 / 30f))
            {
            }

            AreEqual(quatVal, quatStart, 0.001f);
        }