Merge branch 'master' into upgradeStartBoat
# Conflicts: # racevisionGame/src/main/java/visualiser/Controllers/TitleController.java
@@ -35,12 +35,15 @@ public class NextMarkController {
|
||||
private @FXML Pane pane2d;
|
||||
private @FXML Pane pane3d;
|
||||
|
||||
private View3D view3D;
|
||||
private VisualiserBoat boat;
|
||||
private boolean zoomedOut = false;
|
||||
|
||||
public void initialiseArrowView(VisualiserBoat boat) {
|
||||
public void initialiseArrowView(View3D view3D, VisualiserBoat boat) {
|
||||
this.view3D = view3D;
|
||||
this.boat = boat;
|
||||
pane2d.setVisible(true);
|
||||
pane3d.setVisible(false);
|
||||
pane2d.setVisible(false);
|
||||
pane3d.setVisible(true);
|
||||
initialise2dArrowView();
|
||||
initialise3dArrowView();
|
||||
}
|
||||
@@ -66,13 +69,15 @@ public class NextMarkController {
|
||||
String arrowPath = "assets/mark_arrow.x3d";
|
||||
|
||||
Shape3D arrow = Assets3D.loadX3d(arrowPath);
|
||||
AmbientLight ambientLight = new AmbientLight(Color.web("#CCCCCC"));
|
||||
|
||||
arrow.setScaleX(15);
|
||||
arrow.setScaleY(25);
|
||||
arrow.setScaleZ(50);
|
||||
arrow.setScaleY(15);
|
||||
arrow.setScaleZ(200);
|
||||
arrow.setRotationAxis(new Point3D(1,0,0));
|
||||
|
||||
arrowStackPane3d.getChildren().add(arrow);
|
||||
arrowStackPane3d.getChildren().add(ambientLight);
|
||||
|
||||
AnimationTimer arrow3d = new AnimationTimer() {
|
||||
@Override
|
||||
@@ -80,7 +85,7 @@ public class NextMarkController {
|
||||
if (boat.getCurrentLeg().getEndCompoundMark() != null) {
|
||||
arrow.getTransforms().clear();
|
||||
double zRotation = calculateZRotate();
|
||||
arrow.setRotate(calculateXRotate(zRotation));
|
||||
arrow.getTransforms().add(new Rotate(calculateXRotate(), new Point3D(1, 0, 0)));
|
||||
arrow.getTransforms().add(new Rotate(zRotation, new Point3D(0, 0, 1)));
|
||||
} else {
|
||||
stop();
|
||||
@@ -91,33 +96,23 @@ public class NextMarkController {
|
||||
}
|
||||
|
||||
public void show2d() {
|
||||
pane3d.setVisible(false);
|
||||
pane2d.setVisible(true);
|
||||
zoomedOut = true;
|
||||
}
|
||||
|
||||
public void show3d() {
|
||||
pane2d.setVisible(false);
|
||||
pane3d.setVisible(true);
|
||||
zoomedOut = false;
|
||||
}
|
||||
|
||||
private double calculateZRotate() {
|
||||
CompoundMark target = boat.getCurrentLeg().getEndCompoundMark();
|
||||
Bearing headingToMark = GPSCoordinate.calculateBearing(boat.getPosition(), target.getAverageGPSCoordinate());
|
||||
if (zoomedOut) {
|
||||
return -headingToMark.degrees() + 180;
|
||||
}
|
||||
return -headingToMark.degrees() + boat.getBearing().degrees() + 180;
|
||||
}
|
||||
|
||||
private double calculateXRotate(double zRotation) {
|
||||
// if (zRotation > 360) {
|
||||
// zRotation -=360;
|
||||
// } else if (zRotation < 0) {
|
||||
// zRotation += 360;
|
||||
// }
|
||||
//
|
||||
// if (zRotation > 180) {
|
||||
// zRotation = 360 - zRotation;
|
||||
// }
|
||||
|
||||
return 70;
|
||||
//return 90 - 20 * Math.cos(Math.toRadians(zRotation));
|
||||
private double calculateXRotate() {
|
||||
return 100 - view3D.getPitch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +118,7 @@ public class RaceViewController extends Controller {
|
||||
private @FXML TableColumn<VisualiserBoat, Number> boatHealthColumn;
|
||||
private @FXML LineChart<Number, Number> sparklineChart;
|
||||
private @FXML Label tutorialText;
|
||||
private @FXML ImageView tom;
|
||||
private @FXML AnchorPane infoWrapper;
|
||||
private @FXML AnchorPane lineChartWrapper;
|
||||
private @FXML StackPane speedPane;
|
||||
@@ -157,6 +158,7 @@ public class RaceViewController extends Controller {
|
||||
if (App.gameType == 4) {
|
||||
isTutorial = true;
|
||||
tutorialText.setVisible(true);
|
||||
tom.setVisible(true);
|
||||
tutorialStates = new ArrayList<>(Arrays.asList(TutorialState.values()));
|
||||
currentState = tutorialStates.get(0);
|
||||
tutorialStates.remove(0);
|
||||
@@ -169,6 +171,7 @@ public class RaceViewController extends Controller {
|
||||
} else {
|
||||
isTutorial = false;
|
||||
tutorialText.setVisible(false);
|
||||
tom.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,12 +351,6 @@ public class RaceViewController extends Controller {
|
||||
private void initialiseView3D(VisualiserRaceEvent race) {
|
||||
viewSubjects = FXCollections.observableArrayList();
|
||||
|
||||
try {
|
||||
nextMarkController.initialiseArrowView(race.getVisualiserRaceState().getBoat(race.getVisualiserRaceState().getPlayerBoatID()));
|
||||
} catch (BoatNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
AmbientLight ambientLight = new AmbientLight(Color.web("#CCCCFF"));
|
||||
ambientLight.setTranslateX(250);
|
||||
ambientLight.setTranslateZ(210);
|
||||
@@ -364,6 +361,11 @@ public class RaceViewController extends Controller {
|
||||
pointLight.setTranslateZ(210);
|
||||
pointLight.setLightOn(true);
|
||||
|
||||
if (!App.dayMode) {
|
||||
ambientLight.setColor(Color.web("#9999AA"));
|
||||
pointLight.setColor(Color.web("#777799"));
|
||||
}
|
||||
|
||||
// Import boat mesh
|
||||
URL asset = RaceViewController.class.getClassLoader().getResource("assets/V1.2 Complete Boat.stl");
|
||||
StlMeshImporter importer = new StlMeshImporter();
|
||||
@@ -390,11 +392,17 @@ public class RaceViewController extends Controller {
|
||||
windCompass = new WindCompass(view3D, this.raceState.windProperty());
|
||||
arrowPane.getChildren().add(windCompass);
|
||||
|
||||
try {
|
||||
nextMarkController.initialiseArrowView(view3D, race.getVisualiserRaceState().getBoat(race.getVisualiserRaceState().getPlayerBoatID()));
|
||||
} catch (BoatNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Set up projection from GPS to view
|
||||
RaceDataSource raceData = visualiserRace.getVisualiserRaceState().getRaceDataSource();
|
||||
gpsConverter = new GPSConverter(raceData, 450, 450);
|
||||
|
||||
SkyBox skyBox = Assets3D.skyBox;
|
||||
SkyBox skyBox = new SkyBox(750, 200, 250, 0, 210);
|
||||
viewSubjects.addAll(skyBox.getSkyBoxPlanes());
|
||||
|
||||
// Set up sea surface
|
||||
@@ -472,8 +480,12 @@ public class RaceViewController extends Controller {
|
||||
AnimationTimer highlightTrack = new AnimationTimer() {
|
||||
@Override
|
||||
public void handle(long now) {
|
||||
Assets3D.boatHighlight.setX(gpsConverter.convertGPS(boat.getPosition()).getX());
|
||||
Assets3D.boatHighlight.setZ(gpsConverter.convertGPS(boat.getPosition()).getY());
|
||||
double boatX = gpsConverter.convertGPS(boat.getPosition()).getX();
|
||||
double boatZ = gpsConverter.convertGPS(boat.getPosition()).getY();
|
||||
Assets3D.boatHighlight.setX(boatX);
|
||||
Assets3D.boatHighlight.setZ(boatZ);
|
||||
// pointLight.setTranslateX(boatX);
|
||||
// pointLight.setTranslateZ(boatZ);
|
||||
}
|
||||
};
|
||||
highlightTrack.start();
|
||||
|
||||
@@ -51,22 +51,31 @@ public class TitleController extends Controller {
|
||||
private @FXML ImageView imgSun;
|
||||
private @FXML GridPane view3DContainer;
|
||||
private ToggleGroup toggleGroup = new ToggleGroup();
|
||||
private SkyBox skyBox;
|
||||
private SeaSurface seaSurface;
|
||||
private Subject3D boat;
|
||||
private AmbientLight ambientLight;
|
||||
private ObservableList<Subject3D> subjects = FXCollections.observableArrayList();
|
||||
|
||||
public void initialize() {
|
||||
dayModeRD.setToggleGroup(toggleGroup);
|
||||
nightModeRD.setToggleGroup(toggleGroup);
|
||||
|
||||
AmbientLight ambientLight = new AmbientLight(Color.web("#CCCCFF"));
|
||||
if (App.dayMode) dayModeRD.setSelected(true);
|
||||
else nightModeRD.setSelected(true);
|
||||
|
||||
ambientLight = new AmbientLight(Color.web("#CCCCFF"));
|
||||
ambientLight.setTranslateX(250);
|
||||
ambientLight.setTranslateZ(210);
|
||||
ambientLight.setLightOn(true);
|
||||
|
||||
if (!App.dayMode) ambientLight.setColor(Color.web("#9999AA"));
|
||||
|
||||
PointLight pointLight = new PointLight(Color.web("#AAAAFF"));
|
||||
pointLight.setTranslateX(250);
|
||||
pointLight.setTranslateZ(210);
|
||||
pointLight.setLightOn(true);
|
||||
|
||||
ObservableList<Subject3D> subjects = FXCollections.observableArrayList();
|
||||
View3D view3D = new View3D();
|
||||
view3D.addAmbientLight(ambientLight);
|
||||
view3D.addPointLight(pointLight);
|
||||
@@ -74,10 +83,10 @@ public class TitleController extends Controller {
|
||||
view3D.setPitch(5);
|
||||
view3D.setItems(subjects);
|
||||
|
||||
SkyBox skyBox = new SkyBox(750,200,250,0,250);
|
||||
skyBox = new SkyBox(750,200,250,0,250);
|
||||
subjects.addAll(skyBox.getSkyBoxPlanes());
|
||||
|
||||
SeaSurface seaSurface = new SeaSurface(750, 200);
|
||||
seaSurface = new SeaSurface(750, 200);
|
||||
seaSurface.setX(250);
|
||||
seaSurface.setZ(250);
|
||||
subjects.add(seaSurface);
|
||||
@@ -158,6 +167,7 @@ public class TitleController extends Controller {
|
||||
dayModeRD.getScene().getStylesheets().add("/css/dayMode.css");
|
||||
nightModeRD.setSelected(false);
|
||||
App.dayMode = true;
|
||||
newSkyBox();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,6 +178,7 @@ public class TitleController extends Controller {
|
||||
nightModeRD.getScene().getStylesheets().add("/css/nightMode.css");
|
||||
dayModeRD.setSelected(false);
|
||||
App.dayMode = false;
|
||||
newSkyBox();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,4 +201,21 @@ public class TitleController extends Controller {
|
||||
hgc.hostGamePressed();
|
||||
}
|
||||
|
||||
private void newSkyBox() {
|
||||
if (skyBox != null) {
|
||||
SkyBox newSkyBox = new SkyBox(750,200,250,0,250);
|
||||
subjects.removeAll(skyBox.getSkyBoxPlanes());
|
||||
subjects.addAll(newSkyBox.getSkyBoxPlanes());
|
||||
skyBox = newSkyBox;
|
||||
seaSurface.getMesh().toFront();
|
||||
boat.getMesh().toFront();
|
||||
|
||||
if (App.dayMode) {
|
||||
ambientLight.setColor(Color.web("#CCCCFF"));
|
||||
} else {
|
||||
ambientLight.setColor(Color.web("#9999AA"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class Assets3D {
|
||||
loadWindArrow();
|
||||
loadNextArrow();
|
||||
loadSeaSurface();
|
||||
loadSkybox();
|
||||
//loadSkybox();
|
||||
loadSeagull();
|
||||
loadBoatHightlight();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.PhongMaterial;
|
||||
import javafx.scene.shape.MeshView;
|
||||
import javafx.scene.transform.Rotate;
|
||||
import visualiser.app.App;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -44,7 +45,10 @@ public class SkyBox {
|
||||
}
|
||||
|
||||
private void addTop() {
|
||||
MeshView surface = makeSurface(new Image(getClass().getClassLoader().getResourceAsStream("images/skybox/ThickCloudsWaterUp2048.png")), size);
|
||||
String imagePath;
|
||||
if (App.dayMode) imagePath = "images/skybox/ThickCloudsWaterUp2048.png";
|
||||
else imagePath = "images/skybox/DarkStormyUp2048.png";
|
||||
MeshView surface = makeSurface(new Image(getClass().getClassLoader().getResourceAsStream(imagePath)), size);
|
||||
|
||||
surface.setRotationAxis(new Point3D(0, 0, 1));
|
||||
surface.setRotate(180);
|
||||
@@ -58,7 +62,10 @@ public class SkyBox {
|
||||
}
|
||||
|
||||
private void addRight() {
|
||||
MeshView surface = makeSurface(new Image(getClass().getClassLoader().getResourceAsStream("images/skybox/ThickCloudsWaterRight2048.png")), size + 1);
|
||||
String imagePath;
|
||||
if (App.dayMode) imagePath = "images/skybox/ThickCloudsWaterRight2048.png";
|
||||
else imagePath = "images/skybox/DarkStormyRight2048.png";
|
||||
MeshView surface = makeSurface(new Image(getClass().getClassLoader().getResourceAsStream(imagePath)), size + 1);
|
||||
|
||||
surface.setTranslateX(size/2);
|
||||
surface.setTranslateY(size/2);
|
||||
@@ -77,7 +84,10 @@ public class SkyBox {
|
||||
}
|
||||
|
||||
private void addLeft() {
|
||||
MeshView surface = makeSurface(new Image(getClass().getClassLoader().getResourceAsStream("images/skybox/ThickCloudsWaterLeft2048.png")), size + 1);
|
||||
String imagePath;
|
||||
if (App.dayMode) imagePath = "images/skybox/ThickCloudsWaterLeft2048.png";
|
||||
else imagePath = "images/skybox/DarkStormyLeft2048.png";
|
||||
MeshView surface = makeSurface(new Image(getClass().getClassLoader().getResourceAsStream(imagePath)), size + 1);
|
||||
|
||||
surface.setTranslateX(size/2);
|
||||
surface.setTranslateY(size/2);
|
||||
@@ -99,7 +109,10 @@ public class SkyBox {
|
||||
}
|
||||
|
||||
private void addBack() {
|
||||
MeshView surface = makeSurface(new Image(getClass().getClassLoader().getResourceAsStream("images/skybox/ThickCloudsWaterBack2048.png")), size);
|
||||
String imagePath;
|
||||
if (App.dayMode) imagePath = "images/skybox/ThickCloudsWaterBack2048.png";
|
||||
else imagePath = "images/skybox/DarkStormyBack2048.png";
|
||||
MeshView surface = makeSurface(new Image(getClass().getClassLoader().getResourceAsStream(imagePath)), size);
|
||||
surface.getTransforms().add(new Rotate(90, 0, 0));
|
||||
|
||||
surface.setRotationAxis(new Point3D(1, 0, 0));
|
||||
@@ -117,8 +130,10 @@ public class SkyBox {
|
||||
}
|
||||
|
||||
private void addFront() {
|
||||
MeshView surface = makeSurface(new Image(getClass().getClassLoader().getResourceAsStream("images/skybox/ThickCloudsWaterFront2048.png")), size);
|
||||
|
||||
String imagePath;
|
||||
if (App.dayMode) imagePath = "images/skybox/ThickCloudsWaterFront2048.png";
|
||||
else imagePath = "images/skybox/DarkStormyFront2048.png";
|
||||
MeshView surface = makeSurface(new Image(getClass().getClassLoader().getResourceAsStream(imagePath)), size);
|
||||
surface.setTranslateX(size/2);
|
||||
surface.setTranslateY(size/2);
|
||||
surface.setRotationAxis(new Point3D(0, 0, 1));
|
||||
@@ -126,6 +141,7 @@ public class SkyBox {
|
||||
surface.setTranslateX(-size/2);
|
||||
surface.setTranslateY(-size/2);
|
||||
|
||||
|
||||
surface.setTranslateX(x + size/2 - clipOverlap);
|
||||
surface.setTranslateY(y + yshift);
|
||||
surface.setTranslateZ(z);
|
||||
|
||||
|
After Width: | Height: | Size: 681 KiB |
|
After Width: | Height: | Size: 2.0 MiB |
|
After Width: | Height: | Size: 2.0 MiB |
|
After Width: | Height: | Size: 1.8 MiB |
|
After Width: | Height: | Size: 2.2 MiB |
|
After Width: | Height: | Size: 1.7 MiB |
|
Before Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 103 KiB |
|
Before Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 99 KiB |
|
Before Width: | Height: | Size: 48 KiB |
@@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.paint.*?>
|
||||
<?import javafx.scene.shape.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.chart.*?>
|
||||
@@ -114,7 +116,7 @@
|
||||
<Insets left="10.0" top="10.0" />
|
||||
</padding>
|
||||
</GridPane>
|
||||
<Label fx:id="tutorialText" alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" style="-fx-border-color: orange; -fx-border-radius: 5px; -fx-background-color: #ffffcc; -fx-text-fill: #3399ff; -fx-border-width: 3; -fx-border-insets: -3;" text="This is the tutorial text" visible="false" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="150.0" AnchorPane.topAnchor="150.0" />
|
||||
<Label fx:id="tutorialText" alignment="CENTER" minHeight="-Infinity" minWidth="-Infinity" style="-fx-border-color: orange; -fx-border-radius: 5px; -fx-background-color: #ffffcc; -fx-text-fill: #3399ff; -fx-border-width: 3; -fx-border-insets: -3;" text="This is the tutorial text" visible="false" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="150.0" AnchorPane.topAnchor="150.0" />
|
||||
<StackPane fx:id="speedPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="14.0" AnchorPane.rightAnchor="2.0">
|
||||
<padding>
|
||||
<Insets right="20.0" />
|
||||
@@ -202,6 +204,11 @@
|
||||
</Button>
|
||||
</children>
|
||||
</StackPane>
|
||||
<ImageView fx:id="tom" fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" visible="false" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="100.0">
|
||||
<image>
|
||||
<Image url="@../../images/sailertom.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<ImageView fitHeight="150.0" fitWidth="200.0" focusTraversable="true" mouseTransparent="true" pickOnBounds="true" preserveRatio="true" StackPane.alignment="BOTTOM_CENTER">
|
||||
|
||||