|
|
|
@ -323,16 +323,16 @@ public class RaceViewController extends Controller {
|
|
|
|
|
|
|
|
|
|
|
|
Material markColor = new PhongMaterial(new Color(0.15,0.9,0.2,1));
|
|
|
|
Material markColor = new PhongMaterial(new Color(0.15,0.9,0.2,1));
|
|
|
|
CompoundMark nextMark = boat.getCurrentLeg().getEndCompoundMark();
|
|
|
|
CompoundMark nextMark = boat.getCurrentLeg().getEndCompoundMark();
|
|
|
|
view3D.getShape(nextMark.getMark1().getSourceID()).setMaterial(markColor);
|
|
|
|
view3D.getShape(nextMark.getMark1().getSourceID()).getMesh().setMaterial(markColor);
|
|
|
|
if(nextMark.getMark2() != null) {
|
|
|
|
if(nextMark.getMark2() != null) {
|
|
|
|
view3D.getShape(nextMark.getMark2().getSourceID()).setMaterial(markColor);
|
|
|
|
view3D.getShape(nextMark.getMark2().getSourceID()).getMesh().setMaterial(markColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Subject3D shockwave = new Shockwave(10);
|
|
|
|
Subject3D shockwave = new Shockwave(10);
|
|
|
|
|
|
|
|
|
|
|
|
viewSubjects.add(shockwave);
|
|
|
|
viewSubjects.add(shockwave);
|
|
|
|
|
|
|
|
|
|
|
|
boat.legProperty().addListener((o, prev, curr) -> swapColours(curr));
|
|
|
|
boat.legProperty().addListener((o, prev, curr) -> Platform.runLater(() -> swapColours(curr)));
|
|
|
|
boat.hasCollidedProperty().addListener((o, prev, curr) -> showCollision(boatModel, shockwave));
|
|
|
|
boat.hasCollidedProperty().addListener((o, prev, curr) -> Platform.runLater(() -> showCollision(boat, 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));
|
|
|
|
@ -341,7 +341,7 @@ public class RaceViewController extends Controller {
|
|
|
|
if(curr != null && visualiserRace.getVisualiserRaceState().isVisualiserBoat(curr.getSourceID())) {
|
|
|
|
if(curr != null && visualiserRace.getVisualiserRaceState().isVisualiserBoat(curr.getSourceID())) {
|
|
|
|
addThirdPersonAnnotations(curr);
|
|
|
|
addThirdPersonAnnotations(curr);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
removeThirdPersonAnnotations(prev);
|
|
|
|
removeThirdPersonAnnotations();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
@ -390,18 +390,20 @@ public class RaceViewController extends Controller {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void showCollision(Subject3D boat, Subject3D shockwave) {
|
|
|
|
private void showCollision(VisualiserBoat boat, Subject3D shockwave) {
|
|
|
|
|
|
|
|
Subject3D boatModel = view3D.getShape(boat.getSourceID());
|
|
|
|
AnimationTimer shockFront = new AnimationTimer() {
|
|
|
|
AnimationTimer shockFront = new AnimationTimer() {
|
|
|
|
double opacity = 1;
|
|
|
|
double opacity = 1;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void handle(long now) {
|
|
|
|
public void handle(long now) {
|
|
|
|
shockwave.setX(boat.getPosition().getX());
|
|
|
|
shockwave.setX(boatModel.getPosition().getX());
|
|
|
|
shockwave.setY(boat.getPosition().getY());
|
|
|
|
shockwave.setY(boatModel.getPosition().getY());
|
|
|
|
shockwave.setZ(boat.getPosition().getZ());
|
|
|
|
shockwave.setZ(boatModel.getPosition().getZ());
|
|
|
|
|
|
|
|
|
|
|
|
if(opacity <= 0) {
|
|
|
|
if(opacity <= 0) {
|
|
|
|
shockwave.getMesh().setMaterial(new PhongMaterial(new Color(1,0,0,0)));
|
|
|
|
shockwave.getMesh().setMaterial(new PhongMaterial(Color.TRANSPARENT));
|
|
|
|
|
|
|
|
boat.setHasCollided(false);
|
|
|
|
this.stop();
|
|
|
|
this.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
@ -435,38 +437,14 @@ public class RaceViewController extends Controller {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
arrowToNextMark.start();
|
|
|
|
arrowToNextMark.start();
|
|
|
|
/*
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
VisualiserBoat boat = visualiserRace.getVisualiserRaceState().getBoat(subject3D.getSourceID());
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
pointToMark.start();
|
|
|
|
|
|
|
|
} catch (BoatNotFoundException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void removeThirdPersonAnnotations(Subject3D subject3D) {
|
|
|
|
private void removeThirdPersonAnnotations() {
|
|
|
|
viewSubjects.remove(nextMarkArrow);
|
|
|
|
viewSubjects.remove(nextMarkArrow);
|
|
|
|
|
|
|
|
if (arrowToNextMark != null) {
|
|
|
|
arrowToNextMark.stop();
|
|
|
|
arrowToNextMark.stop();
|
|
|
|
/*
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
|
|
|
|
VisualiserBoat boat = visualiserRace.getVisualiserRaceState().getBoat(subject3D.getSourceID());
|
|
|
|
|
|
|
|
boat.positionProperty().removeListener(pointToMark);
|
|
|
|
|
|
|
|
} catch (BoatNotFoundException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
//pointToMark.stop();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -477,21 +455,26 @@ public class RaceViewController extends Controller {
|
|
|
|
CompoundMark start = leg.getStartCompoundMark();
|
|
|
|
CompoundMark start = leg.getStartCompoundMark();
|
|
|
|
CompoundMark end = leg.getEndCompoundMark();
|
|
|
|
CompoundMark end = leg.getEndCompoundMark();
|
|
|
|
|
|
|
|
|
|
|
|
Shape3D start1 = view3D.getShape(start.getMark1().getSourceID());
|
|
|
|
//The last leg "finish" doesn't have compound marks.
|
|
|
|
Shape3D end1 = view3D.getShape(end.getMark1().getSourceID());
|
|
|
|
if (start == null || end == null ) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Shape3D start1 = view3D.getShape(start.getMark1().getSourceID()).getMesh();
|
|
|
|
|
|
|
|
Shape3D end1 = view3D.getShape(end.getMark1().getSourceID()).getMesh();
|
|
|
|
|
|
|
|
|
|
|
|
Material nextMark = start1.getMaterial();
|
|
|
|
Material nextMark = start1.getMaterial();
|
|
|
|
Material lastMark = end1.getMaterial();
|
|
|
|
Material lastMark = end1.getMaterial();
|
|
|
|
|
|
|
|
|
|
|
|
start1.setMaterial(lastMark);
|
|
|
|
start1.setMaterial(lastMark);
|
|
|
|
if(start.getMark2() != null) {
|
|
|
|
if(start.getMark2() != null) {
|
|
|
|
Shape3D start2 = view3D.getShape(start.getMark2().getSourceID());
|
|
|
|
Shape3D start2 = view3D.getShape(start.getMark2().getSourceID()).getMesh();
|
|
|
|
start2.setMaterial(lastMark);
|
|
|
|
start2.setMaterial(lastMark);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
end1.setMaterial(nextMark);
|
|
|
|
end1.setMaterial(nextMark);
|
|
|
|
if(end.getMark2() != null) {
|
|
|
|
if(end.getMark2() != null) {
|
|
|
|
Shape3D end2 = view3D.getShape(end.getMark2().getSourceID());
|
|
|
|
Shape3D end2 = view3D.getShape(end.getMark2().getSourceID()).getMesh();
|
|
|
|
end2.setMaterial(nextMark);
|
|
|
|
end2.setMaterial(nextMark);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -600,6 +583,7 @@ public class RaceViewController extends Controller {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Transition from the race view to the finish view.
|
|
|
|
* Transition from the race view to the finish view.
|
|
|
|
|
|
|
|
* @throws IOException Thrown if the finish scene cannot be loaded.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void finishRace() throws IOException {
|
|
|
|
private void finishRace() throws IOException {
|
|
|
|
RaceFinishController fc =
|
|
|
|
RaceFinishController fc =
|
|
|
|
|