Merge remote-tracking branch 'origin/NewUI_merge' into NewUI_merge

This commit is contained in:
Haoming Yin
2017-09-12 15:52:34 +12:00
4 changed files with 37 additions and 46 deletions
@@ -28,6 +28,7 @@ import seng302.model.token.Token;
import seng302.utilities.GeoUtility; import seng302.utilities.GeoUtility;
import seng302.utilities.Sounds; import seng302.utilities.Sounds;
import seng302.visualiser.fxObjects.assets_2D.*; import seng302.visualiser.fxObjects.assets_2D.*;
import seng302.visualiser.fxObjects.assets_3D.Marker3D;
import seng302.visualiser.fxObjects.assets_3D.ModelFactory; import seng302.visualiser.fxObjects.assets_3D.ModelFactory;
import seng302.visualiser.fxObjects.assets_3D.ModelType; import seng302.visualiser.fxObjects.assets_3D.ModelType;
import seng302.visualiser.map.Boundary; import seng302.visualiser.map.Boundary;
@@ -63,7 +64,7 @@ public class GameView extends Pane {
/* 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 List<Limit> borderPoints; private List<Limit> borderPoints;
private Map<Mark, Marker> markerObjects; private Map<Mark, Marker3D> markerObjects;
private Map<ClientYacht, BoatObject> boatObjects = new HashMap<>(); private Map<ClientYacht, BoatObject> boatObjects = new HashMap<>();
private Map<ClientYacht, AnnotationBox> annotations = new HashMap<>(); private Map<ClientYacht, AnnotationBox> annotations = new HashMap<>();
@@ -342,10 +343,10 @@ public class GameView extends Pane {
rescaleRace(new ArrayList<>(markerObjects.keySet())); rescaleRace(new ArrayList<>(markerObjects.keySet()));
} }
//Move the Markers to initial position. //Move the Markers to initial position.
markerObjects.forEach(((mark, marker) -> { markerObjects.forEach(((mark, marker3D) -> {
Point2D p2d = findScaledXY(mark.getLat(), mark.getLng()); Point2D p2d = findScaledXY(mark.getLat(), mark.getLng());
marker.setLayoutX(p2d.getX()); marker3D.setLayoutX(p2d.getX());
marker.setLayoutY(p2d.getY()); marker3D.setLayoutY(p2d.getY());
})); }));
Platform.runLater(() -> { Platform.runLater(() -> {
markers.getChildren().clear(); markers.getChildren().clear();
@@ -435,9 +436,9 @@ public class GameView extends Pane {
* @param colour The desired colour of the mark * @param colour The desired colour of the mark
*/ */
private void makeAndBindMarker(Mark observableMark, Paint colour) { private void makeAndBindMarker(Mark observableMark, Paint colour) {
Marker marker = new Marker(colour); Marker3D marker3D = new Marker3D(colour);
// marker.addArrows(MarkArrowFactory.RoundingSide.PORT, ThreadLocalRandom.current().nextDouble(91, 180), ThreadLocalRandom.current().nextDouble(1, 90)); // marker.addArrows(MarkArrowFactory.RoundingSide.PORT, ThreadLocalRandom.current().nextDouble(91, 180), ThreadLocalRandom.current().nextDouble(1, 90));
markerObjects.put(observableMark, marker); markerObjects.put(observableMark, marker3D);
observableMark.addPositionListener((mark, lat, lon) -> { observableMark.addPositionListener((mark, lat, lon) -> {
Point2D p2d = findScaledXY(lat, lon); Point2D p2d = findScaledXY(lat, lon);
markerObjects.get(mark).setLayoutX(p2d.getX()); markerObjects.get(mark).setLayoutX(p2d.getX());
@@ -453,7 +454,7 @@ public class GameView extends Pane {
* @param colour The desired colour of the gate. * @param colour The desired colour of the gate.
* @return the new gate. * @return the new gate.
*/ */
private Gate makeAndBindGate(Marker m1, Marker m2, Paint colour) { private Gate makeAndBindGate(Marker3D m1, Marker3D m2, Paint colour) {
Gate gate = new Gate(colour); Gate gate = new Gate(colour);
gate.startXProperty().bind( gate.startXProperty().bind(
m1.layoutXProperty() m1.layoutXProperty()
@@ -1,17 +1,12 @@
package seng302.visualiser.controllers.cells; package seng302.visualiser.controllers.cells;
import javafx.animation.AnimationTimer;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.geometry.Point3D;
import javafx.scene.Group; import javafx.scene.Group;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane; import javafx.scene.layout.Pane;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.scene.transform.Rotate;
import javafx.scene.transform.Scale;
import javafx.scene.transform.Translate;
import seng302.utilities.Sounds; import seng302.utilities.Sounds;
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType; import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
import seng302.visualiser.fxObjects.assets_3D.BoatModel; import seng302.visualiser.fxObjects.assets_3D.BoatModel;
@@ -29,7 +24,6 @@ public class PlayerCell {
//---------FXML END---------// //---------FXML END---------//
private String name; private String name;
private Integer boatAngle;
private Color boatColor; private Color boatColor;
private Integer playerId; private Integer playerId;
@@ -37,34 +31,13 @@ public class PlayerCell {
this.playerId = playerId; this.playerId = playerId;
this.name = playerName; this.name = playerName;
this.boatColor = color; this.boatColor = color;
this.boatAngle = -45;
} }
public void initialize() { public void initialize() {
playerName.setText(name); playerName.setText(name);
Group group = new Group(); Group group = new Group();
boatPane.getChildren().add(group); boatPane.getChildren().add(group);
BoatModel bo = ModelFactory.boatIconView(BoatMeshType.DINGHY, this.boatColor); BoatModel bo = ModelFactory.boatIconView(BoatMeshType.DINGHY, this.boatColor);
bo.showSail();
bo.rotateSail(45);
bo.getAssets().getTransforms().setAll(
new Scale(4, 4, 4),
new Translate(12, 14, 0),
new Rotate(270, new Point3D(1, 0, 0)),
new Rotate(-45, new Point3D(0, 0, 1))
);
bo.setAnimation(new AnimationTimer() {
Group group = bo.getAssets();
@Override
public void handle(long now) {
((Rotate) group.getTransforms().get(3)).setAngle(boatAngle++);
}
});
group.getChildren().add(bo.getAssets()); group.getChildren().add(bo.getAssets());
} }
@@ -1,4 +1,4 @@
package seng302.visualiser.fxObjects.assets_2D; package seng302.visualiser.fxObjects.assets_3D;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -6,15 +6,14 @@ import javafx.application.Platform;
import javafx.scene.Group; import javafx.scene.Group;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.scene.paint.Paint; import javafx.scene.paint.Paint;
import javafx.scene.shape.Circle;
import javafx.scene.transform.Scale; import javafx.scene.transform.Scale;
import seng302.visualiser.fxObjects.assets_3D.ModelFactory; import seng302.visualiser.fxObjects.assets_2D.MarkArrowFactory;
import seng302.visualiser.fxObjects.assets_3D.ModelType; import seng302.visualiser.fxObjects.assets_2D.MarkArrowFactory.RoundingSide;
/** /**
* Visual object for a mark. Contains a coloured circle and any specified arrows. * Visual object for a mark. Contains a coloured circle and any specified arrows.
*/ */
public class Marker extends Group { public class Marker3D extends Group {
private Group mark = ModelFactory.importModel(ModelType.PLAIN_MARKER).getAssets(); private Group mark = ModelFactory.importModel(ModelType.PLAIN_MARKER).getAssets();
private Paint colour = Color.BLACK; private Paint colour = Color.BLACK;
@@ -26,7 +25,7 @@ public class Marker extends Group {
/** /**
* Creates a new Marker containing only a circle. The default colour is black. * Creates a new Marker containing only a circle. The default colour is black.
*/ */
public Marker() { public Marker3D() {
// mark.setRadius(5); // mark.setRadius(5);
// mark.setCenterX(0); // mark.setCenterX(0);
// mark.setCenterY(0); // mark.setCenterY(0);
@@ -40,7 +39,7 @@ public class Marker extends Group {
* Creates a new Marker containing only a circle of the given colour. * Creates a new Marker containing only a circle of the given colour.
* @param colour the desired colour for the marker. * @param colour the desired colour for the marker.
*/ */
public Marker(Paint colour) { public Marker3D(Paint colour) {
this(); this();
this.colour = colour; this.colour = colour;
// mark.setFill(colour); // mark.setFill(colour);
@@ -53,7 +52,7 @@ public class Marker extends Group {
* @param entryAngle The angle the arrow will point towards a marker * @param entryAngle The angle the arrow will point towards a marker
* @param exitAngle The angle the arrow wil point from the marker. * @param exitAngle The angle the arrow wil point from the marker.
*/ */
public void addArrows(MarkArrowFactory.RoundingSide roundingSide, double entryAngle, public void addArrows(RoundingSide roundingSide, double entryAngle,
double exitAngle) { double exitAngle) {
//Change Color.GRAY to this.colour to revert all gray arrows. //Change Color.GRAY to this.colour to revert all gray arrows.
enterArrows.add( enterArrows.add(
@@ -2,6 +2,7 @@ package seng302.visualiser.fxObjects.assets_3D;
import com.interactivemesh.jfx.importer.col.ColModelImporter; import com.interactivemesh.jfx.importer.col.ColModelImporter;
import com.interactivemesh.jfx.importer.stl.StlMeshImporter; import com.interactivemesh.jfx.importer.stl.StlMeshImporter;
import java.util.Random;
import javafx.animation.AnimationTimer; import javafx.animation.AnimationTimer;
import javafx.geometry.Point3D; import javafx.geometry.Point3D;
import javafx.scene.AmbientLight; import javafx.scene.AmbientLight;
@@ -22,12 +23,29 @@ public class ModelFactory {
public static BoatModel boatIconView(BoatMeshType boatType, Color primaryColour) { public static BoatModel boatIconView(BoatMeshType boatType, Color primaryColour) {
Group boatAssets = getUnmodifiedBoatModel(boatType, primaryColour); Group boatAssets = getUnmodifiedBoatModel(boatType, primaryColour);
boatAssets.getTransforms().addAll( boatAssets.getTransforms().addAll(
new Scale(20, 20, 20), new Scale(10, 10, 10),
new Rotate(90, new Point3D(0,0,1)), new Rotate(45, new Point3D(0,0,1)),
new Rotate(90, new Point3D(0, 1, 0)) new Rotate(90, new Point3D(0, 1, 0)),
new Rotate(270, new Point3D(1, 0, 0)),
new Translate(12, 14, 0)
); );
BoatModel bo = new BoatModel(boatAssets, null, boatType);
bo.showSail();
bo.rotateSail(45);
bo.setAnimation(new AnimationTimer() {
Group group = bo.getAssets();
double boatAngle = 0;
int id = new Random().nextInt();
@Override
public void handle(long now) {
((Rotate) group.getTransforms().get(3)).setAngle(boatAngle++);
System.out.println("animating a thingy " + id);
}
});
boatAssets.getChildren().add(new AmbientLight(new Color(1, 1, 1, 0.01))); boatAssets.getChildren().add(new AmbientLight(new Color(1, 1, 1, 0.01)));
return new BoatModel(boatAssets, null, boatType); return bo;
} }
public static BoatModel boatRotatingView(BoatMeshType boatType, Color primaryColour) { public static BoatModel boatRotatingView(BoatMeshType boatType, Color primaryColour) {