Set up architecture for next mark arrow and did a 2d template when the camera is zoomed out. #story[1299]
This commit is contained in:
@@ -0,0 +1,67 @@
|
|||||||
|
package visualiser.Controllers;
|
||||||
|
|
||||||
|
import com.interactivemesh.jfx.importer.stl.StlMeshImporter;
|
||||||
|
import javafx.animation.AnimationTimer;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.layout.Pane;
|
||||||
|
import javafx.scene.layout.StackPane;
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
|
import javafx.scene.paint.PhongMaterial;
|
||||||
|
import javafx.scene.shape.Cylinder;
|
||||||
|
import javafx.scene.shape.MeshView;
|
||||||
|
import shared.model.Bearing;
|
||||||
|
import shared.model.CompoundMark;
|
||||||
|
import shared.model.GPSCoordinate;
|
||||||
|
import visualiser.model.VisualiserBoat;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Observable;
|
||||||
|
import java.util.Observer;
|
||||||
|
|
||||||
|
public class NextMarkController {
|
||||||
|
private @FXML StackPane arrowStackPane2d;
|
||||||
|
private @FXML Pane pane2d;
|
||||||
|
private @FXML Pane pane3d;
|
||||||
|
|
||||||
|
private VisualiserBoat boat;
|
||||||
|
|
||||||
|
public void initialiseArrowView(VisualiserBoat boat) {
|
||||||
|
this.boat = boat;
|
||||||
|
pane2d.setVisible(true);
|
||||||
|
pane3d.setVisible(false);
|
||||||
|
initialise2dArrowView();
|
||||||
|
initialise3dArrowView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialise2dArrowView() {
|
||||||
|
AnimationTimer arrow2d = new AnimationTimer() {
|
||||||
|
@Override
|
||||||
|
public void handle(long now) {
|
||||||
|
CompoundMark target = boat.getCurrentLeg().getEndCompoundMark();
|
||||||
|
Bearing headingToMark = GPSCoordinate.calculateBearing(boat.getPosition(), target.getAverageGPSCoordinate());
|
||||||
|
arrowStackPane2d.setRotate(headingToMark.degrees());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
arrow2d.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialise3dArrowView() {
|
||||||
|
URL asset = this.getClass().getClassLoader().getResource("assets/arrow V1.0.4.stl");
|
||||||
|
StlMeshImporter importer = new StlMeshImporter();
|
||||||
|
importer.read(asset);
|
||||||
|
|
||||||
|
MeshView arrow = new MeshView(importer.getImport());
|
||||||
|
PhongMaterial arrowMat = new PhongMaterial(Color.RED);
|
||||||
|
arrow.setMaterial(arrowMat);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void show2d() {
|
||||||
|
pane3d.setVisible(false);
|
||||||
|
pane2d.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void show3d() {
|
||||||
|
pane2d.setVisible(false);
|
||||||
|
pane3d.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,10 +16,12 @@ import javafx.scene.input.KeyCode;
|
|||||||
import javafx.scene.input.KeyEvent;
|
import javafx.scene.input.KeyEvent;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.paint.Material;
|
import javafx.scene.paint.Material;
|
||||||
import javafx.scene.paint.PhongMaterial;
|
import javafx.scene.paint.PhongMaterial;
|
||||||
|
import javafx.scene.shape.Cylinder;
|
||||||
import javafx.scene.shape.MeshView;
|
import javafx.scene.shape.MeshView;
|
||||||
import javafx.scene.shape.Shape3D;
|
import javafx.scene.shape.Shape3D;
|
||||||
import javafx.scene.transform.Translate;
|
import javafx.scene.transform.Translate;
|
||||||
@@ -77,9 +79,11 @@ public class RaceViewController extends Controller {
|
|||||||
|
|
||||||
// note: it says it's not used but it is! do not remove :)
|
// note: it says it's not used but it is! do not remove :)
|
||||||
private @FXML ArrowController arrowController;
|
private @FXML ArrowController arrowController;
|
||||||
|
private @FXML NextMarkController nextMarkController;
|
||||||
private @FXML GridPane canvasBase;
|
private @FXML GridPane canvasBase;
|
||||||
private @FXML SplitPane racePane;
|
private @FXML SplitPane racePane;
|
||||||
private @FXML StackPane arrowPane;
|
private @FXML StackPane arrowPane;
|
||||||
|
private @FXML Pane nextMarkPane;
|
||||||
private @FXML Label timer;
|
private @FXML Label timer;
|
||||||
private @FXML Label FPS;
|
private @FXML Label FPS;
|
||||||
private @FXML Label timeZone;
|
private @FXML Label timeZone;
|
||||||
@@ -204,25 +208,13 @@ public class RaceViewController extends Controller {
|
|||||||
* Initialises the various UI components to listen to the {@link #visualiserRace}.
|
* Initialises the various UI components to listen to the {@link #visualiserRace}.
|
||||||
*/
|
*/
|
||||||
private void initialiseRaceVisuals() {
|
private void initialiseRaceVisuals() {
|
||||||
|
|
||||||
// Import arrow mesh
|
|
||||||
URL asset = this.getClass().getClassLoader().getResource("assets/arrow V1.0.4.stl");
|
|
||||||
StlMeshImporter importer = new StlMeshImporter();
|
|
||||||
importer.read(asset);
|
|
||||||
|
|
||||||
MeshView arrow = new MeshView(importer.getImport());
|
|
||||||
PhongMaterial arrowMat = new PhongMaterial(Color.RED);
|
|
||||||
arrow.setMaterial(arrowMat);
|
|
||||||
|
|
||||||
this.nextMarkArrow = new Annotation3D(arrow);
|
|
||||||
this.nextMarkArrow.setScale(0.1);
|
|
||||||
|
|
||||||
// initialise displays
|
// initialise displays
|
||||||
initialiseFps();
|
initialiseFps();
|
||||||
initialiseInfoTable();
|
initialiseInfoTable();
|
||||||
initialiseView3D(this.visualiserRace);
|
initialiseView3D(this.visualiserRace);
|
||||||
initialiseRaceClock();
|
initialiseRaceClock();
|
||||||
raceTimer(); // start the timer
|
raceTimer(); // start the timer
|
||||||
|
nextMarkPane.toFront();
|
||||||
new Sparkline(this.raceState, this.sparklineChart);
|
new Sparkline(this.raceState, this.sparklineChart);
|
||||||
timeZone.setText(this.raceState.getRaceClock().getTimeZone());
|
timeZone.setText(this.raceState.getRaceClock().getTimeZone());
|
||||||
arrowController.setWindProperty(this.raceState.windProperty());
|
arrowController.setWindProperty(this.raceState.windProperty());
|
||||||
@@ -231,6 +223,13 @@ public class RaceViewController extends Controller {
|
|||||||
private void initialiseView3D(VisualiserRaceEvent race) {
|
private void initialiseView3D(VisualiserRaceEvent race) {
|
||||||
viewSubjects = FXCollections.observableArrayList();
|
viewSubjects = FXCollections.observableArrayList();
|
||||||
|
|
||||||
|
try {
|
||||||
|
nextMarkController.initialiseArrowView(race.getVisualiserRaceState().getBoat(race.getVisualiserRaceState().getPlayerBoatID()));
|
||||||
|
System.out.println("hi");
|
||||||
|
} catch (BoatNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
AmbientLight ambientLight = new AmbientLight(Color.web("#CCCCFF"));
|
AmbientLight ambientLight = new AmbientLight(Color.web("#CCCCFF"));
|
||||||
ambientLight.setTranslateX(250);
|
ambientLight.setTranslateX(250);
|
||||||
ambientLight.setTranslateZ(210);
|
ambientLight.setTranslateZ(210);
|
||||||
@@ -417,35 +416,32 @@ public class RaceViewController extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addThirdPersonAnnotations(Subject3D subject3D) {
|
private void addThirdPersonAnnotations(Subject3D subject3D) {
|
||||||
viewSubjects.add(nextMarkArrow);
|
nextMarkController.show3d();
|
||||||
final VisualiserBoat boat;
|
// viewSubjects.add(nextMarkArrow);
|
||||||
try {
|
// final VisualiserBoat boat;
|
||||||
boat = visualiserRace.getVisualiserRaceState().getBoat(subject3D.getSourceID());
|
// try {
|
||||||
} catch (BoatNotFoundException e) {
|
// boat = visualiserRace.getVisualiserRaceState().getBoat(subject3D.getSourceID());
|
||||||
e.printStackTrace();
|
// } catch (BoatNotFoundException e) {
|
||||||
return;
|
// e.printStackTrace();
|
||||||
}
|
// return;
|
||||||
arrowToNextMark = new AnimationTimer() {
|
// }
|
||||||
@Override
|
// arrowToNextMark = new AnimationTimer() {
|
||||||
public void handle(long now) {
|
// @Override
|
||||||
CompoundMark target = boat.getCurrentLeg().getEndCompoundMark();
|
// public void handle(long now) {
|
||||||
Bearing headingToMark = GPSCoordinate.calculateBearing(boat.getPosition(), target.getAverageGPSCoordinate());
|
// CompoundMark target = boat.getCurrentLeg().getEndCompoundMark();
|
||||||
|
// Bearing headingToMark = GPSCoordinate.calculateBearing(boat.getPosition(), target.getAverageGPSCoordinate());
|
||||||
nextMarkArrow.setX(view3D.getPivot().getX());
|
//
|
||||||
nextMarkArrow.setY(view3D.getPivot().getY());
|
// nextMarkArrow.setX(view3D.getPivot().getX());
|
||||||
nextMarkArrow.setZ(view3D.getPivot().getZ() + 15);
|
// nextMarkArrow.setY(view3D.getPivot().getY());
|
||||||
nextMarkArrow.setHeading(headingToMark.degrees());
|
// nextMarkArrow.setZ(view3D.getPivot().getZ() + 15);
|
||||||
}
|
// nextMarkArrow.setHeading(headingToMark.degrees());
|
||||||
};
|
// }
|
||||||
arrowToNextMark.start();
|
// };
|
||||||
|
// arrowToNextMark.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeThirdPersonAnnotations() {
|
private void removeThirdPersonAnnotations() {
|
||||||
viewSubjects.remove(nextMarkArrow);
|
nextMarkController.show2d();
|
||||||
if (arrowToNextMark != null) {
|
|
||||||
arrowToNextMark.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<?import javafx.scene.layout.StackPane?>
|
<?import javafx.scene.layout.StackPane?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<SplitPane fx:id="racePane" prefHeight="431.0" prefWidth="610.0" visible="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.RaceViewController">
|
<SplitPane fx:id="racePane" prefHeight="431.0" prefWidth="610.0" visible="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.RaceViewController">
|
||||||
<items>
|
<items>
|
||||||
<StackPane fx:id="newPane" prefHeight="150.0" prefWidth="200.0">
|
<StackPane fx:id="newPane" prefHeight="150.0" prefWidth="200.0">
|
||||||
<children>
|
<children>
|
||||||
@@ -35,6 +35,13 @@
|
|||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<StackPane fx:id="nextMarkPane" alignment="TOP_CENTER" mouseTransparent="true" prefHeight="150.0" prefWidth="150.0" snapToPixel="false">
|
||||||
|
<children>
|
||||||
|
<fx:include fx:id="nextMark" source="nextMark.fxml" />
|
||||||
|
</children>
|
||||||
|
</StackPane>
|
||||||
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
<Pane prefHeight="200.0" prefWidth="400.0" visible="false">
|
<Pane prefHeight="200.0" prefWidth="400.0" visible="false">
|
||||||
<children>
|
<children>
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.*?>
|
||||||
|
<?import javafx.geometry.*?>
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.shape.*?>
|
||||||
|
<?import javafx.scene.text.*?>
|
||||||
|
<?import javafx.scene.image.*?>
|
||||||
|
<?import java.lang.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
|
<GridPane fx:id="arrowGridPane" alignment="TOP_CENTER" maxHeight="-Infinity" maxWidth="-Infinity" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.NextMarkController">
|
||||||
|
<children>
|
||||||
|
<Pane fx:id="pane2d" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="125.0" prefWidth="125.0">
|
||||||
|
<children>
|
||||||
|
<StackPane fx:id="arrowStackPane2d" prefHeight="125.0" prefWidth="125.0">
|
||||||
|
<children>
|
||||||
|
<ImageView fx:id="arrowImage" fitHeight="75.0" fitWidth="75.0">
|
||||||
|
<image>
|
||||||
|
<Image url="@../images/arrow.png" />
|
||||||
|
</image>
|
||||||
|
</ImageView>
|
||||||
|
</children>
|
||||||
|
</StackPane>
|
||||||
|
<Circle fx:id="circle" fill="#1f93ff00" layoutX="63.0" layoutY="63.0" radius="60.0" stroke="BLACK" strokeType="INSIDE" strokeWidth="3.0" />
|
||||||
|
</children>
|
||||||
|
</Pane>
|
||||||
|
<Label text="Next Mark" GridPane.halignment="CENTER" GridPane.hgrow="NEVER" GridPane.rowIndex="1">
|
||||||
|
<font>
|
||||||
|
<Font name="System Bold" size="16.0" />
|
||||||
|
</font>
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets />
|
||||||
|
</GridPane.margin>
|
||||||
|
</Label>
|
||||||
|
<Pane fx:id="pane3d" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="125.0" prefWidth="125.0" />
|
||||||
|
</children>
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
</GridPane>
|
||||||
Reference in New Issue
Block a user