Changed Sea Surface to new Sea Surface and optimised some assets to load at the beginning
This commit is contained in:
@@ -290,7 +290,6 @@ public class RaceViewController extends Controller {
|
||||
* Initialises the various UI components to listen to the {@link #visualiserRace}.
|
||||
*/
|
||||
private void initialiseRaceVisuals() {
|
||||
|
||||
// Import arrow mesh
|
||||
URL asset = this.getClass().getClassLoader().getResource("assets/arrow V1.0.4.stl");
|
||||
StlMeshImporter importer = new StlMeshImporter();
|
||||
@@ -302,7 +301,6 @@ public class RaceViewController extends Controller {
|
||||
|
||||
this.nextMarkArrow = new Annotation3D(arrow);
|
||||
this.nextMarkArrow.setScale(0.1);
|
||||
|
||||
// initialise displays
|
||||
initialiseFps();
|
||||
initialiseInfoTable();
|
||||
@@ -359,20 +357,38 @@ public class RaceViewController extends Controller {
|
||||
RaceDataSource raceData = visualiserRace.getVisualiserRaceState().getRaceDataSource();
|
||||
gpsConverter = new GPSConverter(raceData, 450, 450);
|
||||
|
||||
SkyBox skyBox = new SkyBox(750, 200, 250, 0, 210);
|
||||
SkyBox skyBox = Assets3D.skyBox;
|
||||
viewSubjects.addAll(skyBox.getSkyBoxPlanes());
|
||||
|
||||
// Set up sea surface
|
||||
SeaSurface sea = new SeaSurface(750, 200);
|
||||
sea.setX(250);
|
||||
sea.setZ(210);
|
||||
viewSubjects.add(sea);
|
||||
// SeaSurface sea = new SeaSurface(750, 200);
|
||||
// sea.setX(250);
|
||||
// sea.setZ(210);
|
||||
// viewSubjects.add(sea);
|
||||
|
||||
// Set up sea surface overlay
|
||||
SeaSurface seaOverlay = new SeaSurface(4000, 200);
|
||||
seaOverlay.setX(250);
|
||||
seaOverlay.setZ(210);
|
||||
viewSubjects.add(seaOverlay);
|
||||
// SeaSurface seaOverlay = new SeaSurface(4000, 200);
|
||||
// seaOverlay.setX(250);
|
||||
// seaOverlay.setZ(210);
|
||||
// viewSubjects.add(seaOverlay);
|
||||
// int seaX = 15;
|
||||
// int seaY = 15;
|
||||
int seaX = 15;
|
||||
int seaY = 15;
|
||||
for (int x = 0; x < seaX; x++) {
|
||||
for (int y = 0; y < seaY; y++) {
|
||||
NewSeaSurface seaSurface = new NewSeaSurface();
|
||||
Subject3D seaSubject = new Annotation3D(seaSurface);
|
||||
seaSubject.setXRot(0);
|
||||
// seaSubject.setX(-75 + x * 50);
|
||||
// seaSubject.setZ(-150 + y * 50);
|
||||
// seaSubject.setX(-150 + x * 250);
|
||||
// seaSubject.setZ(-80 + y * 250);
|
||||
seaSubject.setX(-75 + x * 100);
|
||||
seaSubject.setZ(-150 + y * 100);
|
||||
viewSubjects.add(seaSubject);
|
||||
}
|
||||
}
|
||||
|
||||
Boundary3D boundary3D = new Boundary3D(visualiserRace.getVisualiserRaceState().getRaceDataSource().getBoundary(), gpsConverter);
|
||||
for (Subject3D subject3D: boundary3D.getBoundaryNodes()){
|
||||
|
||||
@@ -20,15 +20,19 @@ import java.net.URL;
|
||||
public class Assets3D {
|
||||
|
||||
public static MeshView[] sails;
|
||||
public static MeshView[] sea;
|
||||
public static Subject3D windArrow;
|
||||
public static Subject3D compass;
|
||||
public static Subject3D cwNextArrow;
|
||||
public static Subject3D ccwNextArrow;
|
||||
public static SkyBox skyBox;
|
||||
|
||||
public static void loadAssets(){
|
||||
loadSails();
|
||||
loadWindArrow();
|
||||
loadNextArrow();
|
||||
loadSeaSurface();
|
||||
loadSkybox();
|
||||
}
|
||||
|
||||
private static void loadNextArrow(){
|
||||
@@ -67,6 +71,22 @@ public class Assets3D {
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadSeaSurface(){
|
||||
sea = new MeshView[100];
|
||||
ObjModelImporter objModelImporter = new ObjModelImporter();
|
||||
|
||||
for (int i = 0; i < sea.length; i++){
|
||||
// String path = String.format("assets/Ocean V1.0 Small Animation/Ocean V1.0 Large Animation_%06d.obj", i + 1);
|
||||
// String path = String.format("assets/Ocean V1.0 Animation/Ocean V1.0_%06d.obj", i + 1);
|
||||
String path = String.format("assets/Ocean Animation/Ocean Animation_%06d.obj", i + 1);
|
||||
URL asset = Assets3D.class.getClassLoader().getResource(path);
|
||||
objModelImporter.read(asset);
|
||||
if (objModelImporter.getImport().length > 0) {
|
||||
sea[i] = objModelImporter.getImport()[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Shape3D getBoat(){
|
||||
String path = "assets/V1.4 Boat.x3d";
|
||||
return loadX3d(path);
|
||||
@@ -100,4 +120,8 @@ public class Assets3D {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void loadSkybox(){
|
||||
skyBox = new SkyBox(750, 200, 250, 0, 210);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package visualiser.layout;
|
||||
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.Material;
|
||||
import javafx.scene.paint.PhongMaterial;
|
||||
import javafx.scene.shape.MeshView;
|
||||
|
||||
/**
|
||||
* Created by Gondr on 27/09/2017.
|
||||
*/
|
||||
public class NewSeaSurface extends MeshView{
|
||||
private int seaIndex = 0;
|
||||
|
||||
private AnimationTimer seaRipple = new AnimationTimer() {
|
||||
@Override
|
||||
public void handle(long now) {
|
||||
seaIndex = (seaIndex + 1) % Assets3D.sea.length;
|
||||
setMesh(Assets3D.sea[seaIndex].getMesh());
|
||||
}
|
||||
};
|
||||
|
||||
public NewSeaSurface(){
|
||||
super(Assets3D.sea[0].getMesh());
|
||||
Color seaBlue = new Color(0.284, 0.573, 1.00, 1);
|
||||
Material seaMat = new PhongMaterial(seaBlue);
|
||||
setMaterial(seaMat);
|
||||
seaRipple.start();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package visualiser.layout;
|
||||
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.geometry.Point3D;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
@@ -16,7 +17,7 @@ import visualiser.utils.PerlinNoiseGenerator;
|
||||
/**
|
||||
* Creates a SeaSurface
|
||||
*/
|
||||
public class SeaSurface extends Subject3D {
|
||||
public class SeaSurface extends Annotation3D {
|
||||
private static Image image;
|
||||
|
||||
/**
|
||||
@@ -26,7 +27,7 @@ public class SeaSurface extends Subject3D {
|
||||
* @param freq frequency the perlin noise is to be generated at
|
||||
*/
|
||||
public SeaSurface(int size, double freq) {
|
||||
super(createSurface(size, freq), 0);
|
||||
super(createSurface(size, freq));
|
||||
image = new Image(getClass().getClassLoader().getResourceAsStream("images/skybox/ThickCloudsWaterDown2048.png"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user