mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Removed rounding in GameView that caused objects to be rendered at incorrect positions.
#bug
This commit is contained in:
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.Point2D;
|
||||
import javafx.geometry.Point3D;
|
||||
import javafx.scene.AmbientLight;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.Node;
|
||||
@@ -20,6 +21,7 @@ import javafx.scene.transform.Translate;
|
||||
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||
import seng302.visualiser.fxObjects.assets_3D.BoatModel;
|
||||
import seng302.visualiser.fxObjects.assets_3D.ModelFactory;
|
||||
import seng302.visualiser.fxObjects.assets_3D.ModelType;
|
||||
|
||||
/**
|
||||
* BoatGroup is a javafx group that by default contains a graphical objects for representing a 2
|
||||
@@ -61,7 +63,7 @@ public class BoatObject extends Group {
|
||||
// private Polygon boatPoly;
|
||||
private BoatModel boatPoly;
|
||||
private Polygon sail;
|
||||
private Wake wake;
|
||||
private Group wake;
|
||||
private Line leftLayLine;
|
||||
private Line rightLayline;
|
||||
private double distanceTravelled, lastRotation;
|
||||
@@ -133,8 +135,8 @@ public class BoatObject extends Group {
|
||||
rightLayline = new Line();
|
||||
trail.getStrokeDashArray().setAll(5d, 10d);
|
||||
trail.setCache(true);
|
||||
wake = new Wake(0, -BOAT_HEIGHT);
|
||||
wake.setVisible(true);
|
||||
|
||||
wake = ModelFactory.importModel(ModelType.WAKE).getAssets();
|
||||
|
||||
sail = new Polygon(0.0,BOAT_HEIGHT / 4,
|
||||
0.0, BOAT_HEIGHT);
|
||||
@@ -162,7 +164,7 @@ public class BoatObject extends Group {
|
||||
// super.getChildren().add(pointLight);
|
||||
AmbientLight light = new AmbientLight(new Color(0.5,0.5,0.5,1));
|
||||
super.getChildren().add(light);
|
||||
super.getChildren().addAll(boatPoly.getAssets());//, sail);
|
||||
super.getChildren().addAll(boatPoly.getAssets());
|
||||
}
|
||||
|
||||
public void setFill (Color value) {
|
||||
@@ -229,8 +231,8 @@ public class BoatObject extends Group {
|
||||
// sail.setLayoutX(x);
|
||||
// sail.setLayoutY(y);
|
||||
// }
|
||||
// wake.setLayoutX(x);
|
||||
// wake.setLayoutY(y);
|
||||
wake.setLayoutX(x);
|
||||
wake.setLayoutY(y);
|
||||
});
|
||||
// wake.setRotation(rotation, velocity);
|
||||
// rotateTo(rotation);
|
||||
@@ -262,6 +264,7 @@ public class BoatObject extends Group {
|
||||
|
||||
private void rotateTo(double heading, boolean sailsIn, double windDir) {
|
||||
rotation.setAngle(heading);
|
||||
wake.getTransforms().setAll(new Rotate(heading, new Point3D(0,0,1)));
|
||||
if (!sailsIn) {
|
||||
boatPoly.showSail();
|
||||
Double sailWindOffset = 30.0;
|
||||
@@ -270,19 +273,19 @@ public class BoatObject extends Group {
|
||||
Double normalizedHeading = normalizeHeading(heading, windDir);
|
||||
if (normalizedHeading < 180) {
|
||||
if (normalizedHeading < sailWindOffset + upwindAngleLimit){
|
||||
boatPoly.rotateSail(heading + 90 - upwindAngleLimit);
|
||||
boatPoly.rotateSail(90 - upwindAngleLimit);
|
||||
} else if (normalizedHeading > 90 + sailWindOffset){
|
||||
boatPoly.rotateSail(heading + downwindAngleLimit);
|
||||
boatPoly.rotateSail(downwindAngleLimit);
|
||||
} else {
|
||||
boatPoly.rotateSail(windDir + 90 + sailWindOffset);
|
||||
boatPoly.rotateSail(90 + sailWindOffset);
|
||||
}
|
||||
} else {
|
||||
if (normalizedHeading > 360 - (sailWindOffset + upwindAngleLimit)){
|
||||
boatPoly.rotateSail(heading + 90 + upwindAngleLimit);
|
||||
boatPoly.rotateSail(90 + upwindAngleLimit);
|
||||
} else if (normalizedHeading < 270 - sailWindOffset){
|
||||
boatPoly.rotateSail(heading + 180 - downwindAngleLimit);
|
||||
boatPoly.rotateSail(180 - downwindAngleLimit);
|
||||
} else {
|
||||
boatPoly.rotateSail(windDir + 90 - sailWindOffset);
|
||||
boatPoly.rotateSail(90 - sailWindOffset);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -447,7 +450,7 @@ public class BoatObject extends Group {
|
||||
}
|
||||
|
||||
public void setTrajectory(double heading, double velocity, double windDir) {
|
||||
wake.setRotation(lastHeading - heading, velocity);
|
||||
// wake.r(lastHeading - heading, velocity);
|
||||
// rotateTo(heading, false, windDir);
|
||||
xVelocity = Math.cos(Math.toRadians(heading)) * velocity;
|
||||
yVelocity = Math.sin(Math.toRadians(heading)) * velocity;
|
||||
|
||||
@@ -104,8 +104,10 @@ public class ModelFactory {
|
||||
case START_LINE:
|
||||
case GATE_LINE:
|
||||
return makeGate(assets);
|
||||
case WAKE:
|
||||
return makeWake(assets);
|
||||
default:
|
||||
return new Model(assets, null);
|
||||
return new Model(new Group(assets), null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +120,7 @@ public class ModelFactory {
|
||||
new Translate(0,-1,0),
|
||||
new Rotate(0 ,new Point3D(1,1,1))
|
||||
);
|
||||
return new Model(assets, new AnimationTimer() {
|
||||
return new Model(new Group(assets), new AnimationTimer() {
|
||||
|
||||
private double rotation = 0;
|
||||
private Group group = assets;
|
||||
@@ -137,14 +139,14 @@ public class ModelFactory {
|
||||
Group area = new Group(importer.getImport());
|
||||
area.getChildren().add(marker);
|
||||
area.getTransforms().add(new Rotate(90, new Point3D(1, 0, 0)));
|
||||
return new Model(area, null);
|
||||
return new Model(new Group(area), null);
|
||||
}
|
||||
|
||||
private static Model makeOcean(Group group) {
|
||||
// group.setScaleY(Double.MAX_VALUE);
|
||||
// group.setScaleX(Double.MAX_VALUE);
|
||||
// group.getTransforms().add(new Rotate(90, new Point3D(1, 0, 0)));
|
||||
Circle ocean = new Circle(0,0,1000, Color.DEEPSKYBLUE);
|
||||
Circle ocean = new Circle(0,0,1000, Color.DARKSEAGREEN);
|
||||
ocean.setStroke(Color.TRANSPARENT);
|
||||
group.getChildren().add(ocean);
|
||||
return new Model(group, null);
|
||||
@@ -155,13 +157,22 @@ public class ModelFactory {
|
||||
new Rotate(90, new Point3D(1,0,0)),
|
||||
new Scale(1.5,1.5,1.5)
|
||||
);
|
||||
return new Model(assets, null);
|
||||
return new Model(new Group(assets), null);
|
||||
}
|
||||
|
||||
private static Model makeGate(Group assets) {
|
||||
assets.getTransforms().addAll(
|
||||
new Rotate(90, new Point3D(1,0,0))
|
||||
);
|
||||
return new Model(assets, null);
|
||||
return new Model(new Group(assets), null);
|
||||
}
|
||||
|
||||
private static Model makeWake(Group assets) {
|
||||
assets.getTransforms().setAll(
|
||||
new Rotate(-90, new Point3D(0,0,1)),
|
||||
new Rotate(90, new Point3D(1,0,0)),
|
||||
new Scale(0.5, 0.5, 0.5)
|
||||
);
|
||||
return new Model(new Group(assets), null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ public enum ModelType {
|
||||
BORDER_BARRIER ("barrier_segment.dae"),
|
||||
FINISH_LINE ("finish_line.dae"),
|
||||
START_LINE ("start_line.dae"),
|
||||
GATE_LINE ("gate_line.dae");
|
||||
GATE_LINE ("gate_line.dae"),
|
||||
WAKE ("wake.dae");
|
||||
|
||||
final String filename;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user