mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Added 3D assets for a trail and generated them at regular intervals.
#story[1266] #implement
This commit is contained in:
@@ -5,11 +5,19 @@ import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.Point2D;
|
||||
import javafx.geometry.Point3D;
|
||||
import javafx.scene.*;
|
||||
import javafx.scene.AmbientLight;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.PerspectiveCamera;
|
||||
import javafx.scene.PointLight;
|
||||
import javafx.scene.SceneAntialiasing;
|
||||
import javafx.scene.SubScene;
|
||||
import javafx.scene.effect.BlendMode;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
@@ -29,7 +37,8 @@ import seng302.model.mark.Corner;
|
||||
import seng302.model.mark.Mark;
|
||||
import seng302.model.token.Token;
|
||||
import seng302.utilities.GeoUtility;
|
||||
import seng302.visualiser.fxObjects.assets_2D.*;
|
||||
import seng302.visualiser.fxObjects.assets_2D.AnnotationBox;
|
||||
import seng302.visualiser.fxObjects.assets_2D.BoatObject;
|
||||
import seng302.visualiser.fxObjects.assets_3D.ModelFactory;
|
||||
import seng302.visualiser.fxObjects.assets_3D.ModelType;
|
||||
|
||||
@@ -78,11 +87,12 @@ public class GameView3D {
|
||||
private Group annotationsGroup = new Group();
|
||||
private Group wakesGroup = new Group();
|
||||
private Group boatObjectGroup = new Group();
|
||||
private Group trails = new Group();
|
||||
private Group markers = new Group();
|
||||
private Group tokens = new Group();
|
||||
private List<CompoundMark> course = new ArrayList<>();
|
||||
private List<Node> mapTokens;
|
||||
private Timer trailMaker = new Timer();
|
||||
private Group trail = new Group();
|
||||
|
||||
private ImageView mapImage = new ImageView();
|
||||
|
||||
@@ -171,7 +181,7 @@ public class GameView3D {
|
||||
|
||||
gameObjects.getChildren().addAll(
|
||||
// ModelFactory.importModel(ModelType.OCEAN).getAssets(),
|
||||
raceBorder, markers, tokens,
|
||||
raceBorder, trail, markers, tokens,
|
||||
white, blue, green, black, red
|
||||
);
|
||||
|
||||
@@ -660,4 +670,50 @@ public class GameView3D {
|
||||
tokens.getChildren().setAll(mapTokens);
|
||||
});
|
||||
}
|
||||
|
||||
public void setBoatAsPlayer (ClientYacht playerYacht) {
|
||||
this.playerYacht = playerYacht;
|
||||
|
||||
trailMaker.scheduleAtFixedRate(new TimerTask() {
|
||||
|
||||
private Point2D lastLocation = findScaledXY(playerYacht.getLocation());
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Node segment = ModelFactory.importModel(ModelType.TRAIL_SEGMENT).getAssets();
|
||||
Point2D location = findScaledXY(playerYacht.getLocation());
|
||||
segment.getTransforms().addAll(
|
||||
new Translate(location.getX(), location.getY()),
|
||||
new Rotate(playerYacht.getHeading(), new Point3D(0,0,1)),
|
||||
new Scale(1, lastLocation.distance(location) / 5)
|
||||
);
|
||||
Platform.runLater(() -> {
|
||||
trail.getChildren().add(segment);
|
||||
if (trail.getChildren().size() > 100) {
|
||||
trail.getChildren().remove(0);
|
||||
}
|
||||
});
|
||||
lastLocation = location;
|
||||
}
|
||||
}, 0L, 500L);
|
||||
|
||||
// playerYacht.toggleSail();
|
||||
// boatObjects.get(playerYacht).setAsPlayer();
|
||||
// CompoundMark currentMark = course.get(playerYacht.getLegNumber());
|
||||
// for (Mark mark : currentMark.getMarks()) {
|
||||
// markerObjects.get(mark).showNextExitArrow();
|
||||
// }
|
||||
// annotations.get(playerYacht).addAnnotation(
|
||||
// "velocity",
|
||||
// playerYacht.getVelocityProperty(),
|
||||
// (velocity) -> String.format("Speed: %.2f ms", velocity.doubleValue())
|
||||
// );
|
||||
// Platform.runLater(() -> {
|
||||
// boatObjectGroup.getChildren().remove(boatObjects.get(playerYacht));
|
||||
// gameObjects.add(boatObjects.get(playerYacht));
|
||||
// annotationsGroup.getChildren().remove(annotations.get(playerYacht));
|
||||
// gameObjects.add(annotations.get(playerYacht));
|
||||
// });
|
||||
// playerYacht.addMarkRoundingListener(this::updateMarkArrows);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
new ArrayList<>(raceData.getCompoundMarks().values()), raceData.getMarkSequence()
|
||||
);
|
||||
// gameView.enableZoom();
|
||||
// gameView.setBoatAsPlayer(player);
|
||||
gameView.setBoatAsPlayer(player);
|
||||
// gameView.startRace();
|
||||
|
||||
// raceState.addCollisionListener(gameView::drawCollision);
|
||||
|
||||
@@ -111,6 +111,8 @@ public class ModelFactory {
|
||||
return makeGate(assets);
|
||||
case WAKE:
|
||||
return makeWake(assets);
|
||||
case TRAIL_SEGMENT:
|
||||
return makeTrail(assets);
|
||||
default:
|
||||
return new Model(new Group(assets), null);
|
||||
}
|
||||
@@ -184,4 +186,11 @@ public class ModelFactory {
|
||||
);
|
||||
return new Model(new Group(assets), null);
|
||||
}
|
||||
|
||||
private static Model makeTrail(Group trailPiece) {
|
||||
trailPiece.getTransforms().addAll(
|
||||
new Rotate(90, new Point3D(0,0,1))
|
||||
);
|
||||
return new Model(new Group(trailPiece), null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ public enum ModelType {
|
||||
FINISH_LINE ("finish_line.dae"),
|
||||
START_LINE ("start_line.dae"),
|
||||
GATE_LINE ("gate_line.dae"),
|
||||
WAKE ("wake.dae");
|
||||
WAKE ("wake.dae"),
|
||||
TRAIL_SEGMENT ("trail_segment.dae");
|
||||
|
||||
final String filename;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user