Merge remote-tracking branch 'remotes/origin/master' into scoreTable

This commit is contained in:
hba56
2017-09-14 23:50:29 +12:00
11 changed files with 61 additions and 64 deletions
@@ -322,16 +322,16 @@ public class RaceViewController extends Controller {
Material markColor = new PhongMaterial(new Color(0.15,0.9,0.2,1));
CompoundMark nextMark = boat.getCurrentLeg().getEndCompoundMark();
view3D.getShape(nextMark.getMark1().getSourceID()).setMaterial(markColor);
view3D.getShape(nextMark.getMark1().getSourceID()).getMesh().setMaterial(markColor);
if(nextMark.getMark2() != null) {
view3D.getShape(nextMark.getMark2().getSourceID()).setMaterial(markColor);
view3D.getShape(nextMark.getMark2().getSourceID()).getMesh().setMaterial(markColor);
}
Subject3D shockwave = new Shockwave(10);
viewSubjects.add(shockwave);
boat.legProperty().addListener((o, prev, curr) -> swapColours(curr));
boat.hasCollidedProperty().addListener((o, prev, curr) -> showCollision(boatModel, shockwave));
boat.legProperty().addListener((o, prev, curr) -> Platform.runLater(() -> swapColours(curr)));
boat.hasCollidedProperty().addListener((o, prev, curr) -> Platform.runLater(() -> showCollision(boat, shockwave)));
}
// Fix initial bird's-eye position
view3D.updatePivot(new Translate(250, 0, 210));
@@ -340,7 +340,7 @@ public class RaceViewController extends Controller {
if(curr != null && visualiserRace.getVisualiserRaceState().isVisualiserBoat(curr.getSourceID())) {
addThirdPersonAnnotations(curr);
} else {
removeThirdPersonAnnotations(prev);
removeThirdPersonAnnotations();
}
});
@@ -389,18 +389,20 @@ public class RaceViewController extends Controller {
});
}
private void showCollision(Subject3D boat, Subject3D shockwave) {
private void showCollision(VisualiserBoat boat, Subject3D shockwave) {
Subject3D boatModel = view3D.getShape(boat.getSourceID());
AnimationTimer shockFront = new AnimationTimer() {
double opacity = 1;
@Override
public void handle(long now) {
shockwave.setX(boat.getPosition().getX());
shockwave.setY(boat.getPosition().getY());
shockwave.setZ(boat.getPosition().getZ());
shockwave.setX(boatModel.getPosition().getX());
shockwave.setY(boatModel.getPosition().getY());
shockwave.setZ(boatModel.getPosition().getZ());
if(opacity <= 0) {
shockwave.getMesh().setMaterial(new PhongMaterial(new Color(1,0,0,0)));
shockwave.getMesh().setMaterial(new PhongMaterial(Color.TRANSPARENT));
boat.setHasCollided(false);
this.stop();
}
else {
@@ -434,38 +436,14 @@ public class RaceViewController extends Controller {
}
};
arrowToNextMark.start();
/*
try {
VisualiserBoat boat = visualiserRace.getVisualiserRaceState().getBoat(subject3D.getSourceID());
this.pointToMark = new AnimationTimer() {
@Override
public void handle(long now) {
CompoundMark target = boat.getCurrentLeg().getEndCompoundMark();
Bearing headingToMark = GPSCoordinate.calculateBearing(boat.getPosition(), target.getAverageGPSCoordinate());
nextMarkArrow.setX(view3D.getPivot().getX());
nextMarkArrow.setY(view3D.getPivot().getY());
nextMarkArrow.setZ(view3D.getPivot().getZ() + 10);
nextMarkArrow.setHeading(headingToMark.degrees());
}
};
pointToMark.start();
} catch (BoatNotFoundException e) {
e.printStackTrace();
}*/
}
private void removeThirdPersonAnnotations(Subject3D subject3D) {
private void removeThirdPersonAnnotations() {
viewSubjects.remove(nextMarkArrow);
arrowToNextMark.stop();
/*
try {
VisualiserBoat boat = visualiserRace.getVisualiserRaceState().getBoat(subject3D.getSourceID());
boat.positionProperty().removeListener(pointToMark);
} catch (BoatNotFoundException e) {
e.printStackTrace();
}*/
//pointToMark.stop();
if (arrowToNextMark != null) {
arrowToNextMark.stop();
}
}
/**
@@ -476,21 +454,26 @@ public class RaceViewController extends Controller {
CompoundMark start = leg.getStartCompoundMark();
CompoundMark end = leg.getEndCompoundMark();
Shape3D start1 = view3D.getShape(start.getMark1().getSourceID());
Shape3D end1 = view3D.getShape(end.getMark1().getSourceID());
//The last leg "finish" doesn't have compound marks.
if (start == null || end == null ) {
return;
}
Shape3D start1 = view3D.getShape(start.getMark1().getSourceID()).getMesh();
Shape3D end1 = view3D.getShape(end.getMark1().getSourceID()).getMesh();
Material nextMark = start1.getMaterial();
Material lastMark = end1.getMaterial();
start1.setMaterial(lastMark);
if(start.getMark2() != null) {
Shape3D start2 = view3D.getShape(start.getMark2().getSourceID());
Shape3D start2 = view3D.getShape(start.getMark2().getSourceID()).getMesh();
start2.setMaterial(lastMark);
}
end1.setMaterial(nextMark);
if(end.getMark2() != null) {
Shape3D end2 = view3D.getShape(end.getMark2().getSourceID());
Shape3D end2 = view3D.getShape(end.getMark2().getSourceID()).getMesh();
end2.setMaterial(nextMark);
}
}
@@ -599,6 +582,7 @@ public class RaceViewController extends Controller {
/**
* Transition from the race view to the finish view.
* @throws IOException Thrown if the finish scene cannot be loaded.
*/
private void finishRace() throws IOException {
RaceFinishController fc =
@@ -749,4 +733,4 @@ public class RaceViewController extends Controller {
}
}
}
}
@@ -80,8 +80,9 @@ public class ControllerServer implements RunnableWithFramePeriod {
try {
Command command = CommandFactory.createCommand(raceState, boatAction);
compositeCommand.addCommand(command);
if(command != null) {
compositeCommand.addCommand(command);
}
} catch (CommandConstructionException e) {
Logger.getGlobal().log(Level.WARNING, "ControllerServer could not create a Command for BoatAction: " + boatAction + ".", e);
@@ -35,7 +35,7 @@ public class Boundary3D {
if (points.size() < 2){
return;
}
System.out.println(points.size());
for (int i = 0; i < points.size(); i++){
if (i + 1 != points.size()){
addBound(points.get(i), points.get(i + 1));
@@ -32,6 +32,9 @@ public class SeaSurface extends Subject3D {
/**
* Creates the sea surface
* @param size size of sea noise array.
* @param freq frequency of sea noise array.
* @return The sea surface.
*/
private static Shape3D createSurface(int size, double freq) {
float[][] noiseArray = PerlinNoiseGenerator.createNoise(size, freq);
@@ -33,6 +33,7 @@ public class Subject3D {
/**
* Constructor for view subject wrapper
* @param mesh to be rendered
* @param sourceID Source ID of the subject.
*/
public Subject3D(Shape3D mesh, int sourceID) {
this.mesh = mesh;
@@ -36,9 +36,9 @@ public class View3D extends Pane {
*/
private Map<Shape3D, Subject3D> shapeMap;
/**
* Map for selecting Shape3D from source ID
* Map for selecting Subject3D from source ID
*/
private Map<Integer, Shape3D> sourceMap;
private Map<Integer, Subject3D> sourceMap;
/**
* Subject tracked by camera
*/
@@ -150,14 +150,14 @@ public class View3D extends Pane {
for (Subject3D shape : c.getAddedSubList()) {
world.getChildren().add(shape.getMesh());
shapeMap.put(shape.getMesh(), shape);
sourceMap.put(shape.getSourceID(), shape.getMesh());
sourceMap.put(shape.getSourceID(), shape);
}
}
}
});
}
public Shape3D getShape(int sourceID) {
public Subject3D getShape(int sourceID) {
return sourceMap.get(sourceID);
}