Added tracking for angle between third person boat and next mark

#story[1195]
This commit is contained in:
Connor Taylor-Brown
2017-09-13 14:44:18 +12:00
parent 83e696b79e
commit e657a0cc99
2 changed files with 47 additions and 17 deletions
@@ -1,5 +1,7 @@
package visualiser.layout;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ChangeListener;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
@@ -39,7 +41,7 @@ public class View3D extends Pane {
/**
* Subject tracked by camera
*/
private Subject3D target;
private ObjectProperty<Subject3D> target;
/**
* Rendering container for shapes
*/
@@ -101,7 +103,7 @@ public class View3D extends Pane {
this.world = new Group();
this.shapeMap = new HashMap<>();
this.sourceMap = new HashMap<>();
this.target = null;
this.target = new SimpleObjectProperty<>(null);
this.scene = new SubScene(world, 300, 300);
scene.widthProperty().bind(this.widthProperty());
@@ -184,6 +186,10 @@ public class View3D extends Pane {
});
}
public ObjectProperty<Subject3D> targetProperty() {
return target;
}
/**
* Configures camera to third person view
*/
@@ -212,11 +218,12 @@ public class View3D extends Pane {
* Stop camera from following the last selected subject
*/
private void untrackSubject() {
if(target != null) {
target.getPosition().xProperty().removeListener(pivotX);
target.getPosition().yProperty().removeListener(pivotY);
target.getPosition().zProperty().removeListener(pivotZ);
target.getHeading().angleProperty().removeListener(pivotHeading);
if(target.get() != null) {
target.get().getPosition().xProperty().removeListener(pivotX);
target.get().getPosition().yProperty().removeListener(pivotY);
target.get().getPosition().zProperty().removeListener(pivotZ);
target.get().getHeading().angleProperty().removeListener(pivotHeading);
target.setValue(null);
}
}
@@ -225,15 +232,15 @@ public class View3D extends Pane {
* @param subject to track
*/
private void trackSubject(Subject3D subject) {
target = subject;
target.set(subject);
updatePivot(target.getPosition());
setYaw(target.getHeading().getAngle());
updatePivot(target.get().getPosition());
setYaw(target.get().getHeading().getAngle());
target.getPosition().xProperty().addListener(pivotX);
target.getPosition().yProperty().addListener(pivotY);
target.getPosition().zProperty().addListener(pivotZ);
target.getHeading().angleProperty().addListener(pivotHeading);
target.get().getPosition().xProperty().addListener(pivotX);
target.get().getPosition().yProperty().addListener(pivotY);
target.get().getPosition().zProperty().addListener(pivotZ);
target.get().getHeading().angleProperty().addListener(pivotHeading);
}
public void setNearClip(double nearClip) {