mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Added pirate ship meshes to application. Updated boat model to allow for jib sails and a fixed sail. #story[1274]
This commit is contained in:
@@ -37,7 +37,7 @@ public class PlayerCell {
|
|||||||
// Add Rotating Boat to Player Cell with players color on it.
|
// Add Rotating Boat to Player Cell with players color on it.
|
||||||
Group group = new Group();
|
Group group = new Group();
|
||||||
boatPane.getChildren().add(group);
|
boatPane.getChildren().add(group);
|
||||||
BoatModel bo = ModelFactory.boatIconView(BoatMeshType.CAT_ATE_A_MERINGUE, this.boatColor);
|
BoatModel bo = ModelFactory.boatIconView(BoatMeshType.PIRATE_SHIP, this.boatColor);
|
||||||
group.getChildren().add(bo.getAssets());
|
group.getChildren().add(bo.getAssets());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,22 +2,29 @@ package seng302.visualiser.fxObjects.assets_3D;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum for boat meshes. Enum values should be of the form :
|
* Enum for boat meshes. Enum values should be of the form :
|
||||||
* ENUM_VALUE (hull file, mast file, Y offset of mast CoR from origin, sail file, Y offset of sail CoR from origin)
|
* ENUM_VALUE (hull file, mast file, Y offset of mast CoR from origin, sail file, Y offset of sail CoR from origin, jib file, fixed sail)
|
||||||
* Files must be valid .stl files.
|
* Files must be valid .stl files.
|
||||||
*/
|
*/
|
||||||
public enum BoatMeshType {
|
public enum BoatMeshType {
|
||||||
|
|
||||||
DINGHY ("dinghy_hull.stl", "dinghy_mast.stl", 1.36653, "dinghy_sail.stl", 1.36653),
|
DINGHY("dinghy_hull.stl", "dinghy_mast.stl", 1.36653, "dinghy_sail.stl", 1.36653, null, false),
|
||||||
CAT_ATE_A_MERINGUE ("catamaran_hull.stl", "catamaran_mast.stl", 0.997, "catamaran_sail.stl", 0.997);
|
CAT_ATE_A_MERINGUE("catamaran_hull.stl", "catamaran_mast.stl", 0.997, "catamaran_sail.stl",
|
||||||
|
0.997, null, false),
|
||||||
|
PIRATE_SHIP("pirateship_hull.stl", "pirateship_mast.stl", -0.5415, "pirateship_mainsail.stl",
|
||||||
|
-0.5415, "pirateship_frontsail.stl", true);
|
||||||
|
|
||||||
final String hullFile, mastFile, sailFile;
|
final String hullFile, mastFile, sailFile, jibFile;
|
||||||
final double mastOffset, sailOffset;
|
final double mastOffset, sailOffset;
|
||||||
|
final boolean fixedSail;
|
||||||
|
|
||||||
BoatMeshType(String hullFile, String mastFile, double mastOffset, String sailFile, double sailOffset) {
|
BoatMeshType(String hullFile, String mastFile, double mastOffset, String sailFile,
|
||||||
|
double sailOffset, String jibFile, boolean fixedSail) {
|
||||||
this.hullFile = hullFile;
|
this.hullFile = hullFile;
|
||||||
this.mastFile = mastFile;
|
this.mastFile = mastFile;
|
||||||
this.mastOffset = mastOffset;
|
this.mastOffset = mastOffset;
|
||||||
this.sailFile = sailFile;
|
this.sailFile = sailFile;
|
||||||
this.sailOffset = sailOffset;
|
this.sailOffset = sailOffset;
|
||||||
|
this.jibFile = jibFile;
|
||||||
|
this.fixedSail = fixedSail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public class BoatModel extends Model {
|
|||||||
* @param degrees The rotation of the sail in degrees
|
* @param degrees The rotation of the sail in degrees
|
||||||
*/
|
*/
|
||||||
public void rotateSail(double degrees) {
|
public void rotateSail(double degrees) {
|
||||||
|
if (!meshType.fixedSail) {
|
||||||
MeshView mast = getMeshViewChild(MAST_INDEX);
|
MeshView mast = getMeshViewChild(MAST_INDEX);
|
||||||
MeshView sail = getMeshViewChild(SAIL_INDEX);
|
MeshView sail = getMeshViewChild(SAIL_INDEX);
|
||||||
mast.getTransforms().setAll(
|
mast.getTransforms().setAll(
|
||||||
@@ -43,6 +44,7 @@ public class BoatModel extends Model {
|
|||||||
new Rotate(degrees, 0, -meshType.sailOffset,0, new Point3D(0, 0, 1))
|
new Rotate(degrees, 0, -meshType.sailOffset,0, new Point3D(0, 0, 1))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void hideSail() {
|
public void hideSail() {
|
||||||
getMeshViewChild(SAIL_INDEX).setVisible(false);
|
getMeshViewChild(SAIL_INDEX).setVisible(false);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class BoatObject extends Group {
|
|||||||
* Creates a BoatGroup with the default triangular boat polygon.
|
* Creates a BoatGroup with the default triangular boat polygon.
|
||||||
*/
|
*/
|
||||||
public BoatObject() {
|
public BoatObject() {
|
||||||
boatAssets = ModelFactory.boatGameView(BoatMeshType.CAT_ATE_A_MERINGUE, colour);
|
boatAssets = ModelFactory.boatGameView(BoatMeshType.PIRATE_SHIP, colour);
|
||||||
boatAssets.hideSail();
|
boatAssets.hideSail();
|
||||||
boatAssets.getAssets().getTransforms().addAll(
|
boatAssets.getAssets().getTransforms().addAll(
|
||||||
rotation
|
rotation
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ public class ModelFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Group getUnmodifiedBoatModel(BoatMeshType boatType, Color primaryColour) {
|
private static Group getUnmodifiedBoatModel(BoatMeshType boatType, Color primaryColour) {
|
||||||
|
|
||||||
Group boatAssets = new Group();
|
Group boatAssets = new Group();
|
||||||
MeshView hull = importSTL(boatType.hullFile);
|
MeshView hull = importSTL(boatType.hullFile);
|
||||||
hull.setMaterial(new PhongMaterial(primaryColour));
|
hull.setMaterial(new PhongMaterial(primaryColour));
|
||||||
@@ -91,7 +92,15 @@ public class ModelFactory {
|
|||||||
mast.setMaterial(new PhongMaterial(primaryColour));
|
mast.setMaterial(new PhongMaterial(primaryColour));
|
||||||
MeshView sail = importSTL(boatType.sailFile);
|
MeshView sail = importSTL(boatType.sailFile);
|
||||||
sail.setMaterial(new PhongMaterial(Color.WHITE));
|
sail.setMaterial(new PhongMaterial(Color.WHITE));
|
||||||
|
|
||||||
|
if (boatType.jibFile != null) {
|
||||||
|
MeshView jib = importSTL(boatType.jibFile);
|
||||||
|
sail.setMaterial(new PhongMaterial(Color.WHITE));
|
||||||
|
boatAssets.getChildren().addAll(hull, mast, sail, jib);
|
||||||
|
} else {
|
||||||
boatAssets.getChildren().addAll(hull, mast, sail);
|
boatAssets.getChildren().addAll(hull, mast, sail);
|
||||||
|
}
|
||||||
|
|
||||||
return boatAssets;
|
return boatAssets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user