CompactQuaternionArrayTest.java 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package com.jme.animation;
  2. import com.jme3.animation.CompactQuaternionArray;
  3. import com.jme3.math.Quaternion;
  4. import java.util.Arrays;
  5. import static org.junit.Assert.assertTrue;
  6. import org.junit.Before;
  7. import org.junit.Test;
  8. public class CompactQuaternionArrayTest {
  9. @Before
  10. public void setUp() throws Exception {
  11. }
  12. @Test
  13. public void testCompactQuaternionArrayQuaternionArray() {
  14. Quaternion[] objArray = new Quaternion[] {
  15. new Quaternion(1, 0, 1, 1),
  16. new Quaternion(1, 1, 1, 0),
  17. new Quaternion(0, 1, 1, 0),
  18. new Quaternion(1, 1, 1, 0),
  19. new Quaternion(1, 0, 1, 1),
  20. };
  21. CompactQuaternionArray compact = new CompactQuaternionArray();
  22. compact.add(objArray);
  23. assertTrue(Arrays.equals(compact.getIndex(objArray), new int[] {0, 1, 2, 1, 0}));
  24. assertTrue(Arrays.equals(compact.getSerializedData(), new float[] {1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0}));
  25. }
  26. @Test
  27. public void testCompactQuaternionArrayDoubleArrayIntArray() {
  28. int[] indexArray = new int[] {0, 1, 2, 1, 0};
  29. float[] dataArray = new float[] {1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0};
  30. Quaternion[] objArray = new Quaternion[] {
  31. new Quaternion(1, 0, 1, 1),
  32. new Quaternion(1, 1, 1, 0),
  33. new Quaternion(0, 1, 1, 0),
  34. new Quaternion(1, 1, 1, 0),
  35. new Quaternion(1, 0, 1, 1),
  36. };
  37. CompactQuaternionArray compact = new CompactQuaternionArray(dataArray, indexArray);
  38. assertTrue(Arrays.deepEquals(compact.toObjectArray(), objArray));
  39. }
  40. }