mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Added ocean asset. Moved camera to center of race.
#story[1266]
This commit is contained in:
@@ -47,7 +47,7 @@ public class ClientYacht extends Observable {
|
|||||||
private Integer position;
|
private Integer position;
|
||||||
|
|
||||||
private Long estimateTimeAtFinish;
|
private Long estimateTimeAtFinish;
|
||||||
private Boolean sailIn = true;
|
private Boolean sailIn = false;
|
||||||
private Integer currentMarkSeqID = 0;
|
private Integer currentMarkSeqID = 0;
|
||||||
private Long markRoundTime;
|
private Long markRoundTime;
|
||||||
private Long timeTillNext;
|
private Long timeTillNext;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import javafx.application.Platform;
|
|||||||
import javafx.geometry.Point2D;
|
import javafx.geometry.Point2D;
|
||||||
import javafx.geometry.Point3D;
|
import javafx.geometry.Point3D;
|
||||||
import javafx.scene.*;
|
import javafx.scene.*;
|
||||||
|
import javafx.scene.effect.BlendMode;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.input.KeyEvent;
|
import javafx.scene.input.KeyEvent;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
@@ -119,15 +120,30 @@ public class GameView3D {
|
|||||||
camera.setNearClip(0.1);
|
camera.setNearClip(0.1);
|
||||||
camera.setFieldOfView(FOV);
|
camera.setFieldOfView(FOV);
|
||||||
gameObjects = new Group();
|
gameObjects = new Group();
|
||||||
|
PointLight pl = new PointLight(Color.DARKGRAY);
|
||||||
|
pl.setLightOn(true);
|
||||||
|
pl.setBlendMode(BlendMode.ADD);
|
||||||
|
pl.setOpacity(0.5);
|
||||||
|
pl.getTransforms().add(new Translate(0,0,-500));
|
||||||
|
AmbientLight al = new AmbientLight();
|
||||||
|
al.setLightOn(true);
|
||||||
|
al.setBlendMode(BlendMode.SOFT_LIGHT);
|
||||||
|
al.getTransforms().add(new Translate(0, 0, -100));
|
||||||
root3D = new Group(camera, gameObjects);
|
root3D = new Group(camera, gameObjects);
|
||||||
view = new SubScene(
|
view = new SubScene(
|
||||||
root3D, 1000, 1000, true, SceneAntialiasing.BALANCED
|
root3D, 1000, 1000, true, SceneAntialiasing.BALANCED
|
||||||
);
|
);
|
||||||
view.setCamera(camera);
|
view.setCamera(camera);
|
||||||
view.setFill(Color.SKYBLUE);
|
// view.setFill(Color.LIGHTBLUE);
|
||||||
camera.getTransforms().add(new Rotate(30, new Point3D(1,0,0)));
|
camera.getTransforms().add(new Rotate(30, new Point3D(1,0,0)));
|
||||||
// gameObjects.getChildren().addAll(raceBorder, markers, tokens);
|
// gameObjects.getChildren().addAll(raceBorder, markers, tokens);
|
||||||
|
System.out.println(camera.getLayoutX());
|
||||||
|
System.out.println(camera.getTranslateX());
|
||||||
|
System.out.println(camera.getLayoutY());
|
||||||
|
System.out.println(camera.getTranslateY());
|
||||||
|
System.out.println(camera.getTranslateZ());
|
||||||
|
camera.setTranslateZ(-80);
|
||||||
|
camera.setTranslateY(150);
|
||||||
Sphere red = new Sphere(1);
|
Sphere red = new Sphere(1);
|
||||||
red.setMaterial(new PhongMaterial(Color.RED));
|
red.setMaterial(new PhongMaterial(Color.RED));
|
||||||
red.setLayoutX(0);
|
red.setLayoutX(0);
|
||||||
@@ -154,11 +170,16 @@ public class GameView3D {
|
|||||||
black.setLayoutY(0);
|
black.setLayoutY(0);
|
||||||
|
|
||||||
gameObjects.getChildren().addAll(
|
gameObjects.getChildren().addAll(
|
||||||
ModelFactory.importModel(ModelType.OCEAN).getAssets(),
|
// ModelFactory.importModel(ModelType.OCEAN).getAssets(),
|
||||||
raceBorder, markers, tokens,
|
raceBorder, markers, tokens,
|
||||||
white, blue, green, black, red
|
white, blue, green, black, red
|
||||||
);
|
);
|
||||||
|
|
||||||
|
System.out.println(camera.getLayoutX());
|
||||||
|
System.out.println(camera.getTranslateX());
|
||||||
|
System.out.println(camera.getLayoutY());
|
||||||
|
System.out.println(camera.getTranslateY());
|
||||||
|
System.out.println(camera.getTranslateZ());
|
||||||
// Sphere s = new Sphere(1);
|
// Sphere s = new Sphere(1);
|
||||||
// s.setMaterial(new PhongMaterial(Color.RED));
|
// s.setMaterial(new PhongMaterial(Color.RED));
|
||||||
// Sphere left = new Sphere(1);
|
// Sphere left = new Sphere(1);
|
||||||
|
|||||||
@@ -154,17 +154,17 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
// gameView.startRace();
|
// gameView.startRace();
|
||||||
|
|
||||||
// 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) ->
|
||||||
// Platform.runLater(() -> updateWindSpeed(newSpeed.doubleValue()))
|
// Platform.runLater(() -> updateWindSpeed(newSpeed.doubleValue()))
|
||||||
// );
|
// );
|
||||||
// Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
// updateWindDirection(raceState.windDirectionProperty().doubleValue());
|
updateWindDirection(raceState.windDirectionProperty().doubleValue());
|
||||||
// updateWindSpeed(raceState.getWindSpeed());
|
updateWindSpeed(raceState.getWindSpeed());
|
||||||
// });
|
});
|
||||||
// gameView.setWindDir(raceState.windDirectionProperty().doubleValue());
|
// gameView.setWindDir(raceState.windDirectionProperty().doubleValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,8 +60,7 @@ public class BoatObject extends Group {
|
|||||||
private double sailState;
|
private double sailState;
|
||||||
//Graphical objects
|
//Graphical objects
|
||||||
private Polyline trail = new Polyline();
|
private Polyline trail = new Polyline();
|
||||||
// private Polygon boatPoly;
|
private BoatModel boatAssets;
|
||||||
private BoatModel boatPoly;
|
|
||||||
private Polygon sail;
|
private Polygon sail;
|
||||||
private Group wake;
|
private Group wake;
|
||||||
private Line leftLayLine;
|
private Line leftLayLine;
|
||||||
@@ -102,31 +101,32 @@ public class BoatObject extends Group {
|
|||||||
* polygon.
|
* polygon.
|
||||||
*/
|
*/
|
||||||
private void initChildren(double... points) {
|
private void initChildren(double... points) {
|
||||||
boatPoly = makeBoatPolygon();
|
boatAssets = ModelFactory.boatGameView(BoatMeshType.DINGHY, colour);
|
||||||
boatPoly.getAssets().getTransforms().addAll(
|
boatAssets.hideSail();
|
||||||
|
boatAssets.getAssets().getTransforms().addAll(
|
||||||
// new Rotate(-40, new Point3D(1,0,0)),
|
// new Rotate(-40, new Point3D(1,0,0)),
|
||||||
rotation
|
rotation
|
||||||
// new Rotate(-90, new Point3D(0,0,1))
|
// new Rotate(-90, new Point3D(0,0,1))
|
||||||
);
|
);
|
||||||
boatPoly.getAssets().getTransforms().add(new Scale(5, 5, 5));
|
boatAssets.getAssets().getTransforms().add(new Scale(5, 5, 5));
|
||||||
// boatPoly.setDrawMode(DrawMode.FILL);
|
// boatAssets.setDrawMode(DrawMode.FILL);
|
||||||
// boatPoly.setFill(colour);
|
// boatAssets.setFill(colour);
|
||||||
// boatPoly.setFill(this.colour);
|
// boatAssets.setFill(this.colour);
|
||||||
// boatPoly.setMaterial(new PhongMaterial(this.colour));
|
// boatAssets.setMaterial(new PhongMaterial(this.colour));
|
||||||
boatPoly.getAssets().setOnMouseEntered(event -> {
|
boatAssets.getAssets().setOnMouseEntered(event -> {
|
||||||
// boatPoly.setFill(Color.FLORALWHITE);
|
// boatAssets.setFill(Color.FLORALWHITE);
|
||||||
// boatPoly.setStroke(Color.RED);
|
// boatAssets.setStroke(Color.RED);
|
||||||
// boatPoly.setMaterial(new PhongMaterial(Color.FLORALWHITE));
|
// boatAssets.setMaterial(new PhongMaterial(Color.FLORALWHITE));
|
||||||
});
|
});
|
||||||
boatPoly.getAssets().setOnMouseExited(event -> {
|
boatAssets.getAssets().setOnMouseExited(event -> {
|
||||||
// boatPoly.setMaterial(new PhongMaterial(this.colour));
|
// boatAssets.setMaterial(new PhongMaterial(this.colour));
|
||||||
// boatPoly.setFill(colour);
|
// boatAssets.setFill(colour);
|
||||||
// boatPoly.setFill(this.colour);
|
// boatAssets.setFill(this.colour);
|
||||||
// boatPoly.setStroke(Color.BLACK);
|
// boatAssets.setStroke(Color.BLACK);
|
||||||
});
|
});
|
||||||
boatPoly.getAssets().setOnMouseClicked(event -> setIsSelected(!isSelected));
|
boatAssets.getAssets().setOnMouseClicked(event -> setIsSelected(!isSelected));
|
||||||
boatPoly.getAssets().setCache(true);
|
boatAssets.getAssets().setCache(true);
|
||||||
// boatPoly.setCacheHint(CacheHint.SPEED);
|
// boatAssets.setCacheHint(CacheHint.SPEED);
|
||||||
|
|
||||||
// annotationBox = new AnnotationBox();
|
// annotationBox = new AnnotationBox();
|
||||||
// annotationBox.setFill(colour);
|
// annotationBox.setFill(colour);
|
||||||
@@ -164,46 +164,21 @@ public class BoatObject extends Group {
|
|||||||
// super.getChildren().add(pointLight);
|
// super.getChildren().add(pointLight);
|
||||||
AmbientLight light = new AmbientLight(new Color(0.5,0.5,0.5,1));
|
AmbientLight light = new AmbientLight(new Color(0.5,0.5,0.5,1));
|
||||||
super.getChildren().add(light);
|
super.getChildren().add(light);
|
||||||
super.getChildren().addAll(boatPoly.getAssets());
|
super.getChildren().addAll(boatAssets.getAssets());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFill (Color value) {
|
public void setFill (Color value) {
|
||||||
this.colour = value;
|
this.colour = value;
|
||||||
PhongMaterial pm = new PhongMaterial(this.colour);
|
PhongMaterial pm = new PhongMaterial(this.colour);
|
||||||
|
pm.setSpecularPower(0.5);
|
||||||
|
pm.setSpecularColor(Color.BLACK);
|
||||||
for (int i=0;i<2;i++) {
|
for (int i=0;i<2;i++) {
|
||||||
Shape3D s = (Shape3D) boatPoly.getAssets().getChildren().get(i);
|
Shape3D s = (Shape3D) boatAssets.getAssets().getChildren().get(i);
|
||||||
s.setMaterial(pm);
|
s.setMaterial(pm);
|
||||||
}
|
}
|
||||||
trail.setStroke(colour);
|
trail.setStroke(colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoatModel makeBoatPolygon () {
|
|
||||||
// StlMeshImporter importer = new StlMeshImporter();
|
|
||||||
// importer.read(getClass().getResource("/meshes/hollow_simple_boat.stl").toString());
|
|
||||||
// importer.read(getClass().getResource("/cube.stl").toString());
|
|
||||||
// importer.read(getClass().getResource("/meshes/simple_yacht.stl").toString());
|
|
||||||
// ObjModelImporter importer = new ObjModelImporter();
|
|
||||||
// ColModelImporter importer = new ColModelImporter();
|
|
||||||
// ColModelImporter importer = new ColModelImporter();
|
|
||||||
// importer.read(getClass().getResource("/meshes/hollow_simple_boat.dae"));
|
|
||||||
// MeshView mesh = importer.getImport()[0];
|
|
||||||
// FileInputStream inputStream = null;
|
|
||||||
// try{
|
|
||||||
// inputStream = new FileInputStream(getClass().getResource("/meshes/simple_yacht.stl").toString());
|
|
||||||
// Obj obj = ObjUtils.convertToRenderable(
|
|
||||||
// ObjReader.read(inputStream));
|
|
||||||
//
|
|
||||||
// IntBuffer indices = ObjData.getFaceVertexIndices(obj);
|
|
||||||
// FloatBuffer vertices = ObjData.getVertices(obj);
|
|
||||||
// FloatBuffer texCoords = ObjData.getTexCoords(obj);
|
|
||||||
// MeshView
|
|
||||||
// FloatBuffer normals = ObjData.getNormals(obj);
|
|
||||||
return ModelFactory.boatGameView(BoatMeshType.DINGHY, colour);
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the boat and its children annotations to coordinates specified
|
* Moves the boat and its children annotations to coordinates specified
|
||||||
@@ -214,12 +189,12 @@ public class BoatObject extends Group {
|
|||||||
* @param sailIn Boolean to toggle sail state.
|
* @param sailIn Boolean to toggle sail state.
|
||||||
*/
|
*/
|
||||||
public void moveTo(double x, double y, double rotation, double velocity, Boolean sailIn, double windDir) {
|
public void moveTo(double x, double y, double rotation, double velocity, Boolean sailIn, double windDir) {
|
||||||
Double dx = Math.abs(boatPoly.getAssets().getLayoutX() - x);
|
Double dx = Math.abs(boatAssets.getAssets().getLayoutX() - x);
|
||||||
Double dy = Math.abs(boatPoly.getAssets().getLayoutY() - y);
|
Double dy = Math.abs(boatAssets.getAssets().getLayoutY() - y);
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
rotateTo(rotation, sailIn, windDir);
|
rotateTo(rotation, sailIn, windDir);
|
||||||
boatPoly.getAssets().setLayoutX(x);
|
boatAssets.getAssets().setLayoutX(x);
|
||||||
boatPoly.getAssets().setLayoutY(y);
|
boatAssets.getAssets().setLayoutY(y);
|
||||||
// if (sailIn) {
|
// if (sailIn) {
|
||||||
//// sail.getPoints().clear();
|
//// sail.getPoints().clear();
|
||||||
//// sail.getPoints().addAll(0.0, 0.0, 4.0, 1.5, 8.0, 3.0, 12.0, 3.5, 16.0, 3.0, 20.0, 1.5, 24.0, 0.0);
|
//// sail.getPoints().addAll(0.0, 0.0, 4.0, 1.5, 8.0, 3.0, 12.0, 3.5, 16.0, 3.0, 20.0, 1.5, 24.0, 0.0);
|
||||||
@@ -236,8 +211,8 @@ public class BoatObject extends Group {
|
|||||||
});
|
});
|
||||||
// wake.setRotation(rotation, velocity);
|
// wake.setRotation(rotation, velocity);
|
||||||
// rotateTo(rotation);
|
// rotateTo(rotation);
|
||||||
// boatPoly.setLayoutX(x);
|
// boatAssets.setLayoutX(x);
|
||||||
// boatPoly.setLayoutY(y);
|
// boatAssets.setLayoutY(y);
|
||||||
// wake.setLayoutX(x);
|
// wake.setLayoutX(x);
|
||||||
// wake.setLayoutY(y);
|
// wake.setLayoutY(y);
|
||||||
// wake.rotate(rotation);
|
// wake.rotate(rotation);
|
||||||
@@ -265,31 +240,32 @@ public class BoatObject extends Group {
|
|||||||
private void rotateTo(double heading, boolean sailsIn, double windDir) {
|
private void rotateTo(double heading, boolean sailsIn, double windDir) {
|
||||||
rotation.setAngle(heading);
|
rotation.setAngle(heading);
|
||||||
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) {
|
||||||
boatPoly.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);
|
||||||
if (normalizedHeading < 180) {
|
if (normalizedHeading < 180) {
|
||||||
if (normalizedHeading < sailWindOffset + upwindAngleLimit){
|
if (normalizedHeading < sailWindOffset + upwindAngleLimit){
|
||||||
boatPoly.rotateSail(90 - upwindAngleLimit);
|
boatAssets.rotateSail(-heading + 90 - upwindAngleLimit);
|
||||||
} else if (normalizedHeading > 90 + sailWindOffset){
|
} else if (normalizedHeading > 90 + sailWindOffset){
|
||||||
boatPoly.rotateSail(downwindAngleLimit);
|
boatAssets.rotateSail(-heading + downwindAngleLimit);
|
||||||
} else {
|
} else {
|
||||||
boatPoly.rotateSail(90 + sailWindOffset);
|
boatAssets.rotateSail(-heading + 90 + sailWindOffset);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (normalizedHeading > 360 - (sailWindOffset + upwindAngleLimit)){
|
// if (normalizedHeading > 360 - (sailWindOffset + upwindAngleLimit)){
|
||||||
boatPoly.rotateSail(90 + upwindAngleLimit);
|
// boatAssets.rotateSail(-heading + 90 + upwindAngleLimit);
|
||||||
} else if (normalizedHeading < 270 - sailWindOffset){
|
// } else if (normalizedHeading < 270 - sailWindOffset){
|
||||||
boatPoly.rotateSail(180 - downwindAngleLimit);
|
// boatAssets.rotateSail(-heading + 180 - downwindAngleLimit);
|
||||||
} else {
|
// } else {
|
||||||
boatPoly.rotateSail(90 - sailWindOffset);
|
// boatAssets.rotateSail(-heading + 90 - sailWindOffset);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
boatPoly.hideSail();
|
boatAssets.hideSail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,7 +291,7 @@ public class BoatObject extends Group {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateLocation() {
|
public void updateLocation() {
|
||||||
// boatPoly.getTransforms().add(new Rotate(2, new Point3D(1,1,1)));
|
// boatAssets.getTransforms().add(new Rotate(2, new Point3D(1,1,1)));
|
||||||
// double dx = xVelocity / 60;
|
// double dx = xVelocity / 60;
|
||||||
// double dy = yVelocity / 60;
|
// double dy = yVelocity / 60;
|
||||||
//
|
//
|
||||||
@@ -329,8 +305,8 @@ public class BoatObject extends Group {
|
|||||||
// Line l = new Line(
|
// Line l = new Line(
|
||||||
// lastPoint.getX(),
|
// lastPoint.getX(),
|
||||||
// lastPoint.getY(),
|
// lastPoint.getY(),
|
||||||
// boatPoly.getLayoutX(),
|
// boatAssets.getLayoutX(),
|
||||||
// boatPoly.getLayoutY()
|
// boatAssets.getLayoutY()
|
||||||
// );
|
// );
|
||||||
// l.getStrokeDashArray().setAll(3d, 7d);
|
// l.getStrokeDashArray().setAll(3d, 7d);
|
||||||
// l.setStroke(colour);
|
// l.setStroke(colour);
|
||||||
@@ -338,7 +314,7 @@ public class BoatObject extends Group {
|
|||||||
// l.setCacheHint(CacheHint.SPEED);
|
// l.setCacheHint(CacheHint.SPEED);
|
||||||
// lineGroup.getChildren().add(l);
|
// lineGroup.getChildren().add(l);
|
||||||
// }
|
// }
|
||||||
// lastPoint = new Point2D(boatPoly.getLayoutX(), boatPoly.getLayoutY());
|
// lastPoint = new Point2D(boatAssets.getLayoutX(), boatAssets.getLayoutY());
|
||||||
// }
|
// }
|
||||||
// wake.updatePosition();
|
// wake.updatePosition();
|
||||||
}
|
}
|
||||||
@@ -359,7 +335,7 @@ public class BoatObject extends Group {
|
|||||||
// Point2D nextMarkPoint1 = canvasController.findScaledXY(nextMark1.getLatitude(), nextMark1.getLongitude());
|
// Point2D nextMarkPoint1 = canvasController.findScaledXY(nextMark1.getLatitude(), nextMark1.getLongitude());
|
||||||
// Point2D nextMarkPoint2 = canvasController.findScaledXY(nextMark2.getLatitude(), nextMark2.getLongitude());
|
// Point2D nextMarkPoint2 = canvasController.findScaledXY(nextMark2.getLatitude(), nextMark2.getLongitude());
|
||||||
//
|
//
|
||||||
// Point2D boatCurrentPoint = new Point2D(boatPoly.getLayoutX(), boatPoly.getLayoutY());
|
// Point2D boatCurrentPoint = new Point2D(boatAssets.getLayoutX(), boatAssets.getLayoutY());
|
||||||
// Point2D windTestPoint = GeoUtility.makeArbitraryVectorPoint(nextMarkPoint1, windAngle, 10d);
|
// Point2D windTestPoint = GeoUtility.makeArbitraryVectorPoint(nextMarkPoint1, windAngle, 10d);
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -425,26 +401,26 @@ public class BoatObject extends Group {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Double getBoatLayoutX() {
|
public Double getBoatLayoutX() {
|
||||||
return boatPoly.getAssets().getLayoutX();
|
return boatAssets.getAssets().getLayoutX();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Double getBoatLayoutY() {
|
public Double getBoatLayoutY() {
|
||||||
return boatPoly.getAssets().getLayoutY();
|
return boatAssets.getAssets().getLayoutY();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets this boat to appear highlighted
|
* Sets this boat to appear highlighted
|
||||||
*/
|
*/
|
||||||
public void setAsPlayer() {
|
public void setAsPlayer() {
|
||||||
// boatPoly.getPoints().setAll(
|
// boatAssets.getPoints().setAll(
|
||||||
// -BOAT_WIDTH / 1.75, BOAT_HEIGHT / 1.75,
|
// -BOAT_WIDTH / 1.75, BOAT_HEIGHT / 1.75,
|
||||||
// 0.0, -BOAT_HEIGHT / 1.75,
|
// 0.0, -BOAT_HEIGHT / 1.75,
|
||||||
// BOAT_WIDTH / 1.75, BOAT_HEIGHT / 1.75
|
// BOAT_WIDTH / 1.75, BOAT_HEIGHT / 1.75
|
||||||
// );
|
// );
|
||||||
// boatPoly.setStroke(Color.BLACK);
|
// boatAssets.setStroke(Color.BLACK);
|
||||||
// boatPoly.setStrokeWidth(2);
|
// boatAssets.setStrokeWidth(2);
|
||||||
// boatPoly.setStrokeLineCap(StrokeLineCap.ROUND);
|
// boatAssets.setStrokeLineCap(StrokeLineCap.ROUND);
|
||||||
isPlayer = true;
|
isPlayer = true;
|
||||||
animateSail();
|
animateSail();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import com.interactivemesh.jfx.importer.stl.StlMeshImporter;
|
|||||||
import javafx.animation.AnimationTimer;
|
import javafx.animation.AnimationTimer;
|
||||||
import javafx.geometry.Point3D;
|
import javafx.geometry.Point3D;
|
||||||
import javafx.scene.AmbientLight;
|
import javafx.scene.AmbientLight;
|
||||||
|
import javafx.scene.CacheHint;
|
||||||
import javafx.scene.Group;
|
import javafx.scene.Group;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.paint.PhongMaterial;
|
import javafx.scene.paint.PhongMaterial;
|
||||||
import javafx.scene.shape.Circle;
|
|
||||||
import javafx.scene.shape.MeshView;
|
import javafx.scene.shape.MeshView;
|
||||||
import javafx.scene.transform.Rotate;
|
import javafx.scene.transform.Rotate;
|
||||||
import javafx.scene.transform.Scale;
|
import javafx.scene.transform.Scale;
|
||||||
@@ -56,7 +56,7 @@ public class ModelFactory {
|
|||||||
Group boatAssets = getUnmodifiedBoatModel(boatType, primaryColour);
|
Group boatAssets = getUnmodifiedBoatModel(boatType, primaryColour);
|
||||||
boatAssets.getTransforms().setAll(
|
boatAssets.getTransforms().setAll(
|
||||||
new Rotate(-90, new Point3D(0,0,1)),
|
new Rotate(-90, new Point3D(0,0,1)),
|
||||||
new Scale(0.05, 0.05, 0.05)
|
new Scale(0.06, 0.06, 0.06)
|
||||||
);
|
);
|
||||||
return new BoatModel(boatAssets, null, boatType);
|
return new BoatModel(boatAssets, null, boatType);
|
||||||
}
|
}
|
||||||
@@ -76,6 +76,9 @@ public class ModelFactory {
|
|||||||
private static MeshView importFile(String fileName) {
|
private static MeshView importFile(String fileName) {
|
||||||
StlMeshImporter importer = new StlMeshImporter();
|
StlMeshImporter importer = new StlMeshImporter();
|
||||||
importer.read(ModelFactory.class.getResource("/meshes/" + fileName));
|
importer.read(ModelFactory.class.getResource("/meshes/" + fileName));
|
||||||
|
MeshView importedFile = new MeshView(importer.getImport());
|
||||||
|
importedFile.setCache(true);
|
||||||
|
importedFile.setCacheHint(CacheHint.SCALE_AND_ROTATE);
|
||||||
return new MeshView(importer.getImport());
|
return new MeshView(importer.getImport());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,6 +90,8 @@ public class ModelFactory {
|
|||||||
ColModelImporter importer = new ColModelImporter();
|
ColModelImporter importer = new ColModelImporter();
|
||||||
importer.read(ModelFactory.class.getResource("/meshes/" + tokenType.filename));
|
importer.read(ModelFactory.class.getResource("/meshes/" + tokenType.filename));
|
||||||
assets = new Group(importer.getImport());
|
assets = new Group(importer.getImport());
|
||||||
|
assets.setCache(true);
|
||||||
|
assets.setCacheHint(CacheHint.SCALE_AND_ROTATE);
|
||||||
}
|
}
|
||||||
switch (tokenType) {
|
switch (tokenType) {
|
||||||
case VELOCITY_PICKUP:
|
case VELOCITY_PICKUP:
|
||||||
@@ -145,11 +150,15 @@ public class ModelFactory {
|
|||||||
private static Model makeOcean(Group group) {
|
private static Model makeOcean(Group group) {
|
||||||
// group.setScaleY(Double.MAX_VALUE);
|
// group.setScaleY(Double.MAX_VALUE);
|
||||||
// group.setScaleX(Double.MAX_VALUE);
|
// group.setScaleX(Double.MAX_VALUE);
|
||||||
// group.getTransforms().add(new Rotate(90, new Point3D(1, 0, 0)));
|
group.getTransforms().addAll(
|
||||||
Circle ocean = new Circle(0,0,1000, Color.DARKSEAGREEN);
|
new Rotate(90, new Point3D(1, 0, 0)),
|
||||||
ocean.setStroke(Color.TRANSPARENT);
|
new Scale(10,4,10)
|
||||||
group.getChildren().add(ocean);
|
);
|
||||||
return new Model(group, null);
|
// group.getChildren().add(new AmbientLight());
|
||||||
|
// Circle ocean = new Circle(0,0,500, Color.SKYBLUE);
|
||||||
|
// ocean.setStroke(Color.TRANSPARENT);
|
||||||
|
// group.getChildren().add(ocean);
|
||||||
|
return new Model(new Group(group), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Model makeBarrier(Group assets) {
|
private static Model makeBarrier(Group assets) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public enum ModelType {
|
|||||||
START_MARKER ("start_marker.dae"),
|
START_MARKER ("start_marker.dae"),
|
||||||
PLAIN_MARKER ("plain_marker.dae"),
|
PLAIN_MARKER ("plain_marker.dae"),
|
||||||
MARK_AREA ("mark_area.dae"),
|
MARK_AREA ("mark_area.dae"),
|
||||||
OCEAN (null),
|
OCEAN ("ocean.dae"),
|
||||||
BORDER_PYLON ("barrier_pole.dae"),
|
BORDER_PYLON ("barrier_pole.dae"),
|
||||||
BORDER_BARRIER ("barrier_segment.dae"),
|
BORDER_BARRIER ("barrier_segment.dae"),
|
||||||
FINISH_LINE ("finish_line.dae"),
|
FINISH_LINE ("finish_line.dae"),
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user