mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
- Added ability to color the indicators.
#tags [1276]
This commit is contained in:
@@ -8,6 +8,8 @@ import javafx.geometry.Point2D;
|
||||
import javafx.geometry.Point3D;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.PhongMaterial;
|
||||
import javafx.scene.shape.MeshView;
|
||||
import javafx.scene.transform.Rotate;
|
||||
import javafx.scene.transform.Scale;
|
||||
import javafx.scene.transform.Translate;
|
||||
@@ -30,12 +32,14 @@ public class BoatObject extends Group {
|
||||
|
||||
private BoatModel boatAssets;
|
||||
private Group wake;
|
||||
private Group markIndicator;
|
||||
private Group playerIndicator;
|
||||
private Color colour = Color.BLACK;
|
||||
private Boolean isSelected = false;
|
||||
private Rotate rotation = new Rotate(0, new Point3D(0,0,1));
|
||||
|
||||
// This stuff only matters to the players boat object.
|
||||
private Group markIndicator;
|
||||
private MeshView playerIndicator;
|
||||
private Color indicatorColor = Color.LIGHTBLUE;
|
||||
private ReadOnlyDoubleWrapper rotationProperty;
|
||||
|
||||
private List<SelectedBoatListener> selectedBoatListenerListeners = new ArrayList<>();
|
||||
@@ -85,25 +89,18 @@ public class BoatObject extends Group {
|
||||
}
|
||||
|
||||
public void updateMarkIndicator(Point2D markPoint) {
|
||||
// calculate heading between boat and next mark
|
||||
|
||||
System.out.println(markPoint);
|
||||
Point2D boatLoc = new Point2D(this.getLayoutX(), this.getLayoutY());
|
||||
System.out.println(boatLoc);
|
||||
|
||||
Double angle = Math.toDegrees(
|
||||
Math.atan2(boatLoc.getY() - markPoint.getY(), boatLoc.getX() - markPoint.getX())) - 90;
|
||||
|
||||
Double radius = 2.7;
|
||||
Double scale = 0.5;
|
||||
Double scale = 0.8;
|
||||
|
||||
Double originX = this.getLayoutX();
|
||||
Double originY = this.getLayoutY();
|
||||
|
||||
Double transX = (radius * Math.cos(Math.toRadians(angle)));
|
||||
Double transY = (radius * Math.sin(Math.toRadians(angle)));
|
||||
System.out.println(transX);
|
||||
System.out.println(transY);
|
||||
markIndicator.getTransforms().clear();
|
||||
markIndicator.getTransforms().addAll(
|
||||
new Rotate(angle, new Point3D(0, 0, 1)),
|
||||
@@ -154,13 +151,30 @@ public class BoatObject extends Group {
|
||||
public void setMarkIndicator(Group indicator) {
|
||||
this.markIndicator = indicator;
|
||||
this.getChildren().add(markIndicator);
|
||||
createPlayerIndicator();
|
||||
setIndicatorColor(indicatorColor);
|
||||
}
|
||||
|
||||
private void createPlayerIndicator() {
|
||||
Model torus = ModelFactory.importModel(ModelType.PLAYER_IDENTIFIER_TORUS);
|
||||
torus.getAssets().getTransforms().addAll(
|
||||
new Rotate(90, new Point3D(1, 0, 0)),
|
||||
new Scale(0.7, 0.7, 0.7),
|
||||
new Translate(0, 0, 0)
|
||||
);
|
||||
|
||||
this.getChildren().add(torus.getAssets());
|
||||
playerIndicator = (MeshView) ((Group) ((Group) torus.getAssets().getChildren().get(0))
|
||||
.getChildren().get(0)).getChildren().get(0);
|
||||
}
|
||||
|
||||
public void setIndicatorColor(Color color) {
|
||||
this.indicatorColor = color;
|
||||
MeshView markIndicatorMesh = (MeshView) ((Group) ((Group) this.markIndicator.getChildren()
|
||||
.get(0))
|
||||
.getChildren().get(0)).getChildren().get(0);
|
||||
markIndicatorMesh.setMaterial(new PhongMaterial(color));
|
||||
playerIndicator.setMaterial(new PhongMaterial(color));
|
||||
}
|
||||
|
||||
public Group getWake () {
|
||||
|
||||
Reference in New Issue
Block a user