diff --git a/src/main/java/seng302/visualiser/GameView3D.java b/src/main/java/seng302/visualiser/GameView3D.java index fdaca192..4e6b421d 100644 --- a/src/main/java/seng302/visualiser/GameView3D.java +++ b/src/main/java/seng302/visualiser/GameView3D.java @@ -338,8 +338,7 @@ public class GameView3D extends GameView{ ((ChaseCamera) chaseCam).setPlayerBoat(newBoat); ((TopDownCamera) topDownCam).setPlayerBoat(newBoat); - newBoat.setMarkIndicator( - ModelFactory.importModel(ModelType.NEXT_MARK_INDICATOR).getAssets()); + newBoat.setMarkIndicator(ModelFactory.importSTL("mark_pointer.stl")); playerBoat = newBoat; } @@ -562,4 +561,4 @@ public class GameView3D extends GameView{ } } } -} +} \ No newline at end of file diff --git a/src/main/java/seng302/visualiser/fxObjects/assets_3D/BoatObject.java b/src/main/java/seng302/visualiser/fxObjects/assets_3D/BoatObject.java index 9cef0a49..7464f180 100644 --- a/src/main/java/seng302/visualiser/fxObjects/assets_3D/BoatObject.java +++ b/src/main/java/seng302/visualiser/fxObjects/assets_3D/BoatObject.java @@ -11,7 +11,6 @@ import javafx.scene.paint.Color; import javafx.scene.paint.PhongMaterial; import javafx.scene.shape.MeshView; import javafx.scene.transform.Rotate; -import javafx.scene.transform.Scale; import javafx.scene.transform.Translate; /** @@ -37,9 +36,8 @@ public class BoatObject extends Group { private Rotate rotation = new Rotate(0, new Point3D(0,0,1)); // This stuff only matters to the players boat object. - private Group markIndicator; + private MeshView markIndicator; private MeshView playerIndicator; - private Color indicatorColor = Color.BLACK; private ReadOnlyDoubleWrapper rotationProperty; private List selectedBoatListenerListeners = new ArrayList<>(); @@ -93,9 +91,7 @@ public class BoatObject extends Group { Double angle = Math.toDegrees( Math.atan2(boatLoc.getY() - markPoint.getY(), boatLoc.getX() - markPoint.getX())) - 90; - Double radius = 2.7; - Double scale = 0.8; - + Double radius = 0.5; Double originX = this.getLayoutX(); Double originY = this.getLayoutY(); @@ -104,8 +100,7 @@ public class BoatObject extends Group { markIndicator.getTransforms().clear(); markIndicator.getTransforms().addAll( new Rotate(angle, new Point3D(0, 0, 1)), - new Translate(0, -radius, 0.1), - new Scale(scale, scale, scale / 10) + new Translate(0, -radius, 0) ); } @@ -148,33 +143,24 @@ public class BoatObject extends Group { } } - public void setMarkIndicator(Group indicator) { + public void setMarkIndicator(MeshView indicator) { this.markIndicator = indicator; this.getChildren().add(markIndicator); createPlayerIndicator(); - setIndicatorColor(indicatorColor); + setIndicatorColor(); } private void createPlayerIndicator() { - Model torus = ModelFactory.importModel(ModelType.PLAYER_IDENTIFIER_TORUS); - torus.getAssets().getTransforms().addAll( - new Rotate(90, new Point3D(1, 0, 0)), - new Scale(0.7, 0.7, 0.7), - new Translate(0, 0.1, 0) - ); - - this.getChildren().add(torus.getAssets()); - playerIndicator = (MeshView) ((Group) ((Group) torus.getAssets().getChildren().get(0)) - .getChildren().get(0)).getChildren().get(0); + MeshView torus = ModelFactory.importSTL("player_circle.stl"); + playerIndicator = torus; + this.getChildren().add(torus); } - public void setIndicatorColor(Color color) { - this.indicatorColor = color; - MeshView markIndicatorMesh = (MeshView) ((Group) ((Group) this.markIndicator.getChildren() - .get(0)) - .getChildren().get(0)).getChildren().get(0); - markIndicatorMesh.setMaterial(new PhongMaterial(color)); - playerIndicator.setMaterial(new PhongMaterial(color)); + public void setIndicatorColor() { + Platform.runLater(() -> { + markIndicator.setMaterial(new PhongMaterial(Color.DARKORANGE)); + playerIndicator.setMaterial(new PhongMaterial(colour)); + }); } public Group getWake () { diff --git a/src/main/java/seng302/visualiser/fxObjects/assets_3D/ModelFactory.java b/src/main/java/seng302/visualiser/fxObjects/assets_3D/ModelFactory.java index c794b77b..bc0ce008 100644 --- a/src/main/java/seng302/visualiser/fxObjects/assets_3D/ModelFactory.java +++ b/src/main/java/seng302/visualiser/fxObjects/assets_3D/ModelFactory.java @@ -115,9 +115,9 @@ public class ModelFactory { private static Group getUnmodifiedBoatModel(BoatMeshType boatType, Color primaryColour) { Group boatAssets = new Group(); - MeshView hull = importSTL(boatType.hullFile); + MeshView hull = importBoatSTL(boatType.hullFile); hull.setMaterial(new PhongMaterial(primaryColour)); - MeshView sail = importSTL(boatType.sailFile); + MeshView sail = importBoatSTL(boatType.sailFile); sail.setMaterial( new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.BLACK : Color.WHITE) ); @@ -125,13 +125,13 @@ public class ModelFactory { boatAssets.getChildren().addAll(hull, sail); if (boatType.mastFile != null) { - MeshView mast = importSTL(boatType.mastFile); + MeshView mast = importBoatSTL(boatType.mastFile); mast.setMaterial(new PhongMaterial(primaryColour)); boatAssets.getChildren().add(mast); } if (boatType.jibFile != null) { - MeshView jib = importSTL(boatType.jibFile); + MeshView jib = importBoatSTL(boatType.jibFile); sail.setMaterial( new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.DARKGRAY : Color.WHITE) ); @@ -141,9 +141,13 @@ public class ModelFactory { return boatAssets; } - private static MeshView importSTL(String fileName) { + private static MeshView importBoatSTL(String fileName) { + return importSTL("boatSTLs/" + fileName); + } + + public static MeshView importSTL(String fileName) { StlMeshImporter importer = new StlMeshImporter(); - importer.read(ModelFactory.class.getResource("/meshes/boatSTLs/" + fileName)); + importer.read(ModelFactory.class.getResource("/meshes/" + fileName)); MeshView importedFile = new MeshView(importer.getImport()); importedFile.setCache(true); importedFile.setCacheHint(CacheHint.SCALE_AND_ROTATE); diff --git a/src/main/resources/meshes/mark_pointer.stl b/src/main/resources/meshes/mark_pointer.stl new file mode 100644 index 00000000..be51d3f3 Binary files /dev/null and b/src/main/resources/meshes/mark_pointer.stl differ diff --git a/src/main/resources/meshes/player_circle.stl b/src/main/resources/meshes/player_circle.stl new file mode 100644 index 00000000..5afc2bdd Binary files /dev/null and b/src/main/resources/meshes/player_circle.stl differ