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

This commit is contained in:
Calum
2017-09-12 14:11:11 +12:00
5 changed files with 187 additions and 8 deletions
@@ -40,7 +40,6 @@ import seng302.model.mark.Corner;
import seng302.model.mark.Mark; import seng302.model.mark.Mark;
import seng302.model.token.Token; import seng302.model.token.Token;
import seng302.utilities.GeoUtility; import seng302.utilities.GeoUtility;
import seng302.visualiser.fxObjects.assets_2D.AnnotationBox;
import seng302.visualiser.fxObjects.assets_2D.BoatObject; import seng302.visualiser.fxObjects.assets_2D.BoatObject;
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;
@@ -85,18 +84,16 @@ public class GameView3D {
private Map<Mark, Group> markerObjects; private Map<Mark, Group> markerObjects;
private Map<ClientYacht, BoatObject> boatObjects = new HashMap<>(); private Map<ClientYacht, BoatObject> boatObjects = new HashMap<>();
private Map<ClientYacht, AnnotationBox> annotations = new HashMap<>();
private BoatObject selectedBoat = null; private BoatObject selectedBoat = null;
private Group annotationsGroup = new Group();
private Group wakesGroup = new Group(); private Group wakesGroup = new Group();
private Group boatObjectGroup = new Group(); private Group boatObjectGroup = new Group();
private Group markers = new Group(); private Group markers = new Group();
private Group tokens = new Group(); private Group tokens = new Group();
private Group playerAnnotation = new Group();
private List<CompoundMark> course = new ArrayList<>(); private List<CompoundMark> course = new ArrayList<>();
private List<Node> mapTokens; private List<Node> mapTokens;
private Timer trailMaker = new Timer(); private Timer playerBoatAnimationTimer = new Timer();
private Group trail = new Group(); private Group trail = new Group();
private ImageView mapImage = new ImageView(); private ImageView mapImage = new ImageView();
//FRAME RATE //FRAME RATE
@@ -196,7 +193,7 @@ public class GameView3D {
gameObjects.getChildren().addAll( gameObjects.getChildren().addAll(
ocean, ocean,
// ModelFactory.importModel(ModelType.OCEAN).getAssets(), // ModelFactory.importModel(ModelType.OCEAN).getAssets(),
raceBorder, trail, markers, tokens, raceBorder, trail, markers, tokens, playerAnnotation,
white, blue, green, black, red white, blue, green, black, red
); );
@@ -689,7 +686,14 @@ public class GameView3D {
public void setBoatAsPlayer (ClientYacht playerYacht) { public void setBoatAsPlayer (ClientYacht playerYacht) {
this.playerYacht = playerYacht; this.playerYacht = playerYacht;
trailMaker.scheduleAtFixedRate(new TimerTask() { Platform.runLater(() ->
playerAnnotation.getChildren().setAll(ModelFactory.importModel(ModelType.PLAYER_IDENTIFIER).getAssets())
);
BoatObject playerAssets = boatObjects.get(playerYacht);
playerAnnotation.layoutXProperty().bind(playerAssets.layoutXProperty());
playerAnnotation.layoutYProperty().bind(playerAssets.layoutYProperty());
playerBoatAnimationTimer.scheduleAtFixedRate(new TimerTask() {
private Point2D lastLocation = findScaledXY(playerYacht.getLocation()); private Point2D lastLocation = findScaledXY(playerYacht.getLocation());
@@ -709,6 +713,21 @@ public class GameView3D {
} }
}); });
lastLocation = location; lastLocation = location;
// TODO: 11/09/2017 ROTATE PLAYER ICON
// double leg = playerYacht.getLegNumber();
// if (compoundMark != null) {
// for (Mark mark : compoundMark.getMarks()) {
//// System.out.println("markerObjects.get(mark) = " + markerObjects.get(mark));
// markerObjects.get(mark).showNextExitArrow();
// }
// }
// CompoundMark nextMark = null;
// if (legNumber < course.size() - 1) {
// nextMark = course.get(legNumber);
// for (Mark mark : nextMark.getMarks()) {
// markerObjects.get(mark).showNextEnterArrow();
// }
// }
} }
}, 0L, 500L); }, 0L, 500L);
@@ -3,6 +3,8 @@ package seng302.visualiser.fxObjects.assets_2D;
import java.util.ArrayList; 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.SimpleDoubleProperty;
import javafx.geometry.Point2D; import javafx.geometry.Point2D;
import javafx.geometry.Point3D; import javafx.geometry.Point3D;
import javafx.scene.AmbientLight; import javafx.scene.AmbientLight;
@@ -113,6 +113,8 @@ public class ModelFactory {
return makeWake(assets); return makeWake(assets);
case TRAIL_SEGMENT: case TRAIL_SEGMENT:
return makeTrail(assets); return makeTrail(assets);
case PLAYER_IDENTIFIER:
return makeIdentifierIcon(assets);
default: default:
return new Model(new Group(assets), null); return new Model(new Group(assets), null);
} }
@@ -193,4 +195,12 @@ public class ModelFactory {
); );
return new Model(new Group(trailPiece), null); return new Model(new Group(trailPiece), null);
} }
private static Model makeIdentifierIcon(Group assets) {
assets.getTransforms().addAll(
new Rotate(90, new Point3D(1,0,0)),
new Scale(0.5, 0.5, 0.5)
);
return new Model(assets, null);
}
} }
@@ -18,7 +18,8 @@ public enum ModelType {
START_LINE ("start_line.dae"), START_LINE ("start_line.dae"),
GATE_LINE ("gate_line.dae"), GATE_LINE ("gate_line.dae"),
WAKE ("wake.dae"), WAKE ("wake.dae"),
TRAIL_SEGMENT ("trail_segment.dae"); TRAIL_SEGMENT ("trail_segment.dae"),
PLAYER_IDENTIFIER ("player_identifier.dae");
final String filename; final String filename;
File diff suppressed because one or more lines are too long