Search in sources :

Example 81 with Vector3

use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.

the class Matrix4Test method testSetToRotationTwoVector3.

@Test
public void testSetToRotationTwoVector3() throws Exception {
    final double[] expected = new double[] { 0d, -1d, 0d, 0d, 1d, 0d, 0d, 0d, 0d, 0d, 1d, 0d, 0d, 0d, 0d, 1d };
    final Matrix4 m = new Matrix4();
    final Vector3 v1 = new Vector3(1d, 0d, 0d);
    final Vector3 v2 = new Vector3(0d, 1d, 0d);
    final Matrix4 out = m.setToRotation(v1, v2);
    assertNotNull(out);
    final double[] result = out.getDoubleValues();
    assertNotNull(result);
    for (int i = 0; i < expected.length; ++i) {
        assertEquals("Result: " + Arrays.toString(result), expected[i], result[i], 1e-14);
    }
}
Also used : Vector3(org.rajawali3d.math.vector.Vector3) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Example 82 with Vector3

use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.

the class Matrix4Test method testCreateScaleMatrixVector3.

@Test
public void testCreateScaleMatrixVector3() throws Exception {
    final double[] expected = new double[] { 1d, 0d, 0d, 0d, 0d, 2d, 0d, 0d, 0d, 0d, 3d, 0d, 0d, 0d, 0d, 1d };
    final Matrix4 out = Matrix4.createScaleMatrix(new Vector3(1d, 2d, 3d));
    assertNotNull(out);
    final double[] result = out.getDoubleValues();
    assertNotNull(result);
    for (int i = 0; i < expected.length; ++i) {
        assertEquals(expected[i], result[i], 1e-14);
    }
}
Also used : Vector3(org.rajawali3d.math.vector.Vector3) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Example 83 with Vector3

use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.

the class Matrix4Test method testCreateTranslationMatrixVector3.

@Test
public void testCreateTranslationMatrixVector3() throws Exception {
    final double[] expected = new double[] { 1d, 0d, 0d, 0d, 0d, 1d, 0d, 0d, 0d, 0d, 1d, 0d, 1d, 2d, 3d, 1d };
    final Matrix4 out = Matrix4.createTranslationMatrix(new Vector3(1d, 2d, 3d));
    assertNotNull(out);
    final double[] result = out.getDoubleValues();
    assertNotNull(result);
    for (int i = 0; i < expected.length; ++i) {
        assertEquals(expected[i], result[i], 1e-14);
    }
}
Also used : Vector3(org.rajawali3d.math.vector.Vector3) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Example 84 with Vector3

use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.

the class Matrix4Test method testGetTranslation.

@Test
public void testGetTranslation() throws Exception {
    final double[] from = new double[] { // Col 0
    1d, // Col 0
    0d, // Col 0
    0d, // Col 0
    0d, // Col 1
    0d, // Col 1
    2d, // Col 1
    0d, // Col 1
    0d, // Col 2
    0d, // Col 2
    0d, // Col 2
    3d, // Col 2
    0d, // Col 3
    1d, // Col 3
    2d, // Col 3
    3d, // Col 3
    1d };
    final Vector3 expected = new Vector3(1, 2, 3);
    final Matrix4 m = new Matrix4(from);
    final Vector3 out = m.getTranslation();
    assertNotNull(out);
    assertTrue(expected.equals(out, 1e-14));
}
Also used : Vector3(org.rajawali3d.math.vector.Vector3) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Example 85 with Vector3

use of org.rajawali3d.math.vector.Vector3 in project Rajawali by Rajawali.

the class ChaseCameraFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    mCameraOffset = new Vector3();
    super.onCreate(savedInstanceState);
}
Also used : Vector3(org.rajawali3d.math.vector.Vector3)

Aggregations

Vector3 (org.rajawali3d.math.vector.Vector3)166 SmallTest (android.test.suitebuilder.annotation.SmallTest)106 Test (org.junit.Test)106 Material (org.rajawali3d.materials.Material)9 SkeletonJoint (org.rajawali3d.animation.mesh.SkeletalAnimationFrame.SkeletonJoint)6 Matrix4 (org.rajawali3d.math.Matrix4)6 Object3D (org.rajawali3d.Object3D)5 BoundingBox (org.rajawali3d.bounds.BoundingBox)5 DiffuseMethod (org.rajawali3d.materials.methods.DiffuseMethod)4 Quaternion (org.rajawali3d.math.Quaternion)4 ArrayList (java.util.ArrayList)3 DirectionalLight (org.rajawali3d.lights.DirectionalLight)3 ParsingException (org.rajawali3d.loader.ParsingException)3 FileNotFoundException (java.io.FileNotFoundException)2 FloatBuffer (java.nio.FloatBuffer)2 Stack (java.util.Stack)2 BoneVertex (org.rajawali3d.animation.mesh.SkeletalAnimationChildObject3D.BoneVertex)2 BoneWeight (org.rajawali3d.animation.mesh.SkeletalAnimationChildObject3D.BoneWeight)2 BoundingSphere (org.rajawali3d.bounds.BoundingSphere)2 IBoundingVolume (org.rajawali3d.bounds.IBoundingVolume)2