mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
- Removed 2D wind and replaced with 3D wind arrow.
#story[1276]
This commit is contained in:
@@ -20,8 +20,6 @@ import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.geometry.Point2D;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.SubScene;
|
||||
import javafx.scene.chart.LineChart;
|
||||
@@ -48,26 +46,22 @@ import javafx.scene.shape.Polyline;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import javax.swing.ImageIcon;
|
||||
import seng302.model.ClientYacht;
|
||||
import seng302.model.ClientYacht.PowerUpListener;
|
||||
import seng302.model.RaceState;
|
||||
import seng302.model.mark.CompoundMark;
|
||||
import seng302.model.mark.Mark;
|
||||
import seng302.model.stream.xml.parser.RaceXMLData;
|
||||
import seng302.model.token.Token;
|
||||
import seng302.model.token.TokenType;
|
||||
import seng302.utilities.Sounds;
|
||||
import seng302.visualiser.GameView3D;
|
||||
import seng302.visualiser.controllers.annotations.ImportantAnnotationController;
|
||||
import seng302.visualiser.controllers.annotations.ImportantAnnotationDelegate;
|
||||
import seng302.visualiser.controllers.annotations.ImportantAnnotationsState;
|
||||
import seng302.visualiser.controllers.cells.WindCell;
|
||||
import seng302.visualiser.controllers.dialogs.FinishDialogController;
|
||||
import seng302.visualiser.fxObjects.ChatHistory;
|
||||
import seng302.visualiser.fxObjects.assets_2D.WindArrow;
|
||||
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
|
||||
@@ -112,8 +106,8 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
private ComboBox<ClientYacht> yachtSelectionComboBox;
|
||||
@FXML
|
||||
private Text fpsDisplay;
|
||||
@FXML
|
||||
private ImageView windImageView;
|
||||
// @FXML
|
||||
// private ImageView windImageView;
|
||||
@FXML
|
||||
private Label windDirectionLabel;
|
||||
@FXML
|
||||
@@ -122,6 +116,8 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
private Label positionLabel, boatSpeedLabel, boatHeadingLabel;
|
||||
@FXML
|
||||
private ImageView velocityIcon, handlingIcon, windWalkerIcon, bumperIcon, badRandomIcon;
|
||||
@FXML
|
||||
private VBox windArrowVBox;
|
||||
|
||||
//Race Data
|
||||
private Map<Integer, ClientYacht> participants;
|
||||
@@ -211,6 +207,26 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
initialiseWindArrow();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise wind arrow cell.
|
||||
*/
|
||||
private void initialiseWindArrow() {
|
||||
Pane pane = null;
|
||||
FXMLLoader loader = new FXMLLoader(
|
||||
getClass().getResource("/views/cells/WindCell.fxml"));
|
||||
loader.setController(new WindCell());
|
||||
|
||||
try {
|
||||
pane = loader.load();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
windArrowVBox.getChildren().add(pane);
|
||||
}
|
||||
|
||||
public void showFinishDialog(ArrayList<ClientYacht> finishedBoats) {
|
||||
@@ -582,7 +598,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
*/
|
||||
private void updateWindDirection(double direction) {
|
||||
windDirectionLabel.setText(String.format("%.1f°", direction));
|
||||
windImageView.setRotate(direction);
|
||||
// windImageView.setRotate(direction);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package seng302.visualiser.controllers.cells;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.layout.Pane;
|
||||
import seng302.visualiser.fxObjects.assets_3D.Model;
|
||||
import seng302.visualiser.fxObjects.assets_3D.ModelFactory;
|
||||
|
||||
public class WindCell {
|
||||
|
||||
//--------FXML BEGIN--------//
|
||||
@FXML
|
||||
private Pane windPane;
|
||||
//---------FXML END---------//
|
||||
|
||||
/**
|
||||
* Initialise WindCell fxml and load 3D wind arrow into a group.
|
||||
*/
|
||||
public void initialize() {
|
||||
Group group = new Group();
|
||||
windPane.getChildren().add(group);
|
||||
Model windArrowModel = ModelFactory.makeWindArrow();
|
||||
group.getChildren().add(windArrowModel.getAssets());
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import javafx.geometry.Point3D;
|
||||
import javafx.scene.AmbientLight;
|
||||
import javafx.scene.CacheHint;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.PointLight;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.PhongMaterial;
|
||||
import javafx.scene.shape.Circle;
|
||||
@@ -17,7 +16,6 @@ import javafx.scene.transform.Scale;
|
||||
import javafx.scene.transform.Translate;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Factory class for creating 3D models of boatTypes.
|
||||
*/
|
||||
@@ -272,4 +270,40 @@ public class ModelFactory {
|
||||
);
|
||||
return new Model(new Group(assets), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a 3D wind arrow.
|
||||
*
|
||||
* @return 3D wind arrow object
|
||||
*/
|
||||
public static Model makeWindArrow() {
|
||||
ColModelImporter importer = new ColModelImporter();
|
||||
importer.read(ModelFactory.class.getResource("/meshes/" + ModelType.WIND_ARROW.filename));
|
||||
Group assets = new Group(importer.getImport());
|
||||
assets.setCache(true);
|
||||
assets.setCacheHint(CacheHint.SCALE_AND_ROTATE);
|
||||
|
||||
Rotate animationRotate = new Rotate(0, new Point3D(0, 1, 0));
|
||||
assets.getTransforms().addAll(
|
||||
new Scale(6, 6, 6),
|
||||
new Translate(7, 10, 0),
|
||||
animationRotate
|
||||
);
|
||||
|
||||
assets.getChildren().addAll(
|
||||
new AmbientLight()
|
||||
);
|
||||
|
||||
return new Model(new Group(assets), new AnimationTimer() {
|
||||
|
||||
private double rotation = 0;
|
||||
private Rotate rotate = animationRotate;
|
||||
|
||||
@Override
|
||||
public void handle(long now) {
|
||||
rotation += 1;
|
||||
rotate.setAngle(rotation);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ public enum ModelType {
|
||||
PLAYER_IDENTIFIER ("player_identifier.dae"),
|
||||
PLAIN_ARROW ("arrow.dae"),
|
||||
START_ARROW ("start_arrow.dae"),
|
||||
FINISH_ARROW ("finish_arrow.dae");
|
||||
FINISH_ARROW("finish_arrow.dae"),
|
||||
WIND_ARROW("windFiles/log_arrow.dae");
|
||||
|
||||
final String filename;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user