Skip to content

Commit

Permalink
Substantial change to deal with #2744, #3279, #3221
Browse files Browse the repository at this point in the history
Entire removal of the possiblity to setup, change, and get the
"up-vector" / camera orientation, which is now calculated automatically.

Removes all corresponding variables and methods, deprecates the
corresponding facet (camera_orientation:). The #camera_orientation
constant remains however accessible and returns the computed value.
  • Loading branch information
AlexisDrogoul committed Feb 20, 2022
1 parent f130003 commit 9f59fce
Show file tree
Hide file tree
Showing 23 changed files with 83 additions and 209 deletions.
60 changes: 1 addition & 59 deletions msi.gama.core/src/msi/gama/outputs/LayeredDisplayData.java
Expand Up @@ -61,9 +61,6 @@ public enum Changes {
/** The camera target. */
CAMERA_TARGET,

/** The camera orientation. */
CAMERA_ORIENTATION,

/** The camera preset. */
CAMERA_PRESET,

Expand Down Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -836,7 +788,6 @@ public void setContinuousRotation(final boolean r) {
public void setZRotationAngle(final double val) {
zRotationAngleDelta = val;
currentRotationAboutZ = val;
// notifyListeners(Changes.ROTATION, val);
}

/**
Expand Down Expand Up @@ -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));
Expand Down
6 changes: 4 additions & 2 deletions msi.gama.core/src/msi/gama/outputs/LayeredDisplayOutput.java
Expand Up @@ -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,
Expand Down
@@ -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;
Expand All @@ -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;
Expand Down
Expand Up @@ -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") ;
Expand Down
Expand Up @@ -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;
}

Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Expand Up @@ -419,19 +419,19 @@ 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};
species obstacle ;
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;
Expand All @@ -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 ;
Expand Down
Expand Up @@ -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){
Expand Down
Expand Up @@ -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};
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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;}
}
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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");}
Expand Down
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 9f59fce

Please sign in to comment.