AnimationSamplingTests.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Numerics;
  4. using System.Text;
  5. using NUnit.Framework;
  6. namespace SharpGLTF
  7. {
  8. [TestFixture]
  9. [Category("Core")]
  10. public class AnimationSamplingTests
  11. {
  12. private static (float, (Vector3, Vector3, Vector3))[] _TransAnim = new []
  13. {
  14. (0.0f, (new Vector3(0, 0, 0), new Vector3(-1, 0, 0),new Vector3(0, 0, 0))),
  15. (1.0f, (new Vector3(0, 0, 0), new Vector3(+1, 0, 0),new Vector3(0, 3, 0))),
  16. (2.0f, (new Vector3(0, 0, 0), new Vector3(-1, 0, 0),new Vector3(0, 0, 0)))
  17. };
  18. private static (float, (Quaternion, Quaternion, Quaternion))[] _RotAnim = new[]
  19. {
  20. (0.0f, (new Quaternion(0,0,0,0), Quaternion.CreateFromYawPitchRoll(+1.6f, 0, 0), new Quaternion(0,0,0,0))),
  21. (1.0f, (new Quaternion(0,0,0,0), Quaternion.Identity, new Quaternion(0,0,0,0))),
  22. (2.0f, (new Quaternion(0,0,0,0), Quaternion.CreateFromYawPitchRoll(-1.6f, 0, 0), new Quaternion(0,0,0,0))),
  23. (3.0f, (new Quaternion(0,0,0,0), Quaternion.Identity, new Quaternion(0,0,0,0))),
  24. (4.0f, (new Quaternion(0,0,0,0), Quaternion.CreateFromYawPitchRoll(+1.6f, 0, 0), new Quaternion(0,0,0,0))),
  25. };
  26. [Test]
  27. public void TestVector3CubicSplineSampling()
  28. {
  29. var hermite = Transforms.AnimationSamplerFactory.Hermite(new Vector3(1, 0, 0), new Vector3(1, 2, 0), new Vector3(3, 0, 0), new Vector3(3, -2, 0), 0.5f);
  30. var sampler = Transforms.AnimationSamplerFactory.CreateCubicSamplerFunc(_TransAnim);
  31. var a = sampler(0);
  32. var b = sampler(1);
  33. var bc = sampler(1.5f);
  34. var c = sampler(2);
  35. }
  36. [Test]
  37. public void TestQuaternionCubicSplineSampling()
  38. {
  39. var sampler = Transforms.AnimationSamplerFactory.CreateCubicSamplerFunc(_RotAnim);
  40. var a = sampler(0);
  41. var b = sampler(1);
  42. var bc = sampler(1.5f);
  43. var c = sampler(2);
  44. }
  45. }
  46. }