mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Merge branch 'develop' into story1273_minimap
# Conflicts: # src/main/java/seng302/visualiser/fxObjects/assets_3D/ModelFactory.java # src/main/resources/views/RaceView.fxml
This commit is contained in:
@@ -7,6 +7,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.geometry.Point2D;
|
||||
import javafx.geometry.Point3D;
|
||||
import javafx.scene.Camera;
|
||||
@@ -69,6 +70,8 @@ public class GameView3D extends GameView {
|
||||
/* Note that if either of these is null then values for it have not been added and the other
|
||||
should be used as the limits of the map. */
|
||||
private Map<Mark, Marker3D> markerObjects;
|
||||
|
||||
private BoatObject playerBoat;
|
||||
private Map<ClientYacht, BoatObject> boatObjects = new HashMap<>();
|
||||
private Group wakesGroup = new Group();
|
||||
private Group boatObjectGroup = new Group();
|
||||
@@ -334,9 +337,35 @@ public class GameView3D extends GameView {
|
||||
ViewManager.getInstance().getGameClient().getServerThread().getClientId())) {
|
||||
((ChaseCamera) chaseCam).setPlayerBoat(newBoat);
|
||||
((TopDownCamera) topDownCam).setPlayerBoat(newBoat);
|
||||
|
||||
newBoat.setMarkIndicator(ModelFactory.importSTL("mark_pointer.stl"));
|
||||
playerBoat = newBoat;
|
||||
|
||||
}
|
||||
}
|
||||
Platform.runLater(() -> {
|
||||
ClientYacht playerYacht = ViewManager.getInstance().getGameClient().getAllBoatsMap()
|
||||
.get(ViewManager.getInstance().getGameClient().getServerThread().getClientId());
|
||||
|
||||
for (ObservableValue o : Arrays
|
||||
.asList(playerBoat.layoutXProperty(), playerBoat.layoutXProperty())) {
|
||||
o.addListener((obs, oldVal, newVal) -> {
|
||||
|
||||
List<Mark> marks = course.get(playerYacht.getLegNumber()).getMarks();
|
||||
Point2D midPoint = new Point2D(0, 0);
|
||||
if (marks.size() == 1) {
|
||||
midPoint = scaledPoint.findScaledXY(marks.get(0));
|
||||
} else if (marks.size() == 2) {
|
||||
midPoint = (scaledPoint.findScaledXY(marks.get(0)))
|
||||
.midpoint(scaledPoint.findScaledXY(marks.get(1)));
|
||||
}
|
||||
|
||||
if (midPoint != null) {
|
||||
playerBoat.updateMarkIndicator(midPoint);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
gameObjects.getChildren().addAll(wakes);
|
||||
gameObjects.getChildren().addAll(boatObjectGroup);
|
||||
});
|
||||
@@ -532,4 +561,4 @@ public class GameView3D extends GameView {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,33 @@ package seng302.visualiser.controllers;
|
||||
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXDialog;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.application.Platform;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.geometry.Point3D;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.transform.Rotate;
|
||||
import javafx.scene.transform.Scale;
|
||||
import javafx.scene.transform.Translate;
|
||||
import seng302.discoveryServer.DiscoveryServerClient;
|
||||
import seng302.gameServer.GameStages;
|
||||
import seng302.gameServer.GameState;
|
||||
@@ -27,13 +43,10 @@ import seng302.utilities.Sounds;
|
||||
import seng302.visualiser.MapPreview;
|
||||
import seng302.visualiser.controllers.cells.PlayerCell;
|
||||
import seng302.visualiser.controllers.dialogs.BoatCustomizeController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import seng302.visualiser.controllers.dialogs.PopupDialogController;
|
||||
import seng302.visualiser.controllers.dialogs.TokenInfoDialogController;
|
||||
import seng302.visualiser.fxObjects.assets_3D.ModelFactory;
|
||||
import seng302.visualiser.fxObjects.assets_3D.ModelType;
|
||||
|
||||
public class LobbyController implements Initializable {
|
||||
|
||||
@@ -57,10 +70,13 @@ public class LobbyController implements Initializable {
|
||||
private AnchorPane serverMap;
|
||||
@FXML
|
||||
private Label roomLabel;
|
||||
@FXML
|
||||
private Pane speedTokenPane, handlingTokenPane, windWalkerTokenPane, bumperTokenPane, randomTokenPane;
|
||||
//---------FXML END---------//
|
||||
|
||||
private RaceState raceState;
|
||||
private JFXDialog customizationDialog;
|
||||
private JFXDialog tokenInfoDialog;
|
||||
public Color playersColor;
|
||||
private Map<Integer, ClientYacht> playerBoats;
|
||||
private Double mapWidth = INITIAL_MAP_WIDTH, mapHeight = INITIAL_MAP_HEIGHT;
|
||||
@@ -128,6 +144,107 @@ public class LobbyController implements Initializable {
|
||||
beginRaceButton.setOnMouseEntered(e -> Sounds.playHoverSound());
|
||||
|
||||
initMapPreview();
|
||||
initTokenPreviews();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialises the tokens in the side panel
|
||||
*/
|
||||
private void initTokenPreviews() {
|
||||
Group speedToken = ModelFactory.importModel(ModelType.VELOCITY_PICKUP).getAssets();
|
||||
Group handlingToken = ModelFactory.importModel(ModelType.HANDLING_PICKUP).getAssets();
|
||||
Group windWalkerToken = ModelFactory.importModel(ModelType.WIND_WALKER_PICKUP).getAssets();
|
||||
Group bumperToken = ModelFactory.importModel(ModelType.BUMPER_PICKUP).getAssets();
|
||||
Group randomToken = ModelFactory.importModel(ModelType.RANDOM_PICKUP).getAssets();
|
||||
|
||||
HashMap<Pane, Group> tokenPanes = new HashMap<>();
|
||||
tokenPanes.put(speedTokenPane, speedToken);
|
||||
tokenPanes.put(handlingTokenPane, handlingToken);
|
||||
tokenPanes.put(windWalkerTokenPane, windWalkerToken);
|
||||
tokenPanes.put(bumperTokenPane, bumperToken);
|
||||
tokenPanes.put(randomTokenPane, randomToken);
|
||||
|
||||
Scale hoverScale = new Scale(1.2, 1.2, 1.2);
|
||||
|
||||
tokenPanes.entrySet().forEach((entry) -> {
|
||||
Pane thisPane = entry.getKey();
|
||||
Group thisToken = entry.getValue();
|
||||
|
||||
thisToken.getTransforms().addAll(
|
||||
new Translate(40, 50, 0),
|
||||
new Scale(13, 13, 13));
|
||||
|
||||
thisPane.setOnMouseEntered(event -> {
|
||||
thisToken.getTransforms().add(hoverScale);
|
||||
});
|
||||
thisPane.setOnMouseExited(event -> {
|
||||
thisToken.getTransforms().remove(hoverScale);
|
||||
});
|
||||
thisPane.setOnMouseReleased(event -> {
|
||||
tokenInfoDialog = makeTokenDialog(thisPane);
|
||||
tokenInfoDialog.show();
|
||||
});
|
||||
|
||||
thisPane.getChildren().add(thisToken);
|
||||
});
|
||||
|
||||
//Hacky rotations for wind and random to level it in the plane
|
||||
windWalkerToken.getTransforms().addAll(
|
||||
new Rotate(-70, new Point3D(1, 0, 0)),
|
||||
new Translate(0, 2,0)
|
||||
);
|
||||
randomToken.getTransforms().addAll(
|
||||
new Rotate(-90, new Point3D(1, 0, 0)),
|
||||
new Translate(0, 0,1)
|
||||
);
|
||||
}
|
||||
|
||||
private JFXDialog makeTokenDialog(Pane inducingPane) {
|
||||
String header = "...";
|
||||
String body = "Nothing to see here";
|
||||
ModelType modelType = ModelType.RANDOM_PICKUP;
|
||||
|
||||
if (inducingPane == speedTokenPane) {
|
||||
header = "Speed Boost";
|
||||
body = "Increases your max velocity";
|
||||
modelType = ModelType.VELOCITY_PICKUP;
|
||||
} else if (inducingPane == handlingTokenPane) {
|
||||
header = "Handling Boost";
|
||||
body = "Increases your turing rate";
|
||||
modelType = ModelType.HANDLING_PICKUP;
|
||||
} else if (inducingPane == windWalkerTokenPane) {
|
||||
header = "Wind Walker";
|
||||
body = "The wind now rotates with you, giving you your optimal speed in all directions";
|
||||
modelType = ModelType.WIND_WALKER_PICKUP;
|
||||
} else if (inducingPane == bumperTokenPane) {
|
||||
header = "Bumper";
|
||||
body = "While this is active, upon hitting another boat, you will power it down for a short time";
|
||||
modelType = ModelType.BUMPER_PICKUP;
|
||||
} else if (inducingPane == randomTokenPane) {
|
||||
header = "Random";
|
||||
body = "A 50% chance of becoming any other token and a 50% chance of slowing your boat for a time";
|
||||
modelType = ModelType.RANDOM_PICKUP;
|
||||
}
|
||||
|
||||
FXMLLoader dialog = new FXMLLoader(
|
||||
getClass().getResource("/views/dialogs/TokenInfoDialog.fxml"));
|
||||
|
||||
JFXDialog tokenInfoDialog = null;
|
||||
|
||||
try {
|
||||
tokenInfoDialog = new JFXDialog(serverListMainStackPane, dialog.load(),
|
||||
JFXDialog.DialogTransition.CENTER);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
TokenInfoDialogController controller = dialog.getController();
|
||||
controller.setParentController(this);
|
||||
controller.setHeader(header);
|
||||
controller.setContent(body);
|
||||
controller.setToken(modelType);
|
||||
return tokenInfoDialog;
|
||||
}
|
||||
|
||||
private JFXDialog createCustomizeDialog() {
|
||||
@@ -252,6 +369,10 @@ public class LobbyController implements Initializable {
|
||||
customizationDialog.close();
|
||||
}
|
||||
|
||||
public void closeTokenInfoDialog() {
|
||||
tokenInfoDialog.close();
|
||||
}
|
||||
|
||||
public void setRoomCode(String roomCode) {
|
||||
roomLabel.setText("Room: " + roomCode);
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ public class ViewManager {
|
||||
Stage stage = new Stage();
|
||||
initialStartView(stage);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.warn("Could not go to start view");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,12 +28,12 @@ public class ServerCreationController implements Initializable {
|
||||
@FXML
|
||||
private JFXSlider maxPlayersSlider;
|
||||
@FXML
|
||||
private Label maxPlayersLabel;
|
||||
@FXML
|
||||
private JFXButton submitBtn;
|
||||
@FXML
|
||||
private Label closeLabel;
|
||||
@FXML
|
||||
private Label maxPlayersLabel;
|
||||
@FXML
|
||||
private JFXButton nextMapButton;
|
||||
@FXML
|
||||
private JFXButton lastMapButton;
|
||||
@@ -47,11 +47,10 @@ public class ServerCreationController implements Initializable {
|
||||
private JFXCheckBox pickupsCheckBox;
|
||||
@FXML
|
||||
private AnchorPane mapHolder;
|
||||
//---------FXML END---------//
|
||||
|
||||
private MapMaker mapMaker = MapMaker.getInstance();
|
||||
|
||||
//---------FXML END---------//
|
||||
|
||||
private List<ServerCreationDialogListener> serverCreationDialogListeners;
|
||||
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
@@ -96,7 +95,7 @@ public class ServerCreationController implements Initializable {
|
||||
mapHolder.getChildren().setAll(mapMaker.getCurrentGameView());
|
||||
mapNameLabel.setText(mapMaker.getCurrentRegatta().getCourseName());
|
||||
pickupsCheckBox.setSelected(true);
|
||||
//closeLabel.setOnMouseClicked(event -> notifyListeners());
|
||||
closeLabel.setOnMouseClicked(event -> notifyListeners());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +133,8 @@ public class ServerCreationController implements Initializable {
|
||||
*/
|
||||
private void updateMaxPlayerLabel() {
|
||||
maxPlayersSlider.setValue(Math.floor(maxPlayersSlider.getValue()));
|
||||
maxPlayersLabel.setText(String.format("Max players: %.0f", maxPlayersSlider.getValue()));
|
||||
maxPlayersLabel.setText(String
|
||||
.format("Only %.0f players are allowed into the game", maxPlayersSlider.getValue()));
|
||||
}
|
||||
|
||||
private void updateLegSliderLabel() {
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package seng302.visualiser.controllers.dialogs;
|
||||
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXTextArea;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.geometry.Point3D;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.transform.Rotate;
|
||||
import javafx.scene.transform.Scale;
|
||||
import javafx.scene.transform.Translate;
|
||||
import seng302.utilities.Sounds;
|
||||
import seng302.visualiser.controllers.LobbyController;
|
||||
import seng302.visualiser.fxObjects.assets_3D.ModelFactory;
|
||||
import seng302.visualiser.fxObjects.assets_3D.ModelType;
|
||||
|
||||
/**
|
||||
* Created by wmu16 on 28/09/17.
|
||||
*/
|
||||
public class TokenInfoDialogController implements Initializable {
|
||||
|
||||
@FXML
|
||||
private Label headerLabel;
|
||||
@FXML
|
||||
private TextArea contentText;
|
||||
@FXML
|
||||
private Pane tokenPane;
|
||||
@FXML
|
||||
private Button optionButton;
|
||||
|
||||
private LobbyController lobbyController;
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
optionButton.setOnMouseReleased(event -> {
|
||||
Sounds.playButtonClick();
|
||||
lobbyController.closeTokenInfoDialog();
|
||||
});
|
||||
|
||||
contentText.setEditable(false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void setContent(String content) {
|
||||
contentText.setText(content);
|
||||
}
|
||||
|
||||
public void setHeader(String header) {
|
||||
this.headerLabel.setText(header);
|
||||
}
|
||||
|
||||
public void setToken(ModelType token) {
|
||||
tokenPane.getChildren().clear();
|
||||
|
||||
Group tokenObject = ModelFactory.importModel(token).getAssets();
|
||||
|
||||
tokenObject.getTransforms().addAll(
|
||||
new Translate(138 / 2, 138 / 2, 0),
|
||||
new Scale(20, 20, 20));
|
||||
|
||||
if (token == ModelType.WIND_WALKER_PICKUP) {
|
||||
tokenObject.getTransforms().addAll(
|
||||
new Rotate(-70, new Point3D(1, 0, 0)),
|
||||
new Translate(0, 2, 0)
|
||||
);
|
||||
} else if (token == ModelType.RANDOM_PICKUP) {
|
||||
tokenObject.getTransforms().addAll(
|
||||
new Rotate(-90, new Point3D(1, 0, 0)),
|
||||
new Translate(0, 0, 1)
|
||||
);
|
||||
}
|
||||
|
||||
tokenPane.getChildren().add(tokenObject);
|
||||
}
|
||||
|
||||
public void setParentController(LobbyController lobbyController) {
|
||||
this.lobbyController = lobbyController;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -13,7 +13,8 @@ public enum BoatMeshType {
|
||||
PIRATE_SHIP("pirateship_hull.stl", "pirateship_mast.stl", -0.5415, "pirateship_mainsail.stl",
|
||||
-0.5415, "pirateship_frontsail.stl", true, 1.2, 1.6, 1.2),
|
||||
DUCKY("ducky_hull.stl", "ducky_mast.stl", -2.18539, "ducky_sail.stl", -2.18539, "ducky_eyes.stl", false, 1.2, 1.1, 1.4),
|
||||
PARROT("parrot_hull.stl", null, 0, "parrot_sail.stl", 0, "parrot_features.stl", true, 1, 1, 1);
|
||||
PARROT("parrot_hull.stl", null, 0, "parrot_sail.stl", 0, "parrot_features.stl", true, 1, 1, 1),
|
||||
WAKA("waka_hull.stl", "waka_mast.stl", 0, "waka_sail.stl", 0, null, true, 1.7, 0.5, 1.5);
|
||||
|
||||
final String hullFile, mastFile, sailFile, jibFile;
|
||||
final double mastOffset, sailOffset;
|
||||
@@ -21,7 +22,7 @@ public enum BoatMeshType {
|
||||
public final double accelerationMultiplier;
|
||||
public final double turnStep;
|
||||
final boolean fixedSail;
|
||||
final static BoatMeshType[] boatTypes = new BoatMeshType[]{DINGHY, CATAMARAN, PIRATE_SHIP, DUCKY, PARROT};
|
||||
final static BoatMeshType[] boatTypes = new BoatMeshType[]{DINGHY, CATAMARAN, PIRATE_SHIP, DUCKY, PARROT, WAKA};
|
||||
|
||||
BoatMeshType(String hullFile, String mastFile, double mastOffset, String sailFile,
|
||||
double sailOffset, String jibFile, boolean fixedSail, double maxSpeedMultiplier, double accelerationMultiplier, double turnStep) {
|
||||
|
||||
@@ -4,10 +4,14 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.ReadOnlyDoubleWrapper;
|
||||
import javafx.geometry.Point2D;
|
||||
import javafx.geometry.Point3D;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.PhongMaterial;
|
||||
import javafx.scene.shape.MeshView;
|
||||
import javafx.scene.transform.Rotate;
|
||||
import javafx.scene.transform.Translate;
|
||||
|
||||
/**
|
||||
* BoatGroup is a javafx group that by default contains a graphical objects for representing a 2
|
||||
@@ -30,9 +34,10 @@ public class BoatObject extends Group {
|
||||
private Color colour = Color.BLACK;
|
||||
private Boolean isSelected = false;
|
||||
private Rotate rotation = new Rotate(0, new Point3D(0,0,1));
|
||||
// private Rotate tilt = new Rotate(0, new Point3D(0, 1, 0));
|
||||
private double previousRotation = 0;
|
||||
|
||||
// This stuff only matters to the players boat object.
|
||||
private MeshView markIndicator;
|
||||
private MeshView playerIndicator;
|
||||
private ReadOnlyDoubleWrapper rotationProperty;
|
||||
|
||||
private List<SelectedBoatListener> selectedBoatListenerListeners = new ArrayList<>();
|
||||
@@ -81,6 +86,19 @@ public class BoatObject extends Group {
|
||||
});
|
||||
}
|
||||
|
||||
public void updateMarkIndicator(Point2D markPoint) {
|
||||
Point2D boatLoc = new Point2D(this.getLayoutX(), this.getLayoutY());
|
||||
Double angle = Math.toDegrees(
|
||||
Math.atan2(boatLoc.getY() - markPoint.getY(), boatLoc.getX() - markPoint.getX())) - 90;
|
||||
|
||||
Double radius = 0.5;
|
||||
markIndicator.getTransforms().clear();
|
||||
markIndicator.getTransforms().addAll(
|
||||
new Rotate(angle, new Point3D(0, 0, 1)),
|
||||
new Translate(0, -radius, 0)
|
||||
);
|
||||
}
|
||||
|
||||
private Double normalizeHeading(double heading, double windDirection) {
|
||||
Double normalizedHeading = heading - windDirection;
|
||||
normalizedHeading = (double) Math.floorMod(normalizedHeading.longValue(), 360L);
|
||||
@@ -91,14 +109,6 @@ public class BoatObject extends Group {
|
||||
private void rotateTo(double heading, boolean sailsIn, double windDir) {
|
||||
rotationProperty.set(heading);
|
||||
rotation.setAngle(heading);
|
||||
// if (heading == previousRotation) {
|
||||
// tilt.setAngle(0);
|
||||
// } else if (heading < previousRotation) {
|
||||
// tilt.setAngle(-10);
|
||||
// } else {
|
||||
// tilt.setAngle(10);
|
||||
// }
|
||||
// previousRotation = heading;
|
||||
wake.getTransforms().setAll(new Rotate(heading, new Point3D(0,0,1)));
|
||||
if (sailsIn) {
|
||||
boatAssets.showSail();
|
||||
@@ -128,6 +138,26 @@ public class BoatObject extends Group {
|
||||
}
|
||||
}
|
||||
|
||||
public void setMarkIndicator(MeshView indicator) {
|
||||
this.markIndicator = indicator;
|
||||
this.getChildren().add(markIndicator);
|
||||
createPlayerIndicator();
|
||||
setIndicatorColor();
|
||||
}
|
||||
|
||||
private void createPlayerIndicator() {
|
||||
MeshView torus = ModelFactory.importSTL("player_circle.stl");
|
||||
playerIndicator = torus;
|
||||
this.getChildren().add(torus);
|
||||
}
|
||||
|
||||
public void setIndicatorColor() {
|
||||
Platform.runLater(() -> {
|
||||
markIndicator.setMaterial(new PhongMaterial(Color.DARKORANGE));
|
||||
playerIndicator.setMaterial(new PhongMaterial(colour));
|
||||
});
|
||||
}
|
||||
|
||||
public Group getWake () {
|
||||
return wake;
|
||||
}
|
||||
|
||||
@@ -80,30 +80,6 @@ public class ModelFactory {
|
||||
return bo;
|
||||
}
|
||||
|
||||
public static BoatModel boatRotatingView(BoatMeshType boatType, Color primaryColour) {
|
||||
Group boatAssets = getUnmodifiedBoatModel(boatType, primaryColour);
|
||||
boatAssets.getTransforms().addAll(
|
||||
new Scale(40, 40, 40),
|
||||
new Rotate(90, new Point3D(0,0,1)),
|
||||
new Rotate(90, new Point3D(0, 1, 0))
|
||||
);
|
||||
|
||||
final Rotate animationRotate = new Rotate(0, new Point3D(1,1,1));
|
||||
boatAssets.getTransforms().add(animationRotate);
|
||||
|
||||
return new BoatModel(boatAssets, new AnimationTimer() {
|
||||
|
||||
private double rotation = 0;
|
||||
private Rotate rotate = animationRotate;
|
||||
|
||||
@Override
|
||||
public void handle(long now) {
|
||||
rotation += 0.5;
|
||||
rotate.setAngle(rotation);
|
||||
}
|
||||
}, boatType);
|
||||
}
|
||||
|
||||
public static BoatModel boatGameView(BoatMeshType boatType, Color primaryColour) {
|
||||
Group boatAssets = getUnmodifiedBoatModel(boatType, primaryColour);
|
||||
boatAssets.getTransforms().setAll(
|
||||
@@ -115,26 +91,28 @@ 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));
|
||||
boatAssets.getChildren().addAll(hull);
|
||||
|
||||
if (boatType.mastFile != null) {
|
||||
MeshView mast = importSTL(boatType.mastFile);
|
||||
MeshView mast = importBoatSTL(boatType.mastFile);
|
||||
mast.setMaterial(new PhongMaterial(primaryColour));
|
||||
boatAssets.getChildren().add(mast);
|
||||
} else {
|
||||
boatAssets.getChildren().add(new Group());
|
||||
}
|
||||
|
||||
MeshView sail = importSTL(boatType.sailFile);
|
||||
MeshView sail = importBoatSTL(boatType.sailFile);
|
||||
sail.setMaterial(
|
||||
new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.DARKGRAY : Color.WHITE)
|
||||
new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.BLACK : Color.WHITE)
|
||||
);
|
||||
boatAssets.getChildren().addAll(sail);
|
||||
|
||||
if (boatType.jibFile != null) {
|
||||
MeshView jib = importSTL(boatType.jibFile);
|
||||
jib.setMaterial(
|
||||
new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.BLACK : Color.WHITE)
|
||||
MeshView jib = importBoatSTL(boatType.jibFile);
|
||||
sail.setMaterial(
|
||||
new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.DARKGRAY : Color.WHITE)
|
||||
);
|
||||
boatAssets.getChildren().add(jib);
|
||||
}
|
||||
@@ -142,9 +120,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);
|
||||
@@ -163,6 +145,10 @@ public class ModelFactory {
|
||||
assets.setCacheHint(CacheHint.SCALE_AND_ROTATE);
|
||||
}
|
||||
switch (tokenType) {
|
||||
case PLAYER_IDENTIFIER_TORUS:
|
||||
return makeIdentifierTorus(assets);
|
||||
case NEXT_MARK_INDICATOR:
|
||||
return makeNextMarkIndicator(assets);
|
||||
case VELOCITY_PICKUP:
|
||||
case BUMPER_PICKUP:
|
||||
case RANDOM_PICKUP:
|
||||
@@ -197,6 +183,16 @@ public class ModelFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private static Model makeIdentifierTorus(Group assets) {
|
||||
// assets.getChildren().add(new AmbientLight());
|
||||
return new Model(new Group(assets), null);
|
||||
}
|
||||
|
||||
private static Model makeNextMarkIndicator(Group assets) {
|
||||
// assets.getChildren().add(new AmbientLight());
|
||||
return new Model(new Group(assets), null);
|
||||
}
|
||||
|
||||
private static Model makeTokenPickup(Group assets) {
|
||||
Rotate animationRotate = new Rotate(0, new Point3D(0, 0, 1));
|
||||
assets.getTransforms().addAll(
|
||||
|
||||
@@ -28,7 +28,9 @@ public enum ModelType {
|
||||
START_ARROW ("start_arrow.dae"),
|
||||
FINISH_ARROW ("finish_arrow.dae"),
|
||||
LAND("land.dae"),
|
||||
LAND_SMOOTH("land_smooth.dae");
|
||||
LAND_SMOOTH("land_smooth.dae"),
|
||||
NEXT_MARK_INDICATOR("indicator_arrow.dae"),
|
||||
PLAYER_IDENTIFIER_TORUS("torus.dae");
|
||||
|
||||
final String filename;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user