Tried to get multiple boats working but.... it's not #story[1196]

main
Fan-Wu Yang 8 years ago
parent 5bc382304b
commit e149255240

@ -180,7 +180,7 @@ public class Event {
public static String setRaceXMLAtCurrentTimeToNow(String raceXML) { public static String setRaceXMLAtCurrentTimeToNow(String raceXML) {
//The start time is current time + 4 minutes. prestart is 3 minutes, and we add another minute. //The start time is current time + 4 minutes. prestart is 3 minutes, and we add another minute.
long millisecondsToAdd = Constants.RacePreStartTime + Constants.RacePreparatoryTime; long millisecondsToAdd = Constants.RacePreStartTime + 1 * 60 * 10000;
long secondsToAdd = millisecondsToAdd / 1000; long secondsToAdd = millisecondsToAdd / 1000;
//Scale the time using our time scalar. //Scale the time using our time scalar.
secondsToAdd = secondsToAdd / Constants.RaceTimeScale; secondsToAdd = secondsToAdd / Constants.RaceTimeScale;

@ -187,7 +187,7 @@ public class RaceXMLCreator {
public static void setRaceXMLAtCurrentTimeToNow(XMLRace raceXML) { public static void setRaceXMLAtCurrentTimeToNow(XMLRace raceXML) {
//The start time is current time + 4 minutes. prestart is 3 minutes, and we add another minute. //The start time is current time + 4 minutes. prestart is 3 minutes, and we add another minute.
long millisecondsToAdd = Constants.RacePreStartTime + Constants.RacePreparatoryTime; long millisecondsToAdd = Constants.RacePreStartTime + 1 * 60 * 1000;
long secondsToAdd = millisecondsToAdd / 1000; long secondsToAdd = millisecondsToAdd / 1000;
//Scale the time using our time scalar. //Scale the time using our time scalar.
secondsToAdd = secondsToAdd / Constants.RaceTimeScale; secondsToAdd = secondsToAdd / Constants.RaceTimeScale;

@ -39,14 +39,14 @@ public class Constants {
* The race pre-start time, in milliseconds. 3 minutes (30 seconds for development). * The race pre-start time, in milliseconds. 3 minutes (30 seconds for development).
*/ */
// public static final long RacePreStartTime = 30 * 1000; // public static final long RacePreStartTime = 30 * 1000;
public static final long RacePreStartTime = 1000; public static final long RacePreStartTime = 30 * 1000;
/** /**
* The race preparatory time, in milliseconds. 1 minute. * The race preparatory time, in milliseconds. 1 minute.
*/ */
// public static final long RacePreparatoryTime = 60 * 1000; // public static final long RacePreparatoryTime = 60 * 1000;
public static final long RacePreparatoryTime = 3 * 1000; public static final long RacePreparatoryTime = 60 * 1000;

@ -93,7 +93,7 @@ public class HostController extends Controller {
*/ */
public void hostGamePressed() { public void hostGamePressed() {
try { try {
this.game = new Event(false); this.game = new Event(true);
connectSocket("localhost", 4942); connectSocket("localhost", 4942);
} catch (EventConstructionException e) { } catch (EventConstructionException e) {
Logger.getGlobal().log(Level.SEVERE, "Could not create Event.", e); Logger.getGlobal().log(Level.SEVERE, "Could not create Event.", e);

@ -191,6 +191,10 @@ public class RaceController extends Controller {
StlMeshImporter importerMark = new StlMeshImporter(); StlMeshImporter importerMark = new StlMeshImporter();
importerMark.read(markerAsset); importerMark.read(markerAsset);
URL alternateBoatAsset = HostController.class.getClassLoader().getResource("assets/V1.3 BurgerBoat.stl");
StlMeshImporter importerBurgerBoat = new StlMeshImporter();
importerBurgerBoat.read(alternateBoatAsset);
view3D = new View3D(); view3D = new View3D();
view3D.setDistance(1050); view3D.setDistance(1050);
view3D.setYaw(0); view3D.setYaw(0);
@ -222,10 +226,14 @@ public class RaceController extends Controller {
} }
for(VisualiserBoat boat: race.getVisualiserRaceState().getBoats()) { for(VisualiserBoat boat: race.getVisualiserRaceState().getBoats()) {
MeshView mesh = new MeshView(importer.getImport()); MeshView mesh = null;
if(boat.getSourceID() == race.getVisualiserRaceState().getPlayerBoatID()) {
mesh = new MeshView(importer.getImport());
} else {
mesh = new MeshView(importerBurgerBoat.getImport());
}
Subject3D subject = new Subject3D(mesh); Subject3D subject = new Subject3D(mesh);
subjects.add(subject); subjects.add(subject);
AnimationTimer trackBoat = new AnimationTimer() { AnimationTimer trackBoat = new AnimationTimer() {
@Override @Override
public void handle(long now) { public void handle(long now) {

@ -33,9 +33,9 @@ public class Subject3D {
this.heading = new Rotate(0, Rotate.Y_AXIS); this.heading = new Rotate(0, Rotate.Y_AXIS);
this.mesh.getTransforms().addAll(position, heading, new Rotate(90, Rotate.X_AXIS), new Rotate(180, Rotate.Y_AXIS)); this.mesh.getTransforms().addAll(position, heading, new Rotate(90, Rotate.X_AXIS), new Rotate(180, Rotate.Y_AXIS));
this.position.xProperty().addListener(((observable, oldValue, newValue) -> System.out.println("Boat x: " + newValue))); // this.position.xProperty().addListener(((observable, oldValue, newValue) -> System.out.println("Boat x: " + newValue)));
this.position.yProperty().addListener(((observable, oldValue, newValue) -> System.out.println("Boat y: " + newValue))); // this.position.yProperty().addListener(((observable, oldValue, newValue) -> System.out.println("Boat y: " + newValue)));
this.position.zProperty().addListener(((observable, oldValue, newValue) -> System.out.println("Boat z: " + newValue))); // this.position.zProperty().addListener(((observable, oldValue, newValue) -> System.out.println("Boat z: " + newValue)));
} }
public Shape3D getMesh() { public Shape3D getMesh() {

Loading…
Cancel
Save