Merge branch 'storyA_sounds' into storyD-3D
This commit is contained in:
@@ -21,10 +21,7 @@ import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.Material;
|
||||
import javafx.scene.paint.PhongMaterial;
|
||||
import javafx.scene.shape.Box;
|
||||
import javafx.scene.shape.MeshView;
|
||||
import javafx.scene.shape.Shape3D;
|
||||
import javafx.scene.shape.Sphere;
|
||||
import javafx.scene.shape.*;
|
||||
import javafx.scene.transform.Translate;
|
||||
import javafx.util.Callback;
|
||||
import network.Messages.Enums.RaceStatusEnum;
|
||||
@@ -72,8 +69,14 @@ public class RaceViewController extends Controller {
|
||||
private View3D view3D;
|
||||
private ObservableList<Subject3D> viewSubjects;
|
||||
|
||||
/**
|
||||
* Arrow pointing to next mark in third person
|
||||
*/
|
||||
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 :)
|
||||
private @FXML ArrowController arrowController;
|
||||
@@ -313,8 +316,12 @@ public class RaceViewController extends Controller {
|
||||
if(nextMark.getMark2() != null) {
|
||||
view3D.getShape(nextMark.getMark2().getSourceID()).setMaterial(markColor);
|
||||
}
|
||||
Subject3D shockwave = new Shockwave(10);
|
||||
|
||||
viewSubjects.add(shockwave);
|
||||
|
||||
boat.legProperty().addListener((o, prev, curr) -> swapColours(curr));
|
||||
boat.hasCollidedProperty().addListener((o, prev, curr) -> showCollision(boatModel, shockwave));
|
||||
}
|
||||
// Fix initial bird's-eye position
|
||||
view3D.updatePivot(new Translate(250, 0, 210));
|
||||
@@ -372,22 +379,47 @@ 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) {
|
||||
viewSubjects.add(nextMarkArrow);
|
||||
|
||||
try {
|
||||
VisualiserBoat boat = visualiserRace.getVisualiserRaceState().getBoat(subject3D.getSourceID());
|
||||
this.pointToMark = (o, prev, curr) -> {
|
||||
CompoundMark target = boat.getCurrentLeg().getEndCompoundMark();
|
||||
Bearing headingToMark = GPSCoordinate.calculateBearing(boat.getPosition(), target.getAverageGPSCoordinate());
|
||||
this.pointToMark = new AnimationTimer() {
|
||||
@Override
|
||||
public void handle(long now) {
|
||||
CompoundMark target = boat.getCurrentLeg().getEndCompoundMark();
|
||||
Bearing headingToMark = GPSCoordinate.calculateBearing(boat.getPosition(), target.getAverageGPSCoordinate());
|
||||
|
||||
nextMarkArrow.setX(view3D.getPivot().getX());
|
||||
nextMarkArrow.setY(view3D.getPivot().getY());
|
||||
nextMarkArrow.setZ(view3D.getPivot().getZ() + 10);
|
||||
nextMarkArrow.setHeading(headingToMark.degrees());
|
||||
nextMarkArrow.setX(view3D.getPivot().getX());
|
||||
nextMarkArrow.setY(view3D.getPivot().getY());
|
||||
nextMarkArrow.setZ(view3D.getPivot().getZ() + 10);
|
||||
nextMarkArrow.setHeading(headingToMark.degrees());
|
||||
}
|
||||
};
|
||||
|
||||
boat.positionProperty().addListener(pointToMark);
|
||||
pointToMark.start();
|
||||
} catch (BoatNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -395,13 +427,7 @@ public class RaceViewController extends Controller {
|
||||
|
||||
private void removeThirdPersonAnnotations(Subject3D subject3D) {
|
||||
viewSubjects.remove(nextMarkArrow);
|
||||
|
||||
try {
|
||||
VisualiserBoat boat = visualiserRace.getVisualiserRaceState().getBoat(subject3D.getSourceID());
|
||||
boat.positionProperty().removeListener(pointToMark);
|
||||
} catch (BoatNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
pointToMark.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user