Added tracking for angle between third person boat and next mark
#story[1195]
This commit is contained in:
@@ -27,9 +27,8 @@ import javafx.scene.transform.Translate;
|
|||||||
import javafx.util.Callback;
|
import javafx.util.Callback;
|
||||||
import network.Messages.Enums.RaceStatusEnum;
|
import network.Messages.Enums.RaceStatusEnum;
|
||||||
import shared.dataInput.RaceDataSource;
|
import shared.dataInput.RaceDataSource;
|
||||||
import shared.model.CompoundMark;
|
import shared.exceptions.BoatNotFoundException;
|
||||||
import shared.model.Leg;
|
import shared.model.*;
|
||||||
import shared.model.Mark;
|
|
||||||
import visualiser.app.App;
|
import visualiser.app.App;
|
||||||
import visualiser.enums.TutorialState;
|
import visualiser.enums.TutorialState;
|
||||||
import visualiser.gameController.ControllerClient;
|
import visualiser.gameController.ControllerClient;
|
||||||
@@ -304,6 +303,14 @@ public class RaceController extends Controller {
|
|||||||
// Fix initial bird's-eye position
|
// Fix initial bird's-eye position
|
||||||
view3D.updatePivot(new Translate(250, 0, 210));
|
view3D.updatePivot(new Translate(250, 0, 210));
|
||||||
|
|
||||||
|
view3D.targetProperty().addListener((o, prev, curr)-> {
|
||||||
|
if(curr != null && visualiserRace.getVisualiserRaceState().isVisualiserBoat(curr.getSourceID())) {
|
||||||
|
addThirdPersonAnnotations(curr);
|
||||||
|
} else {
|
||||||
|
removeThirdPersonAnnotations();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Bind zooming to scrolling
|
// Bind zooming to scrolling
|
||||||
view3D.setOnScroll(e -> {
|
view3D.setOnScroll(e -> {
|
||||||
view3D.updateDistance(e.getDeltaY());
|
view3D.updateDistance(e.getDeltaY());
|
||||||
@@ -349,6 +356,22 @@ public class RaceController extends Controller {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addThirdPersonAnnotations(Subject3D subject3D) {
|
||||||
|
try {
|
||||||
|
VisualiserBoat boat = visualiserRace.getVisualiserRaceState().getBoat(subject3D.getSourceID());
|
||||||
|
boat.bearingProperty().addListener((o, prev, curr) -> {
|
||||||
|
CompoundMark target = boat.getCurrentLeg().getEndCompoundMark();
|
||||||
|
Bearing headingToMark = GPSCoordinate.calculateBearing(boat.getPosition(), target.getAverageGPSCoordinate());
|
||||||
|
System.out.println(headingToMark.degrees() - boat.getBearing().degrees());
|
||||||
|
});
|
||||||
|
} catch (BoatNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeThirdPersonAnnotations() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swap the colour of the next mark to pass with the last mark passed
|
* Swap the colour of the next mark to pass with the last mark passed
|
||||||
* @param leg boat has started on
|
* @param leg boat has started on
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package visualiser.layout;
|
package visualiser.layout;
|
||||||
|
|
||||||
|
import javafx.beans.property.ObjectProperty;
|
||||||
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.collections.ListChangeListener;
|
import javafx.collections.ListChangeListener;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
@@ -39,7 +41,7 @@ public class View3D extends Pane {
|
|||||||
/**
|
/**
|
||||||
* Subject tracked by camera
|
* Subject tracked by camera
|
||||||
*/
|
*/
|
||||||
private Subject3D target;
|
private ObjectProperty<Subject3D> target;
|
||||||
/**
|
/**
|
||||||
* Rendering container for shapes
|
* Rendering container for shapes
|
||||||
*/
|
*/
|
||||||
@@ -101,7 +103,7 @@ public class View3D extends Pane {
|
|||||||
this.world = new Group();
|
this.world = new Group();
|
||||||
this.shapeMap = new HashMap<>();
|
this.shapeMap = new HashMap<>();
|
||||||
this.sourceMap = new HashMap<>();
|
this.sourceMap = new HashMap<>();
|
||||||
this.target = null;
|
this.target = new SimpleObjectProperty<>(null);
|
||||||
this.scene = new SubScene(world, 300, 300);
|
this.scene = new SubScene(world, 300, 300);
|
||||||
|
|
||||||
scene.widthProperty().bind(this.widthProperty());
|
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
|
* Configures camera to third person view
|
||||||
*/
|
*/
|
||||||
@@ -212,11 +218,12 @@ public class View3D extends Pane {
|
|||||||
* Stop camera from following the last selected subject
|
* Stop camera from following the last selected subject
|
||||||
*/
|
*/
|
||||||
private void untrackSubject() {
|
private void untrackSubject() {
|
||||||
if(target != null) {
|
if(target.get() != null) {
|
||||||
target.getPosition().xProperty().removeListener(pivotX);
|
target.get().getPosition().xProperty().removeListener(pivotX);
|
||||||
target.getPosition().yProperty().removeListener(pivotY);
|
target.get().getPosition().yProperty().removeListener(pivotY);
|
||||||
target.getPosition().zProperty().removeListener(pivotZ);
|
target.get().getPosition().zProperty().removeListener(pivotZ);
|
||||||
target.getHeading().angleProperty().removeListener(pivotHeading);
|
target.get().getHeading().angleProperty().removeListener(pivotHeading);
|
||||||
|
target.setValue(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,15 +232,15 @@ public class View3D extends Pane {
|
|||||||
* @param subject to track
|
* @param subject to track
|
||||||
*/
|
*/
|
||||||
private void trackSubject(Subject3D subject) {
|
private void trackSubject(Subject3D subject) {
|
||||||
target = subject;
|
target.set(subject);
|
||||||
|
|
||||||
updatePivot(target.getPosition());
|
updatePivot(target.get().getPosition());
|
||||||
setYaw(target.getHeading().getAngle());
|
setYaw(target.get().getHeading().getAngle());
|
||||||
|
|
||||||
target.getPosition().xProperty().addListener(pivotX);
|
target.get().getPosition().xProperty().addListener(pivotX);
|
||||||
target.getPosition().yProperty().addListener(pivotY);
|
target.get().getPosition().yProperty().addListener(pivotY);
|
||||||
target.getPosition().zProperty().addListener(pivotZ);
|
target.get().getPosition().zProperty().addListener(pivotZ);
|
||||||
target.getHeading().angleProperty().addListener(pivotHeading);
|
target.get().getHeading().angleProperty().addListener(pivotHeading);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNearClip(double nearClip) {
|
public void setNearClip(double nearClip) {
|
||||||
|
|||||||
Reference in New Issue
Block a user