Scaled down marks and boats to make 3rd person view more realistic
- Added boat and mark annotations to support selection at large camera distance - Reduced collision radius to 15 m - Fixed event startup and XML files as race was crashing on start #story[1296]
This commit is contained in:
@@ -81,7 +81,7 @@ public class Event {
|
|||||||
*/
|
*/
|
||||||
public Event(boolean singlePlayer) throws EventConstructionException {
|
public Event(boolean singlePlayer) throws EventConstructionException {
|
||||||
|
|
||||||
String raceXMLFile = "mock/mockXML/raceTest.xml";
|
String raceXMLFile = "mock/mockXML/raceThreePlayers.xml";
|
||||||
String boatsXMLFile = "mock/mockXML/boatTest.xml";
|
String boatsXMLFile = "mock/mockXML/boatTest.xml";
|
||||||
String regattaXMLFile = "mock/mockXML/regattaTest.xml";
|
String regattaXMLFile = "mock/mockXML/regattaTest.xml";
|
||||||
|
|
||||||
@@ -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 + 1 * 60 * 10000;
|
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;
|
||||||
|
|||||||
@@ -42,11 +42,14 @@ public class SourceIdAllocator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Integer> allocatedIDs = mockRace.getRaceDataSource().getParticipants();
|
List<Integer> allocatedIDs = mockRace.getRaceDataSource().getParticipants();
|
||||||
|
System.out.println(allocatedIDs);
|
||||||
List<Integer> allIDs = new ArrayList<>(mockRace.getBoatDataSource().getBoats().keySet());
|
List<Integer> allIDs = new ArrayList<>(mockRace.getBoatDataSource().getBoats().keySet());
|
||||||
|
System.out.println(allIDs);
|
||||||
|
|
||||||
//Get list of unallocated ids.
|
//Get list of unallocated ids.
|
||||||
List<Integer> unallocatedIDs = new ArrayList<>(allIDs);
|
List<Integer> unallocatedIDs = new ArrayList<>(allIDs);
|
||||||
unallocatedIDs.removeAll(allocatedIDs);
|
unallocatedIDs.removeAll(allocatedIDs);
|
||||||
|
System.out.println(unallocatedIDs.isEmpty());
|
||||||
|
|
||||||
|
|
||||||
if (!unallocatedIDs.isEmpty()) {
|
if (!unallocatedIDs.isEmpty()) {
|
||||||
|
|||||||
@@ -411,14 +411,14 @@ public class Boat extends Collider {
|
|||||||
@Override
|
@Override
|
||||||
public boolean rayCast(Boat boat) {
|
public boolean rayCast(Boat boat) {
|
||||||
if(boat != this) {
|
if(boat != this) {
|
||||||
return rayCast(boat, 100);
|
return rayCast(boat, 15);
|
||||||
} else return false;
|
} else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCollisionEnter(Boat collider, Collision e) {
|
public void onCollisionEnter(Boat collider, Collision e) {
|
||||||
if(e.getBearing().degrees() > 270 || e.getBearing().degrees() < 90) {
|
if(e.getBearing().degrees() > 270 || e.getBearing().degrees() < 90) {
|
||||||
collider.bounce(100);
|
collider.bounce(15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,11 +29,6 @@ public class Mark extends Collider{
|
|||||||
*/
|
*/
|
||||||
private GPSCoordinate position;
|
private GPSCoordinate position;
|
||||||
|
|
||||||
/**
|
|
||||||
* Repulsion radius of the mark
|
|
||||||
*/
|
|
||||||
private double repulsionRadius = 50;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a mark with a given source ID, name, and position.
|
* Constructs a mark with a given source ID, name, and position.
|
||||||
* @param sourceID The source ID of the mark.
|
* @param sourceID The source ID of the mark.
|
||||||
@@ -97,11 +92,11 @@ public class Mark extends Collider{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean rayCast(Boat boat) {
|
public boolean rayCast(Boat boat) {
|
||||||
return rayCast(boat, repulsionRadius);
|
return rayCast(boat, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCollisionEnter(Boat collider, Collision e) {
|
public void onCollisionEnter(Boat collider, Collision e) {
|
||||||
collider.bounce(repulsionRadius);
|
collider.bounce(15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class HostController extends Controller {
|
|||||||
*/
|
*/
|
||||||
public void hostGamePressed() {
|
public void hostGamePressed() {
|
||||||
try {
|
try {
|
||||||
this.game = new Event(true);
|
this.game = new Event(false);
|
||||||
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);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import javafx.scene.input.KeyCode;
|
|||||||
import javafx.scene.input.KeyEvent;
|
import javafx.scene.input.KeyEvent;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
|
import javafx.scene.shape.Box;
|
||||||
import javafx.scene.shape.MeshView;
|
import javafx.scene.shape.MeshView;
|
||||||
import javafx.scene.shape.Sphere;
|
import javafx.scene.shape.Sphere;
|
||||||
import javafx.scene.transform.Translate;
|
import javafx.scene.transform.Translate;
|
||||||
@@ -26,6 +27,7 @@ import visualiser.app.App;
|
|||||||
import visualiser.gameController.ControllerClient;
|
import visualiser.gameController.ControllerClient;
|
||||||
import visualiser.gameController.Keys.ControlKey;
|
import visualiser.gameController.Keys.ControlKey;
|
||||||
import visualiser.gameController.Keys.KeyFactory;
|
import visualiser.gameController.Keys.KeyFactory;
|
||||||
|
import visualiser.layout.BoatArrow;
|
||||||
import visualiser.layout.MarkRadius;
|
import visualiser.layout.MarkRadius;
|
||||||
import visualiser.layout.Subject3D;
|
import visualiser.layout.Subject3D;
|
||||||
import visualiser.layout.View3D;
|
import visualiser.layout.View3D;
|
||||||
@@ -206,16 +208,17 @@ public class RaceController extends Controller {
|
|||||||
view3D.setItems(viewSubjects);
|
view3D.setItems(viewSubjects);
|
||||||
// Position and add each mark to view
|
// Position and add each mark to view
|
||||||
for(Mark mark: race.getVisualiserRaceState().getMarks()) {
|
for(Mark mark: race.getVisualiserRaceState().getMarks()) {
|
||||||
Subject3D subject = new Subject3D(new Sphere(2));
|
|
||||||
subject.setX(gpsConverter.convertGPS(mark.getPosition()).getX());
|
|
||||||
subject.setZ(gpsConverter.convertGPS(mark.getPosition()).getY());
|
|
||||||
MeshView mesh = new MeshView(importerMark.getImport());
|
MeshView mesh = new MeshView(importerMark.getImport());
|
||||||
Subject3D markModel = new Subject3D(mesh);
|
Subject3D markModel = new Subject3D(mesh);
|
||||||
Subject3D markRadius = new MarkRadius(3);
|
Subject3D markRadius = new MarkRadius(3);
|
||||||
|
|
||||||
double x = gpsConverter.convertGPS(mark.getPosition()).getX();
|
double x = gpsConverter.convertGPS(mark.getPosition()).getX();
|
||||||
double z = gpsConverter.convertGPS(mark.getPosition()).getY();
|
double z = gpsConverter.convertGPS(mark.getPosition()).getY();
|
||||||
|
|
||||||
markModel.setX(x);
|
markModel.setX(x);
|
||||||
markModel.setZ(z);
|
markModel.setZ(z);
|
||||||
|
markModel.setScale(0.1);
|
||||||
|
|
||||||
markRadius.setX(x);
|
markRadius.setX(x);
|
||||||
markRadius.setZ(z);
|
markRadius.setZ(z);
|
||||||
|
|
||||||
@@ -230,16 +233,29 @@ public class RaceController extends Controller {
|
|||||||
} else {
|
} else {
|
||||||
mesh = new MeshView(importerBurgerBoat.getImport());
|
mesh = new MeshView(importerBurgerBoat.getImport());
|
||||||
}
|
}
|
||||||
Subject3D subject = new Subject3D(mesh);
|
Subject3D boatModel = new Subject3D(mesh);
|
||||||
viewSubjects.add(subject);
|
Subject3D boatArrow = new BoatArrow(12);
|
||||||
|
|
||||||
|
boatModel.setScale(0.1);
|
||||||
|
|
||||||
|
viewSubjects.add(boatModel);
|
||||||
|
viewSubjects.add(boatArrow);
|
||||||
|
|
||||||
// Track this boat's movement with the new subject
|
// Track this boat's movement with the new subject
|
||||||
AnimationTimer trackBoat = new AnimationTimer() {
|
AnimationTimer trackBoat = new AnimationTimer() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(long now) {
|
public void handle(long now) {
|
||||||
subject.setHeading(boat.getBearing().degrees());
|
double heading = boat.getBearing().degrees();
|
||||||
subject.setX(gpsConverter.convertGPS(boat.getPosition()).getX());
|
double x = gpsConverter.convertGPS(boat.getPosition()).getX();
|
||||||
subject.setZ(gpsConverter.convertGPS(boat.getPosition()).getY());
|
double z = gpsConverter.convertGPS(boat.getPosition()).getY();
|
||||||
|
|
||||||
|
boatModel.setHeading(heading);
|
||||||
|
boatModel.setX(x);
|
||||||
|
boatModel.setZ(z);
|
||||||
|
|
||||||
|
boatArrow.setHeading(heading);
|
||||||
|
boatArrow.setX(x);
|
||||||
|
boatArrow.setZ(z);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
trackBoat.start();
|
trackBoat.start();
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package visualiser.layout;
|
||||||
|
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
|
import javafx.scene.paint.PhongMaterial;
|
||||||
|
import javafx.scene.shape.Box;
|
||||||
|
import javafx.scene.transform.Rotate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by cbt24 on 9/09/17.
|
||||||
|
*/
|
||||||
|
public class BoatArrow extends Subject3D {
|
||||||
|
public BoatArrow(double length) {
|
||||||
|
super(new Box(length/3, 0, length));
|
||||||
|
this.getMesh().getTransforms().add(new Rotate(-90, Rotate.X_AXIS));
|
||||||
|
this.getMesh().setMaterial(new PhongMaterial(new Color(1, 0, 0, 0.5)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package visualiser.layout;
|
|||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.paint.PhongMaterial;
|
import javafx.scene.paint.PhongMaterial;
|
||||||
import javafx.scene.shape.Cylinder;
|
import javafx.scene.shape.Cylinder;
|
||||||
|
import javafx.scene.transform.Rotate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by cbt24 on 9/09/17.
|
* Created by cbt24 on 9/09/17.
|
||||||
@@ -10,6 +11,7 @@ import javafx.scene.shape.Cylinder;
|
|||||||
public class MarkRadius extends Subject3D {
|
public class MarkRadius extends Subject3D {
|
||||||
public MarkRadius(double radius) {
|
public MarkRadius(double radius) {
|
||||||
super(new Cylinder(radius, 0));
|
super(new Cylinder(radius, 0));
|
||||||
|
this.getMesh().getTransforms().add(new Rotate(-90, Rotate.X_AXIS));
|
||||||
this.getMesh().setMaterial(new PhongMaterial(new Color(1, 0, 0, 0.5)));
|
this.getMesh().setMaterial(new PhongMaterial(new Color(1, 0, 0, 0.5)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package visualiser.layout;
|
|||||||
|
|
||||||
import javafx.scene.shape.Shape3D;
|
import javafx.scene.shape.Shape3D;
|
||||||
import javafx.scene.transform.Rotate;
|
import javafx.scene.transform.Rotate;
|
||||||
|
import javafx.scene.transform.Scale;
|
||||||
import javafx.scene.transform.Translate;
|
import javafx.scene.transform.Translate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,16 +24,19 @@ public class Subject3D {
|
|||||||
*/
|
*/
|
||||||
private Rotate heading;
|
private Rotate heading;
|
||||||
|
|
||||||
|
private Scale scale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for view subject wrapper
|
* Constructor for view subject wrapper
|
||||||
* @param mesh to be rendered
|
* @param mesh to be rendered
|
||||||
*/
|
*/
|
||||||
public Subject3D(Shape3D mesh) {
|
public Subject3D(Shape3D mesh) {
|
||||||
this.mesh = mesh;
|
this.mesh = mesh;
|
||||||
|
this.scale = new Scale();
|
||||||
this.position = new Translate();
|
this.position = new Translate();
|
||||||
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, scale, heading, new Rotate(90, Rotate.X_AXIS), new Rotate(180, Rotate.Y_AXIS));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Shape3D getMesh() {
|
public Shape3D getMesh() {
|
||||||
@@ -47,6 +51,12 @@ public class Subject3D {
|
|||||||
return heading;
|
return heading;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setScale(double scale) {
|
||||||
|
this.scale.setX(scale);
|
||||||
|
this.scale.setY(scale);
|
||||||
|
this.scale.setZ(scale);
|
||||||
|
}
|
||||||
|
|
||||||
public void setX(double x) {
|
public void setX(double x) {
|
||||||
position.setX(x);
|
position.setX(x);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
<CreationTimeDate>RACE_CREATION_TIME</CreationTimeDate>
|
<CreationTimeDate>RACE_CREATION_TIME</CreationTimeDate>
|
||||||
<RaceStartTime Postpone="false" Time="RACE_START_TIME"/>
|
<RaceStartTime Postpone="false" Time="RACE_START_TIME"/>
|
||||||
<Participants>
|
<Participants>
|
||||||
<Yacht SourceID="126"/>
|
|
||||||
</Participants>
|
</Participants>
|
||||||
<CompoundMarkSequence>
|
<CompoundMarkSequence>
|
||||||
<Corner SeqID="1" CompoundMarkID="1" Rounding="SP" ZoneSize="3" />
|
<Corner SeqID="1" CompoundMarkID="1" Rounding="SP" ZoneSize="3" />
|
||||||
|
|||||||
@@ -5,9 +5,6 @@
|
|||||||
<CreationTimeDate>RACE_CREATION_TIME</CreationTimeDate>
|
<CreationTimeDate>RACE_CREATION_TIME</CreationTimeDate>
|
||||||
<RaceStartTime Postpone="false" Time="RACE_START_TIME"/>
|
<RaceStartTime Postpone="false" Time="RACE_START_TIME"/>
|
||||||
<Participants>
|
<Participants>
|
||||||
<Yacht SourceID="124"/>
|
|
||||||
<Yacht SourceID="125"/>
|
|
||||||
<Yacht SourceID="126"/>
|
|
||||||
</Participants>
|
</Participants>
|
||||||
<CompoundMarkSequence>
|
<CompoundMarkSequence>
|
||||||
<Corner SeqID="1" CompoundMarkID="1" Rounding="SP" ZoneSize="3" />
|
<Corner SeqID="1" CompoundMarkID="1" Rounding="SP" ZoneSize="3" />
|
||||||
|
|||||||
Reference in New Issue
Block a user