mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 22:38:43 +00:00
Made the windView observer the gameView camera
#story[1276] #pair[ajm412, zyt10]
This commit is contained in:
@@ -2,7 +2,6 @@ package seng302.visualiser;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -24,7 +23,11 @@ import javafx.scene.transform.Scale;
|
|||||||
import javafx.scene.transform.Translate;
|
import javafx.scene.transform.Translate;
|
||||||
import org.fxyz3d.scene.Skybox;
|
import org.fxyz3d.scene.Skybox;
|
||||||
import seng302.gameServer.messages.RoundingSide;
|
import seng302.gameServer.messages.RoundingSide;
|
||||||
import seng302.model.*;
|
import seng302.model.ClientYacht;
|
||||||
|
import seng302.model.GameKeyBind;
|
||||||
|
import seng302.model.KeyAction;
|
||||||
|
import seng302.model.Limit;
|
||||||
|
import seng302.model.ScaledPoint;
|
||||||
import seng302.model.mark.CompoundMark;
|
import seng302.model.mark.CompoundMark;
|
||||||
import seng302.model.mark.Corner;
|
import seng302.model.mark.Corner;
|
||||||
import seng302.model.mark.Mark;
|
import seng302.model.mark.Mark;
|
||||||
@@ -75,6 +78,7 @@ public class GameView3D extends GameView{
|
|||||||
private Double windDir;
|
private Double windDir;
|
||||||
private Skybox skybox;
|
private Skybox skybox;
|
||||||
|
|
||||||
|
|
||||||
public GameView3D () {
|
public GameView3D () {
|
||||||
isometricCam = new IsometricCamera(DEFAULT_CAMERA_X, DEFAULT_CAMERA_Y);
|
isometricCam = new IsometricCamera(DEFAULT_CAMERA_X, DEFAULT_CAMERA_Y);
|
||||||
topDownCam = new TopDownCamera();
|
topDownCam = new TopDownCamera();
|
||||||
@@ -343,6 +347,10 @@ public class GameView3D extends GameView{
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SubScene getView() {
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the boatObjects color with that of the clientYachts object. Used in notification from
|
* Updates the boatObjects color with that of the clientYachts object. Used in notification from
|
||||||
* a listener on this attribute in clientYacht to re paint the boat mesh
|
* a listener on this attribute in clientYacht to re paint the boat mesh
|
||||||
|
|||||||
@@ -9,26 +9,19 @@ import java.util.Map;
|
|||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javafx.animation.RotateTransition;
|
|
||||||
import javafx.animation.Timeline;
|
import javafx.animation.Timeline;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.property.ReadOnlyBooleanProperty;
|
import javafx.beans.property.ReadOnlyBooleanProperty;
|
||||||
import javafx.beans.value.ChangeListener;
|
|
||||||
import javafx.beans.value.ObservableValue;
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ListChangeListener;
|
import javafx.collections.ListChangeListener;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.geometry.Point2D;
|
import javafx.geometry.Point2D;
|
||||||
import javafx.scene.Group;
|
|
||||||
import javafx.scene.Node;
|
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.SubScene;
|
import javafx.scene.SubScene;
|
||||||
import javafx.scene.chart.LineChart;
|
import javafx.scene.chart.LineChart;
|
||||||
import javafx.scene.chart.NumberAxis;
|
import javafx.scene.chart.NumberAxis;
|
||||||
import javafx.scene.chart.XYChart;
|
|
||||||
import javafx.scene.chart.XYChart.Data;
|
|
||||||
import javafx.scene.chart.XYChart.Series;
|
import javafx.scene.chart.XYChart.Series;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.CheckBox;
|
import javafx.scene.control.CheckBox;
|
||||||
@@ -50,14 +43,11 @@ import javafx.scene.shape.Polyline;
|
|||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.stage.StageStyle;
|
import javafx.stage.StageStyle;
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import seng302.model.ClientYacht;
|
import seng302.model.ClientYacht;
|
||||||
import seng302.model.ClientYacht.PowerUpListener;
|
|
||||||
import seng302.model.RaceState;
|
import seng302.model.RaceState;
|
||||||
import seng302.model.mark.CompoundMark;
|
import seng302.model.mark.CompoundMark;
|
||||||
import seng302.model.mark.Mark;
|
import seng302.model.mark.Mark;
|
||||||
import seng302.model.stream.xml.parser.RaceXMLData;
|
import seng302.model.stream.xml.parser.RaceXMLData;
|
||||||
import seng302.model.token.Token;
|
|
||||||
import seng302.model.token.TokenType;
|
import seng302.model.token.TokenType;
|
||||||
import seng302.utilities.Sounds;
|
import seng302.utilities.Sounds;
|
||||||
import seng302.visualiser.GameView3D;
|
import seng302.visualiser.GameView3D;
|
||||||
@@ -69,8 +59,6 @@ import seng302.visualiser.controllers.dialogs.FinishDialogController;
|
|||||||
import seng302.visualiser.fxObjects.ChatHistory;
|
import seng302.visualiser.fxObjects.ChatHistory;
|
||||||
import seng302.visualiser.fxObjects.assets_2D.WindArrow;
|
import seng302.visualiser.fxObjects.assets_2D.WindArrow;
|
||||||
import seng302.visualiser.fxObjects.assets_3D.BoatObject;
|
import seng302.visualiser.fxObjects.assets_3D.BoatObject;
|
||||||
import seng302.visualiser.fxObjects.assets_3D.ModelFactory;
|
|
||||||
import seng302.visualiser.fxObjects.assets_3D.ModelType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller class that manages the display of a race
|
* Controller class that manages the display of a race
|
||||||
@@ -132,6 +120,8 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
@FXML
|
@FXML
|
||||||
private VBox windArrowVBox;
|
private VBox windArrowVBox;
|
||||||
|
|
||||||
|
|
||||||
|
private WindCell windCell;
|
||||||
//Race Data
|
//Race Data
|
||||||
private Map<Integer, ClientYacht> participants;
|
private Map<Integer, ClientYacht> participants;
|
||||||
private Map<Integer, CompoundMark> markers;
|
private Map<Integer, CompoundMark> markers;
|
||||||
@@ -208,25 +198,29 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
|
|
||||||
lastWindDirection = 0d;
|
lastWindDirection = 0d;
|
||||||
|
|
||||||
initialiseWindArrow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialise wind arrow cell.
|
* Initialise wind arrow cell.
|
||||||
*/
|
*/
|
||||||
private void initialiseWindArrow() {
|
private void initialiseWindArrow() {
|
||||||
Pane pane = null;
|
|
||||||
FXMLLoader loader = new FXMLLoader(
|
FXMLLoader loader = new FXMLLoader(
|
||||||
getClass().getResource("/views/cells/WindCell.fxml"));
|
getClass().getResource("/views/cells/WindCell.fxml"));
|
||||||
loader.setController(new WindCell());
|
windCell = new WindCell();
|
||||||
|
loader.setController(windCell);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pane = loader.load();
|
loader.load();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
windArrowVBox.getChildren().add(pane);
|
windCell.setCamera(gameView.getView().getCamera());
|
||||||
|
gameView.getView().cameraProperty()
|
||||||
|
.addListener((obs, oldVal, newVal) -> windCell.setCamera(newVal));
|
||||||
|
System.out.println(windCell);
|
||||||
|
|
||||||
|
windArrowVBox.getChildren().add(windCell.getAssets());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showFinishDialog(ArrayList<ClientYacht> finishedBoats) {
|
public void showFinishDialog(ArrayList<ClientYacht> finishedBoats) {
|
||||||
@@ -320,6 +314,12 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
});
|
});
|
||||||
gameView.setWindDir(raceState.windDirectionProperty().doubleValue());
|
gameView.setWindDir(raceState.windDirectionProperty().doubleValue());
|
||||||
Platform.runLater(this::initializeUpdateTimer);
|
Platform.runLater(this::initializeUpdateTimer);
|
||||||
|
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
//windCell.setCamera(gameView.getView().getCamera());
|
||||||
|
|
||||||
|
initialiseWindArrow();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
package seng302.visualiser.controllers.cells;
|
package seng302.visualiser.controllers.cells;
|
||||||
|
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.Camera;
|
||||||
import javafx.scene.Group;
|
import javafx.scene.Group;
|
||||||
|
import javafx.scene.Node;
|
||||||
import javafx.scene.PerspectiveCamera;
|
import javafx.scene.PerspectiveCamera;
|
||||||
|
import javafx.scene.SceneAntialiasing;
|
||||||
|
import javafx.scene.SubScene;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import seng302.visualiser.cameras.ChaseCamera;
|
import javafx.scene.transform.Transform;
|
||||||
import seng302.visualiser.cameras.IsometricCamera;
|
import javafx.scene.transform.Translate;
|
||||||
import seng302.visualiser.cameras.TopDownCamera;
|
|
||||||
import seng302.visualiser.fxObjects.assets_3D.Model;
|
import seng302.visualiser.fxObjects.assets_3D.Model;
|
||||||
import seng302.visualiser.fxObjects.assets_3D.ModelFactory;
|
import seng302.visualiser.fxObjects.assets_3D.ModelFactory;
|
||||||
|
|
||||||
@@ -19,26 +23,56 @@ public class WindCell {
|
|||||||
|
|
||||||
private final double FOV = 60;
|
private final double FOV = 60;
|
||||||
private final double DEFAULT_CAMERA_X = 0;
|
private final double DEFAULT_CAMERA_X = 0;
|
||||||
private final double DEFAULT_CAMERA_Y = 155;
|
private final double DEFAULT_CAMERA_Y = 50;
|
||||||
|
|
||||||
|
private Group root3D;
|
||||||
|
private SubScene view;
|
||||||
|
private Group gameObjects;
|
||||||
|
|
||||||
// Cameras
|
// Cameras
|
||||||
private PerspectiveCamera isometricCam;
|
private PerspectiveCamera camera = null;
|
||||||
private PerspectiveCamera topDownCam;
|
private ObservableList<Transform> cameraTransforms;
|
||||||
private PerspectiveCamera chaseCam;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialise WindCell fxml and load 3D wind arrow into a group.
|
* Initialise WindCell fxml and load 3D wind arrow into a group.
|
||||||
*/
|
*/
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
Group group = new Group();
|
camera = new PerspectiveCamera();
|
||||||
windPane.getChildren().add(group);
|
camera.setFarClip(1000);
|
||||||
Model windArrowModel = ModelFactory.makeWindArrow();
|
camera.setNearClip(0.1);
|
||||||
group.getChildren().add(windArrowModel.getAssets());
|
camera.setFieldOfView(60);
|
||||||
|
this.cameraTransforms = camera.getTransforms();
|
||||||
isometricCam = new IsometricCamera(DEFAULT_CAMERA_X, DEFAULT_CAMERA_Y);
|
initialiseWindView();
|
||||||
topDownCam = new TopDownCamera();
|
|
||||||
chaseCam = new ChaseCamera();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initialiseWindView() {
|
||||||
|
gameObjects = new Group();
|
||||||
|
System.out.println(windPane);
|
||||||
|
windPane.getChildren().add(gameObjects);
|
||||||
|
|
||||||
|
root3D = new Group(camera, gameObjects);
|
||||||
|
view = new SubScene(
|
||||||
|
root3D, 110, 120, true, SceneAntialiasing.BALANCED
|
||||||
|
);
|
||||||
|
view.setCamera(camera);
|
||||||
|
|
||||||
|
Model windArrowModel = ModelFactory.makeWindArrow();
|
||||||
|
|
||||||
|
gameObjects.getChildren().addAll(
|
||||||
|
windArrowModel.getAssets()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Node getAssets() {
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCamera(Camera camera) {
|
||||||
|
this.camera.getTransforms().clear();
|
||||||
|
for (Transform t : camera.getTransforms()) {
|
||||||
|
if (!(t instanceof Translate)) {
|
||||||
|
this.camera.getTransforms().add(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -293,8 +293,8 @@ public class ModelFactory {
|
|||||||
|
|
||||||
Rotate animationRotate = new Rotate(0, new Point3D(0, 1, 0));
|
Rotate animationRotate = new Rotate(0, new Point3D(0, 1, 0));
|
||||||
assets.getTransforms().addAll(
|
assets.getTransforms().addAll(
|
||||||
new Translate(55, 60, 0),
|
new Translate(0, 0, 0),
|
||||||
new Scale(5, 5, 5),
|
new Scale(4, 4, 4),
|
||||||
animationRotate
|
animationRotate
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -302,16 +302,6 @@ public class ModelFactory {
|
|||||||
new AmbientLight()
|
new AmbientLight()
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Model(new Group(assets), new AnimationTimer() {
|
return new Model(new Group(assets), null);
|
||||||
|
|
||||||
private double rotation = 0;
|
|
||||||
private Rotate rotate = animationRotate;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(long now) {
|
|
||||||
rotation += 1;
|
|
||||||
rotate.setAngle(rotation);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
<author>Blender User</author>
|
<author>Blender User</author>
|
||||||
<authoring_tool>Blender 2.78.0 commit date:2016-09-26, commit time:12:42, hash:4bb1e22</authoring_tool>
|
<authoring_tool>Blender 2.78.0 commit date:2016-09-26, commit time:12:42, hash:4bb1e22</authoring_tool>
|
||||||
</contributor>
|
</contributor>
|
||||||
<created>2017-09-28T10:48:03</created>
|
<created>2017-09-28T12:16:30</created>
|
||||||
<modified>2017-09-28T10:48:03</modified>
|
<modified>2017-09-28T12:16:30</modified>
|
||||||
<unit name="meter" meter="1"/>
|
<unit name="meter" meter="1"/>
|
||||||
<up_axis>Z_UP</up_axis>
|
<up_axis>Z_UP</up_axis>
|
||||||
</asset>
|
</asset>
|
||||||
@@ -318,7 +318,7 @@
|
|||||||
<instance_light url="#Lamp_001-light"/>
|
<instance_light url="#Lamp_001-light"/>
|
||||||
</node>
|
</node>
|
||||||
<node id="Mesh_" name="Mesh_" type="NODE">
|
<node id="Mesh_" name="Mesh_" type="NODE">
|
||||||
<matrix sid="transform">1 0 0 0 0 -4.37114e-8 -1 0 0 1 -4.37114e-8 0 0 0 0 1</matrix>
|
<matrix sid="transform">-0.5221724 3.72788e-8 0.8528399 -0.7108302 0.8528399 2.28249e-8 0.5221724 0 0 1 -4.37114e-8 0 0 0 0 1</matrix>
|
||||||
<instance_geometry url="#Mesh__001-mesh" name="Mesh_">
|
<instance_geometry url="#Mesh__001-mesh" name="Mesh_">
|
||||||
<bind_material>
|
<bind_material>
|
||||||
<technique_common>
|
<technique_common>
|
||||||
|
|||||||
Reference in New Issue
Block a user