Added nightmode skybox. Changed how next mark arrow works.
This commit is contained in:
@@ -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("#999999"));
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,12 +308,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);
|
||||
@@ -324,6 +318,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();
|
||||
@@ -350,6 +349,12 @@ 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();
|
||||
final GPSConverter gpsConverter = new GPSConverter(raceData, 450, 450);
|
||||
@@ -357,6 +362,7 @@ public class RaceViewController extends Controller {
|
||||
SkyBox skyBox = new SkyBox(750, 200, 250, 0, 210);
|
||||
viewSubjects.addAll(skyBox.getSkyBoxPlanes());
|
||||
|
||||
|
||||
// Set up sea surface
|
||||
SeaSurface sea = new SeaSurface(750, 200);
|
||||
sea.setX(250);
|
||||
@@ -410,8 +416,12 @@ public class RaceViewController extends Controller {
|
||||
AnimationTimer highlightTrack = new AnimationTimer() {
|
||||
@Override
|
||||
public void handle(long now) {
|
||||
boatHighlight.setX(gpsConverter.convertGPS(boat.getPosition()).getX());
|
||||
boatHighlight.setZ(gpsConverter.convertGPS(boat.getPosition()).getY());
|
||||
double boatX = gpsConverter.convertGPS(boat.getPosition()).getX();
|
||||
double boatZ = gpsConverter.convertGPS(boat.getPosition()).getY();
|
||||
boatHighlight.setX(boatX);
|
||||
boatHighlight.setZ(boatZ);
|
||||
pointLight.setTranslateX(boatX);
|
||||
pointLight.setTranslateZ(boatZ);
|
||||
}
|
||||
};
|
||||
highlightTrack.start();
|
||||
|
||||
@@ -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,9 @@ public class SkyBox {
|
||||
}
|
||||
|
||||
private void addTop() {
|
||||
MeshView surface = makeSurface(new Image(getClass().getClassLoader().getResourceAsStream("images/skybox/ThickCloudsWaterUp2048.png")), size);
|
||||
String imagePath = "images/skybox/ThickCloudsWaterUp2048.png";
|
||||
if (!App.dayMode) 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 +61,9 @@ public class SkyBox {
|
||||
}
|
||||
|
||||
private void addRight() {
|
||||
MeshView surface = makeSurface(new Image(getClass().getClassLoader().getResourceAsStream("images/skybox/ThickCloudsWaterRight2048.png")), size + 1);
|
||||
String imagePath = "images/skybox/ThickCloudsWaterRight2048.png";
|
||||
if (!App.dayMode) 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 +82,9 @@ public class SkyBox {
|
||||
}
|
||||
|
||||
private void addLeft() {
|
||||
MeshView surface = makeSurface(new Image(getClass().getClassLoader().getResourceAsStream("images/skybox/ThickCloudsWaterLeft2048.png")), size + 1);
|
||||
String imagePath = "images/skybox/ThickCloudsWaterLeft2048.png";
|
||||
if (!App.dayMode) 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 +106,9 @@ public class SkyBox {
|
||||
}
|
||||
|
||||
private void addBack() {
|
||||
MeshView surface = makeSurface(new Image(getClass().getClassLoader().getResourceAsStream("images/skybox/ThickCloudsWaterBack2048.png")), size);
|
||||
String imagePath = "images/skybox/ThickCloudsWaterBack2048.png";
|
||||
if (!App.dayMode) 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 +126,9 @@ public class SkyBox {
|
||||
}
|
||||
|
||||
private void addFront() {
|
||||
MeshView surface = makeSurface(new Image(getClass().getClassLoader().getResourceAsStream("images/skybox/ThickCloudsWaterFront2048.png")), size);
|
||||
|
||||
String imagePath = "images/skybox/ThickCloudsWaterFront2048.png";
|
||||
if (!App.dayMode) 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 +136,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);
|
||||
|
||||
Reference in New Issue
Block a user