Search in sources :

Example 11 with Camera

use of au.gov.asd.tac.constellation.utilities.camera.Camera in project constellation by constellation-app.

the class VisualGraphUtilities method getCamera.

public static Camera getCamera(final GraphReadMethods graph) {
    final int cameraAttribute = VisualConcept.GraphAttribute.CAMERA.get(graph);
    final Camera camera = cameraAttribute != Graph.NOT_FOUND ? graph.getObjectValue(cameraAttribute, 0) : VisualGraphDefaults.DEFAULT_CAMERA;
    return camera != null ? camera : VisualGraphDefaults.DEFAULT_CAMERA;
}
Also used : Camera(au.gov.asd.tac.constellation.utilities.camera.Camera)

Example 12 with Camera

use of au.gov.asd.tac.constellation.utilities.camera.Camera in project constellation by constellation-app.

the class GraphVisualAccessNGTest method testGetCameraAttributeAdded.

/**
 * Test of getCamera method when attribute is added, of class
 * GraphVisualAccess.
 *
 * @throws InterruptedException
 */
@Test
public void testGetCameraAttributeAdded() throws InterruptedException {
    System.out.println("getCameraAttributeAdded");
    final WritableGraph wg = graph.getWritableGraph("Graph Visual Access", true);
    try {
        final int graphCameraAttribute = VisualConcept.GraphAttribute.CAMERA.ensure(wg);
        final Camera newCamera = new Camera();
        newCamera.setVisibilityHigh(0.6f);
        wg.setObjectValue(graphCameraAttribute, 0, newCamera);
    } finally {
        wg.commit();
    }
    final GraphVisualAccess instance = new GraphVisualAccess(graph);
    instance.beginUpdate();
    instance.updateInternally();
    final Camera camera = instance.getCamera();
    instance.endUpdate();
    assertEquals(camera.getVisibilityHigh(), 0.6f);
}
Also used : Camera(au.gov.asd.tac.constellation.utilities.camera.Camera) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Test(org.testng.annotations.Test)

Example 13 with Camera

use of au.gov.asd.tac.constellation.utilities.camera.Camera in project constellation by constellation-app.

the class CameraIOProviderV0 method writeObject.

/**
 * Write a Camera object into a JSON ObjectNode.
 *
 * @param attr
 * @param root The Object Node to serialise into.
 * @param state The Camera object to serialise.
 * @param graph
 *
 * @throws IOException
 */
@Override
public void writeObject(final Attribute attr, final int elementId, final com.fasterxml.jackson.core.JsonGenerator jsonGenerator, final GraphReadMethods graph, final GraphByteWriter byteWriter, final boolean verbose) throws IOException {
    if (verbose || !graph.isDefaultValue(attr.getId(), elementId)) {
        final Camera camera = (Camera) graph.getObjectValue(attr.getId(), elementId);
        if (camera == null) {
            jsonGenerator.writeNullField(attr.getName());
        } else {
            jsonGenerator.writeObjectFieldStart(attr.getName());
            addVector(jsonGenerator, LOOK_AT_EYE, camera.lookAtEye);
            addVector(jsonGenerator, LOOK_AT_CENTRE, camera.lookAtCentre);
            addVector(jsonGenerator, LOOK_AT_UP, camera.lookAtUp);
            addVector(jsonGenerator, LOOK_AT_ROTATION, camera.lookAtRotation);
            addVector(jsonGenerator, LOOK_AT_PREVIOUS_EYE, camera.lookAtPreviousEye);
            addVector(jsonGenerator, LOOK_AT_PREVIOUS_CENTRE, camera.lookAtPreviousCentre);
            addVector(jsonGenerator, LOOK_AT_PREVIOUS_UP, camera.lookAtPreviousUp);
            addVector(jsonGenerator, LOOK_AT_PREVIOUS_ROTATION, camera.lookAtPreviousRotation);
            addFrame(jsonGenerator, FRAME, camera.getObjectFrame());
            addBoundingBox(jsonGenerator, BOUNDING_BOX, camera.boundingBox);
            jsonGenerator.writeNumberField(VISIBILITY_LOW, camera.getVisibilityLow());
            jsonGenerator.writeNumberField(VISIBILITY_HIGH, camera.getVisibilityHigh());
            jsonGenerator.writeNumberField(MIX_RATIO, camera.getMixRatio());
            jsonGenerator.writeEndObject();
        }
    }
}
Also used : Camera(au.gov.asd.tac.constellation.utilities.camera.Camera)

Example 14 with Camera

use of au.gov.asd.tac.constellation.utilities.camera.Camera in project constellation by constellation-app.

the class CameraIOProviderV0 method readObject.

/**
 * Create a new Camera object from a JsonNode.
 *
 * @param jnode The JsonNode to deserialise a Camera instance from.
 * @param graph
 */
@Override
public void readObject(int attributeId, int elementId, final JsonNode jnode, final GraphWriteMethods graph, final Map<Integer, Integer> vertexMap, final Map<Integer, Integer> transactionMap, final GraphByteReader byteReader, ImmutableObjectCache cache) {
    if (!jnode.isNull()) {
        final Camera camera = new Camera();
        final Vector3f lookAtEye = getVector(jnode, LOOK_AT_EYE);
        final Vector3f lookAtCentre = getVector(jnode, LOOK_AT_CENTRE);
        final Vector3f lookAtUp = getVector(jnode, LOOK_AT_UP);
        final Vector3f lookAtRotation = getVector(jnode, LOOK_AT_ROTATION);
        final Vector3f lookAtPreviousEye = getVector(jnode, LOOK_AT_PREVIOUS_EYE);
        final Vector3f lookAtPreviousCentre = getVector(jnode, LOOK_AT_PREVIOUS_CENTRE);
        final Vector3f lookAtPreviousUp = getVector(jnode, LOOK_AT_PREVIOUS_UP);
        final Vector3f lookAtPreviousRotation = getVector(jnode, LOOK_AT_PREVIOUS_ROTATION);
        // In case the look_at objects aren't there, or they're there but aren't valid numbers...
        boolean eyeIsOk = lookAtEye != null && lookAtCentre != null && lookAtUp != null && lookAtRotation != null && lookAtPreviousEye != null && lookAtPreviousCentre != null && lookAtPreviousUp != null && lookAtPreviousRotation != null;
        if (eyeIsOk) {
            eyeIsOk = lookAtEye.isValid() && lookAtCentre.isValid() && lookAtUp.isValid() && lookAtRotation.isValid() && lookAtPreviousEye != null && lookAtPreviousCentre.isValid() && lookAtPreviousUp.isValid() && lookAtPreviousRotation.isValid();
        }
        if (eyeIsOk) {
            camera.lookAtEye.set(lookAtEye);
            camera.lookAtCentre.set(lookAtCentre);
            camera.lookAtUp.set(lookAtUp);
            camera.lookAtRotation.set(lookAtRotation);
            camera.lookAtPreviousEye.set(lookAtPreviousEye);
            camera.lookAtPreviousCentre.set(lookAtPreviousCentre);
            camera.lookAtPreviousUp.set(lookAtPreviousUp);
            camera.lookAtPreviousRotation.set(lookAtPreviousRotation);
            getBoundingBox(camera.boundingBox, jnode, BOUNDING_BOX);
        }
        camera.setObjectFrame(getFrame(jnode, FRAME));
        camera.setVisibilityLow((float) jnode.get(VISIBILITY_LOW).doubleValue());
        camera.setVisibilityHigh((float) jnode.get(VISIBILITY_HIGH).doubleValue());
        camera.setMixRatio((int) jnode.get(MIX_RATIO).doubleValue());
        graph.setObjectValue(attributeId, elementId, camera);
    }
}
Also used : Vector3f(au.gov.asd.tac.constellation.utilities.graphics.Vector3f) Camera(au.gov.asd.tac.constellation.utilities.camera.Camera)

Example 15 with Camera

use of au.gov.asd.tac.constellation.utilities.camera.Camera in project constellation by constellation-app.

the class GraphVisualAccessNGTest method testGetCameraAttributeNotFound.

/**
 * Test of getCamera method when attribute is not found, of class
 * GraphVisualAccess.
 *
 * @throws InterruptedException
 */
@Test
public void testGetCameraAttributeNotFound() throws InterruptedException {
    System.out.println("getCameraAttributeNotFound");
    final GraphVisualAccess instance = new GraphVisualAccess(graph);
    instance.beginUpdate();
    final Camera camera = instance.getCamera();
    instance.endUpdate();
    assertEquals(camera, VisualGraphDefaults.DEFAULT_CAMERA);
    assertEquals(camera.getVisibilityHigh(), 1.0f);
}
Also used : Camera(au.gov.asd.tac.constellation.utilities.camera.Camera) Test(org.testng.annotations.Test)

Aggregations

Camera (au.gov.asd.tac.constellation.utilities.camera.Camera)32 Vector3f (au.gov.asd.tac.constellation.utilities.graphics.Vector3f)11 Test (org.testng.annotations.Test)8 Point (java.awt.Point)5 PanAnimation (au.gov.asd.tac.constellation.graph.interaction.animation.PanAnimation)4 Frame (au.gov.asd.tac.constellation.utilities.graphics.Frame)4 Matrix44f (au.gov.asd.tac.constellation.utilities.graphics.Matrix44f)4 BoundingBox (au.gov.asd.tac.constellation.utilities.camera.BoundingBox)3 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)2 Matrix33f (au.gov.asd.tac.constellation.utilities.graphics.Matrix33f)2 BitSet (java.util.BitSet)2 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)1 SelectionBoxModel (au.gov.asd.tac.constellation.graph.interaction.visual.renderables.SelectionBoxModel)1 DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)1 Blaze (au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.Blaze)1 DeveloperPreferenceKeys (au.gov.asd.tac.constellation.preferences.DeveloperPreferenceKeys)1 Graphics3DUtilities (au.gov.asd.tac.constellation.utilities.camera.Graphics3DUtilities)1 ConstellationColor (au.gov.asd.tac.constellation.utilities.color.ConstellationColor)1 Vector4f (au.gov.asd.tac.constellation.utilities.graphics.Vector4f)1 InfoTextPanel (au.gov.asd.tac.constellation.utilities.gui.InfoTextPanel)1