Added "arrow" pointing to next mark on third person view
#story[1195]
This commit is contained in:
@@ -3,6 +3,7 @@ package visualiser.Controllers;
|
||||
import com.interactivemesh.jfx.importer.stl.StlMeshImporter;
|
||||
import javafx.animation.AnimationTimer;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
@@ -20,6 +21,7 @@ import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.Material;
|
||||
import javafx.scene.paint.PhongMaterial;
|
||||
import javafx.scene.shape.Box;
|
||||
import javafx.scene.shape.MeshView;
|
||||
import javafx.scene.shape.Shape3D;
|
||||
import javafx.scene.shape.Sphere;
|
||||
@@ -79,6 +81,9 @@ public class RaceController extends Controller {
|
||||
private View3D view3D;
|
||||
private ObservableList<Subject3D> viewSubjects;
|
||||
|
||||
private Subject3D nextMarkArrow;
|
||||
private ChangeListener<? super GPSCoordinate> pointToMark;
|
||||
|
||||
/**
|
||||
* The arrow controller.
|
||||
*/
|
||||
@@ -110,6 +115,7 @@ public class RaceController extends Controller {
|
||||
* Ctor.
|
||||
*/
|
||||
public RaceController() {
|
||||
this.nextMarkArrow = new Annotation3D(new Box(1,3,0));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -307,7 +313,7 @@ public class RaceController extends Controller {
|
||||
if(curr != null && visualiserRace.getVisualiserRaceState().isVisualiserBoat(curr.getSourceID())) {
|
||||
addThirdPersonAnnotations(curr);
|
||||
} else {
|
||||
removeThirdPersonAnnotations();
|
||||
removeThirdPersonAnnotations(prev);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -357,19 +363,35 @@ public class RaceController extends Controller {
|
||||
}
|
||||
|
||||
private void addThirdPersonAnnotations(Subject3D subject3D) {
|
||||
viewSubjects.add(nextMarkArrow);
|
||||
|
||||
try {
|
||||
VisualiserBoat boat = visualiserRace.getVisualiserRaceState().getBoat(subject3D.getSourceID());
|
||||
boat.bearingProperty().addListener((o, prev, curr) -> {
|
||||
this.pointToMark = (o, prev, curr) -> {
|
||||
CompoundMark target = boat.getCurrentLeg().getEndCompoundMark();
|
||||
Bearing headingToMark = GPSCoordinate.calculateBearing(boat.getPosition(), target.getAverageGPSCoordinate());
|
||||
System.out.println(headingToMark.degrees() - boat.getBearing().degrees());
|
||||
});
|
||||
|
||||
nextMarkArrow.setY(10);
|
||||
nextMarkArrow.setX(subject3D.getPosition().getX());
|
||||
nextMarkArrow.setZ(subject3D.getPosition().getZ());
|
||||
nextMarkArrow.setHeading(headingToMark.degrees());
|
||||
};
|
||||
|
||||
boat.positionProperty().addListener(pointToMark);
|
||||
} catch (BoatNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeThirdPersonAnnotations() {
|
||||
private void removeThirdPersonAnnotations(Subject3D subject3D) {
|
||||
viewSubjects.remove(nextMarkArrow);
|
||||
|
||||
try {
|
||||
VisualiserBoat boat = visualiserRace.getVisualiserRaceState().getBoat(subject3D.getSourceID());
|
||||
boat.positionProperty().removeListener(pointToMark);
|
||||
} catch (BoatNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package visualiser.layout;
|
||||
|
||||
import javafx.scene.shape.Shape3D;
|
||||
|
||||
/**
|
||||
* Created by connortaylorbrown on 13/09/17.
|
||||
*/
|
||||
public class Annotation3D extends Subject3D {
|
||||
/**
|
||||
* Constructor for view subject wrapper
|
||||
*
|
||||
* @param mesh to be rendered
|
||||
*/
|
||||
public Annotation3D(Shape3D mesh) {
|
||||
super(mesh, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent rescaling of this subject
|
||||
* @param scale ignored
|
||||
*/
|
||||
@Override
|
||||
public void setScale(double scale) {}
|
||||
}
|
||||
Reference in New Issue
Block a user