mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Fixing wakes, bug caused by attempting to fix a issue with jittery boats actually caused by parser.
#bug
This commit is contained in:
@@ -18,8 +18,8 @@ public class App extends Application
|
|||||||
primaryStage.setScene(new Scene(root));
|
primaryStage.setScene(new Scene(root));
|
||||||
|
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
// StreamReceiver sr = new StreamReceiver("csse-s302staff.canterbury.ac.nz", 4941,"TestThread1");
|
StreamReceiver sr = new StreamReceiver("csse-s302staff.canterbury.ac.nz", 4941,"TestThread1");
|
||||||
StreamReceiver sr = new StreamReceiver("livedata.americascup.com", 4941, "TestThread1");
|
// StreamReceiver sr = new StreamReceiver("livedata.americascup.com", 4941, "TestThread1");
|
||||||
sr.start();
|
sr.start();
|
||||||
StreamParser streamParser = new StreamParser("TestThread2");
|
StreamParser streamParser = new StreamParser("TestThread2");
|
||||||
streamParser.start();
|
streamParser.start();
|
||||||
|
|||||||
@@ -18,23 +18,18 @@ public class BoatGroup extends RaceObject{
|
|||||||
private static final double TEAMNAME_Y_OFFSET = -15d;
|
private static final double TEAMNAME_Y_OFFSET = -15d;
|
||||||
private static final double VELOCITY_X_OFFSET = 10d;
|
private static final double VELOCITY_X_OFFSET = 10d;
|
||||||
private static final double VELOCITY_Y_OFFSET = -5d;
|
private static final double VELOCITY_Y_OFFSET = -5d;
|
||||||
private static final double VELOCITY_WAKE_RATIO = 2d;
|
|
||||||
private static final double BOAT_HEIGHT = 15d;
|
private static final double BOAT_HEIGHT = 15d;
|
||||||
private static final double BOAT_WIDTH = 10d;
|
private static final double BOAT_WIDTH = 10d;
|
||||||
private static final int LINE_INTERVAL = 180;
|
private static final int LINE_INTERVAL = 30;
|
||||||
private static double expectedUpdateInterval = 200;
|
private static double expectedUpdateInterval = 200;
|
||||||
private static int WAKE_FRAME_INTERVAL = 30;
|
|
||||||
private double framesForNewLine = 0;
|
private double framesForNewLine = 0;
|
||||||
private boolean destinationSet;
|
private boolean destinationSet;
|
||||||
private Point2D lastPoint;
|
private Point2D lastPoint;
|
||||||
private int wakeGenerationDelay;
|
private int wakeGenerationDelay;
|
||||||
|
|
||||||
private Boat boat;
|
private Boat boat;
|
||||||
private int wakeCounter = WAKE_FRAME_INTERVAL;
|
|
||||||
private Group lineGroup = new Group();
|
private Group lineGroup = new Group();
|
||||||
private Group wakeGroup = new Group();
|
|
||||||
private Polygon boatPoly;
|
private Polygon boatPoly;
|
||||||
private Polygon wakePoly;
|
|
||||||
private Text teamNameObject;
|
private Text teamNameObject;
|
||||||
private Text velocityObject;
|
private Text velocityObject;
|
||||||
private Wake wake;
|
private Wake wake;
|
||||||
@@ -113,7 +108,7 @@ public class BoatGroup extends RaceObject{
|
|||||||
velocityObject.setLayoutY(y);
|
velocityObject.setLayoutY(y);
|
||||||
wake.setLayoutX(x);
|
wake.setLayoutX(x);
|
||||||
wake.setLayoutY(y);
|
wake.setLayoutY(y);
|
||||||
wake.rotate(currentRotation);
|
//wake.rotate(currentRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePosition (long timeInterval) {
|
public void updatePosition (long timeInterval) {
|
||||||
@@ -139,7 +134,7 @@ public class BoatGroup extends RaceObject{
|
|||||||
if (destinationSet){
|
if (destinationSet){
|
||||||
lastPoint = new Point2D(boatPoly.getLayoutX(), boatPoly.getLayoutY());
|
lastPoint = new Point2D(boatPoly.getLayoutX(), boatPoly.getLayoutY());
|
||||||
}
|
}
|
||||||
if (lineGroup.getChildren().size() > 100)
|
if (lineGroup.getChildren().size() > 80)
|
||||||
lineGroup.getChildren().remove(0);
|
lineGroup.getChildren().remove(0);
|
||||||
}
|
}
|
||||||
wake.updatePosition(timeInterval);
|
wake.updatePosition(timeInterval);
|
||||||
@@ -154,13 +149,14 @@ public class BoatGroup extends RaceObject{
|
|||||||
this.pixelVelocityY = (newYValue - boatPoly.getLayoutY()) / expectedUpdateInterval;
|
this.pixelVelocityY = (newYValue - boatPoly.getLayoutY()) / expectedUpdateInterval;
|
||||||
this.rotationalGoal = rotation;
|
this.rotationalGoal = rotation;
|
||||||
calculateRotationalVelocity();
|
calculateRotationalVelocity();
|
||||||
|
System.out.println("rotationalVelocity = " + rotationalVelocity);
|
||||||
rotateTo(rotation);
|
rotateTo(rotation);
|
||||||
if (wakeGenerationDelay > 0) {
|
// if (wakeGenerationDelay > 0) {
|
||||||
wake.rotate(rotationalGoal);
|
// wake.rotate(rotationalGoal);
|
||||||
wakeGenerationDelay--;
|
// wakeGenerationDelay--;
|
||||||
} else {
|
// } else {
|
||||||
wake.setRotationalVelocity(rotationalVelocity, rotationalGoal, pixelVelocityX, pixelVelocityY);
|
wake.setRotationalVelocity(rotationalVelocity, rotationalGoal, pixelVelocityX, pixelVelocityY);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,21 +175,6 @@ public class BoatGroup extends RaceObject{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void resizeWake(){
|
|
||||||
velocityObject.setText(String.valueOf(boat.getVelocity()));
|
|
||||||
super.getChildren().remove(wakePoly);
|
|
||||||
wakePoly = new Polygon(
|
|
||||||
5.0,0.0,
|
|
||||||
10.0, boat.getVelocity() * VELOCITY_WAKE_RATIO,
|
|
||||||
0.0, boat.getVelocity() * VELOCITY_WAKE_RATIO
|
|
||||||
);
|
|
||||||
wakePoly.setLayoutX(boatPoly.getLayoutX());
|
|
||||||
wakePoly.setLayoutY(boatPoly.getLayoutY());
|
|
||||||
wakePoly.setFill(Color.DARKBLUE);
|
|
||||||
super.getChildren().add(wakePoly);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void rotateTo (double rotation) {
|
public void rotateTo (double rotation) {
|
||||||
currentRotation = rotation;
|
currentRotation = rotation;
|
||||||
boatPoly.getTransforms().clear();
|
boatPoly.getTransforms().clear();
|
||||||
@@ -204,7 +185,7 @@ public class BoatGroup extends RaceObject{
|
|||||||
|
|
||||||
public void forceRotation () {
|
public void forceRotation () {
|
||||||
rotateTo (rotationalGoal);
|
rotateTo (rotationalGoal);
|
||||||
wake.rotate(rotationalGoal);
|
//wake.rotate(rotationalGoal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleAnnotations () {
|
public void toggleAnnotations () {
|
||||||
|
|||||||
@@ -50,10 +50,13 @@ class Wake extends Group {
|
|||||||
void setRotationalVelocity (double rotationalVelocity, double rotationGoal, double velocityX, double velocityY) {
|
void setRotationalVelocity (double rotationalVelocity, double rotationGoal, double velocityX, double velocityY) {
|
||||||
sum -= Math.abs(velocities[velocityIndices[0]]);
|
sum -= Math.abs(velocities[velocityIndices[0]]);
|
||||||
sum += Math.abs(rotationalVelocity);
|
sum += Math.abs(rotationalVelocity);
|
||||||
if (sum < 0.0001)
|
if (sum < 0.0001) {
|
||||||
|
System.out.println("***************************************************************************");
|
||||||
|
System.out.println(sum);
|
||||||
|
System.out.println("***************************************************************************");
|
||||||
rotate(rotationGoal); //In relatively straight segments the wake snaps to match the boats current position.
|
rotate(rotationGoal); //In relatively straight segments the wake snaps to match the boats current position.
|
||||||
//This stops the wake from eventually becoming out of sync with the boat.
|
//This stops the wake from eventually becoming out of sync with the boat.
|
||||||
|
}
|
||||||
//Update the index of the array of recent velocities that each wake uses. Each wake is 3 velocities behind the
|
//Update the index of the array of recent velocities that each wake uses. Each wake is 3 velocities behind the
|
||||||
//next smallest wake.
|
//next smallest wake.
|
||||||
velocityIndices[0] = (13 + (velocityIndices[0] - 1) % 13) % 13;
|
velocityIndices[0] = (13 + (velocityIndices[0] - 1) % 13) % 13;
|
||||||
@@ -81,6 +84,12 @@ class Wake extends Group {
|
|||||||
rotations[i] = rotations[i] + velocities[velocityIndices[i]] * timeInterval;
|
rotations[i] = rotations[i] + velocities[velocityIndices[i]] * timeInterval;
|
||||||
arcs[i].getTransforms().setAll(new Rotate(rotations[i]));
|
arcs[i].getTransforms().setAll(new Rotate(rotations[i]));
|
||||||
}
|
}
|
||||||
|
System.out.println("rotations[0] = " + rotations[0]);
|
||||||
|
System.out.println("rotations[1] = " + rotations[1]);
|
||||||
|
System.out.println("rotations[2] = " + rotations[2]);
|
||||||
|
System.out.println("rotations[3] = " + rotations[3]);
|
||||||
|
System.out.println("rotations[4] = " + rotations[4]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user