|
|
|
@ -21,10 +21,7 @@ import javafx.scene.layout.StackPane;
|
|
|
|
import javafx.scene.paint.Color;
|
|
|
|
import javafx.scene.paint.Color;
|
|
|
|
import javafx.scene.paint.Material;
|
|
|
|
import javafx.scene.paint.Material;
|
|
|
|
import javafx.scene.paint.PhongMaterial;
|
|
|
|
import javafx.scene.paint.PhongMaterial;
|
|
|
|
import javafx.scene.shape.Box;
|
|
|
|
import javafx.scene.shape.*;
|
|
|
|
import javafx.scene.shape.MeshView;
|
|
|
|
|
|
|
|
import javafx.scene.shape.Shape3D;
|
|
|
|
|
|
|
|
import javafx.scene.shape.Sphere;
|
|
|
|
|
|
|
|
import javafx.scene.transform.Translate;
|
|
|
|
import javafx.scene.transform.Translate;
|
|
|
|
import javafx.util.Callback;
|
|
|
|
import javafx.util.Callback;
|
|
|
|
import network.Messages.Enums.RaceStatusEnum;
|
|
|
|
import network.Messages.Enums.RaceStatusEnum;
|
|
|
|
@ -72,8 +69,14 @@ public class RaceViewController extends Controller {
|
|
|
|
private View3D view3D;
|
|
|
|
private View3D view3D;
|
|
|
|
private ObservableList<Subject3D> viewSubjects;
|
|
|
|
private ObservableList<Subject3D> viewSubjects;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Arrow pointing to next mark in third person
|
|
|
|
|
|
|
|
*/
|
|
|
|
private Subject3D nextMarkArrow;
|
|
|
|
private Subject3D nextMarkArrow;
|
|
|
|
private ChangeListener<? super GPSCoordinate> pointToMark;
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Animation loop for rotating mark arrow
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private AnimationTimer pointToMark;
|
|
|
|
|
|
|
|
|
|
|
|
// note: it says it's not used but it is! do not remove :)
|
|
|
|
// note: it says it's not used but it is! do not remove :)
|
|
|
|
private @FXML ArrowController arrowController;
|
|
|
|
private @FXML ArrowController arrowController;
|
|
|
|
@ -313,8 +316,12 @@ public class RaceViewController extends Controller {
|
|
|
|
if(nextMark.getMark2() != null) {
|
|
|
|
if(nextMark.getMark2() != null) {
|
|
|
|
view3D.getShape(nextMark.getMark2().getSourceID()).setMaterial(markColor);
|
|
|
|
view3D.getShape(nextMark.getMark2().getSourceID()).setMaterial(markColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Subject3D shockwave = new Shockwave(10);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
viewSubjects.add(shockwave);
|
|
|
|
|
|
|
|
|
|
|
|
boat.legProperty().addListener((o, prev, curr) -> swapColours(curr));
|
|
|
|
boat.legProperty().addListener((o, prev, curr) -> swapColours(curr));
|
|
|
|
|
|
|
|
boat.hasCollidedProperty().addListener((o, prev, curr) -> showCollision(boatModel, shockwave));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 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));
|
|
|
|
@ -372,12 +379,37 @@ public class RaceViewController extends Controller {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void showCollision(Subject3D boat, Subject3D shockwave) {
|
|
|
|
|
|
|
|
AnimationTimer shockFront = new AnimationTimer() {
|
|
|
|
|
|
|
|
double opacity = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void handle(long now) {
|
|
|
|
|
|
|
|
shockwave.setX(boat.getPosition().getX());
|
|
|
|
|
|
|
|
shockwave.setY(boat.getPosition().getY());
|
|
|
|
|
|
|
|
shockwave.setZ(boat.getPosition().getZ());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(opacity <= 0) {
|
|
|
|
|
|
|
|
shockwave.getMesh().setMaterial(new PhongMaterial(new Color(1,0,0,0)));
|
|
|
|
|
|
|
|
this.stop();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
shockwave.getMesh().setMaterial(new PhongMaterial(new Color(1,0,0,opacity)));
|
|
|
|
|
|
|
|
opacity -= 0.1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
shockFront.start();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void addThirdPersonAnnotations(Subject3D subject3D) {
|
|
|
|
private void addThirdPersonAnnotations(Subject3D subject3D) {
|
|
|
|
viewSubjects.add(nextMarkArrow);
|
|
|
|
viewSubjects.add(nextMarkArrow);
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
VisualiserBoat boat = visualiserRace.getVisualiserRaceState().getBoat(subject3D.getSourceID());
|
|
|
|
VisualiserBoat boat = visualiserRace.getVisualiserRaceState().getBoat(subject3D.getSourceID());
|
|
|
|
this.pointToMark = (o, prev, curr) -> {
|
|
|
|
this.pointToMark = new AnimationTimer() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void handle(long now) {
|
|
|
|
CompoundMark target = boat.getCurrentLeg().getEndCompoundMark();
|
|
|
|
CompoundMark target = boat.getCurrentLeg().getEndCompoundMark();
|
|
|
|
Bearing headingToMark = GPSCoordinate.calculateBearing(boat.getPosition(), target.getAverageGPSCoordinate());
|
|
|
|
Bearing headingToMark = GPSCoordinate.calculateBearing(boat.getPosition(), target.getAverageGPSCoordinate());
|
|
|
|
|
|
|
|
|
|
|
|
@ -385,9 +417,9 @@ public class RaceViewController extends Controller {
|
|
|
|
nextMarkArrow.setY(view3D.getPivot().getY());
|
|
|
|
nextMarkArrow.setY(view3D.getPivot().getY());
|
|
|
|
nextMarkArrow.setZ(view3D.getPivot().getZ() + 10);
|
|
|
|
nextMarkArrow.setZ(view3D.getPivot().getZ() + 10);
|
|
|
|
nextMarkArrow.setHeading(headingToMark.degrees());
|
|
|
|
nextMarkArrow.setHeading(headingToMark.degrees());
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
pointToMark.start();
|
|
|
|
boat.positionProperty().addListener(pointToMark);
|
|
|
|
|
|
|
|
} catch (BoatNotFoundException e) {
|
|
|
|
} catch (BoatNotFoundException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -395,13 +427,7 @@ public class RaceViewController extends Controller {
|
|
|
|
|
|
|
|
|
|
|
|
private void removeThirdPersonAnnotations(Subject3D subject3D) {
|
|
|
|
private void removeThirdPersonAnnotations(Subject3D subject3D) {
|
|
|
|
viewSubjects.remove(nextMarkArrow);
|
|
|
|
viewSubjects.remove(nextMarkArrow);
|
|
|
|
|
|
|
|
pointToMark.stop();
|
|
|
|
try {
|
|
|
|
|
|
|
|
VisualiserBoat boat = visualiserRace.getVisualiserRaceState().getBoat(subject3D.getSourceID());
|
|
|
|
|
|
|
|
boat.positionProperty().removeListener(pointToMark);
|
|
|
|
|
|
|
|
} catch (BoatNotFoundException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|