mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
fixed sail rotation broken from port to 3d #story[1266]
This commit is contained in:
@@ -179,19 +179,19 @@ public class GameView3D {
|
|||||||
black.setLayoutX(-.125);
|
black.setLayoutX(-.125);
|
||||||
black.setLayoutY(0);
|
black.setLayoutY(0);
|
||||||
|
|
||||||
ImagePattern oceanImage = new ImagePattern(
|
// ImagePattern oceanImage = new ImagePattern(
|
||||||
new Image(
|
// new Image(
|
||||||
GameView3D.class.getResourceAsStream(
|
// GameView3D.class.getResourceAsStream(
|
||||||
"/pics/creek.gif")
|
// "/pics/water.gif")
|
||||||
), 0, 0, 1000, 1000, false
|
// ), 0, 0, 1000, 1000, false
|
||||||
);
|
// );
|
||||||
|
//
|
||||||
Circle ocean = new Circle(0, 0, 5000);
|
// Circle ocean = new Circle(0, 0, 5000);
|
||||||
ocean.setFill(oceanImage);
|
// ocean.setFill(oceanImage);
|
||||||
ocean.getTransforms().add(new Scale(0.1, 0.1));
|
// ocean.getTransforms().add(new Scale(0.1, 0.1));
|
||||||
|
|
||||||
gameObjects.getChildren().addAll(
|
gameObjects.getChildren().addAll(
|
||||||
ocean,
|
// ocean,
|
||||||
// ModelFactory.importModel(ModelType.OCEAN).getAssets(),
|
// ModelFactory.importModel(ModelType.OCEAN).getAssets(),
|
||||||
raceBorder, trail, markers, tokens, playerAnnotation,
|
raceBorder, trail, markers, tokens, playerAnnotation,
|
||||||
white, blue, green, black, red
|
white, blue, green, black, red
|
||||||
@@ -750,4 +750,8 @@ public class GameView3D {
|
|||||||
// });
|
// });
|
||||||
// playerYacht.addMarkRoundingListener(this::updateMarkArrows);
|
// playerYacht.addMarkRoundingListener(this::updateMarkArrows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setWindDir(double windDir) {
|
||||||
|
this.windDir = windDir;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
|
|
||||||
// raceState.addCollisionListener(gameView::drawCollision);
|
// raceState.addCollisionListener(gameView::drawCollision);
|
||||||
raceState.windDirectionProperty().addListener((obs, oldDirection, newDirection) -> {
|
raceState.windDirectionProperty().addListener((obs, oldDirection, newDirection) -> {
|
||||||
// gameView.setWindDir(newDirection.doubleValue());
|
gameView.setWindDir(newDirection.doubleValue());
|
||||||
Platform.runLater(() -> updateWindDirection(newDirection.doubleValue()));
|
Platform.runLater(() -> updateWindDirection(newDirection.doubleValue()));
|
||||||
});
|
});
|
||||||
// raceState.windSpeedProperty().addListener((obs, oldSpeed, newSpeed) ->
|
// raceState.windSpeedProperty().addListener((obs, oldSpeed, newSpeed) ->
|
||||||
@@ -165,7 +165,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
updateWindDirection(raceState.windDirectionProperty().doubleValue());
|
updateWindDirection(raceState.windDirectionProperty().doubleValue());
|
||||||
updateWindSpeed(raceState.getWindSpeed());
|
updateWindSpeed(raceState.getWindSpeed());
|
||||||
});
|
});
|
||||||
// gameView.setWindDir(raceState.windDirectionProperty().doubleValue());
|
gameView.setWindDir(raceState.windDirectionProperty().doubleValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -244,27 +244,28 @@ public class BoatObject extends Group {
|
|||||||
wake.getTransforms().setAll(new Rotate(heading, new Point3D(0,0,1)));
|
wake.getTransforms().setAll(new Rotate(heading, new Point3D(0,0,1)));
|
||||||
if (sailsIn) {
|
if (sailsIn) {
|
||||||
boatAssets.showSail();
|
boatAssets.showSail();
|
||||||
System.out.println("heading = " + heading);
|
|
||||||
Double sailWindOffset = 30.0;
|
Double sailWindOffset = 30.0;
|
||||||
Double upwindAngleLimit = 15.0;
|
Double upwindAngleLimit = 15.0;
|
||||||
Double downwindAngleLimit = 10.0; //Upwind from normalised horizontal
|
Double downwindAngleLimit = 10.0; //Upwind from normalised horizontal
|
||||||
Double normalizedHeading = normalizeHeading(heading, windDir);
|
Double normalizedHeading = normalizeHeading(heading, windDir);
|
||||||
|
System.out.println("normalizedHeading = " + normalizedHeading);
|
||||||
if (normalizedHeading < 180) {
|
if (normalizedHeading < 180) {
|
||||||
if (normalizedHeading < sailWindOffset + upwindAngleLimit){
|
if (normalizedHeading < sailWindOffset + upwindAngleLimit){
|
||||||
boatAssets.rotateSail(-heading + 90 - upwindAngleLimit);
|
boatAssets.rotateSail(-upwindAngleLimit);
|
||||||
} else if (normalizedHeading > 90 + sailWindOffset){
|
} else if (normalizedHeading > 90 + sailWindOffset){
|
||||||
boatAssets.rotateSail(-heading + downwindAngleLimit);
|
boatAssets.rotateSail(-90 + downwindAngleLimit);
|
||||||
} else {
|
} else {
|
||||||
boatAssets.rotateSail(-heading + 90 + sailWindOffset);
|
boatAssets.rotateSail(-heading + windDir + sailWindOffset);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if (normalizedHeading > 360 - (sailWindOffset + upwindAngleLimit)){
|
if (normalizedHeading > 360 - (sailWindOffset + upwindAngleLimit)) {
|
||||||
// boatAssets.rotateSail(-heading + 90 + upwindAngleLimit);
|
boatAssets.rotateSail(upwindAngleLimit);
|
||||||
// } else if (normalizedHeading < 270 - sailWindOffset){
|
} else if (normalizedHeading < 270 - sailWindOffset) {
|
||||||
// boatAssets.rotateSail(-heading + 180 - downwindAngleLimit);
|
boatAssets.rotateSail(90 - downwindAngleLimit);
|
||||||
// } else {
|
} else {
|
||||||
// boatAssets.rotateSail(-heading + 90 - sailWindOffset);
|
System.out.println("windDir = " + windDir);
|
||||||
// }
|
boatAssets.rotateSail(-heading + windDir - sailWindOffset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
boatAssets.hideSail();
|
boatAssets.hideSail();
|
||||||
|
|||||||
Reference in New Issue
Block a user