mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Merged with remote changes
This commit is contained in:
@@ -15,7 +15,7 @@ import javafx.collections.ObservableList;
|
||||
import javafx.geometry.Point2D;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.PointLight;
|
||||
import javafx.scene.PerspectiveCamera;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
@@ -26,7 +26,6 @@ import javafx.scene.paint.Paint;
|
||||
import javafx.scene.shape.Circle;
|
||||
import javafx.scene.shape.Polygon;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.scene.transform.Translate;
|
||||
import javafx.util.Duration;
|
||||
import seng302.gameServer.messages.RoundingSide;
|
||||
import seng302.model.ClientYacht;
|
||||
@@ -89,6 +88,7 @@ public class GameView extends Pane {
|
||||
private List<Node> mapTokens;
|
||||
|
||||
private ImageView mapImage = new ImageView();
|
||||
private PerspectiveCamera camera;
|
||||
|
||||
//FRAME RATE
|
||||
|
||||
@@ -141,23 +141,25 @@ public class GameView extends Pane {
|
||||
|
||||
public GameView () {
|
||||
gameObjects = this.getChildren();
|
||||
PointLight pointLight = new PointLight(Color.WHITE);
|
||||
pointLight.setLightOn(true);
|
||||
pointLight.getTransforms().add(new Translate(100, 100, -100));
|
||||
gameObjects.add(pointLight);
|
||||
pointLight = new PointLight(Color.WHITE);
|
||||
pointLight.setLightOn(true);
|
||||
pointLight.getTransforms().add(new Translate(900, 900, -100));
|
||||
gameObjects.add(pointLight);
|
||||
// AmbientLight ambientLight = new AmbientLight(new Color(1,1,1,0.4));
|
||||
//// ambientLight.setOpacity(0.5);
|
||||
// gameObjects.add(ambientLight);
|
||||
// create image view for map, bind panel size to image
|
||||
gameObjects.add(mapImage);
|
||||
gameObjects.add(raceBorder);
|
||||
gameObjects.add(markers);
|
||||
gameObjects.add(tokens);
|
||||
// camera = new PerspectiveCamera(true);
|
||||
// camera.setTranslateZ(-500);
|
||||
// camera.setTranslateY(500);
|
||||
// camera.setTranslateX(800);
|
||||
// camera.setFieldOfView(100);
|
||||
// camera.setFarClip(50);
|
||||
// camera.setNearClip(-600);
|
||||
//// gameObjects.add(camera);
|
||||
// this.sceneProperty().addListener((obs, oldValue, scene) -> {
|
||||
// if (scene != null) {
|
||||
// scene.setCamera(camera);
|
||||
// }
|
||||
// });
|
||||
initializeTimer();
|
||||
gameObjects.addAll(mapImage, raceBorder, markers, tokens);
|
||||
}
|
||||
|
||||
private void initializeTimer() {
|
||||
|
||||
@@ -6,11 +6,12 @@ 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;
|
||||
import javafx.scene.PointLight;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.PhongMaterial;
|
||||
import javafx.scene.shape.DrawMode;
|
||||
import javafx.scene.shape.Line;
|
||||
import javafx.scene.shape.MeshView;
|
||||
import javafx.scene.shape.Polygon;
|
||||
@@ -18,6 +19,7 @@ import javafx.scene.shape.Polyline;
|
||||
import javafx.scene.shape.Shape3D;
|
||||
import javafx.scene.transform.Rotate;
|
||||
import javafx.scene.transform.Scale;
|
||||
import javafx.scene.transform.Translate;
|
||||
|
||||
/**
|
||||
* BoatGroup is a javafx group that by default contains a graphical objects for representing a 2
|
||||
@@ -105,7 +107,7 @@ public class BoatObject extends Group {
|
||||
new Rotate(180, new Point3D(0, 0, 1))
|
||||
);
|
||||
boatPoly.getTransforms().add(new Scale(10, 10, 10));
|
||||
boatPoly.setDrawMode(DrawMode.FILL);
|
||||
// boatPoly.setDrawMode(DrawMode.FILL);
|
||||
// boatPoly.setFill(colour);
|
||||
// boatPoly.setFill(this.colour);
|
||||
// boatPoly.setMaterial(new PhongMaterial(this.colour));
|
||||
@@ -142,6 +144,24 @@ public class BoatObject extends Group {
|
||||
sail.setFill(Color.TRANSPARENT);
|
||||
sail.setCache(true);
|
||||
super.getChildren().clear();
|
||||
PointLight pointLight = new PointLight(Color.WHITE);
|
||||
// pointLight.setLightOn(true);
|
||||
pointLight.getTransforms().add(new Translate(0, 0, -30));
|
||||
super.getChildren().add(pointLight);
|
||||
// pointLight = new PointLight(Color.WHITE);
|
||||
//// pointLight.setLightOn(true);
|
||||
// pointLight.getTransforms().add(new Translate(50, 50, -20));
|
||||
// super.getChildren().add(pointLight);
|
||||
// pointLight = new PointLight(Color.WHITE);
|
||||
//// pointLight.setLightOn(true);
|
||||
// pointLight.getTransforms().add(new Translate(50, -50, -20));
|
||||
// super.getChildren().add(pointLight);
|
||||
// pointLight = new PointLight(Color.WHITE);
|
||||
//// pointLight.setLightOn(true);
|
||||
// pointLight.getTransforms().add(new Translate(-50, -50, -20));
|
||||
// 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);//, sail);
|
||||
}
|
||||
|
||||
@@ -155,14 +175,30 @@ public class BoatObject extends Group {
|
||||
|
||||
public Shape3D makeBoatPolygon () {
|
||||
StlMeshImporter importer = new StlMeshImporter();
|
||||
importer.read(getClass().getResource("/meshes/simple_yacht.stl").toString());
|
||||
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();
|
||||
// importer.read(getClass().getResource("/meshes/simple_yacht.dae"));
|
||||
// ColModelImporter importer = new ColModelImporter();
|
||||
// importer.read(getClass().getResource("/meshes/hollow_simple_boat.dae"));
|
||||
// MeshView mesh = importer.getImport()[0];
|
||||
return new MeshView(importer.getImport());
|
||||
// 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 new MeshView(importer.getImport());
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package seng302.visualiser.map;
|
||||
|
||||
import javafx.scene.Camera;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.PerspectiveCamera;
|
||||
import javafx.scene.SceneAntialiasing;
|
||||
import javafx.scene.SubScene;
|
||||
|
||||
/**
|
||||
* Created by cir27 on 5/09/17.
|
||||
*/
|
||||
public class GameView3D {
|
||||
|
||||
Group root3D;
|
||||
SubScene scene;
|
||||
Camera camera;
|
||||
Group gameObjects;
|
||||
|
||||
public GameView3D () {
|
||||
camera = new PerspectiveCamera();
|
||||
gameObjects = new Group();
|
||||
root3D = new Group(camera, gameObjects);
|
||||
scene = new SubScene(
|
||||
root3D, 750, 750, true, SceneAntialiasing.BALANCED
|
||||
);
|
||||
scene.setCamera(camera);
|
||||
}
|
||||
|
||||
public SubScene getScene () {
|
||||
return scene;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user