Wakes no longer become out of sync with boats after extended periods of time. Added in

a limit to the length of boat trails.

#implement
This commit is contained in:
cir27
2017-04-29 02:14:55 +12:00
parent 474f0ee427
commit 6149f7be60
7 changed files with 59 additions and 336 deletions
@@ -6,7 +6,6 @@ import javafx.fxml.FXML;
import javafx.geometry.Point2D;
import javafx.geometry.Point3D;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.layout.AnchorPane;
@@ -14,16 +13,13 @@ import javafx.scene.paint.Color;
import javafx.scene.shape.Arc;
import javafx.scene.shape.ArcType;
import javafx.scene.text.Font;
import javafx.util.Pair;
import seng302.models.Boat;
import seng302.models.BoatGroup;
import seng302.models.Colors;
import seng302.models.RaceObject;
import seng302.models.mark.*;
import seng302.models.parsers.StreamParser;
import seng302.models.parsers.StreamReceiver;
import java.sql.Time;
import java.text.DecimalFormat;
import java.util.*;
@@ -42,14 +38,13 @@ public class CanvasController {
private GraphicsContext gc;
private final int MARK_SIZE = 10;
private final int BUFFER_SIZE = 100;
private final int BUFFER_SIZE = 150;
private final int CANVAS_WIDTH = 1000;
private final int CANVAS_HEIGHT = 1000;
private final int LHS_BUFFER = BUFFER_SIZE;
private final int RHS_BUFFER = BUFFER_SIZE + MARK_SIZE / 2;
private final int TOP_BUFFER = BUFFER_SIZE;
private final int BOT_BUFFER = TOP_BUFFER + MARK_SIZE / 2;
private final int FRAME_RATE = 60;
private double distanceScaleFactor;
private ScaleDirection scaleDirection;
@@ -101,55 +96,9 @@ public class CanvasController {
gc.setFill(Color.SKYBLUE);
gc.fillRect(0,0, CANVAS_WIDTH, CANVAS_HEIGHT);
gc.restore();
drawCourse();
fitMarksToCanvas();
drawBoats();
// drawFps(12);
// // overriding the handle so that it can clean canvas and redraw boats and course marks
// AnimationTimer timer = new AnimationTimer() {
// private long lastUpdate = 0;
// private long lastFpsUpdate = 0;
// private int lastFpsCount = 0;
// private int fpsCount = 0;
// boolean done = true;
//
// @Override
// public void handle(long now) {
// if (true){ //if statement for limiting refresh rate if needed
//// gc.clearRect(0, 0, canvas.getWidth(),canvas.getHeight());
//// gc.setFill(Color.SKYBLUE);
//// gc.fillRect(0,0,canvas.getWidth(),canvas.getHeight());
//
//
// // If race has started, draw the boats and play the timeline
// if (raceViewController.getRace().getRaceTime() > 1) {
// raceViewController.playTimelines();
// }
// // Race has not started, pause the timelines
// else {
// raceViewController.pauseTimelines();
// }
// lastUpdate = now;
// fpsCount ++;
// if (now - lastFpsUpdate >= 1000000000){
// lastFpsCount = fpsCount;
// fpsCount = 0;
// lastFpsUpdate = now;
// }
// }
// }
// };
// timer.start();
//try {
// Thread.sleep(10000);
//}catch (Exception e) {
// e.printStackTrace();
//}
timer = new AnimationTimer() {
private int countdown = 60;
private int[] currentRaceMarker = {1, 1, 1, 1, 1, 1};
List<Mark> marks = raceViewController.getRace().getCourse();
@@ -175,97 +124,18 @@ public class CanvasController {
Double frameRate = 1_000_000_000.0 / elapsedNanosPerFrame ;
drawFps(frameRate.intValue());
}
//if (countdown == 0) {
//System.out.println("called the at");
for (RaceObject raceObject : raceObjects) {
//if (currentRaceMarker[boatIndex] < marks.size()) {
//if (currentRaceMarker[boatIndex] == 6) {
// int debugLine = 4;
//}
//double xb4 = boatGroup.getLayoutX();
//double yb4 = boatGroup.getLayoutY();
//nextMark = marks.get(currentRaceMarker[boatIndex]);
//descending = nextMark.getY() > boatGroup.getLayoutY();
//leftToRight = nextMark.getX() < boatGroup.getLayoutX();
raceObject.updatePosition(1000 / 60);
for (int id : raceObject.getRaceIds()) {
//System.out.println("id = " + id);
if (id != 0 && StreamParser.boatPositions.size() > 0) {
if (StreamParser.boatPositions.containsKey((long) id)) {
Point3D p = StreamParser.boatPositions.get((long) id);
Point2D p2d = latLonToXY(p.getX(), p.getY());
//System.out.println("p2d = " + p2d);
//System.out.println("p.toString() = " + p.toString());
double heading = 360.0 / 0xffff * p.getZ();
//System.out.println("heading = " + heading);
raceObject.setDestination(p2d.getX(), p2d.getY(), heading, id);
//raceObject.setDestination(p2d.getX(), p2d.getY(), id);
}
StreamParser.boatPositions.remove((long) id);
}
}
//Point3D p = StreamParser.boatPositions.get((long) raceObject.getRaceIds()[0]);
//System.out.println("boatGroup = " + boatGroup.getBoat().getId());
//System.out.println("StreamParser.boatPositions.toString() = " + StreamParser.boatPositions.toString());
// if (p != null) {
// Point2D p2d = latLonToXY(p.getX(), p.getY());
// //System.out.println("p2d = " + p2d);
// if (!boatGroup.isSamePos(p2d)) {
// //System.out.println("p.toString() = " + p.toString());
// double heading = 360.0 / 0xffff * p.getZ();
// //System.out.println("heading = " + heading);
//
//
//
// boatGroup.setDestination(p2d.getX(), p2d.getY(), heading, boatGroup.getRaceIds()[0]);
//boatGroup.setDestination(p2d.getX(), p2d.getY());
// }
//}
// if (descending && nextMark.getY() < boatGroup.getLayoutY()) {
// currentRaceMarker[boatIndex]++;
// boatGroup.setDestination(
// marks.get(currentRaceMarker[boatIndex]).getX(), marks.get(currentRaceMarker[boatIndex]).getY()
// );
// } else if (!descending && nextMark.getY() > boatGroup.getLayoutY()) {
// currentRaceMarker[boatIndex]++;
// boatGroup.setDestination(
// marks.get(currentRaceMarker[boatIndex]).getX(), marks.get(currentRaceMarker[boatIndex]).getY()
// );
// } else if (leftToRight && nextMark.getX() > boatGroup.getLayoutX()) {
// currentRaceMarker[boatIndex]++;
// boatGroup.setDestination(
// marks.get(currentRaceMarker[boatIndex]).getX(), marks.get(currentRaceMarker[boatIndex]).getY()
// );
// } else if (!leftToRight && nextMark.getX() < boatGroup.getLayoutX()) {
// currentRaceMarker[boatIndex]++;
// boatGroup.setDestination(
// marks.get(currentRaceMarker[boatIndex]).getX(), marks.get(currentRaceMarker[boatIndex]).getY()
// );
// double xnew = boatGroup.getLayoutX();
// double ynew = boatGroup.getLayoutY();
// double dx = xnew - xb4;
// double dy = ynew -yb4;
// raceFinished = false;
// boatIndex++;
for (RaceObject raceObject : raceObjects) {
raceObject.updatePosition(1000 / 60);
for (int id : raceObject.getRaceIds()) {
if (StreamParser.boatPositions.containsKey((long) id)) {
Point3D p = StreamParser.boatPositions.get((long) id);
Point2D p2d = latLonToXY(p.getX(), p.getY());
double heading = 360.0 / 0xffff * p.getZ();
raceObject.setDestination(p2d.getX(), p2d.getY(), heading, id);
}
//}
//if (raceFinished) {
// System.out.println("DONZEO LADS");
// this.stop();
//}
//} else {
// countdown--;
//}
StreamParser.boatPositions.remove((long) id);
}
}
}
};
for (Mark m : raceViewController.getRace().getCourse()) {
@@ -377,77 +247,10 @@ public class CanvasController {
}
}
/**
* Draws the course.
*/
private void drawCourse() {
fitToCanvas();
// for (Mark mark : raceViewController.getRace().getCourse()) {
// if (mark.getMarkType() == MarkType.SINGLE_MARK) {
// drawSingleMark((SingleMark) mark, Color.BLACK);
// } else {
// drawGateMark((GateMark) mark);
// }
// }
// System.out.println("MIN/MAX POINTS");
// System.out.println(minLatPoint.getName() + " " + minLatPoint.getX() + " " + minLatPoint.getY());
// System.out.println(maxLatPoint.getName() + " " + maxLatPoint.getX() + " " + maxLatPoint.getY());
// System.out.println(minLonPoint.getName() + " " + minLonPoint.getX() + " " + minLonPoint.getY());
// System.out.println(maxLonPoint.getName() + " " + maxLonPoint.getX() + " " + maxLonPoint.getY());
// System.out.println(referencePointX);
// System.out.println(referencePointY);
}
// /**
// * Draw a given mark on canvas
// *
// * @param singleMark
// */
// private void drawSingleMark(SingleMark singleMark, Color color) {
// gc.setFill(color);
// System.out.println("DRAWING " + singleMark.getName() + " at " + singleMark.getX() + ", " + singleMark.getY());
// gc.fillOval(singleMark.getX(), singleMark.getY(),MARK_SIZE,MARK_SIZE);
// }
//
// /**
// * Draw a gate mark which contains two single marks
// *
// * @param gateMark
// */
// private void drawGateMark(GateMark gateMark) {
// Color color = Color.BLUE;
//
// if (gateMark.getName().equals("Start")){
// color = Color.GREEN;
// }
//
// if (gateMark.getName().equals("Finish")){
// color = Color.RED;
// }
//
// drawSingleMark(gateMark.getSingleMark1(), color);
// drawSingleMark(gateMark.getSingleMark2(), color);
//
// GraphicsContext gc = canvas.getGraphicsContext2D();
// gc.save();
// gc.setStroke(color);
// if (gateMark.getMarkType() == MarkType.OPEN_GATE)
// gc.setLineDashes(3, 5);
//
// gc.setLineWidth(2);
// gc.strokeLine(
// gateMark.getSingleMark1().getX() + MARK_SIZE / 2,
// gateMark.getSingleMark1().getY() + MARK_SIZE / 2,
// gateMark.getSingleMark2().getX() + MARK_SIZE / 2,
// gateMark.getSingleMark2().getY() + MARK_SIZE / 2
// );
// gc.restore();
// }
/**
* Calculates x and y location for every marker that fits it to the canvas the race will be drawn on.
*/
private void fitToCanvas() {
private void fitMarksToCanvas() {
findMinMaxPoint();
double minLonToMaxLon = scaleRaceExtremities();
calculateReferencePointLocation(minLonToMaxLon);
@@ -482,16 +285,6 @@ public class CanvasController {
Collections.reverse(sortedPoints);
minLonPoint = sortedPoints.get(0);
maxLonPoint = sortedPoints.get(sortedPoints.size()-1);
System.out.println("ALL POINTS");
for (Mark m : sortedPoints)
{
System.out.println(m.getName() + " " + m.getLatitude() + " " + m.getLongitude());
}
System.out.println("MIN/MAX POINTS");
System.out.println(minLatPoint.getName() + " " + minLatPoint.getLatitude() + " " + minLatPoint.getLongitude());
System.out.println(maxLatPoint.getName() + " " + maxLatPoint.getLatitude() + " " + maxLatPoint.getLongitude());
System.out.println(minLonPoint.getName() + " " + minLonPoint.getLatitude() + " " + minLonPoint.getLongitude());
System.out.println(maxLonPoint.getName() + " " + maxLonPoint.getLatitude() + " " + maxLonPoint.getLongitude());
}
/**
@@ -503,20 +296,11 @@ public class CanvasController {
private void calculateReferencePointLocation (double minLonToMaxLon) {
Mark referencePoint = minLatPoint;
double referenceAngle;
//double mapWidth = canvas.getWidth();
//double mapHeight = canvas.getHeight();
if (scaleDirection == ScaleDirection.HORIZONTAL) {
System.out.println("HORIZONTAL");
System.out.println("ref angle " + Mark.calculateHeadingRad(referencePoint, minLonPoint));
//referenceAngle = Mark.calculateHeadingRad(referencePoint, minLonPoint) - (Math.PI * (3/4));
referenceAngle = Math.abs(Mark.calculateHeadingRad(referencePoint, minLonPoint));
referencePointX = LHS_BUFFER + distanceScaleFactor * Math.sin(referenceAngle) * Mark.calculateDistance(referencePoint, minLonPoint);
//referenceAngle = Mark.calculateHeadingRad(referencePoint, maxLatPoint);
//if (referenceAngle > Math.PI) {
// referenceAngle = (Math.PI * 2) - referenceAngle;
//}
referenceAngle = Math.abs(Mark.calculateHeadingRad(referencePoint, maxLatPoint));
referencePointY = CANVAS_HEIGHT - (TOP_BUFFER + BOT_BUFFER);
referencePointY -= distanceScaleFactor * Math.cos(referenceAngle) * Mark.calculateDistance(referencePoint, maxLatPoint);
@@ -527,17 +311,11 @@ public class CanvasController {
System.out.println("VERTICAL");
referencePointY = CANVAS_HEIGHT - BOT_BUFFER;
//referenceAngle = (Math.PI * 2) - Mark.calculateHeadingRad(referencePoint, minLonPoint);
referenceAngle = Math.abs(Mark.calculateHeadingRad(referencePoint, minLonPoint));
referencePointX = LHS_BUFFER;
referencePointX += distanceScaleFactor * Math.sin(referenceAngle) * Mark.calculateDistance(referencePoint, minLonPoint);
referencePointX += ((CANVAS_WIDTH - (LHS_BUFFER + RHS_BUFFER)) - (minLonToMaxLon * distanceScaleFactor)) / 2;
}
referencePointX = Math.round(referencePointX);
referencePointY = Math.round(referencePointY);
// referencePoint.setX((int) referencePointX);
// referencePoint.setY((int) referencePointY);
}
/**
@@ -545,13 +323,11 @@ public class CanvasController {
* Returns the max horizontal distance of the map.
*/
private double scaleRaceExtremities () {
//double vertAngle = Mark.calculateHeadingRad(minLatPoint, maxLatPoint);
double vertAngle = Math.abs(Mark.calculateHeadingRad(minLatPoint, maxLatPoint));
// if (vertAngle > Math.PI)
// vertAngle = (2 * Math.PI) - vertAngle;
double vertDistance = Math.cos(vertAngle) * Mark.calculateDistance(minLatPoint, maxLatPoint);
double vertAngle = Math.abs(Mark.calculateHeadingRad(minLatPoint, maxLatPoint));
double vertDistance = Math.cos(vertAngle) * Mark.calculateDistance(minLatPoint, maxLatPoint);
double horiAngle = Mark.calculateHeadingRad(minLonPoint, maxLonPoint);
if (horiAngle <= (Math.PI / 2))
horiAngle = (Math.PI / 2) - horiAngle;
else
@@ -575,35 +351,19 @@ public class CanvasController {
* are scaled according to the distanceScaleFactor variable.
*/
private void givePointsXY() {
//Point2D canvasLocation;
List<Mark> allPoints = new ArrayList<>(raceViewController.getRace().getCourse());
List<Mark> processed = new ArrayList<>();
//Set<Mark> unqiuePoints = new HashSet<>(raceViewController.getRace().getCourse());
//System.out.println("unqiuePoints = " + unqiuePoints);
RaceObject markGroup;
for (Mark mark : allPoints) {
if (!processed.contains(mark)) {
if (mark.getMarkType() != MarkType.SINGLE_MARK) {
GateMark gateMark = (GateMark) mark;
// canvasLocation = findScaledXY(gateMark.getSingleMark1());
// gateMark.getSingleMark1().setX((int) canvasLocation.getX());
// gateMark.getSingleMark1().setY((int) canvasLocation.getY());
//
// canvasLocation = findScaledXY(gateMark.getSingleMark2());
// gateMark.getSingleMark2().setX((int) canvasLocation.getX());
// gateMark.getSingleMark2().setY((int) canvasLocation.getY());
markGroup = new MarkGroup(mark, findScaledXY(gateMark.getSingleMark1()), findScaledXY(gateMark.getSingleMark2()));
//group.getChildren().add(markGroup);
raceObjects.add(markGroup);
} else {
// canvasLocation = findScaledXY(mark);
// mark.setX((int) canvasLocation.getX());
// mark.setY((int) canvasLocation.getY());
markGroup = new MarkGroup(mark, findScaledXY(mark));
raceObjects.add(markGroup);
//group.getChildren().add(markGroup);
}
processed.add(mark);
}
@@ -625,35 +385,21 @@ public class CanvasController {
angleFromReference = Mark.calculateHeadingRad(latA, lonA, latB, lonB);
distanceFromReference = Mark.calculateDistance(latA, lonA, latB, lonB);
if (angleFromReference >= 0 && angleFromReference <= Math.PI / 2) {
//System.out.println("1");
xAxisLocation += (int) Math.round(distanceScaleFactor * Math.sin(angleFromReference) * distanceFromReference);
yAxisLocation -= (int) Math.round(distanceScaleFactor * Math.cos(angleFromReference) * distanceFromReference);
} else if (angleFromReference >= 0) {
//System.out.println("2");
angleFromReference = angleFromReference - Math.PI / 2;
xAxisLocation += (int) Math.round(distanceScaleFactor * Math.cos(angleFromReference) * distanceFromReference);
yAxisLocation += (int) Math.round(distanceScaleFactor * Math.sin(angleFromReference) * distanceFromReference);
} else if (angleFromReference < 0 && angleFromReference >= -Math.PI / 2) {
//System.out.println("3");
// System.out.println(distanceFromReference);
angleFromReference = Math.abs(angleFromReference);
// System.out.println(Math.cos(angleFromReference) * distanceFromReference);
xAxisLocation -= (int) Math.round(distanceScaleFactor * Math.sin(angleFromReference) * distanceFromReference);
yAxisLocation -= (int) Math.round(distanceScaleFactor * Math.cos(angleFromReference) * distanceFromReference);
} else {
//System.out.println("4");
angleFromReference = Math.abs(angleFromReference) - Math.PI / 2;
xAxisLocation -= (int) Math.round(distanceScaleFactor * Math.cos(angleFromReference) * distanceFromReference);
yAxisLocation += (int) Math.round(distanceScaleFactor * Math.sin(angleFromReference) * distanceFromReference);
}
// if (angleFromReference > (Math.PI / 2)) {
// angleFromReference = (Math.PI * 2) - angleFromReference;
// xAxisLocation -= (int) Math.round(distanceScaleFactor * Math.sin(angleFromReference) * distanceFromReference);
// } else {
// xAxisLocation += (int) Math.round(distanceScaleFactor * Math.sin(angleFromReference) * distanceFromReference);
// }
// yAxisLocation -= (int) Math.round(distanceScaleFactor * Math.cos(angleFromReference) * distanceFromReference);
//System.out.println(xAxisLocation + " *** " + yAxisLocation);
return new Point2D(xAxisLocation, yAxisLocation);
}
@@ -690,4 +436,8 @@ public class CanvasController {
private Point2D latLonToXY (double latitude, double longitude) {
return findScaledXY(minLatPoint.getLatitude(), minLatPoint.getLongitude(), latitude, longitude);
}
List<RaceObject> getRaceObjects() {
return raceObjects;
}
}
@@ -14,10 +14,7 @@ import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.util.Duration;
import seng302.models.Boat;
import seng302.models.Event;
import seng302.models.Race;
import seng302.models.TimelineInfo;
import seng302.models.*;
import seng302.models.parsers.ConfigParser;
import java.io.IOException;
@@ -288,4 +285,11 @@ public class RaceViewController extends Thread{
public ArrayList<Boat> getStartingBoats(){
return startingBoats;
}
@FXML
private void toggleAnnotations () {
for (RaceObject ro : includedCanvasController.getRaceObjects()) {
ro.toggleAnnotations();
}
}
}
+10 -10
View File
@@ -14,10 +14,10 @@ import seng302.models.parsers.StreamParser;
*/
public class BoatGroup extends RaceObject{
private static final double TEAMNAME_X_OFFSET = 15d;
private static final double TEAMNAME_Y_OFFSET = -20d;
private static final double VELOCITY_X_OFFSET = 15d;
private static final double VELOCITY_Y_OFFSET = -10d;
private static final double TEAMNAME_X_OFFSET = 10d;
private static final double TEAMNAME_Y_OFFSET = -15d;
private static final double VELOCITY_X_OFFSET = 10d;
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_WIDTH = 10d;
@@ -72,9 +72,9 @@ public class BoatGroup extends RaceObject{
private void initChildren (Color color) {
initChildren(color,
BOAT_WIDTH / 2, 0.0,
BOAT_WIDTH, BOAT_HEIGHT,
0.0, BOAT_HEIGHT);
-BOAT_WIDTH / 2, BOAT_HEIGHT,
0.0, 0.0,
BOAT_WIDTH / 2, BOAT_HEIGHT);
}
/**
@@ -111,7 +111,7 @@ public class BoatGroup extends RaceObject{
teamNameObject.setLayoutY(y);
velocityObject.setLayoutX(x);
velocityObject.setLayoutY(y);
wake.setLayoutX(x + BOAT_WIDTH / 2);
wake.setLayoutX(x);
wake.setLayoutY(y);
wake.rotate(currentRotation);
}
@@ -158,7 +158,7 @@ public class BoatGroup extends RaceObject{
wake.rotate(rotationalGoal);
wakeGenerationDelay--;
} else {
wake.setRotationalVelocity(rotationalVelocity);
wake.setRotationalVelocity(rotationalVelocity, rotationalGoal, pixelVelocityX, pixelVelocityY);
}
}
}
@@ -196,7 +196,7 @@ public class BoatGroup extends RaceObject{
public void rotateTo (double rotation) {
currentRotation = rotation;
boatPoly.getTransforms().clear();
boatPoly.getTransforms().add(new Rotate(rotation, BOAT_WIDTH / 2, 0));
boatPoly.getTransforms().add(new Rotate(rotation));
}
@@ -69,5 +69,4 @@ public abstract class RaceObject extends Group {
public abstract int[] getRaceIds ();
public abstract void toggleAnnotations ();
}
+17 -9
View File
@@ -21,6 +21,7 @@ class Wake extends Group {
private Arc[] arcs = new Arc[numWakes];
private double[] rotations = new double[numWakes];
private int velocitiesIndex = 0;
private double sum = 0;
/**
* Create a wake at the given location.
@@ -32,14 +33,7 @@ class Wake extends Group {
super.setLayoutY(startingY);
Arc arc;
for (int i = 0; i < numWakes; i++) {
arc = new Arc(
0,
0,
30 + RADIUS_INCREASE * i,
30 + RADIUS_INCREASE * i,
-110,
40
);
arc = new Arc(0,0,0,0,-110,40);
arc.setFill(new Color(0.18, 0.7, 1.0, 0.50 + OPACITY_INCREASE * i));
arc.setType(ArcType.ROUND);
arcs[i] = arc;
@@ -52,9 +46,23 @@ class Wake extends Group {
* the latest given velocity.
* @param rotationalVelocity The rotationalVelocity the wake should move at.
*/
void setRotationalVelocity (double rotationalVelocity) {
void setRotationalVelocity (double rotationalVelocity, double rotationGoal, double velocityX, double velocityY) {
sum -= Math.abs(velocities[velocitiesIndex]);
sum += Math.abs(rotationalVelocity);
if (sum < 0.0001)
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.
velocitiesIndex = (velocitiesIndex + 1) % 14;
velocities[velocitiesIndex] = rotationalVelocity;
double scaleFactor = Math.abs(Math.log10(Math.abs(velocityX) + Math.abs(velocityY)));
double baseRad = 30;
for (Arc arc :arcs) {
double rad = baseRad + 5 * scaleFactor;
arc.setRadiusX(rad);
arc.setRadiusY(rad);
baseRad += RADIUS_INCREASE;
}
}
/**
@@ -28,10 +28,6 @@ public class MarkGroup extends RaceObject {
private Point2D[] nodeDestinations;
public MarkGroup (Mark mark, Point2D... points) {
// for (Point2D p : points) {
// System.out.println("p.getX() = " + p.getX());
// System.out.println("p.getY() = " + p.getY());
// }
marks.add(mark);
mainMark = mark;
Color color = Color.BLACK;
@@ -43,9 +39,6 @@ public class MarkGroup extends RaceObject {
System.out.println("HERE ARE THE CHILDREN LOL");
if (mark.getMarkType() == MarkType.SINGLE_MARK) {
super.getChildren().add(new Circle(0, 0, MARK_RADIUS, color));
// System.out.println("SingleMark?");
// System.out.println("super.getChildren().get(0).getLayoutX() = " + super.getChildren().get(0).getLayoutX());
// System.out.println("super.getChildren().get(0).getLayoutY() = " + super.getChildren().get(0).getLayoutY());
} else {
marks.add(((GateMark) mark).getSingleMark1());
marks.add(((GateMark) mark).getSingleMark2());
@@ -57,13 +50,6 @@ public class MarkGroup extends RaceObject {
color
)
);
// super.getChildren().add(new Circle(0, 0, MARK_RADIUS, color));
// super.getChildren().get(0).setLayoutX((points[1].getX() - points[0].getX()) / 2d);
// super.getChildren().get(0).setLayoutY((points[1].getY() - points[0].getY()) / 2d);
// System.out.println("!!!!!!!!!!!!!!!!!");
// System.out.println((points[1].getX() - points[0].getX()) / 2d);
// System.out.println((points[1].getY() - points[0].getY()) / 2d);
// System.out.println(super.getChildren().get(0));
super.getChildren().add(
new Circle(
-(points[1].getX() - points[0].getX()) / 2d,
@@ -72,9 +58,6 @@ public class MarkGroup extends RaceObject {
color
)
);
// super.getChildren().add(new Circle(0, 0, MARK_RADIUS, color));
// super.getChildren().get(1).setLayoutX(-(points[1].getX() - points[0].getX()) / 2d);
// super.getChildren().get(1).setLayoutY(-(points[1].getY() - points[0].getY()) / 2d);
Line line = new Line(
(points[1].getX() - points[0].getX()) / 2d,
(points[1].getY() - points[0].getY()) / 2d,
@@ -93,22 +76,8 @@ public class MarkGroup extends RaceObject {
new Point2D(super.getChildren().get(0).getLayoutX(), super.getChildren().get(0).getLayoutY()),
new Point2D(super.getChildren().get(1).getLayoutX(), super.getChildren().get(1).getLayoutY())
};
// nodeDestinations = new Point2D[]{new Point2D(0,0), new Point2D(0,0)};
// System.out.println("super.getChildren().get(0).getLayoutX() = " + super.getChildren().get(0).getLayoutX());
// System.out.println("super.getChildren().get(0).getLayoutY() = " + super.getChildren().get(0).getLayoutY());
// System.out.println("super.getChildren().get(1).getLayoutX() = " + super.getChildren().get(1).getLayoutX());
// System.out.println("super.getChildren().get(1).getLayoutY() = " + super.getChildren().get(1).getLayoutY());
}
moveTo(points[0].getX(), points[0].getY());
// System.out.println("OKAY HERE IS A MARK");
// System.out.println("super.getLayoutX() = " + super.getLayoutX());
// System.out.println("super.getLayoutY() = " + super.getLayoutY());
// System.out.println("super.getChildren().get(0).getLayoutX() = " + super.getChildren().get(0).getLayoutX());
// System.out.println("super.getChildren().get(0).getLayoutY() = " + super.getChildren().get(0).getLayoutY());
// pixelVelocityX = 0;
// pixelVelocityY = 0;
// rotationalVelocity = 0;
// rotationalGoal = 0;
}
public void setDestination (double x, double y, double rotation, int... raceIds) {
@@ -146,14 +115,7 @@ public class MarkGroup extends RaceObject {
public void rotateTo (double rotation) {
super.getTransforms().clear();
// super.getTransforms().add(
// new Rotate(
// rotation,
// super.getChildren().get(1).getLayoutX() - super.getChildren().get(0).getLayoutX(),
// super.getChildren().get(1).getLayoutY() - super.getChildren().get(0).getLayoutY()
// )
// );
super.getTransforms().add(new Rotate(rotation, 0 , 0));
super.getTransforms().add(new Rotate(rotation));
}
public void updatePosition (long timeInterval) {