Merge remote-tracking branch 'remotes/origin/master' into raceView_UI

# Conflicts:
#	racevisionGame/src/main/java/visualiser/Controllers/RaceViewController.java
#	racevisionGame/src/main/resources/visualiser/scenes/newRaceView.fxml
main
hba56 8 years ago
commit bb24e13387

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectCodeStyleSettingsManager">
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</component>
</project>

@ -25,6 +25,7 @@ import shared.model.Boat;
import visualiser.app.App;
import visualiser.gameController.ControllerClient;
import visualiser.layout.SeaSurface;
import visualiser.layout.Shockwave;
import visualiser.layout.Subject3D;
import visualiser.layout.View3D;
import visualiser.model.VisualiserBoat;
@ -168,6 +169,15 @@ public class InGameLobbyController extends Controller {
playerBoatToSet.setPitch(20);
if (boat.isClientBoat()) {
Shockwave boatHighlight = new Shockwave(10);
boatHighlight.getMesh().setMaterial(new PhongMaterial(new Color(1, 1, 0, 0.1)));
boatHighlight.setX(subject.getPosition().getX());
boatHighlight.setY(subject.getPosition().getY());
boatHighlight.setZ(subject.getPosition().getZ());
subjects.add(boatHighlight);
subject.getMesh().toFront();
}
AnimationTimer rotate = new AnimationTimer() {
@Override
@ -239,7 +249,7 @@ public class InGameLobbyController extends Controller {
public void handle(long arg0) {
//Get the current race status.
RaceStatusEnum raceStatus = visualiserRaceEvent.getVisualiserRaceState().getRaceStatusEnum();
//Try catch for getting interval times
try {
long interval = ChronoUnit.MILLIS.between(visualiserRaceEvent.getVisualiserRaceState().getRaceClock().getCurrentTime(), visualiserRaceEvent.getVisualiserRaceState().getRaceClock().getStartingTime());

@ -38,10 +38,7 @@ import visualiser.gameController.ControllerClient;
import visualiser.gameController.Keys.ControlKey;
import visualiser.gameController.Keys.KeyFactory;
import visualiser.layout.*;
import visualiser.model.Sparkline;
import visualiser.model.VisualiserBoat;
import visualiser.model.VisualiserRaceEvent;
import visualiser.model.VisualiserRaceState;
import visualiser.model.*;
import visualiser.utils.GPSConverter;
import java.io.IOException;
@ -70,6 +67,8 @@ public class RaceViewController extends Controller {
private FGauge fGauge;
private long positionDelay = 1000;
private long positionTime = 0;
private ResizableRaceCanvas raceCanvas;
private boolean mapToggle = true;
/**
* Arrow pointing to next mark in third person
@ -83,6 +82,7 @@ public class RaceViewController extends Controller {
// note: it says it's not used but it is! do not remove :)
private @FXML ArrowController arrowController;
private @FXML GridPane canvasBase;
private @FXML GridPane canvasBase1;
private @FXML SplitPane racePane;
private @FXML StackPane arrowPane;
private @FXML Label timer;
@ -119,6 +119,7 @@ public class RaceViewController extends Controller {
tutorialCheck();
initKeypressHandler();
initialiseRaceVisuals();
initialiseRaceCanvas();
}
/**
@ -154,6 +155,9 @@ public class RaceViewController extends Controller {
// tab key
if (codeString.equals("TAB")){toggleTable();}
//map key
if (codeString.equals("M")){bigMap();}
// any key pressed
ControlKey controlKey = keyFactory.getKey(codeString);
if(controlKey != null) {
@ -411,8 +415,25 @@ public class RaceViewController extends Controller {
viewSubjects.add(markModel);
}
for (VisualiserBoat boat: race.getVisualiserRaceState().getBoats()) {
if (boat.isClientBoat()) {
Shockwave boatHighlight = new Shockwave(10);
boatHighlight.getMesh().setMaterial(new PhongMaterial(new Color(1, 1, 0, 0.1)));
viewSubjects.add(boatHighlight);
AnimationTimer highlightTrack = new AnimationTimer() {
@Override
public void handle(long now) {
boatHighlight.setX(gpsConverter.convertGPS(boat.getPosition()).getX());
boatHighlight.setZ(gpsConverter.convertGPS(boat.getPosition()).getY());
}
};
highlightTrack.start();
}
}
// Position and add each boat to view
for(VisualiserBoat boat: race.getVisualiserRaceState().getBoats()) {
for (VisualiserBoat boat: race.getVisualiserRaceState().getBoats()) {
MeshView mesh;
if(boat.getSourceID() == race.getVisualiserRaceState().getPlayerBoatID()) {
mesh = new MeshView(importer.getImport());
@ -724,18 +745,9 @@ public class RaceViewController extends Controller {
e.printStackTrace();
}
} else {
raceCanvas.drawRace();
boatInfoTable.sort();
// try {
// System.out.println(raceState.getBoat(raceState.getPlayerBoatID()).getCurrentSpeed());
// gauge.setValue(raceState.getBoat(raceState.getPlayerBoatID()).getCurrentSpeed());
// for (VisualiserBoat boat : boatInfoTable.getItems()){
// if(raceState.getPlayerBoatID()==boat.getSourceID()){
// gauge.setTitle("Position: " + (boatInfoTable.getItems().indexOf(boat)+1));
// }
// }
// } catch (BoatNotFoundException e) {
// e.printStackTrace();
// }
}
//Return to main screen if we lose connection.
@ -890,4 +902,48 @@ public class RaceViewController extends Controller {
}
}
/**
* Initialises the map
*/
private void initialiseRaceCanvas() {
//Create canvas.
raceCanvas = new ResizableRaceCanvas(raceState);
//Set properties.
raceCanvas.setMouseTransparent(true);
raceCanvas.widthProperty().bind(canvasBase1.widthProperty());
raceCanvas.heightProperty().bind(canvasBase1.heightProperty());
//Draw it and show it.
raceCanvas.draw();
raceCanvas.setVisible(true);
//Add to scene.
canvasBase1.getChildren().add(0, raceCanvas);
}
private void bigMap(){
if (mapToggle){
raceCanvas.widthProperty().bind(canvasBase.widthProperty());
raceCanvas.heightProperty().bind(canvasBase.heightProperty());
raceCanvas.setFullScreen(true);
raceCanvas.setOpacity(0.6);
canvasBase1.getChildren().remove(raceCanvas);
canvasBase.getChildren().add(1, raceCanvas);
}else{
raceCanvas.widthProperty().bind(canvasBase1.widthProperty());
raceCanvas.heightProperty().bind(canvasBase1.heightProperty());
raceCanvas.setFullScreen(false);
canvasBase.getChildren().remove(raceCanvas);
canvasBase1.getChildren().add(0, raceCanvas);
}
mapToggle = !mapToggle;
}
}

@ -13,5 +13,6 @@ public class Shockwave extends Subject3D {
super(new Cylinder(radius,0),0);
getMesh().getTransforms().add(new Rotate(-90, Rotate.X_AXIS));
getMesh().setMaterial(new PhongMaterial(new Color(0,0,0,0)));
getMesh().setMouseTransparent(true);
}
}

@ -6,13 +6,11 @@ import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.text.Font;
import javafx.scene.transform.Rotate;
import network.Messages.Enums.BoatStatusEnum;
import shared.dataInput.RaceDataSource;
import shared.enums.RoundingType;
import shared.model.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
/**
@ -44,13 +42,15 @@ public class ResizableRaceCanvas extends ResizableCanvas {
private VisualiserRaceState raceState;
private boolean annoName = true;
private boolean annoName = false;
private boolean annoAbbrev = true;
private boolean annoSpeed = true;
private boolean annoSpeed = false;
private boolean annoPath = true;
private boolean annoEstTime = true;
private boolean annoTimeSinceLastMark = true;
private boolean annoGuideLine = false;
private boolean annoEstTime = false;
private boolean annoTimeSinceLastMark = false;
private boolean annoGuideLine = true;
private boolean isFullScreen = false;
@ -293,7 +293,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
List<VisualiserBoat> boats = new ArrayList<>(raceState.getBoats());
//Sort to ensure we draw boats in consistent order.
boats.sort(Comparator.comparingInt(Boat::getSourceID));
// boats.sort(Comparator.comparingInt(Boat::getSourceID));
//Current draw order:
// track points
@ -302,29 +302,29 @@ public class ResizableRaceCanvas extends ResizableCanvas {
// text
//Track points.
for (VisualiserBoat boat : boats) {
drawTrack(boat);
}
if (isFullScreen){
for (VisualiserBoat boat : boats) {
drawTrack(boat);
}
//Wake.
for (VisualiserBoat boat : boats) {
//Only draw wake if they are currently racing.
if (boat.getStatus() == BoatStatusEnum.RACING) {
drawWake(boat);
//Text.
for (VisualiserBoat boat : boats) {
drawBoatText(boat);
}
}
//Wake.
// for (VisualiserBoat boat : boats) {
// //Only draw wake if they are currently racing.
// if (boat.getStatus() == BoatStatusEnum.RACING) {
// drawWake(boat);
// }
// }
//Boat.
for (VisualiserBoat boat : boats) {
drawBoat(boat);
}
//Text.
for (VisualiserBoat boat : boats) {
drawBoatText(boat);
}
}
/**
@ -364,9 +364,9 @@ public class ResizableRaceCanvas extends ResizableCanvas {
gc.fillPolygon(x, y, x.length);
gc.restore();
if (boat.getSourceID() == ThisBoat.getInstance().getSourceID()) {
drawSails(boat);
}
// if (boat.getSourceID() == ThisBoat.getInstance().getSourceID()) {
// drawSails(boat);
// }
}
/**
@ -605,7 +605,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
//Prepare to draw.
gc.setLineWidth(1);
gc.setFill(Color.AQUA);
gc.setFill(Color.DEEPSKYBLUE);
//Calculate the screen coordinates of the boundary.
@ -645,19 +645,23 @@ public class ResizableRaceCanvas extends ResizableCanvas {
//Race boundary.
drawBoundary();
//Guiding Line
if (annoGuideLine){
//rounding lines
if (isFullScreen){
drawRoundingLines();
drawRaceLine();
}
//Guiding Line
// if (annoGuideLine){
// drawRaceLine();
// }
//Boats.
drawBoats();
//Marks.
drawMarks();
//TEMP
drawRoundingLines();
}
@ -752,7 +756,8 @@ public class ResizableRaceCanvas extends ResizableCanvas {
gc.save();
gc.setLineWidth(2);
gc.setStroke(Color.MEDIUMAQUAMARINE);
gc.setStroke(getLineColor(legs.get(index)));
gc.beginPath();
gc.moveTo(startPath.getX(), startPath.getY());
@ -772,7 +777,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
gc.save();
gc.setLineWidth(2);
gc.setStroke(Color.MEDIUMAQUAMARINE);
gc.setStroke(getLineColor(legs.get(index)));
gc.beginPath();
gc.moveTo(startPath.getX(), startPath.getY());
@ -788,6 +793,21 @@ public class ResizableRaceCanvas extends ResizableCanvas {
}
}
private Color getLineColor(Leg leg) {
for (VisualiserBoat boat : raceState.getBoats()) {
if (boat.isClientBoat()) {
if (boat.getCurrentLeg() == leg) {
return Color.ORANGE;
} else {
return Color.MEDIUMAQUAMARINE;
}
}else{
return Color.MEDIUMAQUAMARINE;
}
}
return Color.MEDIUMAQUAMARINE;
}
private void drawArrowHead(GPSCoordinate start, GPSCoordinate end){
GraphCoordinate lineStart = this.map.convertGPS(start);
@ -862,6 +882,11 @@ public class ResizableRaceCanvas extends ResizableCanvas {
}
public boolean isFullScreen() {
return isFullScreen;
}
public void setFullScreen(boolean fullScreen) {
isFullScreen = fullScreen;
}
}

@ -137,6 +137,9 @@ public class VisualiserBoat extends Boat {
//Update the nextValidTime for the next track point.
nextValidTime = currentTimeMilli + trackPointTimeInterval;
if (track.size() > trackPointLimit) {
track.remove(0);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 803 KiB

@ -91,18 +91,18 @@
<Font name="System Bold" size="15.0" />
</font>
</Label>
<Label fx:id="FPS" text="FPS: 0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0">
<Label fx:id="FPS" mouseTransparent="true" text="FPS: 0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="System Bold" size="15.0" />
</font>
<padding>
<Insets top="20.0" />
</padding>
</Label>
<Label fx:id="timeZone" text="Label" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="System Bold" size="15.0" />
</font>
<padding>
<Insets bottom="20.0" />
</padding>
</Label>
<StackPane fx:id="arrowPane" alignment="TOP_RIGHT" mouseTransparent="true" prefHeight="150.0" prefWidth="150.0" snapToPixel="false" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
@ -114,6 +114,65 @@
<padding>
<Insets right="20.0" />
</padding></StackPane>
<AnchorPane maxHeight="200.0" maxWidth="200.0" mouseTransparent="true" opacity="0.6" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0">
<children>
<AnchorPane maxHeight="200.0" maxWidth="200.0" prefHeight="200.0" prefWidth="216.0">
<children>
<GridPane fx:id="canvasBase1" maxHeight="200.0" maxWidth="200.0" prefHeight="200.0" prefWidth="216.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
<Pane maxHeight="200.0" maxWidth="200.0" prefHeight="200.0" prefWidth="216.0" visible="false">
<children>
<Accordion>
<panes>
<TitledPane animated="false" prefHeight="395.0" prefWidth="222.0" text="Annotation Control">
<content>
<AnchorPane fx:id="annotationPane1" minHeight="0.0" minWidth="0.0">
<children>
<CheckBox fx:id="showName1" layoutY="39.0" mnemonicParsing="false" selected="true" text="Show Boat Name" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
<CheckBox fx:id="showAbbrev1" layoutY="61.0" mnemonicParsing="false" selected="true" text="Show Boat Abbreviation" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="25.0" />
<CheckBox fx:id="showSpeed1" layoutY="90.0" mnemonicParsing="false" selected="true" text="Show Boat Speed" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="50.0" />
<CheckBox fx:id="showBoatPath1" mnemonicParsing="false" selected="true" text="Show Boat Paths" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="75.0" />
<CheckBox fx:id="showTime1" mnemonicParsing="false" selected="true" text="Show Boat Leg Time" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="100.0" />
<CheckBox fx:id="showEstTime1" mnemonicParsing="false" selected="true" text="Show Est. Time to Next Mark" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="125.0" />
<CheckBox fx:id="showGuideline1" mnemonicParsing="false" text="Show Guideline" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="150.0" />
<Separator layoutX="19.6" layoutY="175.6" prefHeight="0.0" prefWidth="200.0" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="175.0" />
<Label text="Annotations" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="175.0" />
<RadioButton fx:id="hideAnnoRBtn1" mnemonicParsing="false" text="Hidden" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="200.0">
<toggleGroup>
<ToggleGroup fx:id="annoToggleGroup1" />
</toggleGroup>
</RadioButton>
<RadioButton fx:id="showAnnoRBtn1" mnemonicParsing="false" text="Visible" toggleGroup="$annoToggleGroup1" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="225.0" />
<RadioButton fx:id="partialAnnoRBtn1" mnemonicParsing="false" text="Partial" toggleGroup="$annoToggleGroup1" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="250.0" />
<RadioButton fx:id="importantAnnoRBtn1" mnemonicParsing="false" text="Important" toggleGroup="$annoToggleGroup1" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="275.0" />
<Button fx:id="saveAnno1" layoutX="11.0" layoutY="126.0" mnemonicParsing="false" text="Save Important Annotations" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="300.0" />
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane animated="false" text="FPS Control">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<CheckBox fx:id="showFPS1" layoutX="-14.0" layoutY="13.0" mnemonicParsing="false" selected="true" text="Show FPS" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
</content>
</TitledPane>
</panes>
</Accordion>
</children>
</Pane>
</children>
</AnchorPane>
</children>
</AnchorPane>
</children>
</AnchorPane>
<AnchorPane fx:id="infoWrapper" focusTraversable="true" minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="200.0" visible="false">

Loading…
Cancel
Save