mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 09c02d5c54 | |||
| 08c34a0b1e |
@@ -1,14 +1,5 @@
|
|||||||
package seng302.visualiser;
|
package seng302.visualiser;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
|
||||||
import javafx.util.Pair;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import seng302.gameServer.messages.*;
|
|
||||||
import seng302.model.stream.packets.PacketType;
|
|
||||||
import seng302.model.stream.packets.StreamPacket;
|
|
||||||
import seng302.utilities.XMLParser;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -23,6 +14,7 @@ import java.util.TimerTask;
|
|||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.zip.CRC32;
|
import java.util.zip.CRC32;
|
||||||
import java.util.zip.Checksum;
|
import java.util.zip.Checksum;
|
||||||
|
import javafx.application.Platform;
|
||||||
import javafx.util.Pair;
|
import javafx.util.Pair;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -99,6 +91,7 @@ public class ClientToServerThread implements Runnable {
|
|||||||
|
|
||||||
private ByteArrayOutputStream crcBuffer;
|
private ByteArrayOutputStream crcBuffer;
|
||||||
private boolean socketOpen = true;
|
private boolean socketOpen = true;
|
||||||
|
private boolean ignoreDC = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for ClientToServerThread which takes in ipAddress and portNumber and attempts to
|
* Constructor for ClientToServerThread which takes in ipAddress and portNumber and attempts to
|
||||||
@@ -181,8 +174,10 @@ public class ClientToServerThread implements Runnable {
|
|||||||
closeSocket();
|
closeSocket();
|
||||||
|
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
|
if (ignoreDC) {
|
||||||
ViewManager.getInstance().showErrorSnackBar("Server rejected connection.");
|
ViewManager.getInstance().showErrorSnackBar("Server rejected connection.");
|
||||||
ViewManager.getInstance().goToStartView();
|
ViewManager.getInstance().goToStartView();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +193,7 @@ public class ClientToServerThread implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void notifyDisconnectListeners (String message) {
|
private void notifyDisconnectListeners (String message) {
|
||||||
if (socketOpen) {
|
if (socketOpen && !ignoreDC) {
|
||||||
for (DisconnectedFromHostListener listener : disconnectionListeners) {
|
for (DisconnectedFromHostListener listener : disconnectionListeners) {
|
||||||
listener.notifyDisconnection(message);
|
listener.notifyDisconnection(message);
|
||||||
}
|
}
|
||||||
@@ -448,4 +443,8 @@ public class ClientToServerThread implements Runnable {
|
|||||||
public boolean hasStarted() {
|
public boolean hasStarted() {
|
||||||
return isStarted;
|
return isStarted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ignoreDC() {
|
||||||
|
ignoreDC = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,12 +49,6 @@ import seng302.visualiser.controllers.RaceViewController;
|
|||||||
import seng302.visualiser.controllers.ViewManager;
|
import seng302.visualiser.controllers.ViewManager;
|
||||||
import seng302.visualiser.controllers.dialogs.PopupDialogController;
|
import seng302.visualiser.controllers.dialogs.PopupDialogController;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZoneOffset;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is a client side instance of a yacht racing game in JavaFX. The game is instantiated
|
* This class is a client side instance of a yacht racing game in JavaFX. The game is instantiated
|
||||||
* with a JavaFX Pane to insert itself into.
|
* with a JavaFX Pane to insert itself into.
|
||||||
@@ -210,7 +204,11 @@ public class GameClient {
|
|||||||
controller.setContent(message);
|
controller.setContent(message);
|
||||||
controller.setOptionButtonText("GO HOME");
|
controller.setOptionButtonText("GO HOME");
|
||||||
controller
|
controller
|
||||||
.setOptionButtonEventHandler(event -> ViewManager.getInstance().goToStartView());
|
.setOptionButtonEventHandler(event -> {
|
||||||
|
System.out.println("inShowConnectionError");
|
||||||
|
ViewManager.getInstance().goToStartView();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javafx.animation.AnimationTimer;
|
import javafx.animation.AnimationTimer;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.value.ObservableValue;
|
|
||||||
import javafx.geometry.Point2D;
|
import javafx.geometry.Point2D;
|
||||||
import javafx.geometry.Point3D;
|
import javafx.geometry.Point3D;
|
||||||
import javafx.scene.Camera;
|
import javafx.scene.Camera;
|
||||||
@@ -55,7 +54,7 @@ public class GameView3D extends GameView{
|
|||||||
|
|
||||||
private final double FOV = 60;
|
private final double FOV = 60;
|
||||||
private final double DEFAULT_CAMERA_X = 0;
|
private final double DEFAULT_CAMERA_X = 0;
|
||||||
private final double DEFAULT_CAMERA_Y = 100;
|
private final double DEFAULT_CAMERA_Y = 160;
|
||||||
|
|
||||||
private Group root3D;
|
private Group root3D;
|
||||||
private SubScene view;
|
private SubScene view;
|
||||||
@@ -70,8 +69,6 @@ public class GameView3D extends GameView{
|
|||||||
/* Note that if either of these is null then values for it have not been added and the other
|
/* 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. */
|
should be used as the limits of the map. */
|
||||||
private Map<Mark, Marker3D> markerObjects;
|
private Map<Mark, Marker3D> markerObjects;
|
||||||
|
|
||||||
private BoatObject playerBoat;
|
|
||||||
private Map<ClientYacht, BoatObject> boatObjects = new HashMap<>();
|
private Map<ClientYacht, BoatObject> boatObjects = new HashMap<>();
|
||||||
private Group wakesGroup = new Group();
|
private Group wakesGroup = new Group();
|
||||||
private Group boatObjectGroup = new Group();
|
private Group boatObjectGroup = new Group();
|
||||||
@@ -170,6 +167,7 @@ public class GameView3D extends GameView{
|
|||||||
}
|
}
|
||||||
|
|
||||||
createMarkArrows();
|
createMarkArrows();
|
||||||
|
course.get(0).getMarks().forEach((mark -> markerObjects.get(mark).showNextExitArrow()));
|
||||||
|
|
||||||
//Scale race to markers if there is no border.
|
//Scale race to markers if there is no border.
|
||||||
if (borderPoints == null) {
|
if (borderPoints == null) {
|
||||||
@@ -337,35 +335,9 @@ public class GameView3D extends GameView{
|
|||||||
ViewManager.getInstance().getGameClient().getServerThread().getClientId())) {
|
ViewManager.getInstance().getGameClient().getServerThread().getClientId())) {
|
||||||
((ChaseCamera) chaseCam).setPlayerBoat(newBoat);
|
((ChaseCamera) chaseCam).setPlayerBoat(newBoat);
|
||||||
((TopDownCamera) topDownCam).setPlayerBoat(newBoat);
|
((TopDownCamera) topDownCam).setPlayerBoat(newBoat);
|
||||||
|
|
||||||
newBoat.setMarkIndicator(ModelFactory.importSTL("mark_pointer.stl"));
|
|
||||||
playerBoat = newBoat;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Platform.runLater(() -> {
|
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(wakes);
|
||||||
gameObjects.getChildren().addAll(boatObjectGroup);
|
gameObjects.getChildren().addAll(boatObjectGroup);
|
||||||
});
|
});
|
||||||
@@ -537,7 +509,7 @@ public class GameView3D extends GameView{
|
|||||||
|
|
||||||
private void updateMarkArrows (ClientYacht yacht, int legNumber) {
|
private void updateMarkArrows (ClientYacht yacht, int legNumber) {
|
||||||
CompoundMark compoundMark;
|
CompoundMark compoundMark;
|
||||||
if (legNumber - 1 >= 0) {
|
if (legNumber - 1 >= 0 && legNumber-1 < course.size()) {
|
||||||
Sounds.playMarkRoundingSound();
|
Sounds.playMarkRoundingSound();
|
||||||
compoundMark = course.get(legNumber-1);
|
compoundMark = course.get(legNumber-1);
|
||||||
for (Mark mark : compoundMark.getMarks()) {
|
for (Mark mark : compoundMark.getMarks()) {
|
||||||
@@ -545,7 +517,7 @@ public class GameView3D extends GameView{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
CompoundMark nextMark = null;
|
CompoundMark nextMark = null;
|
||||||
if (legNumber < course.size() - 1) {
|
if (legNumber < course.size()) {
|
||||||
Sounds.playMarkRoundingSound();
|
Sounds.playMarkRoundingSound();
|
||||||
nextMark = course.get(legNumber);
|
nextMark = course.get(legNumber);
|
||||||
for (Mark mark : nextMark.getMarks()) {
|
for (Mark mark : nextMark.getMarks()) {
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ public class IsometricCamera extends PerspectiveCamera implements RaceCamera {
|
|||||||
private final Double MAX_Y = 170.0;
|
private final Double MAX_Y = 170.0;
|
||||||
|
|
||||||
private final Double PAN_LIMIT = 160.0;
|
private final Double PAN_LIMIT = 160.0;
|
||||||
private final Double NEAR_ZOOM_LIMIT = -50.0;
|
private final Double NEAR_ZOOM_LIMIT = -30.0;
|
||||||
private final Double FAR_ZOOM_LIMIT = -160.0;
|
private final Double FAR_ZOOM_LIMIT = -180.0;
|
||||||
|
|
||||||
private Double horizontalPan;
|
private Double horizontalPan;
|
||||||
private Double verticalPan;
|
private Double verticalPan;
|
||||||
@@ -29,7 +29,8 @@ public class IsometricCamera extends PerspectiveCamera implements RaceCamera {
|
|||||||
super(true);
|
super(true);
|
||||||
transforms = this.getTransforms();
|
transforms = this.getTransforms();
|
||||||
|
|
||||||
zoomFactor = (FAR_ZOOM_LIMIT + NEAR_ZOOM_LIMIT) / 2.0;
|
// zoomFactor = (FAR_ZOOM_LIMIT + NEAR_ZOOM_LIMIT) / 2.0;
|
||||||
|
zoomFactor = FAR_ZOOM_LIMIT;
|
||||||
horizontalPan = cameraStartX;
|
horizontalPan = cameraStartX;
|
||||||
verticalPan = cameraStartY;
|
verticalPan = cameraStartY;
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import seng302.visualiser.fxObjects.assets_3D.BoatObject;
|
|||||||
|
|
||||||
public class TopDownCamera extends PerspectiveCamera implements RaceCamera {
|
public class TopDownCamera extends PerspectiveCamera implements RaceCamera {
|
||||||
|
|
||||||
private final Double PAN_LIMIT = 30.0;
|
private final Double PAN_LIMIT = 40d;
|
||||||
private final Double NEAR_ZOOM_LIMIT = -30.0;
|
private final Double NEAR_ZOOM_LIMIT = -35d;
|
||||||
private final Double FAR_ZOOM_LIMIT = -130.0;
|
private final Double FAR_ZOOM_LIMIT = -145d;
|
||||||
private final Double ZOOM_STEP = 2.5;
|
private final Double ZOOM_STEP = 2.5;
|
||||||
|
|
||||||
private ObservableList<Transform> transforms;
|
private ObservableList<Transform> transforms;
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ public class LobbyController implements Initializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void leaveLobby() {
|
private void leaveLobby() {
|
||||||
|
System.out.println("LEFT LOBBY");
|
||||||
ViewManager.getInstance().getGameClient().stopGame();
|
ViewManager.getInstance().getGameClient().stopGame();
|
||||||
ViewManager.getInstance().goToStartView();
|
ViewManager.getInstance().goToStartView();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,7 +197,9 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showFinishDialog(ArrayList<ClientYacht> finishedBoats) {
|
public void showFinishDialog(ArrayList<ClientYacht> finishedBoats) {
|
||||||
|
System.out.println("called");
|
||||||
raceState.setRaceStarted(false);
|
raceState.setRaceStarted(false);
|
||||||
|
ViewManager.getInstance().getGameClient().getServerThread().ignoreDC();
|
||||||
createFinishDialog(finishedBoats);
|
createFinishDialog(finishedBoats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.jfoenix.controls.JFXButton;
|
|||||||
import com.jfoenix.controls.JFXListView;
|
import com.jfoenix.controls.JFXListView;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
@@ -26,7 +25,10 @@ public class FinishDialogController implements Initializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
playAgain.setOnAction(event -> ViewManager.getInstance().goToStartView());
|
playAgain.setOnAction(event -> {
|
||||||
|
System.out.println("CALLED HERE");
|
||||||
|
ViewManager.getInstance().goToStartView();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFinishedBoats(ArrayList<ClientYacht> finishedBoats) {
|
public void setFinishedBoats(ArrayList<ClientYacht> finishedBoats) {
|
||||||
|
|||||||
@@ -4,14 +4,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.property.ReadOnlyDoubleWrapper;
|
import javafx.beans.property.ReadOnlyDoubleWrapper;
|
||||||
import javafx.geometry.Point2D;
|
|
||||||
import javafx.geometry.Point3D;
|
import javafx.geometry.Point3D;
|
||||||
import javafx.scene.Group;
|
import javafx.scene.Group;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.paint.PhongMaterial;
|
|
||||||
import javafx.scene.shape.MeshView;
|
|
||||||
import javafx.scene.transform.Rotate;
|
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
|
* BoatGroup is a javafx group that by default contains a graphical objects for representing a 2
|
||||||
@@ -34,10 +30,9 @@ public class BoatObject extends Group {
|
|||||||
private Color colour = Color.BLACK;
|
private Color colour = Color.BLACK;
|
||||||
private Boolean isSelected = false;
|
private Boolean isSelected = false;
|
||||||
private Rotate rotation = new Rotate(0, new Point3D(0,0,1));
|
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 ReadOnlyDoubleWrapper rotationProperty;
|
||||||
|
|
||||||
private List<SelectedBoatListener> selectedBoatListenerListeners = new ArrayList<>();
|
private List<SelectedBoatListener> selectedBoatListenerListeners = new ArrayList<>();
|
||||||
@@ -86,19 +81,6 @@ 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) {
|
private Double normalizeHeading(double heading, double windDirection) {
|
||||||
Double normalizedHeading = heading - windDirection;
|
Double normalizedHeading = heading - windDirection;
|
||||||
normalizedHeading = (double) Math.floorMod(normalizedHeading.longValue(), 360L);
|
normalizedHeading = (double) Math.floorMod(normalizedHeading.longValue(), 360L);
|
||||||
@@ -109,6 +91,14 @@ public class BoatObject extends Group {
|
|||||||
private void rotateTo(double heading, boolean sailsIn, double windDir) {
|
private void rotateTo(double heading, boolean sailsIn, double windDir) {
|
||||||
rotationProperty.set(heading);
|
rotationProperty.set(heading);
|
||||||
rotation.setAngle(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)));
|
wake.getTransforms().setAll(new Rotate(heading, new Point3D(0,0,1)));
|
||||||
if (sailsIn) {
|
if (sailsIn) {
|
||||||
boatAssets.showSail();
|
boatAssets.showSail();
|
||||||
@@ -138,26 +128,6 @@ 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 () {
|
public Group getWake () {
|
||||||
return wake;
|
return wake;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,9 +115,9 @@ public class ModelFactory {
|
|||||||
private static Group getUnmodifiedBoatModel(BoatMeshType boatType, Color primaryColour) {
|
private static Group getUnmodifiedBoatModel(BoatMeshType boatType, Color primaryColour) {
|
||||||
|
|
||||||
Group boatAssets = new Group();
|
Group boatAssets = new Group();
|
||||||
MeshView hull = importBoatSTL(boatType.hullFile);
|
MeshView hull = importSTL(boatType.hullFile);
|
||||||
hull.setMaterial(new PhongMaterial(primaryColour));
|
hull.setMaterial(new PhongMaterial(primaryColour));
|
||||||
MeshView sail = importBoatSTL(boatType.sailFile);
|
MeshView sail = importSTL(boatType.sailFile);
|
||||||
sail.setMaterial(
|
sail.setMaterial(
|
||||||
new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.BLACK : Color.WHITE)
|
new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.BLACK : Color.WHITE)
|
||||||
);
|
);
|
||||||
@@ -125,13 +125,13 @@ public class ModelFactory {
|
|||||||
boatAssets.getChildren().addAll(hull, sail);
|
boatAssets.getChildren().addAll(hull, sail);
|
||||||
|
|
||||||
if (boatType.mastFile != null) {
|
if (boatType.mastFile != null) {
|
||||||
MeshView mast = importBoatSTL(boatType.mastFile);
|
MeshView mast = importSTL(boatType.mastFile);
|
||||||
mast.setMaterial(new PhongMaterial(primaryColour));
|
mast.setMaterial(new PhongMaterial(primaryColour));
|
||||||
boatAssets.getChildren().add(mast);
|
boatAssets.getChildren().add(mast);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boatType.jibFile != null) {
|
if (boatType.jibFile != null) {
|
||||||
MeshView jib = importBoatSTL(boatType.jibFile);
|
MeshView jib = importSTL(boatType.jibFile);
|
||||||
sail.setMaterial(
|
sail.setMaterial(
|
||||||
new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.DARKGRAY : Color.WHITE)
|
new PhongMaterial(boatType == BoatMeshType.PARROT ? Color.DARKGRAY : Color.WHITE)
|
||||||
);
|
);
|
||||||
@@ -141,13 +141,9 @@ public class ModelFactory {
|
|||||||
return boatAssets;
|
return boatAssets;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MeshView importBoatSTL(String fileName) {
|
private static MeshView importSTL(String fileName) {
|
||||||
return importSTL("boatSTLs/" + fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MeshView importSTL(String fileName) {
|
|
||||||
StlMeshImporter importer = new StlMeshImporter();
|
StlMeshImporter importer = new StlMeshImporter();
|
||||||
importer.read(ModelFactory.class.getResource("/meshes/" + fileName));
|
importer.read(ModelFactory.class.getResource("/meshes/boatSTLs/" + fileName));
|
||||||
MeshView importedFile = new MeshView(importer.getImport());
|
MeshView importedFile = new MeshView(importer.getImport());
|
||||||
importedFile.setCache(true);
|
importedFile.setCache(true);
|
||||||
importedFile.setCacheHint(CacheHint.SCALE_AND_ROTATE);
|
importedFile.setCacheHint(CacheHint.SCALE_AND_ROTATE);
|
||||||
@@ -166,10 +162,6 @@ public class ModelFactory {
|
|||||||
assets.setCacheHint(CacheHint.SCALE_AND_ROTATE);
|
assets.setCacheHint(CacheHint.SCALE_AND_ROTATE);
|
||||||
}
|
}
|
||||||
switch (tokenType) {
|
switch (tokenType) {
|
||||||
case PLAYER_IDENTIFIER_TORUS:
|
|
||||||
return makeIdentifierTorus(assets);
|
|
||||||
case NEXT_MARK_INDICATOR:
|
|
||||||
return makeNextMarkIndicator(assets);
|
|
||||||
case VELOCITY_PICKUP:
|
case VELOCITY_PICKUP:
|
||||||
case BUMPER_PICKUP:
|
case BUMPER_PICKUP:
|
||||||
case RANDOM_PICKUP:
|
case RANDOM_PICKUP:
|
||||||
@@ -204,16 +196,6 @@ 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) {
|
private static Model makeTokenPickup(Group assets) {
|
||||||
Rotate animationRotate = new Rotate(0, new Point3D(0, 0, 1));
|
Rotate animationRotate = new Rotate(0, new Point3D(0, 0, 1));
|
||||||
assets.getTransforms().addAll(
|
assets.getTransforms().addAll(
|
||||||
|
|||||||
@@ -28,9 +28,7 @@ public enum ModelType {
|
|||||||
START_ARROW ("start_arrow.dae"),
|
START_ARROW ("start_arrow.dae"),
|
||||||
FINISH_ARROW ("finish_arrow.dae"),
|
FINISH_ARROW ("finish_arrow.dae"),
|
||||||
LAND("land.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;
|
final String filename;
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
<Corner CompoundMarkID="1" Rounding="PS"/>
|
<Corner CompoundMarkID="1" Rounding="PS"/>
|
||||||
<Corner CompoundMarkID="2" Rounding="S"/>
|
<Corner CompoundMarkID="2" Rounding="S"/>
|
||||||
<Corner CompoundMarkID="3" Rounding="S"/>
|
<Corner CompoundMarkID="3" Rounding="S"/>
|
||||||
<Corner CompoundMarkID="4" Rounding="SP"/>
|
<Corner CompoundMarkID="4" Rounding="PS"/>
|
||||||
</OpeningSegment>
|
</OpeningSegment>
|
||||||
|
|
||||||
<RepeatingSegment>
|
<RepeatingSegment>
|
||||||
|
|||||||
@@ -1,99 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<asset>
|
|
||||||
<contributor>
|
|
||||||
<author>Blender User</author>
|
|
||||||
<authoring_tool>Blender 2.79.0 commit date:2017-09-11, commit time:10:43, hash:5bd8ac9</authoring_tool>
|
|
||||||
</contributor>
|
|
||||||
<created>2017-09-28T01:59:46</created>
|
|
||||||
<modified>2017-09-28T01:59:46</modified>
|
|
||||||
<unit name="meter" meter="1"/>
|
|
||||||
<up_axis>Z_UP</up_axis>
|
|
||||||
</asset>
|
|
||||||
<library_images/>
|
|
||||||
<library_effects>
|
|
||||||
<effect id="Material_001-effect">
|
|
||||||
<profile_COMMON>
|
|
||||||
<technique sid="common">
|
|
||||||
<phong>
|
|
||||||
<emission>
|
|
||||||
<color sid="emission">0 0 0 1</color>
|
|
||||||
</emission>
|
|
||||||
<ambient>
|
|
||||||
<color sid="ambient">0 0 0 1</color>
|
|
||||||
</ambient>
|
|
||||||
<diffuse>
|
|
||||||
<color sid="diffuse">0 0.3215737 0.002428917 1</color>
|
|
||||||
</diffuse>
|
|
||||||
<specular>
|
|
||||||
<color sid="specular">0.1614584 0.1614584 0.1614584 1</color>
|
|
||||||
</specular>
|
|
||||||
<shininess>
|
|
||||||
<float sid="shininess">50</float>
|
|
||||||
</shininess>
|
|
||||||
<index_of_refraction>
|
|
||||||
<float sid="index_of_refraction">1</float>
|
|
||||||
</index_of_refraction>
|
|
||||||
</phong>
|
|
||||||
</technique>
|
|
||||||
</profile_COMMON>
|
|
||||||
</effect>
|
|
||||||
</library_effects>
|
|
||||||
<library_materials>
|
|
||||||
<material id="Material_001-material" name="Material_001">
|
|
||||||
<instance_effect url="#Material_001-effect"/>
|
|
||||||
</material>
|
|
||||||
</library_materials>
|
|
||||||
<library_geometries>
|
|
||||||
<geometry id="Cone-mesh" name="Cone">
|
|
||||||
<mesh>
|
|
||||||
<source id="Cone-mesh-positions">
|
|
||||||
<float_array id="Cone-mesh-positions-array" count="99">0 1 -1 0 0 1 0.1950902 0.9807853 -1 0.3826835 0.9238795 -1 0.5555703 0.8314696 -1 0.7071068 0.7071068 -1 0.8314697 0.5555702 -1 0.9238795 0.3826834 -1 0.9807853 0.1950902 -1 1 0 -1 0.9807853 -0.1950902 -1 0.9238796 -0.3826833 -1 0.8314697 -0.5555702 -1 0.7071068 -0.7071068 -1 0.5555702 -0.8314697 -1 0.3826833 -0.9238796 -1 0.1950901 -0.9807853 -1 -3.25841e-7 -1 -1 -0.1950907 -0.9807852 -1 -0.3826839 -0.9238793 -1 -0.5555707 -0.8314693 -1 -0.7071073 -0.7071064 -1 -0.83147 -0.5555697 -1 -0.9238799 -0.3826827 -1 -0.9807854 -0.1950893 -1 -1 9.65599e-7 -1 -0.9807851 0.1950913 -1 -0.9238791 0.3826845 -1 -0.8314689 0.5555713 -1 -0.7071059 0.7071077 -1 -0.5555691 0.8314704 -1 -0.3826821 0.9238801 -1 -0.1950888 0.9807856 -1</float_array>
|
|
||||||
<technique_common>
|
|
||||||
<accessor source="#Cone-mesh-positions-array" count="33" stride="3">
|
|
||||||
<param name="X" type="float"/>
|
|
||||||
<param name="Y" type="float"/>
|
|
||||||
<param name="Z" type="float"/>
|
|
||||||
</accessor>
|
|
||||||
</technique_common>
|
|
||||||
</source>
|
|
||||||
<source id="Cone-mesh-normals">
|
|
||||||
<float_array id="Cone-mesh-normals-array" count="117">0.08775347 0.8909768 0.4454884 0.2598883 0.8567371 0.4454883 0.4220357 0.7895733 0.4454883 0.5679644 0.6920669 0.4454883 0.6920669 0.5679644 0.4454883 0.7895736 0.4220353 0.4454883 0.8567369 0.2598885 0.4454883 0.8909768 0.08775347 0.4454884 0.8909768 -0.08775347 0.4454884 0.8567371 -0.2598881 0.4454883 0.7895734 -0.4220355 0.4454884 0.6920669 -0.5679644 0.4454883 0.5679644 -0.6920669 0.4454883 0.4220356 -0.7895734 0.4454883 0.2598879 -0.8567371 0.4454885 0.08775335 -0.8909768 0.4454884 -0.08775389 -0.8909767 0.4454883 -0.2598887 -0.8567368 0.4454883 -0.4220361 -0.7895731 0.4454884 -0.5679646 -0.6920668 0.4454883 -0.6920675 -0.5679637 0.4454884 -0.7895734 -0.4220355 0.4454884 -0.8567374 -0.2598869 0.4454883 -0.8909769 -0.08775287 0.4454884 -0.8909766 0.08775418 0.4454883 -0.8567367 0.2598895 0.4454884 -0.7895728 0.4220367 0.4454883 -0.6920663 0.5679652 0.4454883 -0.5679636 0.6920676 0.4454884 -0.4220345 0.789574 0.4454885 -0.259887 0.8567373 0.4454883 -0.08775269 0.8909768 0.4454884 0 0 -1 -3.97508e-6 0 -1 3.97512e-6 0 -1 3.88859e-7 0 -1 -1.36853e-6 0 -1 1.36853e-6 0 -1 -3.88857e-7 0 -1</float_array>
|
|
||||||
<technique_common>
|
|
||||||
<accessor source="#Cone-mesh-normals-array" count="39" stride="3">
|
|
||||||
<param name="X" type="float"/>
|
|
||||||
<param name="Y" type="float"/>
|
|
||||||
<param name="Z" type="float"/>
|
|
||||||
</accessor>
|
|
||||||
</technique_common>
|
|
||||||
</source>
|
|
||||||
<vertices id="Cone-mesh-vertices">
|
|
||||||
<input semantic="POSITION" source="#Cone-mesh-positions"/>
|
|
||||||
</vertices>
|
|
||||||
<triangles material="Material_001-material" count="62">
|
|
||||||
<input semantic="VERTEX" source="#Cone-mesh-vertices" offset="0"/>
|
|
||||||
<input semantic="NORMAL" source="#Cone-mesh-normals" offset="1"/>
|
|
||||||
<p>0 0 1 0 2 0 2 1 1 1 3 1 3 2 1 2 4 2 4 3 1 3 5 3 5 4 1 4 6 4 6 5 1 5 7 5 7 6 1 6 8 6 8 7 1 7 9 7 9 8 1 8 10 8 10 9 1 9 11 9 11 10 1 10 12 10 12 11 1 11 13 11 13 12 1 12 14 12 14 13 1 13 15 13 15 14 1 14 16 14 16 15 1 15 17 15 17 16 1 16 18 16 18 17 1 17 19 17 19 18 1 18 20 18 20 19 1 19 21 19 21 20 1 20 22 20 22 21 1 21 23 21 23 22 1 22 24 22 24 23 1 23 25 23 25 24 1 24 26 24 26 25 1 25 27 25 27 26 1 26 28 26 28 27 1 27 29 27 29 28 1 28 30 28 30 29 1 29 31 29 31 30 1 30 32 30 32 31 1 31 0 31 16 32 24 32 8 32 32 32 0 32 2 32 2 32 3 32 4 32 4 32 5 32 6 32 6 32 7 32 4 32 8 32 9 32 10 32 10 32 11 32 8 32 12 32 13 32 16 32 14 32 15 32 16 32 16 32 17 32 18 32 18 32 19 32 20 32 20 32 21 32 22 32 22 33 23 33 24 33 24 34 25 34 26 34 26 32 27 32 28 32 28 32 29 32 32 32 30 32 31 32 32 32 32 35 2 35 8 35 4 36 7 36 8 36 8 37 11 37 12 37 13 32 14 32 16 32 16 32 18 32 24 32 20 32 22 32 24 32 24 38 26 38 32 38 29 32 30 32 32 32 2 32 4 32 8 32 8 32 12 32 16 32 18 32 20 32 24 32 26 32 28 32 32 32 32 32 8 32 24 32</p>
|
|
||||||
</triangles>
|
|
||||||
</mesh>
|
|
||||||
</geometry>
|
|
||||||
</library_geometries>
|
|
||||||
<library_controllers/>
|
|
||||||
<library_visual_scenes>
|
|
||||||
<visual_scene id="Scene" name="Scene">
|
|
||||||
<node id="Cone" name="Cone" type="NODE">
|
|
||||||
<matrix sid="transform">1 0 0 0 0 1 0 0 0 0 1 1.015816 0 0 0 1</matrix>
|
|
||||||
<instance_geometry url="#Cone-mesh" name="Cone">
|
|
||||||
<bind_material>
|
|
||||||
<technique_common>
|
|
||||||
<instance_material symbol="Material_001-material" target="#Material_001-material"/>
|
|
||||||
</technique_common>
|
|
||||||
</bind_material>
|
|
||||||
</instance_geometry>
|
|
||||||
</node>
|
|
||||||
</visual_scene>
|
|
||||||
</library_visual_scenes>
|
|
||||||
<scene>
|
|
||||||
<instance_visual_scene url="#Scene"/>
|
|
||||||
</scene>
|
|
||||||
</COLLADA>
|
|
||||||
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user