Skip to content

Commit

Permalink
Fixes #3221.
Browse files Browse the repository at this point in the history
There is however something strange in the upVector computation, which
doesnt to influence anything. It needs to be verified again with some
further tests
  • Loading branch information
AlexisDrogoul committed Dec 19, 2021
1 parent b158288 commit eac5eb4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
1 change: 0 additions & 1 deletion msi.gama.core/src/msi/gama/outputs/LayeredDisplayData.java
Expand Up @@ -692,7 +692,6 @@ public void setCameraOrientation(final GamaPoint point) {
final GamaPoint c = point;
if (cameraOrientation != null) {
if (c.equals(cameraOrientation)) return;
DEBUG.OUT("UpVectors different: x " + point.x + " != " + cameraOrientation.x);
cameraOrientation.setLocation(c);
} else {
cameraOrientation = new GamaPoint(c);
Expand Down
Expand Up @@ -123,9 +123,6 @@ public abstract class AbstractCamera implements ICamera {
/** The use num keys. */
private final boolean useNumKeys = GamaPreferences.Displays.OPENGL_NUM_KEYS_CAM.getValue();

/** The Constant UP_Z. */
private static final GamaPoint UP_Z = new GamaPoint(0, 0, 1);

/**
* Instantiates a new abstract camera.
*
Expand All @@ -136,7 +133,7 @@ public AbstractCamera(final IOpenGLRenderer renderer2) {
this.renderer = renderer2;
// LayeredDisplayData data = renderer.getData();
// if (!data.isCameraUpVectorDefined() && !data.getCameraOrientation().equals(UP_Z)) {
setUpVector(0.0, 1.0, 0.0);
setUpVector(0.0, 0.0, 1.0);
// }
glu = new GLU();
}
Expand Down Expand Up @@ -235,6 +232,7 @@ 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)
glu.gluLookAt(position.x, position.y, position.z, target.x, target.y, target.z, upVector.x, upVector.y,
upVector.z);
}
Expand Down
Expand Up @@ -48,15 +48,13 @@ public void updateCartesianCoordinatesFromAngles() {
final double sinT = Math.sin(factorT);
final double cosP = Math.cos(factorP);
final double sinP = Math.sin(factorP);
setPosition(getDistance() * cosT * sinP + target.x, getDistance() * sinT * sinP + target.y,
getDistance() * cosP + target.z);
final double radius = getDistance();
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(-(-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));
setUpVector(-(-cosT * cosP), -(-sinT * cosP), -sinP);
} 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));
setUpVector(-cosT * cosP, -sinT * cosP, sinP);
}
}

Expand Down

0 comments on commit eac5eb4

Please sign in to comment.