示例#1
0
 public void TestMod()
 {
     Assert.AreEqual(0, IntegerUtils.Mod(-3, 3));
     Assert.AreEqual(1, IntegerUtils.Mod(-2, 3));
     Assert.AreEqual(2, IntegerUtils.Mod(-1, 3));
     Assert.AreEqual(0, IntegerUtils.Mod(0, 3));
     Assert.AreEqual(1, IntegerUtils.Mod(1, 3));
     Assert.AreEqual(2, IntegerUtils.Mod(2, 3));
     Assert.AreEqual(0, IntegerUtils.Mod(3, 3));
     Assert.AreEqual(1, IntegerUtils.Mod(4, 3));
     Assert.AreEqual(2, IntegerUtils.Mod(5, 3));
 }
示例#2
0
    private Pose GetBlendedPose(float time)
    {
        var posesByFrame = model.Animation.ActiveAnimation.PosesByFrame;

        float unloopedFrameIdx = time * FramesPerSecond;
        float currentFrameIdx  = unloopedFrameIdx % posesByFrame.Count;

        int  baseFrameIdx  = (int)currentFrameIdx;
        Pose prevFramePose = posesByFrame[IntegerUtils.Mod(baseFrameIdx + 0, posesByFrame.Count)];
        Pose nextFramePose = posesByFrame[IntegerUtils.Mod(baseFrameIdx + 1, posesByFrame.Count)];

        var   poseBlender = new PoseBlender(model.MainDefinition.BoneSystem.Bones.Count);
        float alpha       = currentFrameIdx - baseFrameIdx;

        poseBlender.Add(1 - alpha, prevFramePose);
        poseBlender.Add(alpha, nextFramePose);
        var blendedPose = poseBlender.GetResult();

        return(blendedPose);
    }