Merge branch 'master' into story1306_wind_arrow
This commit is contained in:
@@ -19,3 +19,5 @@ Erika Savell <[email protected]>
|
|||||||
Connor Taylor-Brown <[email protected]> <[email protected]>
|
Connor Taylor-Brown <[email protected]> <[email protected]>
|
||||||
Fraser Cope <[email protected]>
|
Fraser Cope <[email protected]>
|
||||||
Jessica Syder <[email protected]> Jessica Syder <[email protected]>
|
Jessica Syder <[email protected]> Jessica Syder <[email protected]>
|
||||||
|
Joseph Gardner <[email protected]>
|
||||||
|
Hamish Ball <[email protected]> hba56 <[email protected]>
|
||||||
@@ -467,7 +467,7 @@ public class RaceViewController extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
view3D.updateDistance(-10);
|
view3D.zoomIn();
|
||||||
break;
|
break;
|
||||||
case "Zoom Out":
|
case "Zoom Out":
|
||||||
//Check if race is a tutorial
|
//Check if race is a tutorial
|
||||||
@@ -482,7 +482,7 @@ public class RaceViewController extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
view3D.updateDistance(10);
|
view3D.zoomOut();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package visualiser.layout;
|
|||||||
import javafx.animation.AnimationTimer;
|
import javafx.animation.AnimationTimer;
|
||||||
import javafx.beans.property.ObjectProperty;
|
import javafx.beans.property.ObjectProperty;
|
||||||
import javafx.beans.property.SimpleObjectProperty;
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
import javafx.beans.value.ChangeListener;
|
|
||||||
import javafx.collections.ListChangeListener;
|
import javafx.collections.ListChangeListener;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.scene.*;
|
import javafx.scene.*;
|
||||||
@@ -78,11 +77,17 @@ public class View3D extends Pane {
|
|||||||
/**
|
/**
|
||||||
* Distance to switch from third person to bird's eye
|
* Distance to switch from third person to bird's eye
|
||||||
*/
|
*/
|
||||||
private final double THIRD_PERSON_LIMIT = 100;
|
private final double THIRD_PERSON_LIMIT = 500;
|
||||||
/**
|
/**
|
||||||
* Distance to stop zoom
|
* Distance to stop zoom
|
||||||
*/
|
*/
|
||||||
private final double FIRST_PERSON_LIMIT = 2;
|
private final double ZOOM_IN_LIMIT = 30;
|
||||||
|
private final double ZOOM_OUT_LIMIT = 700;
|
||||||
|
private final double MAX_ZOOM_LIMIT = 1500;
|
||||||
|
private final double MAX_PITCH = 60; // birds eye view
|
||||||
|
private final double MIN_PITCH = 5; // third person view
|
||||||
|
private final double ZOOM_PER_KEYPRESS = 5; // distance changed per zoom
|
||||||
|
private double itemScale = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor for View3D. Sets up Scene and PerspectiveCamera.
|
* Default constructor for View3D. Sets up Scene and PerspectiveCamera.
|
||||||
@@ -183,12 +188,9 @@ public class View3D extends Pane {
|
|||||||
* Configures camera to third person view
|
* Configures camera to third person view
|
||||||
*/
|
*/
|
||||||
public void setThirdPerson() {
|
public void setThirdPerson() {
|
||||||
this.setDistance(THIRD_PERSON_LIMIT / 2);
|
this.setDistance(ZOOM_IN_LIMIT * 2);
|
||||||
this.setPitch(10);
|
adjustPitchForZoom();
|
||||||
|
adjustScaleForZoom();
|
||||||
for(Subject3D item: items) {
|
|
||||||
item.setScale(0.1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -196,17 +198,14 @@ public class View3D extends Pane {
|
|||||||
*/
|
*/
|
||||||
public void setBirdsEye() {
|
public void setBirdsEye() {
|
||||||
this.setYaw(0);
|
this.setYaw(0);
|
||||||
this.setPitch(60);
|
this.setPitch(MAX_PITCH);
|
||||||
|
adjustScaleForZoom();
|
||||||
for(Subject3D item: items) {
|
|
||||||
item.setScale(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop camera from following the last selected subject
|
* Stop camera from following the last selected subject
|
||||||
*/
|
*/
|
||||||
private void untrackSubject() {
|
public void untrackSubject() {
|
||||||
if(target.get() != null) {
|
if(target.get() != null) {
|
||||||
trackBoat.stop();
|
trackBoat.stop();
|
||||||
target.setValue(null);
|
target.setValue(null);
|
||||||
@@ -217,7 +216,7 @@ public class View3D extends Pane {
|
|||||||
* Set camera to follow the selected subject
|
* Set camera to follow the selected subject
|
||||||
* @param subject to track
|
* @param subject to track
|
||||||
*/
|
*/
|
||||||
private void trackSubject(Subject3D subject) {
|
public void trackSubject(Subject3D subject) {
|
||||||
target.set(subject);
|
target.set(subject);
|
||||||
|
|
||||||
this.trackBoat = new AnimationTimer() {
|
this.trackBoat = new AnimationTimer() {
|
||||||
@@ -267,17 +266,79 @@ public class View3D extends Pane {
|
|||||||
* @param delta amount to change distance by
|
* @param delta amount to change distance by
|
||||||
*/
|
*/
|
||||||
public void updateDistance(double delta) {
|
public void updateDistance(double delta) {
|
||||||
double distance = -this.distance.getZ() + delta;
|
double newDistance = -this.distance.getZ() + delta;
|
||||||
|
if (target.get() == null){
|
||||||
if(distance <= FIRST_PERSON_LIMIT) {
|
if (newDistance > MAX_ZOOM_LIMIT){
|
||||||
this.setDistance(FIRST_PERSON_LIMIT);
|
setDistance(MAX_ZOOM_LIMIT);
|
||||||
} else if(distance > THIRD_PERSON_LIMIT) {
|
|
||||||
this.setDistance(distance);
|
|
||||||
untrackSubject();
|
|
||||||
setBirdsEye();
|
|
||||||
} else {
|
} else {
|
||||||
this.setDistance(distance);
|
setDistance(newDistance);
|
||||||
}
|
}
|
||||||
|
} else if(newDistance <= ZOOM_IN_LIMIT) {
|
||||||
|
setDistance(ZOOM_IN_LIMIT);
|
||||||
|
} else if (newDistance > ZOOM_OUT_LIMIT){
|
||||||
|
untrackSubject();
|
||||||
|
setDistance(1050);
|
||||||
|
updatePivot(new Translate(250, 0, 210));
|
||||||
|
setYaw(0);
|
||||||
|
} else {
|
||||||
|
setDistance(newDistance);
|
||||||
|
}
|
||||||
|
adjustPitchForZoom();
|
||||||
|
adjustScaleForZoom();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adjusts the scale size of boats and markers as a user zooms in or out,
|
||||||
|
* to smooth the change between third person to birds eye view.
|
||||||
|
*/
|
||||||
|
private void adjustScaleForZoom(){
|
||||||
|
double itemScale = (((-distance.getZ() - (ZOOM_IN_LIMIT * 2)) /
|
||||||
|
((THIRD_PERSON_LIMIT - (ZOOM_IN_LIMIT * 2)) /
|
||||||
|
(1 - 0.1))) + 0.1);
|
||||||
|
// if zoomed right in
|
||||||
|
if (itemScale < 0.1){
|
||||||
|
itemScale = 0.1;
|
||||||
|
// if zoomed right out
|
||||||
|
} else if (itemScale > 1) {
|
||||||
|
itemScale = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update scale
|
||||||
|
for (Subject3D item : items) {
|
||||||
|
item.setScale(itemScale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adjusts the pitch as a user zooms in or out, to smooth the change
|
||||||
|
* between third person to birds eye view.
|
||||||
|
*/
|
||||||
|
private void adjustPitchForZoom(){
|
||||||
|
double pitch = (((-distance.getZ() - (ZOOM_IN_LIMIT*2)) /
|
||||||
|
((THIRD_PERSON_LIMIT - (ZOOM_IN_LIMIT*2)) / (MAX_PITCH -
|
||||||
|
MIN_PITCH))) + MIN_PITCH);
|
||||||
|
|
||||||
|
// if pitch is out of bounds, set it to the min/max
|
||||||
|
if (pitch < MIN_PITCH) {
|
||||||
|
pitch = MIN_PITCH;
|
||||||
|
} else if (pitch > MAX_PITCH){
|
||||||
|
pitch = MAX_PITCH;
|
||||||
|
}
|
||||||
|
setPitch(pitch);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to be called when the zoom in key is pressed.
|
||||||
|
*/
|
||||||
|
public void zoomIn(){
|
||||||
|
updateDistance(-ZOOM_PER_KEYPRESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to be called when the zoom out key is pressed.
|
||||||
|
*/
|
||||||
|
public void zoomOut(){
|
||||||
|
updateDistance(ZOOM_PER_KEYPRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user