|
|
|
|
@ -15,12 +15,17 @@ import javafx.scene.input.KeyEvent;
|
|
|
|
|
import javafx.scene.layout.AnchorPane;
|
|
|
|
|
import javafx.scene.layout.GridPane;
|
|
|
|
|
import javafx.scene.layout.StackPane;
|
|
|
|
|
import javafx.scene.paint.Color;
|
|
|
|
|
import javafx.scene.paint.Material;
|
|
|
|
|
import javafx.scene.paint.PhongMaterial;
|
|
|
|
|
import javafx.scene.shape.MeshView;
|
|
|
|
|
import javafx.scene.shape.Shape3D;
|
|
|
|
|
import javafx.scene.shape.Sphere;
|
|
|
|
|
import javafx.scene.transform.Translate;
|
|
|
|
|
import javafx.util.Callback;
|
|
|
|
|
import network.Messages.Enums.RaceStatusEnum;
|
|
|
|
|
import shared.dataInput.RaceDataSource;
|
|
|
|
|
import shared.model.CompoundMark;
|
|
|
|
|
import shared.model.Leg;
|
|
|
|
|
import shared.model.Mark;
|
|
|
|
|
import visualiser.app.App;
|
|
|
|
|
@ -224,7 +229,7 @@ public class RaceController extends Controller {
|
|
|
|
|
view3D.setItems(viewSubjects);
|
|
|
|
|
// Position and add each mark to view
|
|
|
|
|
for(Mark mark: race.getVisualiserRaceState().getMarks()) {
|
|
|
|
|
Subject3D subject = new Subject3D(new Sphere(2));
|
|
|
|
|
Subject3D subject = new Subject3D(new Sphere(2), mark.getSourceID());
|
|
|
|
|
subject.setX(gpsConverter.convertGPS(mark.getPosition()).getX());
|
|
|
|
|
subject.setZ(gpsConverter.convertGPS(mark.getPosition()).getY());
|
|
|
|
|
|
|
|
|
|
@ -233,7 +238,7 @@ public class RaceController extends Controller {
|
|
|
|
|
// Position and add each boat to view
|
|
|
|
|
for(VisualiserBoat boat: race.getVisualiserRaceState().getBoats()) {
|
|
|
|
|
MeshView mesh = new MeshView(importer.getImport());
|
|
|
|
|
Subject3D subject = new Subject3D(mesh);
|
|
|
|
|
Subject3D subject = new Subject3D(mesh, boat.getSourceID());
|
|
|
|
|
viewSubjects.add(subject);
|
|
|
|
|
|
|
|
|
|
// Track this boat's movement with the new subject
|
|
|
|
|
@ -247,10 +252,11 @@ public class RaceController extends Controller {
|
|
|
|
|
};
|
|
|
|
|
trackBoat.start();
|
|
|
|
|
|
|
|
|
|
System.out.println(boat.getCurrentLeg().getEndCompoundMark().toString());
|
|
|
|
|
boat.legProperty().addListener((o, prev, curr) -> {
|
|
|
|
|
System.out.println(curr.getEndCompoundMark().toString());
|
|
|
|
|
});
|
|
|
|
|
Material markColor = new PhongMaterial(new Color(0.15,0.9,0.2,1));
|
|
|
|
|
CompoundMark nextMark = boat.getCurrentLeg().getEndCompoundMark();
|
|
|
|
|
view3D.getShape(nextMark.getMark1().getSourceID()).setMaterial(markColor);
|
|
|
|
|
view3D.getShape(nextMark.getMark2().getSourceID()).setMaterial(markColor);
|
|
|
|
|
boat.legProperty().addListener((o, prev, curr) -> swapColours(curr));
|
|
|
|
|
}
|
|
|
|
|
// Fix initial bird's-eye position
|
|
|
|
|
view3D.updatePivot(new Translate(250, 0, 210));
|
|
|
|
|
@ -300,8 +306,27 @@ public class RaceController extends Controller {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Swap the colour of the next mark to pass with the last mark passed
|
|
|
|
|
* @param leg boat has started on
|
|
|
|
|
*/
|
|
|
|
|
private void swapColours(Leg leg) {
|
|
|
|
|
CompoundMark start = leg.getStartCompoundMark();
|
|
|
|
|
CompoundMark end = leg.getEndCompoundMark();
|
|
|
|
|
|
|
|
|
|
Shape3D start1 = view3D.getShape(start.getMark1().getSourceID());
|
|
|
|
|
Shape3D start2 = view3D.getShape(start.getMark2().getSourceID());
|
|
|
|
|
Shape3D end1 = view3D.getShape(end.getMark1().getSourceID());
|
|
|
|
|
Shape3D end2 = view3D.getShape(end.getMark2().getSourceID());
|
|
|
|
|
|
|
|
|
|
Material nextMark = start1.getMaterial();
|
|
|
|
|
Material lastMark = end1.getMaterial();
|
|
|
|
|
|
|
|
|
|
start1.setMaterial(lastMark);
|
|
|
|
|
start2.setMaterial(lastMark);
|
|
|
|
|
end1.setMaterial(nextMark);
|
|
|
|
|
end2.setMaterial(nextMark);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Initialises the frame rate functionality. This allows for toggling the frame rate, and connect the fps label to the race's fps property.
|
|
|
|
|
|