diff --git a/msi.gama.core/src/msi/gama/outputs/LayeredDisplayData.java b/msi.gama.core/src/msi/gama/outputs/LayeredDisplayData.java index 371059ebc1..1f8fa40ca3 100644 --- a/msi.gama.core/src/msi/gama/outputs/LayeredDisplayData.java +++ b/msi.gama.core/src/msi/gama/outputs/LayeredDisplayData.java @@ -61,9 +61,6 @@ public enum Changes { /** The camera target. */ CAMERA_TARGET, - /** The camera orientation. */ - CAMERA_ORIENTATION, - /** The camera preset. */ CAMERA_PRESET, @@ -254,7 +251,7 @@ public void notifyListeners(final Changes property, final Object value) { private GamaPoint cameraLookPos = null; /** The camera orientation. */ - private GamaPoint cameraOrientation = null; + private final GamaPoint cameraOrientation = null; /** The preset camera. */ private String presetCamera = ""; @@ -295,7 +292,6 @@ public void notifyListeners(final Changes property, final Object value) { * Overlay */ - // private boolean isDisplayingScale = GamaPreferences.Displays.CORE_SCALE.getValue(); private int fullScreen = -1; /** @@ -385,21 +381,6 @@ public void setBackgroundColor(final GamaColor backgroundColor) { */ public void setOrtho(final boolean ortho) { this.ortho = ortho; } - // /** - // * @return the displayScale - // */ - // public boolean isDisplayScale() { - // return isDisplayingScale; - // } - - // /** - // * @param displayScale - // * the displayScale to set - // */ - // public void setDisplayScale(final boolean displayScale) { - // this.isDisplayingScale = displayScale; - // } - /** * @return the showfps */ @@ -628,13 +609,6 @@ public boolean cameraInteractionDisabled() { */ public boolean isCameraLookAtDefined() { return cameraLookPos != null; } - /** - * Checks if is camera up vector defined. - * - * @return true, if is camera up vector defined - */ - public boolean isCameraUpVectorDefined() { return getCameraOrientation() != null; } - /** * @return the cameraPos */ @@ -679,28 +653,6 @@ public void setCameraLookPos(final GamaPoint point) { notifyListeners(Changes.CAMERA_TARGET, cameraLookPos); } - /** - * @return the cameraUpVector - */ - public GamaPoint getCameraOrientation() { return cameraOrientation; } - - /** - * @param cameraOrientation - * the cameraUpVector to set - */ - public void setCameraOrientation(final GamaPoint point) { - if (point == null) return; - final GamaPoint c = point; - if (cameraOrientation != null) { - if (c.equals(cameraOrientation)) return; - cameraOrientation.setLocation(c); - } else { - cameraOrientation = new GamaPoint(c); - } - - notifyListeners(Changes.CAMERA_ORIENTATION, cameraOrientation); - } - /** * @return the cameraLens */ @@ -836,7 +788,6 @@ public void setContinuousRotation(final boolean r) { public void setZRotationAngle(final double val) { zRotationAngleDelta = val; currentRotationAboutZ = val; - // notifyListeners(Changes.ROTATION, val); } /** @@ -1156,15 +1107,6 @@ public void initWith(final IScope scope, final IDescription desc) { } } - // Set the up vector of the opengl Camera (see gluPerspective) - final IExpression cameraUp = facets.getExpr(IKeyword.CAMERA_ORIENTATION); - if (cameraUp != null) { - final GamaPoint location = Cast.asPoint(scope, cameraUp.value(scope)); - location.setY(-location.getY()); // y component need to be reverted - setCameraOrientation(location); - } - - // Set the up vector of the opengl Camera (see gluPerspective) final IExpression cameraLens = facets.getExpr(IKeyword.CAMERA_LENS); if (cameraLens != null) { final int lens = Cast.asInt(scope, cameraLens.value(scope)); diff --git a/msi.gama.core/src/msi/gama/outputs/LayeredDisplayOutput.java b/msi.gama.core/src/msi/gama/outputs/LayeredDisplayOutput.java index c9d542c94f..edd999b55d 100644 --- a/msi.gama.core/src/msi/gama/outputs/LayeredDisplayOutput.java +++ b/msi.gama.core/src/msi/gama/outputs/LayeredDisplayOutput.java @@ -222,13 +222,15 @@ name = IKeyword.CAMERA_ORIENTATION, type = IType.POINT, optional = true, - doc = @doc ("Allows to define the orientation of the 'up-vector' of the camera")), + doc = @doc ( + deprecated = "This facet is not used anymore. The orientation of the camera is computed automatically by GAMA", + value = "Allows to define the orientation of the 'up-vector' of the camera")), @facet ( name = "camera_up_vector", type = IType.POINT, optional = true, doc = @doc ( - deprecated = "Use 'camera_orientation' instead", + deprecated = "This facet is not used anymore. The orientation of the camera is computed automatically by GAMA", value = "Allows to define the orientation of the 'up-vector' of the camera")), @facet ( name = IKeyword.CAMERA_LENS, diff --git a/msi.gama.core/src/msi/gaml/expressions/units/CameraOrientationUnitExpression.java b/msi.gama.core/src/msi/gaml/expressions/units/CameraOrientationUnitExpression.java index 81c76164f1..51b64494c1 100644 --- a/msi.gama.core/src/msi/gaml/expressions/units/CameraOrientationUnitExpression.java +++ b/msi.gama.core/src/msi/gaml/expressions/units/CameraOrientationUnitExpression.java @@ -1,19 +1,17 @@ /******************************************************************************************************* * - * CameraOrientationUnitExpression.java, in msi.gama.core, is part of the source code of the - * GAMA modeling and simulation platform (v.1.8.2). + * CameraOrientationUnitExpression.java, in msi.gama.core, is part of the source code of the GAMA modeling and + * simulation platform (v.1.8.2). * * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) * * Visit https://github.com/gama-platform/gama for license information and contacts. - * + * ********************************************************************************************************/ package msi.gaml.expressions.units; -import msi.gama.common.interfaces.IDisplaySurface; import msi.gama.common.interfaces.IGraphics; import msi.gama.metamodel.shape.GamaPoint; -import msi.gama.runtime.GAMA; import msi.gama.runtime.IScope; import msi.gama.runtime.IScope.IGraphicsScope; import msi.gaml.types.Types; @@ -38,11 +36,7 @@ public CameraOrientationUnitExpression(final String doc) { @Override public GamaPoint _value(final IScope sc) { - if (sc == null || !sc.isGraphics()) { - IDisplaySurface surface = GAMA.getGui().getFrontmostDisplaySurface(); - if (surface != null) return surface.getData().getCameraOrientation().clone(); - return null; - } + if (sc == null || !sc.isGraphics()) return null; IGraphicsScope scope = (IGraphicsScope) sc; final IGraphics g = scope.getGraphics(); if (g.is2D()) return null; diff --git a/msi.gama.models/models/Data/Data Importation/models/GIF File Loading.gaml b/msi.gama.models/models/Data/Data Importation/models/GIF File Loading.gaml index b5e58cb5c9..33f01132a9 100644 --- a/msi.gama.models/models/Data/Data Importation/models/GIF File Loading.gaml +++ b/msi.gama.models/models/Data/Data Importation/models/GIF File Loading.gaml @@ -27,7 +27,8 @@ global { experiment "Ripples and Fishes" type: gui { output { - display Ripples synchronized: true type: opengl camera_location: {50.00000000000001,140.93835147797245,90.93835147797242} camera_target: {50.0,50.0,0.0} camera_orientation: {-4.3297802811774646E-17,0.7071067811865472,0.7071067811865478}{ + display Ripples synchronized: true type: opengl camera_location: {50.00000000000001,140.93835147797245,90.93835147797242} camera_target: {50.0,50.0,0.0} + { species fish position: {0,0,0.05}; graphics world transparency: 0.4{ draw cube(100) scaled_by {1,1,0.08} texture:("../images/water2.gif") ; diff --git a/msi.gama.models/models/Data/Data Importation/models/Grid DEM.gaml b/msi.gama.models/models/Data/Data Importation/models/Grid DEM.gaml index 3cad4816b3..9ec0df971d 100644 --- a/msi.gama.models/models/Data/Data Importation/models/Grid DEM.gaml +++ b/msi.gama.models/models/Data/Data Importation/models/Grid DEM.gaml @@ -131,39 +131,39 @@ experiment "Meshes" type: gui { output { layout #split toolbars: false; - display "Large file, rectangles, wireframe and scaled" type: opengl draw_env: false camera_location: {100.0,269.7056,169.7056} camera_target: {100.0,100.0,0.0} camera_orientation: {0.0,0.7071,0.7071}{ + display "Large file, rectangles, wireframe and scaled" type: opengl draw_env: false camera_location: {100.0,269.7056,169.7056} camera_target: {100.0,100.0,0.0} { mesh europe wireframe: true border: #green refresh: false size: {1,1,0.2}; } - display "Large file, triangles, wireframe and scaled" type: opengl draw_env: false camera_location: {100.0,269.7056,169.7056} camera_target: {100.0,100.0,0.0} camera_orientation: {0.0,0.7071,0.7071}{ + display "Large file, triangles, wireframe and scaled" type: opengl draw_env: false camera_location: {100.0,269.7056,169.7056} camera_target: {100.0,100.0,0.0} { mesh europe grayscale: true triangulation: true smooth: true refresh: false size: {1,1,0.2}; } - display "Large file, triangles, smooth, wireframe and scaled" type: opengl draw_env: false camera_location: {100.0,269.7056,169.7056} camera_target: {100.0,100.0,0.0} camera_orientation: {0.0,0.7071,0.7071}{ + display "Large file, triangles, smooth, wireframe and scaled" type: opengl draw_env: false camera_location: {100.0,269.7056,169.7056} camera_target: {100.0,100.0,0.0} { mesh europe wireframe: true triangulation: true border: #green refresh: false size: {1,1,0.2} smooth: true; } - display "Triangles, grayscale, lines, colored and scaled" type: opengl draw_env: false camera_location: {100.0,269.7056,169.7056} camera_target: {100.0,100.0,0.0} camera_orientation: {0.0,0.7071,0.7071}{ + display "Triangles, grayscale, lines, colored and scaled" type: opengl draw_env: false camera_location: {100.0,269.7056,169.7056} camera_target: {100.0,100.0,0.0} { mesh grid_data size: {1, 1, 0.75} triangulation: true border: #yellow color: #violet; } - display "Triangles, textured, no scale" type: opengl draw_env: false camera_location: {100.0,269.7056,169.7056} camera_target: {100.0,100.0,0.0} camera_orientation: {0.0,0.7071,0.7071}{ + display "Triangles, textured, no scale" type: opengl draw_env: false camera_location: {100.0,269.7056,169.7056} camera_target: {100.0,100.0,0.0} { mesh grid_data texture: texture triangulation: true; } - display "Triangles, textured and scaled" type: opengl draw_env: false camera_location: {100.0,269.7056,169.7056} camera_target: {100.0,100.0,0.0} camera_orientation: {0.0,0.7071,0.7071}{ + display "Triangles, textured and scaled" type: opengl draw_env: false camera_location: {100.0,269.7056,169.7056} camera_target: {100.0,100.0,0.0} { mesh grid_data texture: texture triangulation: true scale: 0.75; } - display "Triangles, textured, smooth and scaled" type: opengl draw_env: false camera_location: {100.0,269.7056,169.7056} camera_target: {100.0,100.0,0.0} camera_orientation: {0.0,0.7071,0.7071}{ + display "Triangles, textured, smooth and scaled" type: opengl draw_env: false camera_location: {100.0,269.7056,169.7056} camera_target: {100.0,100.0,0.0} { mesh grid_data texture: texture smooth: true triangulation: true size: {1, 1, 0.75}; } - display "Triangles, textured, scaled, with labels" type: opengl draw_env: false camera_location: {100.0,269.7056,169.7056} camera_target: {100.0,100.0,0.0} camera_orientation: {0.0,0.7071,0.7071}{ + display "Triangles, textured, scaled, with labels" type: opengl draw_env: false camera_location: {100.0,269.7056,169.7056} camera_target: {100.0,100.0,0.0} { mesh grid_data texture: texture triangulation: true size: {1, 1, 0.5} text: true; } - display "Large file, trianges, grayscale, scaled" type: opengl draw_env: false camera_location: {119.8782,301.7184,408.395} camera_target: {119.8782,-3.3383,103.3383} camera_orientation: {0.0,0.7071,0.7071} { + display "Large file, trianges, grayscale, scaled" type: opengl draw_env: false camera_location: {119.8782,301.7184,408.395} camera_target: {119.8782,-3.3383,103.3383} { mesh dem_file grayscale: true triangulation: true scale: 2.0; } diff --git a/msi.gama.models/models/Toy Models/Art/Gama 1.8/models/GAMA 1.8.gaml b/msi.gama.models/models/Toy Models/Art/Gama 1.8/models/GAMA 1.8.gaml index b9fb698447..d932f7e135 100644 --- a/msi.gama.models/models/Toy Models/Art/Gama 1.8/models/GAMA 1.8.gaml +++ b/msi.gama.models/models/Toy Models/Art/Gama 1.8/models/GAMA 1.8.gaml @@ -201,7 +201,7 @@ species runner skills: [moving] { experiment "Run me !" type: gui autorun: true { output { display "1.8" type: opengl fullscreen: true toolbar: #black background: #black draw_env: false - camera_location: {1298.0375, 3277.2938, 2177.5545} camera_target: {1261.3366, 1174.7007, 0.0} camera_orientation: {-0.0126, 0.7192, 0.6947}{ + camera_location: {1298.0375, 3277.2938, 2177.5545} camera_target: {1261.3366, 1174.7007, 0.0} { species roads; species runner { draw my_shape at: location depth: depth color: color; diff --git a/msi.gama.models/models/Toy Models/Art/L-Trees/models/Tree and Seasons.gaml b/msi.gama.models/models/Toy Models/Art/L-Trees/models/Tree and Seasons.gaml index feb9dbc163..19501cc079 100644 --- a/msi.gama.models/models/Toy Models/Art/L-Trees/models/Tree and Seasons.gaml +++ b/msi.gama.models/models/Toy Models/Art/L-Trees/models/Tree and Seasons.gaml @@ -401,7 +401,7 @@ species fruit { experiment "Random" type: gui autorun: true { output { - display 'Tree' type: opengl background: season.sky_color ambient_light: 150 draw_env: false toolbar: false fullscreen: true camera_location: {50.0,249.6629,199.6559} camera_target: {50.0,50.0,0.0} camera_orientation: {0.0,0.7071,0.7071} { + display 'Tree' type: opengl background: season.sky_color ambient_light: 150 draw_env: false toolbar: false fullscreen: true camera_location: {50.0,249.6629,199.6559} camera_target: {50.0,50.0,0.0} { species branch aspect: default; species leaf aspect: default; species trunk aspect: default; @@ -422,7 +422,7 @@ experiment "4 simulations" type: gui autorun: true { } output { - display 'Tree' type: opengl background: season.sky_color ambient_light: 150 draw_env: false toolbar: false camera_location: {50.0,249.6629,199.6559} camera_target: {50.0,50.0,0.0} camera_orientation: {0.0,0.7071,0.7071} { + display 'Tree' type: opengl background: season.sky_color ambient_light: 150 draw_env: false toolbar: false camera_location: {50.0,249.6629,199.6559} camera_target: {50.0,50.0,0.0} { species branch aspect: default; species leaf aspect: default; species trunk aspect: default; @@ -439,7 +439,7 @@ experiment L_Tri type: gui autorun: true { float minimum_cycle_duration <- 0.0005; float seed <- 0.05387546426306633; output { - display 'Tree' type: opengl background: season.sky_color ambient_light: 150 draw_env: false toolbar: true camera_location: {50.0,249.6629,199.6559} camera_target: {50.0,50.0,0.0} camera_orientation: {0.0,0.7071,0.7071} { + display 'Tree' type: opengl background: season.sky_color ambient_light: 150 draw_env: false toolbar: true camera_location: {50.0,249.6629,199.6559} camera_target: {50.0,50.0,0.0} { species branch aspect: default; species leaf aspect: default; species trunk aspect: default; diff --git a/msi.gama.models/models/Toy Models/Boids/models/Boids 3D Analysis.gaml b/msi.gama.models/models/Toy Models/Boids/models/Boids 3D Analysis.gaml index aeca420b69..1f914888c9 100644 --- a/msi.gama.models/models/Toy Models/Boids/models/Boids 3D Analysis.gaml +++ b/msi.gama.models/models/Toy Models/Boids/models/Boids 3D Analysis.gaml @@ -419,9 +419,9 @@ experiment "Space & Time Cube" type: gui { experiment "Multiple views" type: gui { float minimum_cycle_duration <- 0.05; - output { + output{ layout #split; - display RealBoids type:opengl synchronized: true{ + display RealBoids type:java2D synchronized: true { image 'background' file:file_path_to_ocean; species boids aspect: dynamicColor transparency:0.5 position:{0,0,0.1}; species boids_goal transparency:0.2 position:{0,0,0.25}; @@ -429,9 +429,9 @@ experiment "Multiple views" type: gui { species boids aspect: dynamicColor transparency:0.2 position:{0,0,0.24}; } - display ThirdPersonn type:opengl camera_interaction:false camera_location:{int(first(boids).location.x),int(first(boids).location.y),250} - camera_target:{int(first(boids).location.x),first(boids).location.y,0} - camera_orientation:{0.0,-1.0,0.0} { + display ThirdPerson type:opengl camera_interaction:true camera_location:{int(first(boids).location.x),int(first(boids).location.y),2500} + camera_target:{int(first(boids).location.x),int(first(boids).location.y),0} + { image 'background' file:file_path_to_ocean; species obstacle; @@ -443,7 +443,7 @@ experiment "Multiple views" type: gui { display FirstPerson type:opengl camera_interaction:false camera_location:{int(first(boids).location.x),int(first(boids).location.y),10} camera_target:{cos(first(boids).heading)*first(boids).speed+int(first(boids).location.x), sin(first(boids).heading)*first(boids).speed+int(first(boids).location.y),10} - camera_orientation:{0.0,0.0,1.0} { + { image 'background' file:file_path_to_ocean; species obstacle ; species boids aspect: dynamicColor transparency:0.2 ; diff --git a/msi.gama.models/models/Visualization and User Interaction/Visualization/3D Visualization/models/Camera_Position.gaml b/msi.gama.models/models/Visualization and User Interaction/Visualization/3D Visualization/models/Camera_Position.gaml index 8b83508d10..79fc0af116 100644 --- a/msi.gama.models/models/Visualization and User Interaction/Visualization/3D Visualization/models/Camera_Position.gaml +++ b/msi.gama.models/models/Visualization and User Interaction/Visualization/3D Visualization/models/Camera_Position.gaml @@ -35,24 +35,24 @@ experiment Display type: gui autorun:true{ } display FixCameraPosition camera_interaction:false camera_location:{world.shape.width/2,world.shape.height*2,world.shape.width*2} camera_target:{world.shape.width/2,world.shape.height/2,0} - camera_orientation:{0.0,-1.0,0.0}type:opengl{ + type:opengl{ species object aspect:default; } display DynamicCameraPosition type:opengl camera_location:{world.shape.width*cos(cycle),world.shape.width*sin(cycle),world.shape.width*2} camera_target:{world.shape.width/2,world.shape.height/2,0} - camera_orientation:{0.0,-1.0,0.0}{ + { species object aspect:default; } display FollowObjectCamera type:opengl camera_interaction:false camera_location:{int(first(object).location.x),int(first(object).location.y),250} camera_target:{int(first(object).location.x),first(object).location.y,0} - camera_orientation:{0.0,-1.0,0.0}{ + { species object aspect:default; } display FirstPerson type:opengl camera_interaction:true camera_location:{int(first(object).location.x),int(first(object).location.y),10} camera_target:{cos(first(object).heading)*first(object).speed+int(first(object).location.x), sin(first(object).heading)*first(object).speed+int(first(object).location.y),10} - camera_orientation:{0.0,0.0,1.0}{ + { species object aspect:default; } display FocusPerson type:opengl focus:first(object){ diff --git a/simtools.gaml.extensions.physics/models/Physics Engine/models/Eroding Vulcano.gaml b/simtools.gaml.extensions.physics/models/Physics Engine/models/Eroding Vulcano.gaml index d247760cb3..41062d84ec 100644 --- a/simtools.gaml.extensions.physics/models/Physics Engine/models/Eroding Vulcano.gaml +++ b/simtools.gaml.extensions.physics/models/Physics Engine/models/Eroding Vulcano.gaml @@ -106,7 +106,7 @@ experiment "3D view" type: gui { parameter "Show legend" var: show_legend <- true; output { - display "3D" type: opengl draw_env: false background: #black camera_location: {49.7973,137.5162,95.6058} camera_target: {50.2918,44.9051,6.1638} camera_orientation: {0,0,1} antialias: false { + display "3D" type: opengl draw_env: false background: #black camera_location: {49.7973,137.5162,95.6058} camera_target: {50.2918,44.9051,6.1638} antialias: false { graphics title { if (show_legend) { draw "Average height " + (patches mean_of each.grid_value) with_precision 2 + " / # of lava agents " + length(lava) color: #cadetblue font: title at: {world.location.x, 100, patches max_of each.grid_value + 10} anchor: #center depth: 2 rotate: -20::{1,0,0}; diff --git a/simtools.gaml.extensions.physics/models/Physics Engine/models/Flow on Terrain.gaml b/simtools.gaml.extensions.physics/models/Physics Engine/models/Flow on Terrain.gaml index 677828621e..dabe437a4a 100644 --- a/simtools.gaml.extensions.physics/models/Physics Engine/models/Flow on Terrain.gaml +++ b/simtools.gaml.extensions.physics/models/Physics Engine/models/Flow on Terrain.gaml @@ -70,7 +70,7 @@ experiment "3D view" type: gui { output { layout #split; - display "Flow" type: opengl background: #white camera_location: {90.0,184.4875,144.4624} camera_target: {90.0,67.5,0.0} camera_orientation: {0.0,0.7771,0.6293} antialias: false { + display "Flow" type: opengl background: #white camera_location: {90.0,184.4875,144.4624} camera_target: {90.0,67.5,0.0} antialias: false { graphics world { draw "Scale: " + z_scale color: #cadetblue font: font("Helvetica", 18, #bold) at: {world.location.x, -10, 25} anchor: #center depth: 2 rotate: -90::{1,0,0}; draw aabb wireframe: true color: #lightblue; diff --git a/simtools.gaml.extensions.physics/models/Physics Engine/models/Perfect Gas Chamber.gaml b/simtools.gaml.extensions.physics/models/Physics Engine/models/Perfect Gas Chamber.gaml index 3899fbb8b8..19a471f3c3 100644 --- a/simtools.gaml.extensions.physics/models/Physics Engine/models/Perfect Gas Chamber.gaml +++ b/simtools.gaml.extensions.physics/models/Physics Engine/models/Perfect Gas Chamber.gaml @@ -85,7 +85,7 @@ experiment "Gas Chamber" type: gui { } } output { - display Cube type:opengl background:#white draw_env:false camera_location: {236.9814,1275.9964,799.6291} camera_target: {250.0,250.0,150.0} camera_orientation: {0,0.5,1} { + display Cube type:opengl background:#white draw_env:false camera_location: {236.9814,1275.9964,799.6291} camera_target: {250.0,250.0,150.0} { species wall; species particles {draw shape color: color;} } diff --git a/simtools.gaml.extensions.physics/models/Physics Engine/models/Play Pool.gaml b/simtools.gaml.extensions.physics/models/Physics Engine/models/Play Pool.gaml index 709b5c1876..c14d2f8630 100644 --- a/simtools.gaml.extensions.physics/models/Physics Engine/models/Play Pool.gaml +++ b/simtools.gaml.extensions.physics/models/Physics Engine/models/Play Pool.gaml @@ -178,7 +178,7 @@ experiment "Play !" type: gui autorun: true { } output { - display Pool type: opengl background: #white draw_env: false camera_location: {100.0,400.0,300.0} camera_target: {width/2,height/2,-20.0} camera_orientation: {0.0,1.0,0.0} { + display Pool type: opengl background: #white draw_env: false camera_location: {100.0,400.0,300.0} camera_target: {width/2,height/2,-20.0} { graphics user { if (white != nil) and (target != nil) { draw line(white, target) color: #white end_arrow: 3; diff --git a/simtools.gaml.extensions.physics/models/Physics Engine/models/Tricky Fountain.gaml b/simtools.gaml.extensions.physics/models/Physics Engine/models/Tricky Fountain.gaml index 4b4427bd9d..a50d9d65c3 100644 --- a/simtools.gaml.extensions.physics/models/Physics Engine/models/Tricky Fountain.gaml +++ b/simtools.gaml.extensions.physics/models/Physics Engine/models/Tricky Fountain.gaml @@ -105,7 +105,7 @@ species water skills: [dynamic_body] { experiment "3D View" type: gui { output { //The initial orientation of the display makes water drops 'fall' slightly towards the user... calling (hopefully) from immediate action! - display Flow type: opengl background: #black draw_env: false camera_location: {50,300,150} camera_target: {dim/2,dim/2,10} camera_orientation: {0,1,0}{ + display Flow type: opengl background: #black draw_env: false camera_location: {50,300,150} camera_target: {dim/2,dim/2,10} { species water {draw shape color: color;} species wall refresh: false {draw shape texture: image_file("../images/marble2.jpg");} species pillarAndFloor refresh: false {draw shape texture: image_file("../images/marble.jpg");} diff --git a/ummisco.gama.network/models/Network/2 Available protocols/UDP protocol/UDP Listener Mouse from Processing For camera.gaml b/ummisco.gama.network/models/Network/2 Available protocols/UDP protocol/UDP Listener Mouse from Processing For camera.gaml index 1ffcbeb31b..9b4c52d623 100644 --- a/ummisco.gama.network/models/Network/2 Available protocols/UDP protocol/UDP Listener Mouse from Processing For camera.gaml +++ b/ummisco.gama.network/models/Network/2 Available protocols/UDP protocol/UDP Listener Mouse from Processing For camera.gaml @@ -49,7 +49,7 @@ experiment Server_testdd type: gui { output { display d type: opengl camera_target: cam_loc - camera_orientation:{0.0,-1.0,0.0}{ + { species observedAgents; } } diff --git a/ummisco.gama.opengl/src/ummisco/gama/opengl/camera/AbstractCamera.java b/ummisco.gama.opengl/src/ummisco/gama/opengl/camera/AbstractCamera.java index 5ca3e67053..4103fd8b53 100644 --- a/ummisco.gama.opengl/src/ummisco/gama/opengl/camera/AbstractCamera.java +++ b/ummisco.gama.opengl/src/ummisco/gama/opengl/camera/AbstractCamera.java @@ -37,7 +37,7 @@ public abstract class AbstractCamera implements ICamera { static { - DEBUG.OFF(); + DEBUG.ON(); } /** The renderer. */ @@ -75,7 +75,7 @@ public abstract class AbstractCamera implements ICamera { protected final GamaPoint upVector = new GamaPoint(0, 0, 0); /** The initial up vector. */ - protected GamaPoint initialPosition, initialTarget, initialUpVector; + protected GamaPoint initialPosition, initialTarget; /** The theta. */ protected double theta; @@ -85,7 +85,6 @@ public abstract class AbstractCamera implements ICamera { /** The flipped. */ protected boolean flipped = false; - // protected double upVectorAngle; /** The keyboard sensivity. */ private final double _keyboardSensivity = 1d; @@ -132,10 +131,6 @@ public abstract class AbstractCamera implements ICamera { */ public AbstractCamera(final IOpenGLRenderer renderer2) { this.renderer = renderer2; - // LayeredDisplayData data = renderer.getData(); - // if (!data.isCameraUpVectorDefined() && !data.getCameraOrientation().equals(UP_Z)) { - setUpVector(0.0, 0.0, 1.0); - // } glu = new GLU(); } @@ -162,28 +157,12 @@ public void updateTarget() { target.setLocation(renderer.getData().getCameraTarget()); } - @Override - public void updateOrientation() { - // DEBUG.OUT("Upvector updatd as " + upVector); - upVector.setLocation(renderer.getData().getCameraOrientation()); - } - @Override public void update() { final LayeredDisplayData data = renderer.getData(); cameraInteraction = !data.cameraInteractionDisabled(); updateSphericalCoordinatesFromLocations(); - if (initialized) { - // AD Added here to recompute the upVector in case the lookAt and UpVector are aligned... See #3279 - if (flipped) { - setUpVector(-(-Math.cos(theta * Maths.toRad) * Math.cos(phi * Maths.toRad)), - -(-Math.sin(theta * Maths.toRad) * Math.cos(phi * Maths.toRad)), -Math.sin(phi * Maths.toRad)); - } else { - setUpVector(-Math.cos(theta * Maths.toRad) * Math.cos(phi * Maths.toRad), - -Math.sin(theta * Maths.toRad) * Math.cos(phi * Maths.toRad), Math.sin(phi * Maths.toRad)); - } - drawRotationHelper(); - } + if (initialized) { drawRotationHelper(); } initialized = true; } @@ -229,23 +208,6 @@ public void setTarget(final double xLPos, final double yLPos, final double zLPos getRenderer().getData().setCameraLookPos(new GamaPoint(target)); } - /** - * Sets the up vector. - * - * @param xPos - * the x pos - * @param yPos - * the y pos - * @param zPos - * the z pos - */ - // @Override - public void setUpVector(final double xPos, final double yPos, final double zPos) { - upVector.setLocation(xPos, yPos, zPos); - // DEBUG.OUT("setUpVector modified as " + upVector); - getRenderer().getData().setCameraOrientation(new GamaPoint(upVector)); - } - /* -------Get commands--------- */ @Override @@ -259,8 +221,14 @@ public void setUpVector(final double xPos, final double yPos, final double zPos) @Override public void animate() { - // TODO : Y and Z seem to be exchanged... Probably something to look at (see #3221) - // DEBUG.OUT("Animate: upVector = " + upVector); + + // Completely recomputer the up-vector + double tr = theta * Maths.toRad; + double pr = phi * Maths.toRad; + upVector.x = flipped ? -(-Math.cos(tr) * Math.cos(pr)) : -Math.cos(tr) * Math.cos(pr); + upVector.y = flipped ? -(-Math.sin(tr) * Math.cos(pr)) : -Math.sin(tr) * Math.cos(pr); + upVector.z = flipped ? -Math.sin(pr) : Math.sin(pr); + glu.gluLookAt(position.x, position.y, position.z, target.x, target.y, target.z, upVector.x, upVector.y, upVector.z); } @@ -681,8 +649,6 @@ void finishROISelection() { // zPos:" + position.z); // DEBUG.LOG("xLPos:" + target.x + " yLPos:" + target.y + " zLPos:" // + target.z); - // DEBUG.LOG("upX" + upVector.x + " upY:" + upVector.y + " upZ:" + - // upVector.z); // DEBUG.LOG("_phi " + phi + " _theta " + theta); // } diff --git a/ummisco.gama.opengl/src/ummisco/gama/opengl/camera/CameraArcBall.java b/ummisco.gama.opengl/src/ummisco/gama/opengl/camera/CameraArcBall.java index be4f133aa8..1cb5ce910a 100644 --- a/ummisco.gama.opengl/src/ummisco/gama/opengl/camera/CameraArcBall.java +++ b/ummisco.gama.opengl/src/ummisco/gama/opengl/camera/CameraArcBall.java @@ -53,12 +53,6 @@ public void updateCartesianCoordinatesFromAngles() { final double sinP = Math.sin(factorP); final double radius = distance; setPosition(radius * cosT * sinP + target.x, radius * sinT * sinP + target.y, radius * cosP + target.z); - // See #2854 -- see if putting this here does not restrict the moves using the mouse - if (flipped) { - setUpVector(-(-cosT * cosP), -(-sinT * cosP), -sinP); - } else { - setUpVector(-cosT * cosP, -sinT * cosP, sinP); - } } /** @@ -67,10 +61,8 @@ public void updateCartesianCoordinatesFromAngles() { // @Override @Override public void updateSphericalCoordinatesFromLocations() { - final GamaPoint p = position.minus(target); setDistance(p.norm()); - theta = Maths.toDeg * Math.atan2(p.y, p.x); // See issue on camera_pos if (theta == 0) { theta = -90; } @@ -97,9 +89,6 @@ private void translateCameraFromScreenPlan(final double x_translation_in_screen, final double theta_vect_y_norm = theta_vect_y * theta_vect_ratio; final double theta_vect_z_norm = theta_vect_z * theta_vect_ratio; - setUpVector(-Math.cos(theta * Maths.toRad) * Math.cos(phi * Maths.toRad), - -Math.sin(theta * Maths.toRad) * Math.cos(phi * Maths.toRad), Math.sin(phi * Maths.toRad)); - final double phi_vect_x = Math.cos(theta * Maths.toRad) * Math.cos(phi * Maths.toRad); final double phi_vect_y = Math.sin(theta * Maths.toRad) * Math.cos(phi * Maths.toRad); final double phi_vect_z = -Math.sin(phi * Maths.toRad); @@ -222,7 +211,6 @@ public void initialize() { phi = 0; theta = -90.00; } - if (data.isCameraUpVectorDefined()) { updateOrientation(); } updateSphericalCoordinatesFromLocations(); } else { final double envWidth = data.getEnvWidth(); @@ -236,11 +224,9 @@ public void initialize() { } initialPosition = new GamaPoint(position); initialTarget = new GamaPoint(target); - initialUpVector = new GamaPoint(upVector); } else { data.setCameraPos(initialPosition); data.setCameraLookPos(initialTarget); - data.setCameraOrientation(initialUpVector); } } diff --git a/ummisco.gama.opengl/src/ummisco/gama/opengl/camera/FreeFlyCamera.java b/ummisco.gama.opengl/src/ummisco/gama/opengl/camera/FreeFlyCamera.java index f11ada5948..d97c66e336 100644 --- a/ummisco.gama.opengl/src/ummisco/gama/opengl/camera/FreeFlyCamera.java +++ b/ummisco.gama.opengl/src/ummisco/gama/opengl/camera/FreeFlyCamera.java @@ -108,14 +108,8 @@ public void animate() { setTarget(position.plus(forward)); } - @Override - public void setUpVector(final double xPos, final double yPos, final double zPos) { - // Not allowed for this camera - } - @Override public void initialize() { - upVector.setLocation(up); final LayeredDisplayData data = getRenderer().getData(); final double envWidth = data.getEnvWidth(); final double envHeight = data.getEnvHeight(); @@ -215,4 +209,7 @@ protected void updateSphericalCoordinatesFromLocations() { } + @Override + public GamaPoint getOrientation() { return up; } + } diff --git a/ummisco.gama.opengl/src/ummisco/gama/opengl/camera/ICamera.java b/ummisco.gama.opengl/src/ummisco/gama/opengl/camera/ICamera.java index a4e957eded..e0bc17d62b 100644 --- a/ummisco.gama.opengl/src/ummisco/gama/opengl/camera/ICamera.java +++ b/ummisco.gama.opengl/src/ummisco/gama/opengl/camera/ICamera.java @@ -101,11 +101,6 @@ public interface CameraPreset { */ void updateTarget(); - /** - * Update orientation. - */ - void updateOrientation(); - /** * Animate. */ diff --git a/ummisco.gama.opengl/src/ummisco/gama/opengl/renderer/JOGLRenderer.java b/ummisco.gama.opengl/src/ummisco/gama/opengl/renderer/JOGLRenderer.java index 90b4b27c5a..0e5d131a50 100644 --- a/ummisco.gama.opengl/src/ummisco/gama/opengl/renderer/JOGLRenderer.java +++ b/ummisco.gama.opengl/src/ummisco/gama/opengl/renderer/JOGLRenderer.java @@ -1,12 +1,12 @@ /******************************************************************************************************* * - * JOGLRenderer.java, in ummisco.gama.opengl, is part of the source code of the - * GAMA modeling and simulation platform (v.1.8.2). + * JOGLRenderer.java, in ummisco.gama.opengl, is part of the source code of the GAMA modeling and simulation platform + * (v.1.8.2). * * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) * * Visit https://github.com/gama-platform/gama for license information and contacts. - * + * ********************************************************************************************************/ package ummisco.gama.opengl.renderer; diff --git a/ummisco.gama.opengl/src/ummisco/gama/opengl/renderer/helpers/CameraHelper.java b/ummisco.gama.opengl/src/ummisco/gama/opengl/renderer/helpers/CameraHelper.java index 72962bd977..e56692f8e4 100644 --- a/ummisco.gama.opengl/src/ummisco/gama/opengl/renderer/helpers/CameraHelper.java +++ b/ummisco.gama.opengl/src/ummisco/gama/opengl/renderer/helpers/CameraHelper.java @@ -44,34 +44,34 @@ public class CameraHelper extends AbstractRendererHelper implements ICamera { PRESETS.put("Choose...", c -> {}); PRESETS.put("From top", c -> { c.setPosition(c.getTarget().x, c.getTarget().y, c.getRenderer().getMaxEnvDim() * c.getInitialZFactor()); - c.setUpVector(0, 1, 0); + // c.setUpVector(0, 1, 0); }); PRESETS.put("From left", c -> { c.setPosition(c.getTarget().x - c.getRenderer().getEnvWidth() * c.getInitialZFactor(), c.getTarget().y, 0); - c.setUpVector(0, 0, 1); + // c.setUpVector(0, 0, 1); }); PRESETS.put("From up left", c -> { c.setPosition(c.getTarget().x - c.getRenderer().getEnvWidth() * c.getInitialZFactor(), c.getTarget().y, c.getRenderer().getMaxEnvDim() * c.getInitialZFactor()); - c.setUpVector(0, 0, 1); + // c.setUpVector(0, 0, 1); }); PRESETS.put("From right", c -> { c.setPosition(c.getTarget().x + c.getRenderer().getEnvWidth() * c.getInitialZFactor(), c.getTarget().y, 0); - c.setUpVector(0, 0, 1); + // c.setUpVector(0, 0, 1); }); PRESETS.put("From up right", c -> { c.setPosition(c.getTarget().x + c.getRenderer().getEnvWidth() * c.getInitialZFactor(), c.getTarget().y, c.getRenderer().getMaxEnvDim() * c.getInitialZFactor()); - c.setUpVector(0, 0, 1); + // c.setUpVector(0, 0, 1); }); PRESETS.put("From front", c -> { c.setPosition(c.getTarget().x, c.getTarget().y - c.getRenderer().getEnvHeight() * c.getInitialZFactor(), 0); - c.setUpVector(0, 0, 1); + // c.setUpVector(0, 0, 1); }); PRESETS.put("From up front", c -> { c.setPosition(c.getTarget().x, c.getTarget().y - c.getRenderer().getEnvHeight() * c.getInitialZFactor(), c.getRenderer().getMaxEnvDim() * c.getInitialZFactor()); - c.setUpVector(0, 0, 1); + // c.setUpVector(0, 0, 1); }); } @@ -110,10 +110,13 @@ public void updatePosition() { if (camera != null) { camera.updatePosition(); } } - @Override - public void updateOrientation() { - if (camera != null) { camera.updateOrientation(); } - } + /** + * Update orientation. + */ + // @Override + // public void updateOrientation() { + // if (camera != null) { camera.updateOrientation(); } + // } @Override public void updateTarget() { @@ -193,7 +196,12 @@ public GamaPoint getPosition() { return UNDEFINED; } - @Override + /** + * Gets the orientation. + * + * @return the orientation + */ + // @Override public GamaPoint getOrientation() { if (camera != null) return camera.getOrientation(); return UNDEFINED; diff --git a/ummisco.gama.opengl/src/ummisco/gama/opengl/view/SWTOpenGLDisplaySurface.java b/ummisco.gama.opengl/src/ummisco/gama/opengl/view/SWTOpenGLDisplaySurface.java index ec7947bd3a..4ff9ebf58f 100644 --- a/ummisco.gama.opengl/src/ummisco/gama/opengl/view/SWTOpenGLDisplaySurface.java +++ b/ummisco.gama.opengl/src/ummisco/gama/opengl/view/SWTOpenGLDisplaySurface.java @@ -1,12 +1,12 @@ /******************************************************************************************************* * - * SWTOpenGLDisplaySurface.java, in ummisco.gama.opengl, is part of the source code of the - * GAMA modeling and simulation platform (v.1.8.2). + * SWTOpenGLDisplaySurface.java, in ummisco.gama.opengl, is part of the source code of the GAMA modeling and simulation + * platform (v.1.8.2). * * (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU) * * Visit https://github.com/gama-platform/gama for license information and contacts. - * + * ********************************************************************************************************/ package ummisco.gama.opengl.view; @@ -715,9 +715,6 @@ public void changed(final Changes property, final Object value) { case CAMERA_POS: renderer.getCameraHelper().updatePosition(); break; - case CAMERA_ORIENTATION: - renderer.getCameraHelper().updateOrientation(); - break; case CAMERA_TARGET: renderer.getCameraHelper().updateTarget(); break; diff --git a/ummisco.gama.ui.experiment/src/ummisco/gama/ui/views/displays/LayerSideControls.java b/ummisco.gama.ui.experiment/src/ummisco/gama/ui/views/displays/LayerSideControls.java index 3d27fe8f73..6de9cc3c53 100644 --- a/ummisco.gama.ui.experiment/src/ummisco/gama/ui/views/displays/LayerSideControls.java +++ b/ummisco.gama.ui.experiment/src/ummisco/gama/ui/views/displays/LayerSideControls.java @@ -87,7 +87,6 @@ public static void updateIfPaused(final ILayer layer, final IDisplaySurface cont public Composite fill(final Composite parent, final LayeredDisplayView view) { final Composite column = new Composite(parent, SWT.NONE); - // column.setBackground(IGamaColors.WHITE.color()); GridData data = new GridData(SWT.FILL, SWT.TOP, true, false); column.setLayoutData(data); final GridLayout layout = new GridLayout(2, false); @@ -95,7 +94,6 @@ public Composite fill(final Composite parent, final LayeredDisplayView view) { column.setLayout(layout); final Composite viewersComposite = new Composite(parent, SWT.None); - // viewersComposite.setBackground(IGamaColors.WHITE.color()); data = new GridData(SWT.FILL, SWT.FILL, true, true); viewersComposite.setLayoutData(data); viewersComposite.setLayout(new GridLayout(1, true)); @@ -167,7 +165,7 @@ private void fillOpenGLParameters(final ParameterExpandBar viewer, final Layered } /** The camera orientation. */ - PointEditor cameraPos, cameraTarget, cameraOrientation; + PointEditor cameraPos, cameraTarget; /** The preset. */ AbstractEditor preset; @@ -202,7 +200,6 @@ private void fillCameraParameters(final ParameterExpandBar viewer, final Layered preset.setActive(!newValue); cameraPos.setActive(!newValue); cameraTarget.setActive(!newValue); - cameraOrientation.setActive(!newValue); zoom.setActive(!newValue); data.disableCameraInteractions(newValue); }); @@ -224,15 +221,9 @@ private void fillCameraParameters(final ParameterExpandBar viewer, final Layered data.setCameraLookPos(newValue); ds.updateDisplay(true); }); - cameraOrientation = (PointEditor) EditorFactory.create(scope, contents, "Orientation:", - data.getCameraOrientation(), (EditorListener) newValue -> { - data.setCameraOrientation(newValue); - ds.updateDisplay(true); - }); preset.setActive(!cameraLocked); cameraPos.setActive(!cameraLocked); cameraTarget.setActive(!cameraLocked); - cameraOrientation.setActive(!cameraLocked); zoom.setActive(!cameraLocked); data.addListener((p, v) -> { switch (p) { @@ -246,11 +237,6 @@ private void fillCameraParameters(final ParameterExpandBar viewer, final Layered cameraTarget.updateWithValueOfParameter(); copyCameraAndKeystoneDefinition(scope, data); break; - case CAMERA_ORIENTATION: - cameraOrientation.getParam().setValue(scope, data.getCameraOrientation()); - cameraOrientation.updateWithValueOfParameter(); - copyCameraAndKeystoneDefinition(scope, data); - break; case CAMERA_PRESET: preset.getParam().setValue(scope, "Choose..."); preset.updateWithValueOfParameter(); @@ -625,8 +611,8 @@ private String cameraDefinitionToCopy() { .append(new GamaPoint(cameraPos.getCurrentValue()).yNegated().withPrecision(4).serialize(false)); text.append(" ").append(IKeyword.CAMERA_TARGET).append(": ") .append(new GamaPoint(cameraTarget.getCurrentValue()).yNegated().withPrecision(4).serialize(false)); - text.append(" ").append(IKeyword.CAMERA_ORIENTATION).append(": ") - .append(new GamaPoint(cameraOrientation.getCurrentValue()).withPrecision(4).serialize(false)); + // text.append(" ").append(IKeyword.CAMERA_ORIENTATION).append(": ") + // .append(new GamaPoint(cameraOrientation.getCurrentValue()).withPrecision(4).serialize(false)); return text.toString(); }