Boat sails now luff and stay when in the direction of the wind #story[1297]
This commit is contained in:
@@ -299,18 +299,47 @@ public class RaceViewController extends Controller {
|
|||||||
}
|
}
|
||||||
// Position and add each boat to view
|
// Position and add each boat to view
|
||||||
for(VisualiserBoat boat: race.getVisualiserRaceState().getBoats()) {
|
for(VisualiserBoat boat: race.getVisualiserRaceState().getBoats()) {
|
||||||
MeshView mesh;
|
/*if(boat.getSourceID() == race.getVisualiserRaceState().getPlayerBoatID()) {
|
||||||
if(boat.getSourceID() == race.getVisualiserRaceState().getPlayerBoatID()) {
|
|
||||||
mesh = new MeshView(importer.getImport());
|
mesh = new MeshView(importer.getImport());
|
||||||
} else {
|
} else {
|
||||||
mesh = new MeshView(importerBurgerBoat.getImport());
|
mesh = new MeshView(importerBurgerBoat.getImport());
|
||||||
}
|
}*/
|
||||||
|
Shape3D mesh = Assets3D.getBoat();
|
||||||
|
|
||||||
PhongMaterial boatColorMat = new PhongMaterial(boat.getColor());
|
PhongMaterial boatColorMat = new PhongMaterial(boat.getColor());
|
||||||
mesh.setMaterial(boatColorMat);
|
mesh.setMaterial(boatColorMat);
|
||||||
Subject3D boatModel = new Subject3D(mesh, boat.getSourceID());
|
Subject3D boatModel = new Subject3D(mesh, boat.getSourceID());
|
||||||
|
|
||||||
viewSubjects.add(boatModel);
|
viewSubjects.add(boatModel);
|
||||||
|
|
||||||
|
//add sail
|
||||||
|
Sails3D sails3D = new Sails3D();
|
||||||
|
Subject3D sailsSubject = new Subject3D(sails3D, 0);
|
||||||
|
sails3D.setMaterial(boatColorMat);
|
||||||
|
sailsSubject.setXRot(0d);
|
||||||
|
|
||||||
|
viewSubjects.add(sailsSubject);
|
||||||
|
|
||||||
|
AnimationTimer sailsFollowBoat = new AnimationTimer() {
|
||||||
|
@Override
|
||||||
|
public void handle(long now) {
|
||||||
|
if (boat.isSailsOut()) {
|
||||||
|
sailsSubject.setHeading(visualiserRace.getVisualiserRaceState().getWindDirection().degrees() + 90);
|
||||||
|
if (sails3D.isLuffing()) {
|
||||||
|
sails3D.stopLuffing();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sailsSubject.setHeading(visualiserRace.getVisualiserRaceState().getWindDirection().degrees());
|
||||||
|
if (!sails3D.isLuffing()){
|
||||||
|
sails3D.startLuffing();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sailsSubject.setX(gpsConverter.convertGPS(boat.getPosition()).getX());
|
||||||
|
sailsSubject.setZ(gpsConverter.convertGPS(boat.getPosition()).getY());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
sailsFollowBoat.start();
|
||||||
|
|
||||||
// Track this boat's movement with the new subject
|
// Track this boat's movement with the new subject
|
||||||
AnimationTimer trackBoat = new AnimationTimer() {
|
AnimationTimer trackBoat = new AnimationTimer() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ import javafx.scene.shape.MeshView;
|
|||||||
* Created by Gondr on 21/09/2017.
|
* Created by Gondr on 21/09/2017.
|
||||||
*/
|
*/
|
||||||
public class Sails3D extends MeshView {
|
public class Sails3D extends MeshView {
|
||||||
int index = 0;
|
private int index = 0;
|
||||||
|
private boolean isLuffing = false;
|
||||||
|
|
||||||
public Sails3D() {
|
public Sails3D() {
|
||||||
setMesh(Assets3D.sails[0].getMesh());
|
setMesh(Assets3D.sails[0].getMesh());
|
||||||
@@ -24,11 +25,16 @@ public class Sails3D extends MeshView {
|
|||||||
|
|
||||||
public void startLuffing(){
|
public void startLuffing(){
|
||||||
luff.start();
|
luff.start();
|
||||||
|
isLuffing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopLuffing(){
|
public void stopLuffing(){
|
||||||
luff.stop();
|
luff.stop();
|
||||||
|
isLuffing = false;
|
||||||
setMesh(Assets3D.sails[0].getMesh());
|
setMesh(Assets3D.sails[0].getMesh());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLuffing() {
|
||||||
|
return isLuffing;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user