Finished playable 3D race with first person camera
- Camera pivot must be manually updated - GPS coordinates are scaled by an arbitrary amount to make movement visible - Model has to be flipped 180 degrees to move forward #story[1261]
This commit is contained in:
@@ -75,7 +75,6 @@ public class HostController extends Controller {
|
||||
|
||||
subjects.add(subject);
|
||||
|
||||
view3D.setPivot(subject);
|
||||
view3D.setDistance(50);
|
||||
view3D.setYaw(45);
|
||||
view3D.setPitch(20);
|
||||
|
||||
@@ -175,50 +175,47 @@ public class RaceController extends Controller {
|
||||
}
|
||||
|
||||
private void initialiseView3D(VisualiserRaceEvent race) {
|
||||
int scale = 5000;
|
||||
|
||||
ObservableList<Subject3D> subjects = FXCollections.observableArrayList();
|
||||
|
||||
URL asset = HostController.class.getClassLoader().getResource("assets/V1.2 Complete Boat.stl");
|
||||
StlMeshImporter importer = new StlMeshImporter();
|
||||
importer.read(asset);
|
||||
|
||||
view3D = new View3D();
|
||||
view3D.setDistance(100);
|
||||
view3D.setYaw(0);
|
||||
view3D.setPitch(20);
|
||||
|
||||
view3D.setItems(subjects);
|
||||
canvasBase.getChildren().add(0, view3D);
|
||||
|
||||
for(Mark mark: race.getVisualiserRaceState().getMarks()) {
|
||||
Subject3D subject = new Subject3D(new Sphere(2));
|
||||
subject.setX(mark.getPosition().getLongitude());
|
||||
subject.setZ(mark.getPosition().getLatitude());
|
||||
Subject3D subject = new Subject3D(new Sphere(5));
|
||||
subject.setX(mark.getPosition().getLongitude() * scale);
|
||||
subject.setZ(mark.getPosition().getLatitude() * scale);
|
||||
|
||||
System.out.println(subject.getPosition().toString());
|
||||
subjects.add(subject);
|
||||
}
|
||||
|
||||
try {
|
||||
VisualiserBoat boat = race.getVisualiserRaceState().getBoat(race.getVisualiserRaceState().getPlayerBoatID());
|
||||
|
||||
URL asset = HostController.class.getClassLoader().getResource("assets/V1.2 Complete Boat.stl");
|
||||
|
||||
StlMeshImporter importer = new StlMeshImporter();
|
||||
importer.read(asset);
|
||||
for(VisualiserBoat boat: race.getVisualiserRaceState().getBoats()) {
|
||||
Subject3D subject = new Subject3D(new MeshView(importer.getImport()));
|
||||
subject.setX(boat.getPosition().getLongitude());
|
||||
subject.setZ(boat.getPosition().getLatitude());
|
||||
|
||||
System.out.println(subject.getPosition().toString());
|
||||
subjects.add(subject);
|
||||
|
||||
view3D.setPivot(subject);
|
||||
view3D.setDistance(500);
|
||||
view3D.setYaw(0);
|
||||
view3D.setPitch(20);
|
||||
AnimationTimer rotate = new AnimationTimer() {
|
||||
AnimationTimer trackBoat = new AnimationTimer() {
|
||||
@Override
|
||||
public void handle(long now) {
|
||||
subject.setHeading(boat.getBearing().degrees());
|
||||
subject.setX(boat.getPosition().getLongitude());
|
||||
subject.setZ(boat.getPosition().getLatitude());
|
||||
subject.setX(boat.getPosition().getLongitude() * scale);
|
||||
subject.setZ(boat.getPosition().getLatitude()* scale);
|
||||
if(boat.getSourceID() == race.getVisualiserRaceState().getPlayerBoatID()) {
|
||||
view3D.updatePivot(subject.getPosition());
|
||||
}
|
||||
view3D.setYaw(boat.getBearing().degrees());
|
||||
}
|
||||
};
|
||||
rotate.start();
|
||||
} catch(BoatNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
trackBoat.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user