Set up architecture for next mark arrow and did a 2d template when the camera is zoomed out. #story[1299]
parent
ccbe3f86ea
commit
91c442e465
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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>
|
||||
Loading…
Reference in new issue