Improved finish display.
This commit is contained in:
@@ -1,12 +1,29 @@
|
|||||||
package visualiser.Controllers;
|
package visualiser.Controllers;
|
||||||
|
|
||||||
|
import com.interactivemesh.jfx.importer.stl.StlMeshImporter;
|
||||||
|
import javafx.animation.AnimationTimer;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.AmbientLight;
|
||||||
|
import javafx.scene.PointLight;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.TableColumn;
|
import javafx.scene.control.TableColumn;
|
||||||
import javafx.scene.control.TableView;
|
import javafx.scene.control.TableView;
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
|
import javafx.scene.media.AudioClip;
|
||||||
|
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 visualiser.app.App;
|
||||||
|
import visualiser.layout.*;
|
||||||
import visualiser.model.VisualiserBoat;
|
import visualiser.model.VisualiserBoat;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finish Screen for when the race finishes.
|
* Finish Screen for when the race finishes.
|
||||||
*/
|
*/
|
||||||
@@ -15,12 +32,94 @@ public class RaceFinishController extends Controller {
|
|||||||
private @FXML TableColumn<VisualiserBoat, String> boatRankColumn;
|
private @FXML TableColumn<VisualiserBoat, String> boatRankColumn;
|
||||||
private @FXML TableColumn<VisualiserBoat, String> boatNameColumn;
|
private @FXML TableColumn<VisualiserBoat, String> boatNameColumn;
|
||||||
private @FXML Label raceWinnerLabel;
|
private @FXML Label raceWinnerLabel;
|
||||||
|
private @FXML GridPane animatedPane;
|
||||||
|
private SkyBox skyBox;
|
||||||
|
private SeaSurface seaSurface;
|
||||||
|
private Subject3D boat;
|
||||||
|
private AmbientLight ambientLight;
|
||||||
|
private Subject3D sailsSubject;
|
||||||
|
private ObservableList<Subject3D> subjects = FXCollections.observableArrayList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the table
|
* Display the table
|
||||||
* @param boats boats to display on the table.
|
* @param boats boats to display on the table.
|
||||||
*/
|
*/
|
||||||
public void loadFinish(ObservableList<VisualiserBoat> boats) {
|
public void loadFinish(ObservableList<VisualiserBoat> boats) {
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
View3D view3D = new View3D();
|
||||||
|
view3D.addAmbientLight(ambientLight);
|
||||||
|
view3D.addPointLight(pointLight);
|
||||||
|
view3D.setDistance(10);
|
||||||
|
view3D.setPitch(5);
|
||||||
|
view3D.setItems(subjects);
|
||||||
|
|
||||||
|
// URL asset = RaceViewController.class.getClassLoader().getResource("assets/V1.2 Complete Boat.stl");
|
||||||
|
// StlMeshImporter importer = new StlMeshImporter();
|
||||||
|
// importer.read(asset);
|
||||||
|
// Subject3D boat = new Subject3D(new MeshView(importer.getImport()), 0);
|
||||||
|
|
||||||
|
Shape3D mesh = Assets3D.getBoat();
|
||||||
|
boat = new Subject3D(mesh, 0);
|
||||||
|
|
||||||
|
skyBox = new SkyBox(750,200,250,0,250);
|
||||||
|
subjects.addAll(skyBox.getSkyBoxPlanes());
|
||||||
|
|
||||||
|
seaSurface = new SeaSurface(750, 200);
|
||||||
|
seaSurface.setX(250);
|
||||||
|
seaSurface.setZ(250);
|
||||||
|
subjects.add(seaSurface);
|
||||||
|
|
||||||
|
double radius = 100;
|
||||||
|
boat.setX(0);
|
||||||
|
boat.setZ(radius);
|
||||||
|
boat.setScale(0.1);
|
||||||
|
|
||||||
|
subjects.add(boat);
|
||||||
|
view3D.trackSubject(boat, -45);
|
||||||
|
|
||||||
|
//add sail
|
||||||
|
Material whiteSail = new PhongMaterial(Color.WHITE);
|
||||||
|
Sails3D sails3D = new Sails3D();
|
||||||
|
sailsSubject = new Subject3D(sails3D, 0);
|
||||||
|
sails3D.setMouseTransparent(true);
|
||||||
|
sails3D.setMaterial(whiteSail);
|
||||||
|
sailsSubject.setXRot(0d);
|
||||||
|
sailsSubject.setX(0);
|
||||||
|
sailsSubject.setZ(radius);
|
||||||
|
sailsSubject.setScale(0.1);
|
||||||
|
subjects.add(sailsSubject);
|
||||||
|
|
||||||
|
animatedPane.add(view3D, 0, 0);
|
||||||
|
|
||||||
|
AnimationTimer loop = new AnimationTimer() {
|
||||||
|
double angle = -90;
|
||||||
|
double offset = 0.05;
|
||||||
|
@Override
|
||||||
|
public void handle(long now) {
|
||||||
|
boat.setX(radius * Math.cos(angle * Math.PI/180));
|
||||||
|
boat.setZ(radius * Math.sin(angle * Math.PI/180));
|
||||||
|
boat.setHeading(-angle);
|
||||||
|
sailsSubject.setX(boat.getX());
|
||||||
|
sailsSubject.setZ(boat.getZ());
|
||||||
|
sailsSubject.setHeading(boat.getHeading().getAngle());
|
||||||
|
angle += offset;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
loop.start();
|
||||||
|
|
||||||
|
|
||||||
// set table contents
|
// set table contents
|
||||||
boatInfoTable.setItems(boats);
|
boatInfoTable.setItems(boats);
|
||||||
//Name.
|
//Name.
|
||||||
@@ -36,4 +135,12 @@ public class RaceFinishController extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void mainMenuPressed() throws IOException {
|
||||||
|
AudioClip sound = new AudioClip(this.getClass().getResource("/visualiser/sounds/buttonpress.wav").toExternalForm());
|
||||||
|
sound.play();
|
||||||
|
App.game.endEvent();
|
||||||
|
loadTitleScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,9 @@
|
|||||||
|
|
||||||
<AnchorPane fx:id="gameLobbyWrapper" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="780.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.InGameLobbyController">
|
<AnchorPane fx:id="gameLobbyWrapper" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="780.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.InGameLobbyController">
|
||||||
<children>
|
<children>
|
||||||
<GridPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<StackPane prefHeight="150.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<children>
|
||||||
|
<GridPane>
|
||||||
<children>
|
<children>
|
||||||
<Button fx:id="quitBtn" maxHeight="50.0" maxWidth="125.0" mnemonicParsing="false" onAction="#menuBtnPressed" GridPane.rowIndex="2">
|
<Button fx:id="quitBtn" maxHeight="50.0" maxWidth="125.0" mnemonicParsing="false" onAction="#menuBtnPressed" GridPane.rowIndex="2">
|
||||||
<GridPane.margin>
|
<GridPane.margin>
|
||||||
@@ -80,7 +82,8 @@
|
|||||||
<Button fx:id="startButton" disable="true" maxHeight="50.0" maxWidth="125.0" mnemonicParsing="false" onAction="#startBtnPressed" visible="false" GridPane.columnIndex="2" GridPane.halignment="RIGHT" GridPane.rowIndex="2">
|
<Button fx:id="startButton" disable="true" maxHeight="50.0" maxWidth="125.0" mnemonicParsing="false" onAction="#startBtnPressed" visible="false" GridPane.columnIndex="2" GridPane.halignment="RIGHT" GridPane.rowIndex="2">
|
||||||
<GridPane.margin>
|
<GridPane.margin>
|
||||||
<Insets right="20.0" />
|
<Insets right="20.0" />
|
||||||
</GridPane.margin></Button>
|
</GridPane.margin>
|
||||||
|
</Button>
|
||||||
</children>
|
</children>
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
@@ -93,7 +96,7 @@
|
|||||||
<RowConstraints maxHeight="80.0" minHeight="80.0" prefHeight="80.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="80.0" minHeight="80.0" prefHeight="80.0" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
<AnchorPane mouseTransparent="true" opacity="0.3" prefHeight="200.0" prefWidth="200.0" style="-fx-background-color: rgba(0, 0, 0, 1);" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<AnchorPane mouseTransparent="true" opacity="0.3" prefHeight="200.0" prefWidth="200.0" style="-fx-background-color: rgba(0, 0, 0, 1);">
|
||||||
<children>
|
<children>
|
||||||
<GridPane fx:id="animatedPane" opacity="0.42" style="-fx-background-color: rgba(0, 0, 0, 0.5);" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<GridPane fx:id="animatedPane" opacity="0.42" style="-fx-background-color: rgba(0, 0, 0, 0.5);" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
@@ -106,4 +109,6 @@
|
|||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
</children>
|
</children>
|
||||||
|
</StackPane>
|
||||||
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import java.lang.*?>
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
<?import javafx.scene.text.*?>
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.control.TableColumn?>
|
<?import javafx.scene.control.TableColumn?>
|
||||||
<?import javafx.scene.control.TableView?>
|
<?import javafx.scene.control.TableView?>
|
||||||
@@ -9,9 +13,11 @@
|
|||||||
<?import javafx.scene.layout.RowConstraints?>
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<AnchorPane fx:id="finishWrapper" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.RaceFinishController">
|
<AnchorPane fx:id="finishWrapper" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.RaceFinishController">
|
||||||
<children>
|
<children>
|
||||||
<GridPane fx:id="start" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="600.0" prefWidth="780.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<StackPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<children>
|
||||||
|
<GridPane fx:id="start" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="600.0" prefWidth="780.0">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" prefWidth="200.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" prefWidth="200.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="372.0" minWidth="10.0" prefWidth="200.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="372.0" minWidth="10.0" prefWidth="200.0" />
|
||||||
@@ -43,7 +49,22 @@
|
|||||||
</font>
|
</font>
|
||||||
</Label>
|
</Label>
|
||||||
<Label fx:id="raceWinnerLabel" alignment="CENTER" maxWidth="1.7976931348623157E308" text="Winner" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
|
<Label fx:id="raceWinnerLabel" alignment="CENTER" maxWidth="1.7976931348623157E308" text="Winner" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
|
||||||
|
<Button fx:id="mainMenuBtn" maxHeight="50.0" maxWidth="125.0" mnemonicParsing="false" onAction="#mainMenuPressed" GridPane.columnIndex="3" GridPane.halignment="RIGHT" GridPane.rowIndex="5" GridPane.valignment="CENTER" />
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
|
<AnchorPane mouseTransparent="true" opacity="0.3" prefHeight="200.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<GridPane fx:id="animatedPane" opacity="0.4" style="-fx-background-color: rgba(0, 0, 0, 0.5);" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
</GridPane>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</children>
|
||||||
|
</StackPane>
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
|||||||
Reference in New Issue
Block a user