Search in sources :

Example 16 with Frame

use of au.gov.asd.tac.constellation.utilities.graphics.Frame in project constellation by constellation-app.

the class CameraNGTest method testAreSame.

@Test
public void testAreSame() {
    final Camera c = new Camera();
    c.lookAtCentre.set(V1);
    c.lookAtEye.set(V2);
    c.lookAtUp.set(V3);
    c.lookAtRotation.set(V4);
    c.lookAtPreviousEye.set(V5);
    c.lookAtPreviousCentre.set(V6);
    c.lookAtPreviousUp.set(V7);
    c.lookAtPreviousRotation.set(V8);
    c.boundingBox.set(V9, V10, V11, V12);
    c.setVisibilityLow(999F);
    c.setVisibilityHigh(998F);
    c.setMixRatio(654);
    c.setObjectFrame(new Frame(V13, V14, V15));
    final Camera c2 = new Camera();
    c2.lookAtCentre.set(V1);
    c2.lookAtEye.set(V2);
    c2.lookAtUp.set(V3);
    c2.lookAtRotation.set(V4);
    c2.lookAtPreviousEye.set(V5);
    c2.lookAtPreviousCentre.set(V6);
    c2.lookAtPreviousUp.set(V7);
    c2.lookAtPreviousRotation.set(V8);
    c2.boundingBox.set(V9, V10, V11, V12);
    c2.setVisibilityLow(999F);
    c2.setVisibilityHigh(998F);
    c2.setMixRatio(654);
    c2.setObjectFrame(new Frame(V13, V14, V15));
    assertTrue(c.areSame(c2));
    c2.lookAtCentre.set(V2);
    assertFalse(c.areSame(c2));
    c2.lookAtCentre.set(V1);
    c2.lookAtEye.set(V3);
    assertFalse(c.areSame(c2));
    c2.lookAtEye.set(V2);
    c2.lookAtUp.set(V4);
    assertFalse(c.areSame(c2));
    c2.lookAtUp.set(V3);
    c2.lookAtRotation.set(V5);
    assertFalse(c.areSame(c2));
    c2.lookAtRotation.set(V4);
    c2.lookAtPreviousEye.set(V6);
    assertFalse(c.areSame(c2));
    c2.lookAtPreviousEye.set(V5);
    c2.lookAtPreviousCentre.set(V7);
    assertFalse(c.areSame(c2));
    c2.lookAtPreviousCentre.set(V6);
    c2.lookAtPreviousUp.set(V8);
    assertFalse(c.areSame(c2));
    c2.lookAtPreviousUp.set(V7);
    c2.lookAtPreviousRotation.set(V9);
    assertFalse(c.areSame(c2));
    c2.lookAtPreviousRotation.set(V8);
    c2.boundingBox.set(V8, V10, V11, V12);
    assertFalse(c.areSame(c2));
    c2.boundingBox.set(V9, V10, V11, V12);
    c.setVisibilityLow(444F);
    assertFalse(c.areSame(c2));
    c.setVisibilityLow(999F);
    c.setVisibilityHigh(777F);
    assertFalse(c.areSame(c2));
    c.setVisibilityHigh(998F);
    c.setMixRatio(235);
    assertFalse(c.areSame(c2));
    c.setMixRatio(654);
    c.setObjectFrame(new Frame(V13, V8, V15));
    assertFalse(c.areSame(c2));
    c.setObjectFrame(new Frame(V13, V14, V15));
    assertTrue(c.areSame(c2));
}
Also used : Frame(au.gov.asd.tac.constellation.utilities.graphics.Frame) Test(org.testng.annotations.Test)

Example 17 with Frame

use of au.gov.asd.tac.constellation.utilities.graphics.Frame in project constellation by constellation-app.

the class CameraNGTest method assertNewCamera.

// helper to assert a Camera object with no other initialise
private void assertNewCamera(final Camera c) {
    assertEquals(c.lookAtEye.toString(), new Vector3f(0F, 0F, 10F).toString());
    assertEquals(c.lookAtCentre.toString(), ZERO_VECTOR.toString());
    assertEquals(c.lookAtUp.toString(), new Vector3f(0F, 1F, 0F).toString());
    assertEquals(c.lookAtRotation.toString(), ZERO_VECTOR.toString());
    assertEquals(c.lookAtPreviousEye.toString(), new Vector3f(0F, 0F, 10F).toString());
    assertEquals(c.lookAtPreviousCentre.toString(), ZERO_VECTOR.toString());
    assertEquals(c.lookAtPreviousUp.toString(), new Vector3f(0F, 1F, 0F).toString());
    assertEquals(c.lookAtPreviousRotation.toString(), ZERO_VECTOR.toString());
    assertEquals(c.getVisibilityLow(), 0F);
    assertEquals(c.getVisibilityHigh(), 1F);
    final BoundingBox bb = c.boundingBox;
    assertEquals(bb.getMin().toString(), MIN_EXTREME.toString());
    assertEquals(bb.getMax().toString(), MAX_EXTREME.toString());
    assertEquals(bb.getMin2().toString(), MIN_EXTREME.toString());
    assertEquals(bb.getMax2().toString(), MAX_EXTREME.toString());
    assertTrue(bb.isEmpty());
    final Frame objectFrame = c.getObjectFrame();
    assertEquals(objectFrame.getOrigin().toString(), ZERO_VECTOR.toString());
    assertEquals(objectFrame.getUpVector().toString(), new Vector3f(0F, 1F, 0F).toString());
    assertEquals(objectFrame.getForwardVector().toString(), new Vector3f(0F, 0F, 1F).toString());
}
Also used : Frame(au.gov.asd.tac.constellation.utilities.graphics.Frame) Vector3f(au.gov.asd.tac.constellation.utilities.graphics.Vector3f)

Example 18 with Frame

use of au.gov.asd.tac.constellation.utilities.graphics.Frame in project constellation by constellation-app.

the class CameraUtilitiesNGTest method beforeClass.

/**
 * Sets up a Camera object used as the basic template for testing.
 */
@BeforeClass
public void beforeClass() {
    CAMERA.lookAtCentre.set(new Vector3f(V1));
    CAMERA.lookAtEye.set(new Vector3f(V2));
    CAMERA.lookAtUp.set(new Vector3f(V3));
    CAMERA.lookAtRotation.set(new Vector3f(V4));
    CAMERA.lookAtPreviousEye.set(new Vector3f(V5));
    CAMERA.lookAtPreviousCentre.set(new Vector3f(V6));
    CAMERA.lookAtPreviousUp.set(new Vector3f(V7));
    CAMERA.lookAtPreviousRotation.set(new Vector3f(V8));
    CAMERA.boundingBox.set(new Vector3f(V9), new Vector3f(V10), new Vector3f(V11), new Vector3f(V12));
    CAMERA.setVisibilityLow(999F);
    CAMERA.setVisibilityHigh(998F);
    CAMERA.setMixRatio(MIX_RATIO);
    CAMERA.setObjectFrame(new Frame(new Vector3f(V13), new Vector3f(V14), new Vector3f(V15)));
}
Also used : Frame(au.gov.asd.tac.constellation.utilities.graphics.Frame) Vector3f(au.gov.asd.tac.constellation.utilities.graphics.Vector3f) BeforeClass(org.testng.annotations.BeforeClass)

Example 19 with Frame

use of au.gov.asd.tac.constellation.utilities.graphics.Frame in project constellation by constellation-app.

the class CameraUtilitiesNGTest method testRefocus.

/**
 * Can refocus the camera.
 */
@Test
public void testRefocus() {
    final Camera c = new Camera(CAMERA);
    final BoundingBox region = getMockedRegionBoundingBox();
    // refocus a Camera
    CameraUtilities.refocus(c, new Vector3f(V17), new Vector3f(V18), region);
    assertEquals(c.lookAtEye.toString(), new Vector3f(21117.5F, 21241F, 21364.5F).toString());
    assertEquals(c.lookAtCentre.toString(), V16.toString());
    assertEquals(c.lookAtUp.toString(), V18.toString());
    assertEquals(c.lookAtRotation.toString(), V16.toString());
    assertEquals(c.lookAtPreviousEye.toString(), V2.toString());
    assertEquals(c.lookAtPreviousCentre.toString(), V1.toString());
    assertEquals(c.lookAtPreviousUp.toString(), V3.toString());
    assertEquals(c.lookAtPreviousRotation.toString(), V4.toString());
    final Frame of1 = c.getObjectFrame();
    final Frame of2 = new Frame();
    assertEquals(of1.getOrigin().toString(), of2.getOrigin().toString());
    assertEquals(of1.getUpVector().toString(), V15.toString());
    assertEquals(of1.getForwardVector().toString(), new Vector3f(-0.57735026F, -0.57735026F, -0.57735026F).toString());
    // refocus a Camera without an object frame
    c.setObjectFrame(null);
    CameraUtilities.refocus(c, new Vector3f(V17), new Vector3f(V18), region);
    final Frame of3 = c.getObjectFrame();
    assertEquals(of3.getOrigin().toString(), of2.getOrigin().toString());
    assertEquals(of3.getUpVector().toString(), of2.getUpVector().toString());
    assertEquals(of3.getForwardVector().toString(), new Vector3f(0F, 0F, 1F).toString());
    // refocus where the distance is small
    final BoundingBox region2 = getMockedRegionBoundingBox(1F, new Vector3f(V16));
    CameraUtilities.refocus(c, new Vector3f(V17), new Vector3f(V18), region2);
    assertEquals(c.lookAtEye.toString(), new Vector3f(289.700012F, 291.400024F, 293.099976F).toString());
    // refocus where the distance is large
    final BoundingBox region3 = getMockedRegionBoundingBox(1000000F, new Vector3f(V16));
    CameraUtilities.refocus(c, new Vector3f(V17), new Vector3f(V18), region3);
    assertEquals(c.lookAtEye.toString(), new Vector3f(8549999F, 8599999F, 8649998F).toString());
}
Also used : Frame(au.gov.asd.tac.constellation.utilities.graphics.Frame) Vector3f(au.gov.asd.tac.constellation.utilities.graphics.Vector3f) Test(org.testng.annotations.Test)

Aggregations

Frame (au.gov.asd.tac.constellation.utilities.graphics.Frame)19 Vector3f (au.gov.asd.tac.constellation.utilities.graphics.Vector3f)14 Matrix33f (au.gov.asd.tac.constellation.utilities.graphics.Matrix33f)5 Matrix44f (au.gov.asd.tac.constellation.utilities.graphics.Matrix44f)5 Test (org.testng.annotations.Test)5 Camera (au.gov.asd.tac.constellation.utilities.camera.Camera)4 BitSet (java.util.BitSet)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 SetBooleanValuesOperation (au.gov.asd.tac.constellation.graph.operations.SetBooleanValuesOperation)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayList (java.util.ArrayList)1 BeforeClass (org.testng.annotations.BeforeClass)1