From c023c8c573dbaa01e07d1795b32453f0c61a0267 Mon Sep 17 00:00:00 2001 From: AlexisDrogoul Date: Fri, 4 Mar 2022 01:19:42 +0700 Subject: [PATCH] Fix for #995. Addition of the #isometric camera --- .../gama/outputs/layers/CameraDefinition.java | 10 ++++---- .../outputs/layers/ICameraDefinition.java | 24 ++++++++++++------- .../models/Building Elevation.gaml | 2 +- .../models/Camera Definitions.gaml | 3 +++ 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/msi.gama.core/src/msi/gama/outputs/layers/CameraDefinition.java b/msi.gama.core/src/msi/gama/outputs/layers/CameraDefinition.java index e60f38c9e8..13aed4329b 100644 --- a/msi.gama.core/src/msi/gama/outputs/layers/CameraDefinition.java +++ b/msi.gama.core/src/msi/gama/outputs/layers/CameraDefinition.java @@ -96,7 +96,8 @@ public void refresh(final IScope scope) { GamaPoint location; boolean noLocation = temp == null; if (noLocation) { temp = GamaPreferences.Displays.OPENGL_DEFAULT_CAM.getValue(); } - + // We negate the Y ordinate coming from GAML + target = target.yNegated(); if (temp instanceof String pos) { // If it is a symbolic position double w = scope.getSimulation().getWidth(); @@ -105,11 +106,10 @@ public void refresh(final IScope scope) { location = computeLocation(pos, target, w, -h, max); } else { location = Cast.asPoint(scope, temp); + // The location should be a point now and we negate it as well + location = location.yNegated(); } - // We negate the Y ordinate coming from GAML - target = target.yNegated(); - // The location should be a point now and we negate it as well - location = location.yNegated(); + // We determine the distance and apply it to the location if it is explicitly defined or if no location has been // defined Double d = distanceAttribute.get(); diff --git a/msi.gama.core/src/msi/gama/outputs/layers/ICameraDefinition.java b/msi.gama.core/src/msi/gama/outputs/layers/ICameraDefinition.java index 49ad22b341..81add698bd 100644 --- a/msi.gama.core/src/msi/gama/outputs/layers/ICameraDefinition.java +++ b/msi.gama.core/src/msi/gama/outputs/layers/ICameraDefinition.java @@ -73,10 +73,17 @@ public interface ICameraDefinition extends INamed { doc = @doc ("Represent the position of the camera, in front and slightly above the scene")) String from_up_front = "From up front"; + /** The from left. */ + @constant ( + value = "isometric", + category = IOperatorCategory.THREED, + doc = @doc ("Represent the position of the camera, on the left of the scene")) String isometric = + "Isometric"; + /** The presets. */ - String[] PRESETS = - List.of(from_above, from_left, from_right, from_front, from_up_left, from_up_right, from_up_front) - .toArray(new String[7]); + String[] PRESETS = List + .of(from_above, from_left, from_right, from_front, from_up_left, from_up_right, from_up_front, isometric) + .toArray(new String[7]); /** * Gets the location. @@ -173,15 +180,15 @@ default void refresh(final IScope scope) {} * Computes the location of a camera based on a symbolic position, a target and boundarises . * * @param pos - * the pos + * the symbolic position * @param target - * the target + * the target - y-negated already * @param maxX - * the w + * the dimension on the x axis > 0 * @param maxY - * the h + * the dimension on the y axis > 0 * @param maxZ - * the max + * the dimension on the z axis > 0 * @return the gama point */ default GamaPoint computeLocation(final String pos, final GamaPoint target, final double maxX, final double maxY, @@ -194,6 +201,7 @@ default GamaPoint computeLocation(final String pos, final GamaPoint target, fina case from_up_right -> new GamaPoint(target.x + maxX, target.y - maxY / 1000, maxZ); case from_front -> new GamaPoint(target.x, target.y - maxY, 0); case from_up_front -> new GamaPoint(target.x, target.y - maxY, maxZ); + case isometric -> new GamaPoint(target.x + maxZ, -maxZ + target.y, maxZ / 1.2); default -> new GamaPoint(target.x, target.y, maxZ); // FROM_ABOVE }; } diff --git a/msi.gama.models/models/Visualization and User Interaction/Visualization/3D Visualization/models/Building Elevation.gaml b/msi.gama.models/models/Visualization and User Interaction/Visualization/3D Visualization/models/Building Elevation.gaml index e1ef960c24..7b697556fa 100644 --- a/msi.gama.models/models/Visualization and User Interaction/Visualization/3D Visualization/models/Building Elevation.gaml +++ b/msi.gama.models/models/Visualization and User Interaction/Visualization/3D Visualization/models/Building Elevation.gaml @@ -150,7 +150,7 @@ experiment road_traffic type: gui } output { - display city_display type: opengl + display city_display type: opengl camera: #isometric { species building aspect: base refresh: false; species road aspect: base refresh: false; diff --git a/msi.gama.models/models/Visualization and User Interaction/Visualization/3D Visualization/models/Camera Definitions.gaml b/msi.gama.models/models/Visualization and User Interaction/Visualization/3D Visualization/models/Camera Definitions.gaml index fc44d1322b..2579cd86d6 100644 --- a/msi.gama.models/models/Visualization and User Interaction/Visualization/3D Visualization/models/Camera Definitions.gaml +++ b/msi.gama.models/models/Visualization and User Interaction/Visualization/3D Visualization/models/Camera Definitions.gaml @@ -62,6 +62,9 @@ experiment Display type: gui autorun: true { display "From right" parent: shared { camera "default" location: #from_right distance: 40 / factor target: {w, p.y, 0} dynamic: true; } + display "Isometric" parent: shared { + camera default location: #isometric target: {p.x, p.y, 0} dynamic: true; + } }