Merge remote-tracking branch 'origin/story1266_3d_model_factory' into NewUI_merge

# Conflicts:
#	pom.xml
#	src/main/java/seng302/App.java
#	src/main/java/seng302/gameServer/GameState.java
#	src/main/java/seng302/gameServer/MainServerThread.java
#	src/main/java/seng302/gameServer/ServerToClientThread.java
#	src/main/java/seng302/utilities/XMLGenerator.java
#	src/main/java/seng302/visualiser/GameClient.java
#	src/main/java/seng302/visualiser/controllers/RaceViewController.java
#	src/main/resources/views/RaceView.fxml
#	src/main/resources/views/StartScreenView.fxml
This commit is contained in:
Michael Rausch
2017-09-11 15:29:33 +12:00
130 changed files with 24554 additions and 331 deletions
+82 -17
View File
@@ -10,6 +10,8 @@ import seng302.model.*;
import seng302.model.mark.CompoundMark;
import seng302.model.mark.Mark;
import seng302.model.mark.MarkOrder;
import seng302.model.token.Token;
import seng302.model.token.TokenType;
import seng302.utilities.GeoUtility;
import seng302.utilities.XMLParser;
@@ -23,6 +25,7 @@ import java.util.*;
* Created by wmu16 on 10/07/17.
*/
public class GameState implements Runnable {
@FunctionalInterface
interface NewMessageListener {
@@ -31,13 +34,20 @@ public class GameState implements Runnable {
private Logger logger = LoggerFactory.getLogger(GameState.class);
static final int WARNING_TIME = 10 * -1000;
static final int PREPATORY_TIME = 5 * -1000;
private static final int TIME_TILL_START = 10 * 1000;
private static final Long POWERUP_TIMEOUT_MS = 10_000L;
private static final Integer STATE_UPDATES_PER_SECOND = 60;
public static Double ROUNDING_DISTANCE = 50d; // TODO: 14/08/17 wmu16 - Look into this value further
public static final Double MARK_COLLISION_DISTANCE = 15d;
private static Double ROUNDING_DISTANCE = 50d; // TODO: 14/08/17 wmu16 - Look into this value further
private static final Double MARK_COLLISION_DISTANCE = 15d;
public static final Double YACHT_COLLISION_DISTANCE = 25.0;
public static final Double BOUNCE_DISTANCE_MARK = 20.0;
private static final Double BOUNCE_DISTANCE_MARK = 20.0;
public static final Double BOUNCE_DISTANCE_YACHT = 30.0;
public static final Double COLLISION_VELOCITY_PENALTY = 0.3;
private static final Double COLLISION_VELOCITY_PENALTY = 0.3;
private static Long previousUpdateTime;
public static Double windDirection;
@@ -48,6 +58,7 @@ public class GameState implements Runnable {
private static String hostIpAddress;
private static List<Player> players;
private static Map<Integer, ServerYacht> yachts;
private static List<Token> tokens;
private static Boolean isRaceStarted;
private static GameStages currentStage;
private static MarkOrder markOrder;
@@ -76,6 +87,7 @@ public class GameState implements Runnable {
windSpeed = 10000d;
this.hostIpAddress = hostIpAddress;
yachts = new HashMap<>();
tokens = new ArrayList<>();
players = new ArrayList<>();
GameState.hostIpAddress = hostIpAddress;
customizationFlag = false;
@@ -122,6 +134,18 @@ public class GameState implements Runnable {
return players;
}
public static void addToken(Token token) {
tokens.add(token);
}
public static List<Token> getTokens() {
return tokens;
}
public static void clearTokens() {
tokens.clear();
}
public static void addPlayer(Player player) {
players.add(player);
String playerText = player.getYacht().getSourceId() + " " + player.getYacht().getBoatName()
@@ -163,7 +187,7 @@ public class GameState implements Runnable {
}
public static void resetStartTime(){
startTime = System.currentTimeMillis() + MainServerThread.TIME_TILL_START;
startTime = System.currentTimeMillis() + TIME_TILL_START;
}
public static Double getWindDirection() {
@@ -261,10 +285,12 @@ public class GameState implements Runnable {
}
for (ServerYacht yacht : yachts.values()) {
updateVelocity(yacht);
checkPowerUpTimeout(yacht);
yacht.runAutoPilot();
yacht.updateLocation(timeInterval);
if (yacht.getBoatStatus() != BoatStatus.FINISHED) {
checkCollision(yacht);
checkTokenPickUp(yacht);
checkForLegProgression(yacht);
raceFinished = false;
}
@@ -275,6 +301,17 @@ public class GameState implements Runnable {
}
}
private void checkPowerUpTimeout(ServerYacht yacht) {
if (yacht.getPowerUp() != null) {
if (System.currentTimeMillis() - yacht.getPowerUpStartTime() > POWERUP_TIMEOUT_MS) {
yacht.powerDown();
logger.debug("Yacht: " + yacht.getShortName() + " powered down!");
}
}
}
/**
* Check if the yacht has crossed the course limit
*
@@ -295,6 +332,26 @@ public class GameState implements Runnable {
return false;
}
/**
* Checks all tokens to see if a yacht has picked one up
*
* @param serverYacht The yacht to check for
*/
private void checkTokenPickUp(ServerYacht serverYacht) {
for (Token token : tokens) {
Double distance = GeoUtility.getDistance(token, serverYacht.getLocation());
if (distance < YACHT_COLLISION_DISTANCE) {
tokens.remove(token);
serverYacht.powerUp(token.getTokenType());
logger.debug("Yacht: " + serverYacht.getShortName() + " got powerup " + token
.getTokenType());
notifyMessageListeners(MessageFactory.getRaceXML());
break;
}
}
}
public static void checkCollision(ServerYacht serverYacht) {
ServerYacht collidedYacht = checkYachtCollision(serverYacht);
if (collidedYacht != null) {
@@ -346,25 +403,31 @@ public class GameState implements Runnable {
private void updateVelocity(ServerYacht yacht) {
Double velocity = yacht.getCurrentVelocity();
Double trueWindAngle = Math.abs(windDirection - yacht.getHeading());
Double boatSpeedInKnots = PolarTable.getBoatSpeed(getWindSpeedKnots(), trueWindAngle);
Double maxBoatSpeed = GeoUtility.knotsToMMS(boatSpeedInKnots);
Double maxBoatSpeed = GeoUtility.knotsToMMS(boatSpeedInKnots) * 4;
if (yacht.getPowerUp() != null) {
if (yacht.getPowerUp().equals(TokenType.BOOST)) {
maxBoatSpeed *= 2;
}
}
Double currentVelocity = yacht.getCurrentVelocity();
// TODO: 15/08/17 remove magic numbers from these equations.
if (yacht.getSailIn()) {
if (velocity < maxBoatSpeed - 500) {
if (currentVelocity < maxBoatSpeed - 500) {
yacht.changeVelocity(maxBoatSpeed / 100);
} else if (velocity > maxBoatSpeed + 500) {
yacht.changeVelocity(-velocity / 200);
} else if (currentVelocity > maxBoatSpeed + 500) {
yacht.changeVelocity(-currentVelocity / 200);
} else {
yacht.setCurrentVelocity(maxBoatSpeed);
}
} else {
if (velocity > 3000) {
yacht.changeVelocity(-velocity / 200);
} else if (velocity > 100) {
yacht.changeVelocity(-velocity / 50);
} else if (velocity <= 100) {
if (currentVelocity > 3000) {
yacht.changeVelocity(-currentVelocity / 200);
} else if (currentVelocity > 100) {
yacht.changeVelocity(-currentVelocity / 50);
} else if (currentVelocity <= 100) {
yacht.setCurrentVelocity(0d);
}
}
@@ -648,7 +711,8 @@ public class GameState implements Runnable {
// TODO: 13/8/17 figure out the rounding side, rounded mark source ID and boat status.
Message markRoundingMessage = new MarkRoundingMessage(0, 0,
sourceID, RoundingBoatStatus.RACING, roundingMark.getRoundingSide(), markType,
currentMarkSeqID + 1);
currentMark.getId());
// currentMarkSeqID + 1);
notifyMessageListeners(markRoundingMessage);
}
@@ -667,7 +731,7 @@ public class GameState implements Runnable {
}
public static void addMarkPassListener(NewMessageListener listener) {
public static void addMessageEventListener(NewMessageListener listener) {
markListeners.add(listener);
}
@@ -702,4 +766,5 @@ public class GameState implements Runnable {
public static void setMaxPlayers(Integer newMax){
maxPlayers = newMax;
}
}
@@ -5,6 +5,8 @@ import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import seng302.gameServer.messages.*;
import seng302.model.GeoPoint;
import seng302.model.Player;
@@ -12,6 +14,8 @@ import seng302.model.PolarTable;
import seng302.model.ServerYacht;
import seng302.model.mark.CompoundMark;
import seng302.model.stream.xml.parser.RegattaXMLData;
import seng302.model.token.Token;
import seng302.model.token.TokenType;
import seng302.utilities.GeoUtility;
import seng302.utilities.XMLGenerator;
import seng302.utilities.XMLParser;
@@ -22,7 +26,6 @@ import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.io.StringReader;
import java.net.ServerSocket;
import java.time.LocalDateTime;
import java.util.*;
/**
@@ -31,18 +34,14 @@ import java.util.*;
*/
public class MainServerThread implements Runnable, ClientConnectionDelegate {
private Logger logger = LoggerFactory.getLogger(MainServerThread.class);
private static final int PORT = 4942;
private static final Integer CLIENT_UPDATES_PER_SECOND = 60;
private static final int LOG_LEVEL = 1;
private static final int WARNING_TIME = 10 * -1000;
private static final int PREPATORY_TIME = 5 * -1000;
public static final int TIME_TILL_START = 10 * 1000;
private static final int MAX_WIND_SPEED = 12000;
private static final int MIN_WIND_SPEED = 8000;
public static int windSpeed = 1000;
private boolean terminated;
private Thread thread;
@@ -95,16 +94,18 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
try {
serverSocket = new ServerSocket(PORT);
} catch (IOException e) {
serverLog("IO error in server thread handler upon trying to make new server socket", 0);
logger.trace("IO error in server thread handler upon trying to make new server socket",
0);
}
startAdvertisingServer();
PolarTable.parsePolarFile(getClass().getResourceAsStream("/config/acc_polars.csv"));
GameState.addMarkPassListener(this::broadcastMessage);
GameState.addMessageEventListener(this::broadcastMessage);
terminated = false;
thread = new Thread(this, "MainServer");
startUpdatingWind();
startSpawningTokens();
thread.start();
}
@@ -119,24 +120,22 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
try {
Thread.sleep(1000 / CLIENT_UPDATES_PER_SECOND);
} catch (InterruptedException e) {
serverLog("Interrupted exception in Main Server Thread thread sleep", 1);
logger.trace("Interrupted exception in Main Server Thread thread sleep", 1);
}
if (GameState.getCurrentStage() == GameStages.LOBBYING && GameState
.getCustomizationFlag()) {
// TODO: 16/08/17 ajm412: This can probably be done in a nicer way via those fancy functional interfaces.
for (ServerToClientThread thread : serverToClientThreads) {
thread.sendSetupMessages();
}
sendSetupMessages();
GameState.resetCustomizationFlag();
}
if (GameState.getCurrentStage() == GameStages.PRE_RACE) {
updateClients();
sendBoatLocations();
}
//RACING
if (GameState.getCurrentStage() == GameStages.RACING) {
updateClients();
sendBoatLocations();
}
//FINISHED
@@ -157,12 +156,18 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
}
}
public void updateClients() {
for (ServerToClientThread serverToClientThread : serverToClientThreads) {
serverToClientThread.sendBoatLocationPackets();
public void sendBoatLocations() {
for (ServerYacht serverYacht : GameState.getYachts().values()) {
broadcastMessage(MessageFactory.getBoatLocationMessage(serverYacht));
}
}
public void sendSetupMessages() {
broadcastMessage(MessageFactory.getRaceXML());
broadcastMessage(MessageFactory.getRegattaXML());
broadcastMessage(MessageFactory.getBoatXML());
}
private void broadcastMessage(Message message) {
for (ServerToClientThread serverToClientThread : serverToClientThreads) {
serverToClientThread.sendMessage(message);
@@ -198,6 +203,25 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
GameState.setWindDirection(direction.doubleValue());
}
// TODO: 29/08/17 wmu16 - This should not be in one function (init and a scheduling update)
public void startGame() {
initialiseBoatPositions();
Timer t = new Timer();
t.schedule(new TimerTask() {
@Override
public void run() {
broadcastMessage(MessageFactory.getRaceStatusMessage());
if (GameState.getCurrentStage() == GameStages.PRE_RACE
|| GameState.getCurrentStage() == GameStages.LOBBYING) {
broadcastMessage(MessageFactory.getRaceStartStatusMessage());
}
}
}, 0, 500);
}
// TODO: 29/08/17 wmu16 - This sort of update should be in game state
private static void startUpdatingWind(){
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@@ -208,11 +232,41 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
}, 0, 500);
}
/**
* Start spawning coins every 60s after the first minute
*/
private void startSpawningTokens() {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
spawnNewCoins();
broadcastMessage(MessageFactory.getRaceXML());
}
}, 0, 60000);
}
static void serverLog(String message, int logLevel) {
if (logLevel <= LOG_LEVEL) {
System.out.println(
"[SERVER " + LocalDateTime.now().toLocalTime().toString() + "] " + message);
/**
* Randomly select a subset of tokens from a pre defined superset
* Broadasts a new race status message to show this update
*/
private void spawnNewCoins() {
List<Token> allTokens = new ArrayList<>();
Token token1 = new Token(TokenType.BOOST, 57.66946, 11.83154);
Token token2 = new Token(TokenType.BOOST, 57.66877, 11.83382);
Token token3 = new Token(TokenType.BOOST, 57.66914, 11.83965);
Token token4 = new Token(TokenType.BOOST, 57.66684, 11.83214);
allTokens.add(token1);
allTokens.add(token2);
allTokens.add(token3);
allTokens.add(token4);
GameState.clearTokens();
Random random = new Random();
Collections.shuffle(allTokens);
for (int i = 0; i < random.nextInt(allTokens.size()); i++) {
GameState.addToken(allTokens.get(i));
}
}
@@ -223,13 +277,9 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
*/
@Override
public void clientConnected(ServerToClientThread serverToClientThread) {
serverLog("Player Connected From " + serverToClientThread.getThread().getName(), 0);
logger.debug("Player Connected From " + serverToClientThread.getThread().getName(), 0);
serverToClientThreads.add(serverToClientThread);
serverToClientThread.addConnectionListener(() -> {
for (ServerToClientThread thread : serverToClientThreads) {
thread.sendSetupMessages();
}
});
serverToClientThread.addConnectionListener(this::sendSetupMessages);
serverToClientThread.addDisconnectListener(this::clientDisconnected);
try {
@@ -246,12 +296,7 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
*/
@Override
public void clientDisconnected(Player player) {
// try {
// player.getSocket().close();
// } catch (Exception e) {
// serverLog("Cannot disconnect the socket for the disconnected player.", 0);
// }
serverLog("Player " + player.getYacht().getSourceId() + "'s socket disconnected", 0);
logger.debug("Player " + player.getYacht().getSourceId() + "'s socket disconnected", 0);
GameState.removeYacht(player.getYacht().getSourceId());
GameState.removePlayer(player);
ServerToClientThread closedConnection = null;
@@ -290,55 +335,15 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate {
if (GameState.getCurrentStage() == GameStages.PRE_RACE || GameState.getCurrentStage() == GameStages.LOBBYING) {
broadcastMessage(makeRaceStartMessage());
}
serverToClientThreads.remove(closedConnection);
closedConnection.terminate();
}
}, 0, 500);
}
private RaceStartStatusMessage makeRaceStartMessage() {
Long raceStartTime = GameState.getStartTime();
return new RaceStartStatusMessage(1, raceStartTime ,
1, RaceStartNotificationType.SET_RACE_START_TIME);
}
private RaceStatusMessage makeRaceStatusMessage() {
// variables taken from GameServerThread
List<BoatSubMessage> boatSubMessages = new ArrayList<>();
RaceStatus raceStatus;
for (Player player : GameState.getPlayers()) {
ServerYacht y = player.getYacht();
BoatSubMessage m = new BoatSubMessage(y.getSourceId(), y.getBoatStatus(),
y.getLegNumber(),
0, 0, 1234L,
1234L);
boatSubMessages.add(m);
}
long timeTillStart = System.currentTimeMillis() - GameState.getStartTime();
if (GameState.getCurrentStage() == GameStages.LOBBYING) {
raceStatus = RaceStatus.PRESTART;
} else if (GameState.getCurrentStage() == GameStages.PRE_RACE) {
raceStatus = RaceStatus.PRESTART;
if (timeTillStart > WARNING_TIME) {
raceStatus = RaceStatus.WARNING;
}
if (timeTillStart > PREPATORY_TIME) {
raceStatus = RaceStatus.PREPARATORY;
}
} else {
raceStatus = RaceStatus.STARTED;
if (GameState.getCurrentStage() != GameStages.RACING) {
sendSetupMessages();
}
return new RaceStatusMessage(1, raceStatus, GameState.getStartTime(),
GameState.getWindDirection(),
GameState.getWindSpeedMMS().longValue(), GameState.getPlayers().size(),
RaceType.MATCH_RACE, 1, boatSubMessages);
}
public void terminate() {
@@ -0,0 +1,136 @@
package seng302.gameServer;
import java.util.ArrayList;
import java.util.List;
import seng302.gameServer.messages.BoatLocationMessage;
import seng302.gameServer.messages.BoatSubMessage;
import seng302.gameServer.messages.RaceStartNotificationType;
import seng302.gameServer.messages.RaceStartStatusMessage;
import seng302.gameServer.messages.RaceStatus;
import seng302.gameServer.messages.RaceStatusMessage;
import seng302.gameServer.messages.RaceType;
import seng302.gameServer.messages.XMLMessage;
import seng302.gameServer.messages.XMLMessageSubType;
import seng302.model.Player;
import seng302.model.ServerYacht;
import seng302.model.stream.xml.generator.RaceXMLTemplate;
import seng302.model.stream.xml.generator.RegattaXMLTemplate;
import seng302.model.token.Token;
import seng302.utilities.XMLGenerator;
/**
* A Class for interfacing between the data we have in the GameState to the messages we need to send
* through the MainServerThread.
*
* WARNING DO NOT USE THIS CLASS IF GAMESTATE HAS NOT BEEN INSTANTIATED. (Main Server has not started)
* // TODO: 29/08/17 wmu16 - Make GameState non static to fix this ¯\_(ツ)_/¯
* Created by wmu16 on 29/08/17.
*/
/*
Ideally this class would be created with an instance of the GameState (I tried implementing this for
a bit) but it was too difficult to properly make GameState non static without doing some proper
re working. To do later.
*/
public class MessageFactory {
private static XMLGenerator xmlGenerator = new XMLGenerator();
public static RaceStartStatusMessage getRaceStartStatusMessage() {
return new RaceStartStatusMessage(
1,
GameState.getStartTime(),
1,
RaceStartNotificationType.SET_RACE_START_TIME);
}
public static RaceStatusMessage getRaceStatusMessage() {
// variables taken from GameServerThread
List<BoatSubMessage> boatSubMessages = new ArrayList<>();
RaceStatus raceStatus;
for (Player player : GameState.getPlayers()) {
ServerYacht y = player.getYacht();
BoatSubMessage m = new BoatSubMessage(y.getSourceId(), y.getBoatStatus(),
y.getLegNumber(),
0, 0, 1234L,
1234L);
boatSubMessages.add(m);
}
long timeTillStart = System.currentTimeMillis() - GameState.getStartTime();
if (GameState.getCurrentStage() == GameStages.LOBBYING) {
raceStatus = RaceStatus.PRESTART;
} else if (GameState.getCurrentStage() == GameStages.PRE_RACE) {
raceStatus = RaceStatus.PRESTART;
if (timeTillStart > GameState.WARNING_TIME) {
raceStatus = RaceStatus.WARNING;
}
if (timeTillStart > GameState.PREPATORY_TIME) {
raceStatus = RaceStatus.PREPARATORY;
}
} else {
raceStatus = RaceStatus.STARTED;
}
return new RaceStatusMessage(1, raceStatus, GameState.getStartTime(),
GameState.getWindDirection(),
GameState.getWindSpeedMMS().longValue(), GameState.getPlayers().size(),
RaceType.MATCH_RACE, 1, boatSubMessages);
}
public static BoatLocationMessage getBoatLocationMessage(ServerYacht yacht) {
return new BoatLocationMessage(
yacht.getSourceId(),
0, // TODO: 29/08/17 wmu16 - Work out what to do with seqNo. Currently not used
yacht.getLocation().getLat(),
yacht.getLocation().getLng(),
yacht.getHeading(),
yacht.getCurrentVelocity().longValue());
}
public static XMLMessage getRaceXML() {
List<ServerYacht> yachts = new ArrayList<>(GameState.getYachts().values());
List<Token> tokens = GameState.getTokens();
RaceXMLTemplate raceXMLTemplate = new RaceXMLTemplate(yachts, tokens);
xmlGenerator.setRaceTemplate(raceXMLTemplate);
XMLMessage raceXMLMessage = new XMLMessage(
xmlGenerator.getRaceAsXml(),
XMLMessageSubType.RACE,
xmlGenerator.getRaceAsXml().length());
return raceXMLMessage;
}
public static XMLMessage getRegattaXML() {
//@TODO calculate lat/lng values
xmlGenerator.setRegattaTemplate(
new RegattaXMLTemplate(
"Party Parrot Test Server", "Bermuda Test Course",
57.6679590, 11.8503233)
);
return new XMLMessage(
xmlGenerator.getRegattaAsXml(),
XMLMessageSubType.REGATTA,
xmlGenerator.getRegattaAsXml().length());
}
public static XMLMessage getBoatXML() {
List<ServerYacht> yachts = new ArrayList<>(GameState.getYachts().values());
List<Token> tokens = GameState.getTokens();
RaceXMLTemplate raceXMLTemplate = new RaceXMLTemplate(yachts, tokens);
xmlGenerator.setRaceTemplate(raceXMLTemplate);
return new XMLMessage(
xmlGenerator.getBoatsAsXml(),
XMLMessageSubType.BOAT,
xmlGenerator.getBoatsAsXml().length());
}
}
@@ -4,6 +4,16 @@ package seng302.gameServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import seng302.gameServer.messages.*;
import seng302.gameServer.messages.BoatAction;
import seng302.gameServer.messages.BoatLocationMessage;
import seng302.gameServer.messages.ClientType;
import seng302.gameServer.messages.CustomizeRequestType;
import seng302.gameServer.messages.Message;
import seng302.gameServer.messages.RegistrationResponseMessage;
import seng302.gameServer.messages.RegistrationResponseStatus;
import seng302.gameServer.messages.XMLMessage;
import seng302.gameServer.messages.XMLMessageSubType;
import seng302.gameServer.messages.YachtEventCodeMessage;
import seng302.model.Player;
import seng302.model.ServerYacht;
import seng302.model.stream.packets.PacketType;
@@ -19,13 +29,17 @@ import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
import java.util.zip.CRC32;
import java.util.zip.Checksum;
import seng302.model.stream.xml.generator.RaceXMLTemplate;
import seng302.model.stream.xml.generator.RegattaXMLTemplate;
import seng302.model.token.Token;
import seng302.utilities.XMLGenerator;
/**
* A class describing a single connection to a Client for the purposes of sending and receiving on
* its own thread. All server threads created and owned by the server thread handler which can
* trigger client updates on its threads Created by wmu16 on 13/07/17.
*/
public class ServerToClientThread implements Runnable, Observer {
public class ServerToClientThread implements Runnable {
/**
* Called to notify listeners when this thread receives a connection correctly.
@@ -57,7 +71,7 @@ public class ServerToClientThread implements Runnable, Observer {
private ClientType clientType;
private Boolean isRegistered = false;
private XMLGenerator xml;
private XMLGenerator xmlGenerator;
private List<ConnectionListener> connectionListeners = new ArrayList<>();
private DisconnectListener disconnectListener;
@@ -109,21 +123,11 @@ public class ServerToClientThread implements Runnable, Observer {
"Yacht", sourceId, sourceId.toString(), fName, fName + " " + lName, "NZ"
);
yacht.addObserver(this); // TODO: yacht can notify mark rounding message hyi25 13/8/17
player = new Player(socket, yacht);
GameState.addYacht(sourceId, yacht);
GameState.addPlayer(player);
}
@Override
public void update(Observable o, Object arg) {
if (arg != null) {
sendMessage((Message) arg);
} else {
sendSetupMessages();
}
}
private void completeRegistration(ClientType clientType) throws IOException {
// Fail if not a player
if (!clientType.equals(ClientType.PLAYER)){
@@ -293,23 +297,6 @@ public class ServerToClientThread implements Runnable, Observer {
return seqNo;
}
public void sendBoatLocationPackets() {
ArrayList<ServerYacht> yachts = new ArrayList<>(GameState.getYachts().values());
for (ServerYacht yacht : yachts) {
BoatLocationMessage boatLocationMessage =
new BoatLocationMessage(
yacht.getSourceId(),
getSeqNo(),
yacht.getLocation().getLat(),
yacht.getLocation().getLng(),
yacht.getHeading(),
yacht.getCurrentVelocity().longValue());
sendMessage(boatLocationMessage);
}
}
public Thread getThread() {
return thread;
}
+22 -10
View File
@@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory;
import seng302.gameServer.GameState;
import seng302.gameServer.messages.BoatStatus;
import seng302.model.mark.Mark;
import seng302.model.token.TokenType;
import seng302.utilities.GeoUtility;
import java.util.HashMap;
@@ -17,7 +18,7 @@ import java.util.Observer;
* compared to the XMLParser boat class, also done outside Boat class because some old variables are
* not used anymore.
*/
public class ServerYacht extends Observable {
public class ServerYacht {
private Logger logger = LoggerFactory.getLogger(ClientYacht.class);
@@ -31,10 +32,8 @@ public class ServerYacht extends Observable {
private String boatName;
private String country;
private BoatStatus boatStatus;
private Color boatColor;
//Location
private Double lastHeading;
private Boolean sailIn;
@@ -53,6 +52,10 @@ public class ServerYacht extends Observable {
private Boolean hasPassedLine;
private Boolean hasPassedThroughGate;
//PowerUp
private TokenType powerUp;
private Long powerUpStartTime;
public ServerYacht(String boatType, Integer sourceId, String hullID, String shortName,
String boatName, String country) {
@@ -72,6 +75,7 @@ public class ServerYacht extends Observable {
this.currentMarkSeqID = 0;
this.legNumber = 0;
this.boatColor = Colors.getColor(sourceId - 1);
this.powerUp = null;
this.hasEnteredRoundingZone = false;
this.hasPassedLine = false;
@@ -102,13 +106,21 @@ public class ServerYacht extends Observable {
location = geoPoint;
}
/**
* Add ServerToClientThread as the observer, this observer pattern mainly server for the boat
* rounding package.
*/
@Override
public void addObserver(Observer o) {
super.addObserver(o);
public void powerUp(TokenType powerUp) {
this.powerUp = powerUp;
powerUpStartTime = System.currentTimeMillis();
}
public void powerDown() {
this.powerUp = null;
}
public Long getPowerUpStartTime() {
return powerUpStartTime;
}
public TokenType getPowerUp() {
return powerUp;
}
/**
@@ -11,8 +11,10 @@ import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import seng302.gameServer.messages.RoundingSide;
import seng302.model.stream.xml.generator.Race;
import seng302.model.ServerYacht;
import seng302.model.stream.xml.generator.RaceXMLTemplate;
import seng302.model.stream.xml.parser.RaceXMLData;
import seng302.model.token.Token;
import seng302.utilities.XMLGenerator;
import seng302.utilities.XMLParser;
import java.util.*;
@@ -125,7 +127,10 @@ public class MarkOrder {
private void loadRaceProperties(){
XMLGenerator generator = new XMLGenerator();
generator.setRace(new Race());
// TODO: 29/08/17 wmu16 - This is terrible, having to make a template just to receive constant data
generator.setRaceTemplate(new RaceXMLTemplate(
new ArrayList<>(),
new ArrayList<>()));
String raceXML = generator.getRaceAsXml();
@@ -5,28 +5,23 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import seng302.model.ServerYacht;
import seng302.model.token.Token;
/**
* A Race object that can be parsed into XML
*/
public class Race {
public class RaceXMLTemplate {
private List<ServerYacht> yachts;
private LocalDateTime startTime;
private List<Token> tokens;
public Race(){
yachts = new ArrayList<>();
public RaceXMLTemplate(List<ServerYacht> yachts, List<Token> tokens) {
this.yachts = yachts;
this.tokens = tokens;
startTime = LocalDateTime.now();
}
/**
* Add a boat to the race
* @param yacht The boat to add
*/
public void addBoat(ServerYacht yacht) {
yachts.add(yacht);
}
/**
* Get a list of boats in the race
* @return A List of boats
@@ -35,6 +30,15 @@ public class Race {
return Collections.unmodifiableList(yachts);
}
/**
* Get a list of tokens in the race
*
* @return A list of tokens
*/
public List<Token> getTokens() {
return Collections.unmodifiableList(tokens);
}
/**
* Set the time until the race starts
* @param seconds The time in seconds until the race starts
@@ -3,7 +3,7 @@ package seng302.model.stream.xml.generator;
/**
* A Race regatta that can be parsed into XML
*/
public class Regatta {
public class RegattaXMLTemplate {
private final Double DEFAULT_ALTITUDE = 0d;
private final Integer DEFAULT_REGATTA_ID = 0;
@@ -18,7 +18,7 @@ public class Regatta {
private Integer utcOffset;
private Double magneticVariation;
public Regatta(String name, String courseName, Double latitude, Double longitude) {
public RegattaXMLTemplate(String name, String courseName, Double latitude, Double longitude) {
this.name = name;
this.id = DEFAULT_REGATTA_ID;
this.courseName = courseName;
@@ -6,6 +6,7 @@ import java.util.Map;
import seng302.model.Limit;
import seng302.model.mark.CompoundMark;
import seng302.model.mark.Corner;
import seng302.model.token.Token;
/**
* Process a Document object containing race data in XML format and stores the data.
@@ -13,13 +14,16 @@ import seng302.model.mark.Corner;
public class RaceXMLData {
private List<Integer> participants;
private List<Token> tokens;
private Map<Integer, CompoundMark> compoundMarks;
private List<Corner> markSequence;
private List<Limit> courseLimit;
public RaceXMLData(List<Integer> participants, List<CompoundMark> compoundMarks,
public RaceXMLData(List<Integer> participants, List<Token> tokens,
List<CompoundMark> compoundMarks,
List<Corner> markSequence, List<Limit> courseLimit) {
this.participants = participants;
this.tokens = tokens;
this.markSequence = markSequence;
this.courseLimit = courseLimit;
this.compoundMarks = new HashMap<>();
@@ -32,6 +36,10 @@ public class RaceXMLData {
return participants;
}
public List<Token> getTokens() {
return tokens;
}
public Map<Integer, CompoundMark> getCompoundMarks() {
return compoundMarks;
}
@@ -0,0 +1,21 @@
package seng302.model.token;
import seng302.model.GeoPoint;
/**
* A class describing a game token
* Created by wmu16 on 28/08/17.
*/
public class Token extends GeoPoint {
private TokenType tokenType;
public Token(TokenType tokenType, double lat, double lng) {
super(lat, lng);
this.tokenType = tokenType;
}
public TokenType getTokenType() {
return tokenType;
}
}
@@ -0,0 +1,31 @@
package seng302.model.token;
/**
* An enum describing the different types of game objects
* Created by wmu16 on 28/08/17.
*/
public enum TokenType {
BOOST(0),
HANDLING(1);
private int value;
TokenType(int value) {
this.value = value;
}
public int getValue() {
return value;
}
public static TokenType getToken(int value) {
switch (value) {
case 0:
return BOOST;
case 1:
return HANDLING;
default:
return BOOST;
}
}
}
@@ -6,6 +6,7 @@ import seng302.model.GeoPoint;
public class GeoUtility {
private static double EARTH_RADIUS = 6378.137;
// private static double EARTH_RADIUS = 6378.13712121212121212121212121212121212121;
private static Double MS_TO_KNOTS = 1.943844492;
/**
@@ -11,6 +11,9 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import seng302.model.stream.xml.generator.RaceXMLTemplate;
import seng302.model.stream.xml.generator.RegattaXMLTemplate;
import seng302.gameServer.messages.XMLMessageSubType;
import java.util.Random;
/**
@@ -24,6 +27,8 @@ public class XMLGenerator {
private Configuration configuration;
private static Regatta regatta = null;
private Race race;
private RegattaXMLTemplate regatta;
private RaceXMLTemplate race;
public static Regatta DEFAULT_REGATTA = new Regatta("Party Parrot Test Server " + new Random().nextInt(100),
"Bermuda",
@@ -55,7 +60,7 @@ public class XMLGenerator {
* Note: This must be set before a regatta message can be generated
* @param regatta The race regatta
*/
public void setRegatta(Regatta regatta){
public void setRegattaTemplate(RegattaXMLTemplate regatta) {
this.regatta = regatta;
}
@@ -64,7 +69,7 @@ public class XMLGenerator {
* Note: This must be set before a boat or race message can be generated
* @param race The race
*/
public void setRace(Race race){
public void setRaceTemplate(RaceXMLTemplate race) {
this.race = race;
}
@@ -16,6 +16,8 @@ import seng302.model.mark.Corner;
import seng302.model.mark.Mark;
import seng302.model.stream.xml.parser.RaceXMLData;
import seng302.model.stream.xml.parser.RegattaXMLData;
import seng302.model.token.Token;
import seng302.model.token.TokenType;
/**
* Utilities for parsing XML documents
@@ -182,12 +184,32 @@ public class XMLParser {
Element docEle = doc.getDocumentElement();
return new RaceXMLData(
extractParticpantIDs(docEle),
extractTokens(docEle),
extractCompoundMarks(docEle),
extractMarkOrder(docEle),
extractCourseLimit(docEle)
);
}
/**
* Extracts token data
*/
private static List<Token> extractTokens(Element docEle) {
List<Token> tokens = new ArrayList<>();
NodeList tokenList = docEle.getElementsByTagName("Tokens").item(0).getChildNodes();
for (int i = 0; i < tokenList.getLength(); i++) {
Node tokenNode = tokenList.item(i);
if (tokenNode.getNodeName().equals("Token")) {
String tokenType = getNodeAttributeString(tokenNode, "TokenType");
Double lat = getNodeAttributeDouble(tokenNode, "TargetLat");
Double lng = getNodeAttributeDouble(tokenNode, "TargetLng");
tokens.add(new Token(TokenType.valueOf(tokenType), lat, lng));
}
}
return tokens;
}
/**
* Extracts course limit data
*/
@@ -33,8 +33,6 @@ import seng302.model.stream.packets.StreamPacket;
*/
public class ClientToServerThread implements Runnable {
/**
* Functional interface for receiving packets from client socket.
*/
@@ -95,7 +93,7 @@ public class ClientToServerThread implements Runnable {
sendRegistrationRequest();
thread = new Thread(this);
thread = new Thread(this, "ClientToServer");
thread.start();
}
@@ -146,13 +146,15 @@ public class GameClient {
return new ServerDescription(serverName, regattaData.getCourseName(), GameState.getNumberOfPlayers(), GameState.getCapacity(), ipAddress, 4942);
}
private void loadStartScreen() {
private void tearDownConnection() {
socketThread.setSocketToClose();
if (server != null) {
server.terminate();
server = null;
}
}
private void loadStartScreen() {
FXMLLoader fxmlLoader = new FXMLLoader(
getClass().getResource("/views/StartScreenView.fxml"));
try {
@@ -250,11 +252,14 @@ public class GameClient {
break;
case RACE_XML:
courseData = XMLParser.parseRace(
RaceXMLData raceXMLData = XMLParser.parseRace(
StreamParser.extractXmlMessage(packet)
);
if (courseData == null) { //workaround for object comparisons. Avoid recreating
courseData = raceXMLData;
}
if (raceView != null) {
raceView.updateRaceData(courseData);
raceView.updateRaceData(raceXMLData);
}
break;
+72 -32
View File
@@ -13,8 +13,7 @@ import javafx.animation.Timeline;
import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.geometry.Point2D;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.*;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
@@ -26,22 +25,23 @@ import javafx.scene.shape.Circle;
import javafx.scene.shape.Polygon;
import javafx.scene.text.Text;
import javafx.util.Duration;
import seng302.model.ClientYacht;
import seng302.gameServer.messages.RoundingSide;
import seng302.model.ClientYacht;
import seng302.model.Colors;
import seng302.model.GeoPoint;
import seng302.model.Limit;
import seng302.model.mark.CompoundMark;
import seng302.model.mark.Corner;
import seng302.model.mark.Mark;
import seng302.model.token.Token;
import seng302.utilities.GeoUtility;
import seng302.visualiser.fxObjects.AnnotationBox;
import seng302.visualiser.fxObjects.BoatObject;
import seng302.visualiser.fxObjects.CourseBoundary;
import seng302.visualiser.fxObjects.Gate;
import seng302.visualiser.fxObjects.MarkArrowFactory;
import seng302.visualiser.fxObjects.Marker;
import seng302.visualiser.fxObjects.assets_2D.AnnotationBox;
import seng302.visualiser.fxObjects.assets_2D.BoatObject;
import seng302.visualiser.fxObjects.assets_2D.CourseBoundary;
import seng302.visualiser.fxObjects.assets_2D.Gate;
import seng302.visualiser.fxObjects.assets_2D.MarkArrowFactory;
import seng302.visualiser.fxObjects.assets_2D.Marker;
import seng302.visualiser.fxObjects.assets_3D.ModelFactory;
import seng302.visualiser.fxObjects.assets_3D.ModelType;
import seng302.visualiser.map.Boundary;
import seng302.visualiser.map.CanvasMap;
@@ -82,9 +82,12 @@ public class GameView extends Pane {
private Group boatObjectGroup = new Group();
private Group trails = new Group();
private Group markers = new Group();
private Group tokens = new Group();
private List<CompoundMark> course = new ArrayList<>();
private List<Node> mapTokens;
private ImageView mapImage = new ImageView();
private Camera camera;
//FRAME RATE
@@ -142,11 +145,26 @@ public class GameView extends Pane {
public GameView () {
gameObjects = this.getChildren();
// AmbientLight ambientLight = new AmbientLight(new Color(1,1,1,0.4));
// ambientLight.setOpacity(0.5);
// gameObjects.add(ambientLight);
// create image view for map, bind panel size to image
gameObjects.add(mapImage);
gameObjects.add(raceBorder);
gameObjects.add(markers);
camera = new ParallelCamera();
camera.setTranslateZ(-500);
camera.setFarClip(Double.MAX_VALUE);
camera.setNearClip(0.1);
PointLight pl = new PointLight();
pl.setLightOn(true);
pl.layoutYProperty().bind(camera.layoutYProperty());
pl.layoutXProperty().bind(camera.layoutXProperty());
// gameObjects.add(camera);
this.sceneProperty().addListener((obs, oldValue, scene) -> {
if (scene != null) {
scene.setCamera(camera);
}
});
initializeTimer();
gameObjects.addAll(mapImage, raceBorder, markers, tokens, pl);
}
private void initializeTimer() {
@@ -185,7 +203,7 @@ public class GameView extends Pane {
lastTime = now;
}
}
boatObjects.forEach((boat, boatObject) -> boatObject.updateLocation());
// boatObjects.forEach((boat, boatObject) -> boatObject.updateLocation());
}
};
}
@@ -311,18 +329,16 @@ public class GameView extends Pane {
for (int i=1; i < sequence.size()-1; i++) { //General case.
double averageLat = 0;
double averageLng = 0;
int numMarks = 0;
int numMarks = course.get(i-1).getMarks().size();
for (Mark mark : course.get(i-1).getMarks()) {
numMarks += 1;
averageLat += mark.getLat();
averageLng += mark.getLng();
}
GeoPoint lastMarkAv = new GeoPoint(averageLat / numMarks, averageLng / numMarks);
numMarks = 0;
numMarks = course.get(i+1).getMarks().size();
averageLat = 0;
averageLng = 0;
for (Mark mark : course.get(i+1).getMarks()) {
numMarks += 1;
averageLat += mark.getLat();
averageLng += mark.getLng();
}
@@ -440,6 +456,40 @@ public class GameView extends Pane {
raceBorder.getPoints().setAll(boundaryPoints);
}
/**
* Rescales the race to the size of the window.
*
* @param limitingCoordinates the set of geo points that contains the extremities of the race.
*/
private void rescaleRace(List<GeoPoint> limitingCoordinates) {
//Check is called once to avoid unnecessarily change the course limits once the race is running
findMinMaxPoint(limitingCoordinates);
double minLonToMaxLon = scaleRaceExtremities();
calculateReferencePointLocation(minLonToMaxLon);
// drawGoogleMap();
}
/**
* Replaces all tokens in the course with those passed in
*
* @param newTokens the tokens to be put on the course.
*/
public void updateTokens(List<Token> newTokens) {
mapTokens = new ArrayList<>();
for (Token token : newTokens) {
Point2D location = findScaledXY(token.getLat(), token.getLng());
Node tokenObject = ModelFactory.importModel(ModelType.VELOCITY_PICKUP).getAssets();
tokenObject.setLayoutX(location.getX());
tokenObject.setLayoutY(location.getY());
mapTokens.add(tokenObject);
}
Platform.runLater(() -> {
tokens.getChildren().clear();
tokens.getChildren().addAll(mapTokens);
});
}
// TODO: 16/08/17 initialize zooming internal to GameView only
/**
* Enables zoom. Has to be called after this is added to a scene.
@@ -455,18 +505,6 @@ public class GameView extends Pane {
});
}
}
/**
* Rescales the race to the size of the window.
*
* @param limitingCoordinates the set of geo points that contains the extremities of the race.
*/
private void rescaleRace(List<GeoPoint> limitingCoordinates) {
//Check is called once to avoid unnecessarily change the course limits once the race is running
findMinMaxPoint(limitingCoordinates);
double minLonToMaxLon = scaleRaceExtremities();
calculateReferencePointLocation(minLonToMaxLon);
// drawGoogleMap();
}
private void setSelectedBoat(BoatObject bo, Boolean isSelected) {
if (this.selectedBoat == bo && !isSelected) {
@@ -492,7 +530,7 @@ public class GameView extends Pane {
BoatObject newBoat;
final List<Group> wakes = new ArrayList<>();
for (ClientYacht clientYacht : yachts) {
Paint colour = clientYacht.getColour();
Color colour = clientYacht.getColour();
newBoat = new BoatObject();
newBoat.addSelectedBoatListener(this::setSelectedBoat);
newBoat.setFill(colour);
@@ -502,7 +540,7 @@ public class GameView extends Pane {
wakes.add(newBoat.getWake());
boatObjectGroup.getChildren().add(newBoat);
trails.getChildren().add(newBoat.getTrail());
// TODO: 1/08/17 Make this less vile to look at.
clientYacht.addLocationListener((boat, lat, lon, heading, sailIn, velocity) -> {
BoatObject bo = boatObjects.get(boat);
Point2D p2d = findScaledXY(lat, lon);
@@ -789,8 +827,10 @@ public class GameView extends Pane {
private void updateMarkArrows (ClientYacht yacht, CompoundMark compoundMark, int legNumber) {
//Only show arrows for this and next leg.
// System.out.println(markerObjects);
if (compoundMark != null) {
for (Mark mark : compoundMark.getMarks()) {
// System.out.println("markerObjects.get(mark) = " + markerObjects.get(mark));
markerObjects.get(mark).showNextExitArrow();
}
}
@@ -0,0 +1,642 @@
package seng302.visualiser;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javafx.animation.AnimationTimer;
import javafx.application.Platform;
import javafx.geometry.Point2D;
import javafx.geometry.Point3D;
import javafx.scene.*;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyEvent;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.Sphere;
import javafx.scene.text.Text;
import javafx.scene.transform.Rotate;
import javafx.scene.transform.Scale;
import javafx.scene.transform.Translate;
import seng302.gameServer.messages.RoundingSide;
import seng302.model.ClientYacht;
import seng302.model.GeoPoint;
import seng302.model.Limit;
import seng302.model.mark.CompoundMark;
import seng302.model.mark.Corner;
import seng302.model.mark.Mark;
import seng302.model.token.Token;
import seng302.utilities.GeoUtility;
import seng302.visualiser.fxObjects.assets_2D.*;
import seng302.visualiser.fxObjects.assets_3D.ModelFactory;
import seng302.visualiser.fxObjects.assets_3D.ModelType;
/**
* Collection of animated3D assets that displays a race.
*/
public class GameView3D {
private final double FOV = 60;
private final double DEFAULT_CAMERA_DEPTH = 100;
private Group root3D;
private SubScene view;
// ParallelCamera camera;
private PerspectiveCamera camera;
private Group gameObjects;
private double bufferSize = 0;
private double canvasWidth = 200;
private double canvasHeight = 200;
private boolean horizontalInversion = false;
private double distanceScaleFactor;
private ScaleDirection scaleDirection;
private GeoPoint minLatPoint, minLonPoint, maxLatPoint, maxLonPoint;
private double referencePointX, referencePointY;
private double metersPerPixelX, metersPerPixelY;
final double SCALE_DELTA = 1.1;
private Text fpsDisplay = new Text();
private Group raceBorder = new Group();
/* Note that if either of these is null then values for it have not been added and the other
should be used as the limits of the map. */
private List<Limit> borderPoints;
private Map<Mark, Group> markerObjects;
private Map<ClientYacht, BoatObject> boatObjects = new HashMap<>();
private Map<ClientYacht, AnnotationBox> annotations = new HashMap<>();
private BoatObject selectedBoat = null;
private Group annotationsGroup = new Group();
private Group wakesGroup = new Group();
private Group boatObjectGroup = new Group();
private Group trails = new Group();
private Group markers = new Group();
private Group tokens = new Group();
private List<CompoundMark> course = new ArrayList<>();
private List<Node> mapTokens;
private ImageView mapImage = new ImageView();
//FRAME RATE
private AnimationTimer timer;
private int NUM_SAMPLES = 10;
private final long[] frameTimes = new long[NUM_SAMPLES];
private Double frameRate = 60.0;
private int frameTimeIndex = 0;
private boolean arrayFilled = false;
private ClientYacht playerYacht;
private double windDir = 0.0;
double scaleFactor = 1;
private enum ScaleDirection {
HORIZONTAL,
VERTICAL
}
public GameView3D () {
camera = new PerspectiveCamera(true);
// camera = new ParallelCamera();
// gameObjects.getTransforms().add(new Scale(4,4,4));
// camera.setLayoutX(camera.getLayoutX()-400);
// camera.setLayoutY(camera.getLayoutY()-400);
camera.getTransforms().addAll(
new Translate(0,0, -DEFAULT_CAMERA_DEPTH)
);
camera.setFarClip(Double.MAX_VALUE);
camera.setNearClip(0.1);
camera.setFieldOfView(FOV);
gameObjects = new Group();
root3D = new Group(camera, gameObjects);
view = new SubScene(
root3D, 1000, 1000, true, SceneAntialiasing.BALANCED
);
view.setCamera(camera);
view.setFill(Color.SKYBLUE);
camera.getTransforms().add(new Rotate(30, new Point3D(1,0,0)));
// gameObjects.getChildren().addAll(raceBorder, markers, tokens);
Sphere red = new Sphere(1);
red.setMaterial(new PhongMaterial(Color.RED));
red.setLayoutX(0);
red.setLayoutY(0);
Sphere blue = new Sphere(1);
blue.setMaterial(new PhongMaterial(Color.BLUE));
blue.setLayoutX(1);
blue.setLayoutY(0);
Sphere green = new Sphere(1);
green.setMaterial(new PhongMaterial(Color.GREEN));
green.setLayoutX(-.5);
green.setLayoutY(0);
Sphere white = new Sphere(1);
white.setMaterial(new PhongMaterial(Color.WHITE));
white.setLayoutX(-.25);
white.setLayoutY(0);
Sphere black = new Sphere(1);
black.setMaterial(new PhongMaterial(Color.BLACK));
black.setLayoutX(-.125);
black.setLayoutY(0);
gameObjects.getChildren().addAll(
ModelFactory.importModel(ModelType.OCEAN).getAssets(),
raceBorder, markers, tokens,
white, blue, green, black, red
);
// Sphere s = new Sphere(1);
// s.setMaterial(new PhongMaterial(Color.RED));
// Sphere left = new Sphere(1);
// left.setMaterial(new PhongMaterial(Color.LEMONCHIFFON));
// left.getTransforms().add(new Translate(-Math.tan(Math.toRadians(FOV / 2)) * DEFAULT_CAMERA_DEPTH, 0, 0));
// Sphere right = new Sphere(1);
// right.setMaterial(new PhongMaterial(Color.ROSYBROWN));
// right.getTransforms().add(new Translate(Math.tan(Math.toRadians(FOV / 2)) * DEFAULT_CAMERA_DEPTH, 0, 0));
// Sphere top = new Sphere(1);
// top.setMaterial(new PhongMaterial(Color.TEAL));
// top.getTransforms().add(new Translate(0,-Math.tan(Math.toRadians(FOV / 2)) * DEFAULT_CAMERA_DEPTH, 0));
// Sphere bottom = new Sphere(1);
// bottom.setMaterial(new PhongMaterial(Color.BLANCHEDALMOND));
// bottom.getTransforms().add(new Translate(0, Math.tan(Math.toRadians(FOV / 2)) * DEFAULT_CAMERA_DEPTH, 0));
//
// Node boat = ModelFactory.boatGameView(BoatMeshType.DINGHY, Color.BLUE).getAssets();
// Node boat2 = ModelFactory.boatGameView(BoatMeshType.DINGHY, Color.BROWN).getAssets();
// boat2.getTransforms().add(new Translate(0,20, 0));
// Node boat3 = ModelFactory.boatGameView(BoatMeshType.DINGHY, Color.RED).getAssets();
// boat3.getTransforms().add(new Translate(0,-20, 0));
//
// Node sMarker = ModelFactory.importModel(ModelType.START_MARKER).getAssets();
// sMarker.getTransforms().add(0, new Translate(30, 30, 0));
//
// Node fMarker = ModelFactory.importModel(ModelType.FINISH_MARKER).getAssets();
// fMarker.getTransforms().add(0, new Translate(30, -30, 0));
//
// Node marker = ModelFactory.importModel(ModelType.PLAIN_MARKER).getAssets();
// marker.getTransforms().add(0, new Translate(30, 0, 0));
//
// Node coin = ModelFactory.importModel(ModelType.VELOCITY_PICKUP).getAssets();
// coin.setTranslateX(coin.getTranslateX() - 30);
//
// gameObjects.getChildren().addAll(
// ModelFactory.importModel(ModelType.OCEAN).getAssets(),
// s, left, right, top, bottom,
// boat, boat2, boat3,
// sMarker, fMarker, marker,
// coin
// );
view.sceneProperty().addListener((obs, old, scene) -> {
if (scene != null) {
scene.addEventHandler(KeyEvent.KEY_PRESSED, this::cameraMovement);
}
});
}
public void updateCourse(List<CompoundMark> newCourse, List<Corner> sequence) {
markerObjects = new HashMap<>();
for (Corner corner : sequence) { //Makes course out of all compound marks.
for (CompoundMark compoundMark : newCourse) {
if (corner.getCompoundMarkID() == compoundMark.getId()) {
course.add(compoundMark);
}
}
}
// TODO: 16/08/17 Updating mark roundings here. It should not happen here. Nor should it be done this way.
for (Corner corner : sequence){
CompoundMark compoundMark = course.get(corner.getSeqID() - 1);
compoundMark.setRoundingSide(
RoundingSide.getRoundingSide(corner.getRounding())
);
}
final List<Group> gates = new ArrayList<>();
//Creates new markers
for (CompoundMark cMark : newCourse) {
for (Mark mark : cMark.getMarks()) {
if (cMark.getId() == sequence.get(0).getCompoundMarkID()) {
makeAndBindMarker(mark, ModelType.START_MARKER);
} else if (cMark.getId() == sequence.get(sequence.size() - 1).getCompoundMarkID()) {
makeAndBindMarker(mark, ModelType.FINISH_MARKER);
} else {
makeAndBindMarker(mark, ModelType.PLAIN_MARKER);
}
}
//Create gate line
if (cMark.isGate()) {
ModelType gateType;
if (cMark.getId() == sequence.get(0).getCompoundMarkID()) {
gateType = ModelType.START_LINE;
} else if (cMark.getId() == sequence.get(sequence.size() - 1).getCompoundMarkID()) {
gateType = ModelType.FINISH_LINE;
} else {
gateType = ModelType.GATE_LINE;
}
gates.add(makeGate(
cMark.getSubMark(1), cMark.getSubMark(2), gateType
));
}
}
//Scale race to markers if there is no border.
if (borderPoints == null) {
rescaleRace(new ArrayList<>(markerObjects.keySet()));
}
//Move the Markers to initial position.
markerObjects.forEach(((mark, marker) -> {
Point2D p2d = findScaledXY(mark.getLat(), mark.getLng());
System.out.println(mark.toString() + " " + p2d.toString());
marker.setLayoutX(p2d.getX());
marker.setLayoutY(p2d.getY());
}));
Platform.runLater(() -> {
markers.getChildren().clear();
markers.getChildren().addAll(gates);
markers.getChildren().addAll(markerObjects.values());
});
}
/**
* Creates a new Marker and binds it's position to the given Mark.
*
* @param observableMark The mark to bind the marker to.
* @param markerType the type of marker as a ModelType. Should be PLAIN_MARKER, START_MARKER or END_MARKER
*/
private void makeAndBindMarker(Mark observableMark, ModelType markerType) {
Group marker = ModelFactory.importModel(markerType).getAssets();
markerObjects.put(observableMark, marker);
observableMark.addPositionListener((mark, lat, lon) -> {
Point2D p2d = findScaledXY(lat, lon);
markerObjects.get(mark).setLayoutX(p2d.getX());
markerObjects.get(mark).setLayoutY(p2d.getY());
});
}
/**
* Creates a new gate connecting the given marks.
*
* @param m1 The first Mark of the gate.
* @param m2 The second Mark of the gate.
* @param gateType The type of model for the gate.
* @return the new gate.
*/
private Group makeGate(Mark m1, Mark m2, ModelType gateType) {
Point2D m1Location = findScaledXY(m1);
Point2D m2Location = findScaledXY(m2);
Group barrier = ModelFactory.importModel(gateType).getAssets();
barrier.getTransforms().addAll(
new Rotate(
Math.toDegrees(
Math.atan2(m2Location.getY() - m1Location.getY(), m2Location.getX() - m1Location.getX())
) + 90,
new Point3D(0,0,1)
),
new Scale(1, m1Location.distance(m2Location) / 10, 1)
);
Point2D midPoint = m2Location.midpoint(m1Location);
barrier.setLayoutX(midPoint.getX());
barrier.setLayoutY(midPoint.getY());
return barrier;
}
/**
* Sets the class variables minLatPoint, maxLatPoint, minLonPoint, maxLonPoint to the point with
* the leftmost point, rightmost point, southern most point and northern most point
* respectively.
*/
private void findMinMaxPoint(List<GeoPoint> points) {
List<GeoPoint> sortedPoints = new ArrayList<>(points);
sortedPoints.sort(Comparator.comparingDouble(GeoPoint::getLat));
minLatPoint = new GeoPoint(sortedPoints.get(0).getLat(), sortedPoints.get(0).getLng());
GeoPoint maxLat = sortedPoints.get(sortedPoints.size() - 1);
maxLatPoint = new GeoPoint(maxLat.getLat(), maxLat.getLng());
sortedPoints.sort(Comparator.comparingDouble(GeoPoint::getLng));
minLonPoint = new GeoPoint(sortedPoints.get(0).getLat(), sortedPoints.get(0).getLng());
GeoPoint maxLon = sortedPoints.get(sortedPoints.size() - 1);
maxLonPoint = new GeoPoint(maxLon.getLat(), maxLon.getLng());
if (maxLonPoint.getLng() - minLonPoint.getLng() > 180) {
horizontalInversion = true;
}
}
/**
* Calculates the location of a reference point, this is always the point with minimum latitude,
* in relation to the canvas.
*
* @param minLonToMaxLon The horizontal distance between the point of minimum longitude to
* maximum longitude.
*/
private void calculateReferencePointLocation(double minLonToMaxLon) {
GeoPoint referencePoint = minLatPoint;
double referenceAngle;
if (scaleDirection == ScaleDirection.HORIZONTAL) {
referenceAngle = Math.abs(
GeoUtility.getBearingRad(referencePoint, minLonPoint)
);
referencePointX =
-100 + distanceScaleFactor * Math.sin(referenceAngle) * GeoUtility
.getDistance(referencePoint, minLonPoint);
referenceAngle = Math.abs(GeoUtility.getDistance(referencePoint, maxLatPoint));
referencePointY = -100 + canvasHeight - (bufferSize + bufferSize);
referencePointY -= distanceScaleFactor * Math.cos(referenceAngle) * GeoUtility
.getDistance(referencePoint, maxLatPoint);
referencePointY = referencePointY / 2;
referencePointY += bufferSize;
referencePointY += distanceScaleFactor * Math.cos(referenceAngle) * GeoUtility
.getDistance(referencePoint, maxLatPoint);
} else {
referencePointY = -100 + canvasHeight - bufferSize;
referenceAngle = Math.abs(
Math.toRadians(
GeoUtility.getDistance(referencePoint, minLonPoint)
)
);
referencePointX = -100 + bufferSize;
referencePointX += distanceScaleFactor * Math.sin(referenceAngle) * GeoUtility
.getDistance(referencePoint, minLonPoint);
referencePointX +=
((canvasWidth - (bufferSize + bufferSize)) - (minLonToMaxLon * distanceScaleFactor))
/ 2;
}
if (horizontalInversion) {
referencePointX = -100 + canvasWidth - bufferSize - (referencePointX - bufferSize);
}
}
/**
* Finds the scale factor necessary to fit all race markers within the onscreen map and assigns
* it to distanceScaleFactor Returns the max horizontal distance of the map.
*/
private double scaleRaceExtremities() {
double vertAngle = Math.abs(
GeoUtility.getBearingRad(minLatPoint, maxLatPoint)
);
double vertDistance =
Math.cos(vertAngle) * GeoUtility.getDistance(minLatPoint, maxLatPoint);
double horiAngle = Math.abs(
GeoUtility.getBearingRad(minLonPoint, maxLonPoint)
);
if (horiAngle <= (Math.PI / 2)) {
horiAngle = (Math.PI / 2) - horiAngle;
} else {
horiAngle = horiAngle - (Math.PI / 2);
}
double horiDistance =
Math.cos(horiAngle) * GeoUtility.getDistance(minLonPoint, maxLonPoint);
double vertScale = (canvasHeight - (bufferSize + bufferSize)) / vertDistance;
if ((horiDistance * vertScale) > (canvasWidth - (bufferSize + bufferSize))) {
distanceScaleFactor = (canvasWidth - (bufferSize + bufferSize)) / horiDistance;
scaleDirection = ScaleDirection.HORIZONTAL;
} else {
distanceScaleFactor = vertScale;
scaleDirection = ScaleDirection.VERTICAL;
}
return horiDistance;
}
private Point2D findScaledXY(GeoPoint unscaled) {
return findScaledXY(unscaled.getLat(), unscaled.getLng());
}
private Point2D findScaledXY(double unscaledLat, double unscaledLon) {
double distanceFromReference;
double angleFromReference;
double xAxisLocation = referencePointX;
double yAxisLocation = referencePointY;
angleFromReference = GeoUtility.getBearingRad(
minLatPoint, new GeoPoint(unscaledLat, unscaledLon)
);
distanceFromReference = GeoUtility.getDistance(
minLatPoint, new GeoPoint(unscaledLat, unscaledLon)
);
if (angleFromReference >= 0 && angleFromReference <= Math.PI / 2) {
xAxisLocation += distanceScaleFactor * Math.sin(angleFromReference) * distanceFromReference;
yAxisLocation -= distanceScaleFactor * Math.cos(angleFromReference) * distanceFromReference;
} else if (angleFromReference >= 0) {
angleFromReference = angleFromReference - Math.PI / 2;
xAxisLocation += distanceScaleFactor * Math.cos(angleFromReference) * distanceFromReference;
yAxisLocation += distanceScaleFactor * Math.sin(angleFromReference) * distanceFromReference;
} else if (angleFromReference < 0 && angleFromReference >= -Math.PI / 2) {
angleFromReference = Math.abs(angleFromReference);
xAxisLocation -= distanceScaleFactor * Math.sin(angleFromReference) * distanceFromReference;
yAxisLocation -= distanceScaleFactor * Math.cos(angleFromReference) * distanceFromReference;
} else {
angleFromReference = Math.abs(angleFromReference) - Math.PI / 2;
xAxisLocation -= distanceScaleFactor * Math.cos(angleFromReference) * distanceFromReference;
yAxisLocation += distanceScaleFactor * Math.sin(angleFromReference) * distanceFromReference;
}
if (horizontalInversion) {
xAxisLocation = canvasWidth - bufferSize - (xAxisLocation - bufferSize);
}
return new Point2D(xAxisLocation, yAxisLocation);
}
public void cameraMovement(KeyEvent event) {
switch (event.getCode()) {
case NUMPAD8:
camera.getTransforms().addAll(new Rotate(0.5, new Point3D(1,0,0)));
break;
case NUMPAD2:
camera.getTransforms().addAll(new Rotate(-0.5, new Point3D(1,0,0)));
break;
case NUMPAD4:
camera.getTransforms().addAll(new Rotate(-0.5, new Point3D(0,1,0)));
break;
case NUMPAD6:
camera.getTransforms().addAll(new Rotate(0.5, new Point3D(0,1,0)));
break;
case X:
camera.getTransforms().addAll(new Translate(0, 0, 1.5));
break;
case Z:
camera.getTransforms().addAll(new Translate(0, 0, -1.5));
break;
case W:
camera.getTransforms().addAll(new Translate(0, -1, 0));
break;
case S:
camera.getTransforms().addAll(new Translate(0, 1, 0));
break;
case A:
camera.getTransforms().addAll(new Translate(-1, 0, 0));
break;
case D:
camera.getTransforms().addAll(new Translate(1, 0, 0));
break;
}
}
/**
* Rescales the race to the size of the window.
*
* @param limitingCoordinates the set of geo points that contains the extremities of the race.
*/
private void rescaleRace(List<GeoPoint> limitingCoordinates) {
//Check is called once to avoid unnecessarily change the course limits once the race is running
findMinMaxPoint(limitingCoordinates);
double minLonToMaxLon = scaleRaceExtremities();
calculateReferencePointLocation(minLonToMaxLon);
// drawGoogleMap();
}
/**
* Draws all the boats.
* @param yachts The yachts to set in the race
*/
public void setBoats(List<ClientYacht> yachts) {
BoatObject newBoat;
final List<Group> wakes = new ArrayList<>();
for (ClientYacht clientYacht : yachts) {
Color colour = clientYacht.getColour();
newBoat = new BoatObject();
// newBoat.addSelectedBoatListener(this::setSelectedBoat);
newBoat.setFill(colour);
boatObjects.put(clientYacht, newBoat);
// createAndBindAnnotationBox(clientYacht, colour);
wakesGroup.getChildren().add(newBoat.getWake());
wakes.add(newBoat.getWake());
boatObjectGroup.getChildren().add(newBoat);
// trails.getChildren().add(newBoat.getTrail());
clientYacht.addLocationListener((boat, lat, lon, heading, sailIn, velocity) -> {
BoatObject bo = boatObjects.get(boat);
Point2D p2d = findScaledXY(lat, lon);
bo.moveTo(p2d.getX(), p2d.getY(), heading, velocity, sailIn, windDir);
// annotations.get(boat).setLocation(p2d.getX(), p2d.getY());
bo.setTrajectory(
heading,
velocity,
metersPerPixelX,
metersPerPixelY);
});
}
// annotationsGroup.getChildren().addAll(annotations.values());
Platform.runLater(() -> {
// gameObjects.addAll(trails);
gameObjects.getChildren().addAll(wakes);
gameObjects.getChildren().addAll(boatObjectGroup);
// gameObjects.addAll(annotationsGroup);
// gameObjects.addAll(boatObjectGroup);
});
}
public Node getAssets () {
return view;
}
/**
* Adds a border to the GameView and rescales to the size of the border, does not rescale if a
* border already exists. Assumes the border is larger than the course.
*
* @param border the race border to be drawn.
*/
public void updateBorder(List<Limit> border) {
if (borderPoints == null) {
borderPoints = border;
rescaleRace(new ArrayList<>(borderPoints));
}
List<Node> boundaryAssets = new ArrayList<>();
Point2D lastLocation = findScaledXY(border.get(0).getLat(), border.get(0).getLng());
Group pylon = ModelFactory.importModel(ModelType.BORDER_PYLON).getAssets();
pylon.setLayoutX(lastLocation.getX());
pylon.setLayoutY(lastLocation.getY());
boundaryAssets.add(pylon);
for (int i=1; i<border.size(); i++) {
Point2D location = findScaledXY(border.get(i).getLat(), border.get(i).getLng());
pylon = ModelFactory.importModel(ModelType.BORDER_PYLON).getAssets();
pylon.setLayoutX(location.getX());
pylon.setLayoutY(location.getY());
Group barrier = ModelFactory.importModel(ModelType.BORDER_BARRIER).getAssets();
barrier.getTransforms().addAll(
new Rotate(
Math.toDegrees(
Math.atan2(location.getY() - lastLocation.getY(), location.getX() - lastLocation.getX())
),
new Point3D(0,0,1)
),
new Scale((lastLocation.distance(location) / 15)-0.2, 1, 1)
);
Point2D midPoint = location.midpoint(lastLocation);
barrier.setLayoutX(midPoint.getX());
barrier.setLayoutY(midPoint.getY());
lastLocation = location;
boundaryAssets.add(barrier);
boundaryAssets.add(pylon);
}
Point2D firstLocation = findScaledXY(border.get(0).getLat(), border.get(0).getLng());
Group barrier = ModelFactory.importModel(ModelType.BORDER_BARRIER).getAssets();
barrier.getTransforms().addAll(
new Rotate(
Math.toDegrees(
Math.atan2(lastLocation.getY() - firstLocation.getY(), lastLocation.getX() - firstLocation.getX())
),
new Point3D(0,0,1)
),
new Scale((firstLocation.distance(lastLocation) / 15)-0.2, 1, 1)
);
Point2D midPoint = lastLocation.midpoint(firstLocation);
barrier.setLayoutX(midPoint.getX());
barrier.setLayoutY(midPoint.getY());
boundaryAssets.add(barrier);
Platform.runLater(() -> raceBorder.getChildren().setAll(boundaryAssets));
}
/**
* Replaces all tokens in the course with those passed in
*
* @param newTokens the tokens to be put on the course.
*/
public void updateTokens(List<Token> newTokens) {
mapTokens = new ArrayList<>();
for (Token token : newTokens) {
Point2D location = findScaledXY(token.getLat(), token.getLng());
Node tokenObject = ModelFactory.importModel(ModelType.VELOCITY_PICKUP).getAssets();
tokenObject.setLayoutX(location.getX());
tokenObject.setLayoutY(location.getY());
mapTokens.add(tokenObject);
}
Platform.runLater(() -> {
tokens.getChildren().setAll(mapTokens);
});
}
}
@@ -32,6 +32,7 @@ import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Line;
import javafx.scene.shape.Polyline;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
@@ -42,12 +43,12 @@ import seng302.model.RaceState;
import seng302.model.mark.CompoundMark;
import seng302.model.mark.Mark;
import seng302.model.stream.xml.parser.RaceXMLData;
import seng302.visualiser.GameView;
import seng302.visualiser.controllers.annotations.Annotation;
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.fxObjects.BoatObject;
import seng302.visualiser.fxObjects.assets_2D.BoatObject;
import seng302.visualiser.fxObjects.assets_2D.WindArrow;
/**
* Controller class that manages the display of a race
@@ -69,7 +70,9 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
@FXML
private AnchorPane rvAnchorPane;
@FXML
private Text windArrowText, windDirectionText;
private Text windDirectionText;
@FXML
private AnchorPane windArrowHolder;
@FXML
private Slider annotationSlider;
@FXML
@@ -85,13 +88,14 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
private Map<Integer, ClientYacht> participants;
private Map<Integer, CompoundMark> markers;
private RaceXMLData courseData;
private GameView gameView;
private GameView3D gameView;
private RaceState raceState;
private Timeline timerTimeline;
private Timer timer = new Timer();
private List<Series<String, Double>> sparkLineData = new ArrayList<>();
private ImportantAnnotationsState importantAnnotations;
private Polyline windArrow = new WindArrow(Color.LIGHTGRAY);
public void initialize() {
// Load a default important annotation state
@@ -110,6 +114,11 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
//selectAnnotationBtn.setOnAction(event -> loadSelectAnnotationView());
rvAnchorPane.prefWidthProperty().bind(ViewManager.getInstance().getDecorator().widthProperty());
rvAnchorPane.prefHeightProperty().bind(ViewManager.getInstance().getDecorator().heightProperty());
selectAnnotationBtn.setOnAction(event -> loadSelectAnnotationView());
windArrowHolder.getChildren().addAll(windArrow);
windArrow.setLayoutX(windArrowHolder.getWidth() / 2);
windArrow.setLayoutY(windArrowHolder.getHeight() / 2);
}
public void loadRace (
@@ -137,29 +146,32 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
});
updateOrder(raceState.getPlayerPositions());
gameView = new GameView();
//gameView.setFrameRateFXText(fpsDisplay);
Platform.runLater(() -> contentAnchorPane.getChildren().add(gameView));
gameView.setBoats(new ArrayList<>(participants.values()));
gameView.updateBorder(raceData.getCourseLimit());
gameView.updateCourse(
new ArrayList<>(raceData.getCompoundMarks().values()), raceData.getMarkSequence()
gameView = new GameView3D();
// gameView.setFrameRateFXText(fpsDisplay);
Platform.runLater(() -> contentAnchorPane.getChildren().add(0, gameView.getAssets()));
gameView.setBoats(new ArrayList<>(participants.values()));
gameView.updateBorder(raceData.getCourseLimit());
gameView.updateTokens(raceData.getTokens());
gameView.updateCourse(
new ArrayList<>(raceData.getCompoundMarks().values()), raceData.getMarkSequence()
);
gameView.enableZoom();
gameView.setBoatAsPlayer(player);
gameView.startRace();
// gameView.enableZoom();
// gameView.setBoatAsPlayer(player);
// gameView.startRace();
raceState.addCollisionListener(gameView::drawCollision);
raceState.windDirectionProperty().addListener((obs, oldDirection, newDirection) -> {
gameView.setWindDir(newDirection.doubleValue());
updateWindDirection(newDirection.doubleValue());
});
raceState.windSpeedProperty().addListener((obs, oldSpeed, newSpeed) -> {
updateWindSpeed(newSpeed.doubleValue());
});
updateWindDirection(raceState.windDirectionProperty().doubleValue());
updateWindSpeed(raceState.getWindSpeed());
gameView.setWindDir(raceState.windDirectionProperty().doubleValue());
// raceState.addCollisionListener(gameView::drawCollision);
// raceState.windDirectionProperty().addListener((obs, oldDirection, newDirection) -> {
// gameView.setWindDir(newDirection.doubleValue());
// Platform.runLater(() -> updateWindDirection(newDirection.doubleValue()));
// });
// raceState.windSpeedProperty().addListener((obs, oldSpeed, newSpeed) ->
// Platform.runLater(() -> updateWindSpeed(newSpeed.doubleValue()))
// );
// Platform.runLater(() -> {
// updateWindDirection(raceState.windDirectionProperty().doubleValue());
// updateWindSpeed(raceState.getWindSpeed());
// });
// gameView.setWindDir(raceState.windDirectionProperty().doubleValue());
}
/**
@@ -576,31 +588,31 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
}
private void setAnnotations(Integer annotationLevel) {
switch (annotationLevel) {
// No Annotations
case 0:
gameView.setAnnotationVisibilities(
false, false, false, false, false, false
);
break;
// Important Annotations
case 1:
gameView.setAnnotationVisibilities(
importantAnnotations.getAnnotationState(Annotation.NAME),
importantAnnotations.getAnnotationState(Annotation.SPEED),
importantAnnotations.getAnnotationState(Annotation.ESTTIMETONEXTMARK),
importantAnnotations.getAnnotationState(Annotation.LEGTIME),
importantAnnotations.getAnnotationState(Annotation.TRACK),
importantAnnotations.getAnnotationState(Annotation.WAKE)
);
break;
// All Annotations
case 2:
gameView.setAnnotationVisibilities(
true, true, true, true, true, true
);
break;
}
// switch (annotationLevel) {
// // No Annotations
// case 0:
// gameView.setAnnotationVisibilities(
// false, false, false, false, false, false
// );
// break;
// // Important Annotations
// case 1:
// gameView.setAnnotationVisibilities(
// importantAnnotations.getAnnotationState(Annotation.NAME),
// importantAnnotations.getAnnotationState(Annotation.SPEED),
// importantAnnotations.getAnnotationState(Annotation.ESTTIMETONEXTMARK),
// importantAnnotations.getAnnotationState(Annotation.LEGTIME),
// importantAnnotations.getAnnotationState(Annotation.TRACK),
// importantAnnotations.getAnnotationState(Annotation.WAKE)
// );
// break;
// // All Annotations
// case 2:
// gameView.setAnnotationVisibilities(
// true, true, true, true, true, true
// );
// break;
// }
}
@@ -624,7 +636,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
}
public void updateRaceData (RaceXMLData raceData) {
this.courseData = raceData;
gameView.updateBorder(raceData.getCourseLimit());
gameView.updateTokens(raceData.getTokens());
}
}
@@ -1,4 +1,4 @@
package seng302.visualiser.fxObjects;
package seng302.visualiser.fxObjects.assets_2D;
import java.util.HashMap;
import java.util.Map;
@@ -1,16 +1,25 @@
package seng302.visualiser.fxObjects;
package seng302.visualiser.fxObjects.assets_2D;
import javafx.application.Platform;
import javafx.geometry.Point2D;
import javafx.geometry.Point3D;
import javafx.scene.AmbientLight;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.PointLight;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.Line;
import javafx.scene.shape.Polygon;
import javafx.scene.shape.Polyline;
import javafx.scene.shape.StrokeLineCap;
import javafx.scene.shape.Shape3D;
import javafx.scene.transform.Rotate;
import javafx.scene.transform.Scale;
import javafx.scene.transform.Translate;
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
import seng302.visualiser.fxObjects.assets_3D.BoatModel;
import seng302.visualiser.fxObjects.assets_3D.ModelFactory;
import seng302.visualiser.fxObjects.assets_3D.ModelType;
import java.util.ArrayList;
import java.util.List;
@@ -25,6 +34,17 @@ import java.util.List;
*/
public class BoatObject extends Group {
private static final double MODEL_SCALE_FACTOR = 400;
private static final double MODEL_X_OFFSET = 0; // standard
private static final double MODEL_Y_OFFSET = 0; // standard
private static final int VIEWPORT_SIZE = 800;
private static final Color lightColor = Color.rgb(244, 255, 250);
private static final Color jewelColor = Color.rgb(0, 190, 222);
@FunctionalInterface
public interface SelectedBoatListener {
@@ -32,8 +52,8 @@ public class BoatObject extends Group {
}
//Constants for drawing
private static final double BOAT_HEIGHT = 15d;
private static final double BOAT_WIDTH = 10d;
private static final float BOAT_HEIGHT = 15f;
private static final float BOAT_WIDTH = 10f;
private double xVelocity;
private double yVelocity;
@@ -41,16 +61,18 @@ public class BoatObject extends Group {
private double sailState;
//Graphical objects
private Polyline trail = new Polyline();
private Polygon boatPoly;
// private Polygon boatPoly;
private BoatModel boatPoly;
private Polygon sail;
private Wake wake;
private Group wake;
private Line leftLayLine;
private Line rightLayline;
private double distanceTravelled, lastRotation;
private Point2D lastPoint;
private Paint colour = Color.BLACK;
private Color colour = Color.BLACK;
private Boolean isSelected = false, destinationSet; //All boats are initialised as selected
private boolean isPlayer = false;
private Rotate rotation = new Rotate(0,0,1);
private List<SelectedBoatListener> selectedBoatListenerListeners = new ArrayList<>();
@@ -81,20 +103,30 @@ public class BoatObject extends Group {
* polygon.
*/
private void initChildren(double... points) {
boatPoly = new Polygon(points);
boatPoly.setFill(colour);
boatPoly.setFill(this.colour);
boatPoly.setOnMouseEntered(event -> {
boatPoly.setFill(Color.FLORALWHITE);
boatPoly.setStroke(Color.RED);
boatPoly = makeBoatPolygon();
boatPoly.getAssets().getTransforms().addAll(
// new Rotate(-40, new Point3D(1,0,0)),
rotation
// new Rotate(-90, new Point3D(0,0,1))
);
boatPoly.getAssets().getTransforms().add(new Scale(5, 5, 5));
// boatPoly.setDrawMode(DrawMode.FILL);
// boatPoly.setFill(colour);
// boatPoly.setFill(this.colour);
// boatPoly.setMaterial(new PhongMaterial(this.colour));
boatPoly.getAssets().setOnMouseEntered(event -> {
// boatPoly.setFill(Color.FLORALWHITE);
// boatPoly.setStroke(Color.RED);
// boatPoly.setMaterial(new PhongMaterial(Color.FLORALWHITE));
});
boatPoly.setOnMouseExited(event -> {
boatPoly.setFill(colour);
boatPoly.setFill(this.colour);
boatPoly.setStroke(Color.BLACK);
boatPoly.getAssets().setOnMouseExited(event -> {
// boatPoly.setMaterial(new PhongMaterial(this.colour));
// boatPoly.setFill(colour);
// boatPoly.setFill(this.colour);
// boatPoly.setStroke(Color.BLACK);
});
boatPoly.setOnMouseClicked(event -> setIsSelected(!isSelected));
boatPoly.setCache(true);
boatPoly.getAssets().setOnMouseClicked(event -> setIsSelected(!isSelected));
boatPoly.getAssets().setCache(true);
// boatPoly.setCacheHint(CacheHint.SPEED);
// annotationBox = new AnnotationBox();
@@ -104,8 +136,8 @@ public class BoatObject extends Group {
rightLayline = new Line();
trail.getStrokeDashArray().setAll(5d, 10d);
trail.setCache(true);
wake = new Wake(0, -BOAT_HEIGHT);
wake.setVisible(true);
wake = ModelFactory.importModel(ModelType.WAKE).getAssets();
sail = new Polygon(0.0,BOAT_HEIGHT / 4,
0.0, BOAT_HEIGHT);
@@ -115,15 +147,65 @@ public class BoatObject extends Group {
sail.setFill(Color.TRANSPARENT);
sail.setCache(true);
super.getChildren().clear();
super.getChildren().addAll(boatPoly, sail);
PointLight pointLight = new PointLight(Color.WHITE);
// pointLight.setLightOn(true);
pointLight.getTransforms().add(new Translate(0, 0, -30));
super.getChildren().add(pointLight);
// pointLight = new PointLight(Color.WHITE);
//// pointLight.setLightOn(true);
// pointLight.getTransforms().add(new Translate(50, 50, -20));
// super.getChildren().add(pointLight);
// pointLight = new PointLight(Color.WHITE);
//// pointLight.setLightOn(true);
// pointLight.getTransforms().add(new Translate(50, -50, -20));
// super.getChildren().add(pointLight);
// pointLight = new PointLight(Color.WHITE);
//// pointLight.setLightOn(true);
// pointLight.getTransforms().add(new Translate(-50, -50, -20));
// super.getChildren().add(pointLight);
AmbientLight light = new AmbientLight(new Color(0.5,0.5,0.5,1));
super.getChildren().add(light);
super.getChildren().addAll(boatPoly.getAssets());
}
public void setFill (Paint value) {
public void setFill (Color value) {
this.colour = value;
boatPoly.setFill(colour);
PhongMaterial pm = new PhongMaterial(this.colour);
for (int i=0;i<2;i++) {
Shape3D s = (Shape3D) boatPoly.getAssets().getChildren().get(i);
s.setMaterial(pm);
}
trail.setStroke(colour);
}
public BoatModel makeBoatPolygon () {
// StlMeshImporter importer = new StlMeshImporter();
// importer.read(getClass().getResource("/meshes/hollow_simple_boat.stl").toString());
// importer.read(getClass().getResource("/cube.stl").toString());
// importer.read(getClass().getResource("/meshes/simple_yacht.stl").toString());
// ObjModelImporter importer = new ObjModelImporter();
// ColModelImporter importer = new ColModelImporter();
// ColModelImporter importer = new ColModelImporter();
// importer.read(getClass().getResource("/meshes/hollow_simple_boat.dae"));
// MeshView mesh = importer.getImport()[0];
// FileInputStream inputStream = null;
// try{
// inputStream = new FileInputStream(getClass().getResource("/meshes/simple_yacht.stl").toString());
// Obj obj = ObjUtils.convertToRenderable(
// ObjReader.read(inputStream));
//
// IntBuffer indices = ObjData.getFaceVertexIndices(obj);
// FloatBuffer vertices = ObjData.getVertices(obj);
// FloatBuffer texCoords = ObjData.getTexCoords(obj);
// MeshView
// FloatBuffer normals = ObjData.getNormals(obj);
return ModelFactory.boatGameView(BoatMeshType.DINGHY, colour);
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
}
/**
* Moves the boat and its children annotations to coordinates specified
* @param x The X coordinate to move the boat to
@@ -134,27 +216,27 @@ public class BoatObject extends Group {
* @param windDir .
*/
public void moveTo(double x, double y, double rotation, double velocity, Boolean sailIn, double windDir) {
Double dx = Math.abs(boatPoly.getLayoutX() - x);
Double dy = Math.abs(boatPoly.getLayoutY() - y);
Double dx = Math.abs(boatPoly.getAssets().getLayoutX() - x);
Double dy = Math.abs(boatPoly.getAssets().getLayoutY() - y);
Platform.runLater(() -> {
rotateTo(rotation, sailIn, windDir);
boatPoly.setLayoutX(x);
boatPoly.setLayoutY(y);
if (sailIn) {
// sail.getPoints().clear();
// sail.getPoints().addAll(0.0, 0.0, 4.0, 1.5, 8.0, 3.0, 12.0, 3.5, 16.0, 3.0, 20.0, 1.5, 24.0, 0.0);
// sail.getPoints().addAll(0.0, 0.0, 24.0, 0.0);
sail.setLayoutX(x);
sail.setLayoutY(y);
} else {
animateSail();
sail.setLayoutX(x);
sail.setLayoutY(y);
}
boatPoly.getAssets().setLayoutX(x);
boatPoly.getAssets().setLayoutY(y);
// if (sailIn) {
//// sail.getPoints().clear();
//// sail.getPoints().addAll(0.0, 0.0, 4.0, 1.5, 8.0, 3.0, 12.0, 3.5, 16.0, 3.0, 20.0, 1.5, 24.0, 0.0);
//// sail.getPoints().addAll(0.0, 0.0, 24.0, 0.0);
// sail.setLayoutX(x);
// sail.setLayoutY(y);
// } else {
//// animateSail();
// sail.setLayoutX(x);
// sail.setLayoutY(y);
// }
wake.setLayoutX(x);
wake.setLayoutY(y);
});
wake.setRotation(rotation, velocity);
// wake.setRotation(rotation, velocity);
// rotateTo(rotation);
// boatPoly.setLayoutX(x);
// boatPoly.setLayoutY(y);
@@ -183,35 +265,33 @@ public class BoatObject extends Group {
private void rotateTo(double heading, boolean sailsIn, double windDir) {
boatPoly.getTransforms().setAll(new Rotate(heading));
if (sailsIn) {
rotation.setAngle(heading);
wake.getTransforms().setAll(new Rotate(heading, new Point3D(0,0,1)));
if (!sailsIn) {
boatPoly.showSail();
Double sailWindOffset = 30.0;
Double upwindAngleLimit = 15.0;
Double downwindAngleLimit = 10.0; //Upwind from normalised horizontal
Double normalizedHeading = normalizeHeading(heading, windDir);
if (normalizedHeading < 180) {
sail.getTransforms().setAll(new Rotate(windDir + 90 + sailWindOffset));
sail.getPoints().clear();
sail.getPoints().addAll(0.0, 0.0, 4.0, -1.5, 8.0, -3.0, 12.0, -3.5, 16.0, -3.0, 20.0, -1.5, 24.0, 0.0);
if (normalizedHeading > 90 + sailWindOffset){
sail.getTransforms().setAll(new Rotate(heading + downwindAngleLimit));
}
if (normalizedHeading < sailWindOffset + upwindAngleLimit){
sail.getTransforms().setAll(new Rotate(heading + 90 - upwindAngleLimit));
boatPoly.rotateSail(90 - upwindAngleLimit);
} else if (normalizedHeading > 90 + sailWindOffset){
boatPoly.rotateSail(downwindAngleLimit);
} else {
boatPoly.rotateSail(90 + sailWindOffset);
}
} else {
sail.getTransforms().setAll(new Rotate(windDir + 90 - sailWindOffset));
sail.getPoints().clear();
sail.getPoints().addAll(0.0, 0.0, 4.0, 1.5, 8.0, 3.0, 12.0, 3.5, 16.0, 3.0, 20.0, 1.5, 24.0, 0.0);
if (normalizedHeading < 270 - sailWindOffset){
sail.getTransforms().setAll(new Rotate(heading + 180 - downwindAngleLimit));
}
if (normalizedHeading > 360 - (sailWindOffset + upwindAngleLimit)){
sail.getTransforms().setAll(new Rotate(heading + 90 + upwindAngleLimit));
boatPoly.rotateSail(90 + upwindAngleLimit);
} else if (normalizedHeading < 270 - sailWindOffset){
boatPoly.rotateSail(180 - downwindAngleLimit);
} else {
boatPoly.rotateSail(90 - sailWindOffset);
}
}
} else {
sail.getTransforms().setAll(new Rotate(windDir));
boatPoly.hideSail();
}
}
@@ -222,8 +302,8 @@ public class BoatObject extends Group {
double period = 10;
for (int i = 0; i < 50; i++) {
points[i * 2] = amplitude * Math.sin(((Math.PI * i) / period + sailState));
points[i * 2 + 1] = (BOAT_HEIGHT * i) / BOAT_HEIGHT / 2;
points[199 - (i * 2)] = (BOAT_HEIGHT * i) / BOAT_HEIGHT / 2;
points[i * 2 + 1] = (double) (BOAT_HEIGHT * i) / BOAT_HEIGHT / 2;
points[199 - (i * 2)] = (double) (BOAT_HEIGHT * i) / BOAT_HEIGHT / 2;
points[199 - (i * 2 + 1)] = amplitude * Math.sin(((Math.PI * i) / period + sailState));
}
if (sailState == - 2 * Math.PI) {
@@ -237,6 +317,7 @@ public class BoatObject extends Group {
}
public void updateLocation() {
// boatPoly.getTransforms().add(new Rotate(2, new Point3D(1,1,1)));
// double dx = xVelocity / 60;
// double dy = yVelocity / 60;
//
@@ -346,33 +427,33 @@ public class BoatObject extends Group {
}
public Double getBoatLayoutX() {
return boatPoly.getLayoutX();
return boatPoly.getAssets().getLayoutX();
}
public Double getBoatLayoutY() {
return boatPoly.getLayoutY();
return boatPoly.getAssets().getLayoutY();
}
/**
* Sets this boat to appear highlighted
*/
public void setAsPlayer() {
boatPoly.getPoints().setAll(
-BOAT_WIDTH / 1.75, BOAT_HEIGHT / 1.75,
0.0, -BOAT_HEIGHT / 1.75,
BOAT_WIDTH / 1.75, BOAT_HEIGHT / 1.75
);
boatPoly.setStroke(Color.BLACK);
boatPoly.setStrokeWidth(2);
boatPoly.setStrokeLineCap(StrokeLineCap.ROUND);
// boatPoly.getPoints().setAll(
// -BOAT_WIDTH / 1.75, BOAT_HEIGHT / 1.75,
// 0.0, -BOAT_HEIGHT / 1.75,
// BOAT_WIDTH / 1.75, BOAT_HEIGHT / 1.75
// );
// boatPoly.setStroke(Color.BLACK);
// boatPoly.setStrokeWidth(2);
// boatPoly.setStrokeLineCap(StrokeLineCap.ROUND);
isPlayer = true;
animateSail();
}
public void setTrajectory(double heading, double velocity, double windDir) {
wake.setRotation(lastHeading - heading, velocity);
rotateTo(heading, false, windDir);
// wake.r(lastHeading - heading, velocity);
// rotateTo(heading, false, windDir);
xVelocity = Math.cos(Math.toRadians(heading)) * velocity;
yVelocity = Math.sin(Math.toRadians(heading)) * velocity;
lastHeading = heading;
@@ -1,4 +1,4 @@
package seng302.visualiser.fxObjects;
package seng302.visualiser.fxObjects.assets_2D;
import javafx.scene.paint.Color;
import javafx.scene.shape.Polygon;
@@ -1,4 +1,4 @@
package seng302.visualiser.fxObjects;
package seng302.visualiser.fxObjects.assets_2D;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Line;
@@ -1,4 +1,4 @@
package seng302.visualiser.fxObjects;
package seng302.visualiser.fxObjects.assets_2D;
import javafx.scene.Group;
import javafx.scene.paint.Color;
@@ -1,4 +1,4 @@
package seng302.visualiser.fxObjects;
package seng302.visualiser.fxObjects.assets_2D;
import java.util.ArrayList;
import java.util.List;
@@ -7,13 +7,16 @@ import javafx.scene.Group;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Circle;
import javafx.scene.transform.Scale;
import seng302.visualiser.fxObjects.assets_3D.ModelFactory;
import seng302.visualiser.fxObjects.assets_3D.ModelType;
/**
* Visual object for a mark. Contains a coloured circle and any specified arrows.
*/
public class Marker extends Group {
private Circle mark = new Circle();
private Group mark = ModelFactory.importModel(ModelType.PLAIN_MARKER).getAssets();
private Paint colour = Color.BLACK;
private List<Group> enterArrows = new ArrayList<>();
private List<Group> exitArrows = new ArrayList<>();
@@ -24,10 +27,13 @@ public class Marker extends Group {
* Creates a new Marker containing only a circle. The default colour is black.
*/
public Marker() {
mark.setRadius(5);
mark.setCenterX(0);
mark.setCenterY(0);
Platform.runLater(() -> this.getChildren().addAll(mark, new Group())); //Empty group placeholder or arrows.
// mark.setRadius(5);
// mark.setCenterX(0);
// mark.setCenterY(0);
Platform.runLater(() -> {
mark.getTransforms().add(new Scale(5,5,5));
this.getChildren().addAll(mark, new Group());
}); //Empty group placeholder or arrows.
}
/**
@@ -37,7 +43,7 @@ public class Marker extends Group {
public Marker(Paint colour) {
this();
this.colour = colour;
mark.setFill(colour);
// mark.setFill(colour);
}
/**
@@ -48,7 +54,7 @@ public class Marker extends Group {
* @param exitAngle The angle the arrow wil point from the marker.
*/
public void addArrows(MarkArrowFactory.RoundingSide roundingSide, double entryAngle,
double exitAngle) {
double exitAngle) {
//Change Color.GRAY to this.colour to revert all gray arrows.
enterArrows.add(
MarkArrowFactory.constructEntryArrow(roundingSide, entryAngle, exitAngle, Color.GRAY)
@@ -1,4 +1,4 @@
package seng302.visualiser.fxObjects;
package seng302.visualiser.fxObjects.assets_2D;
import javafx.application.Platform;
import javafx.scene.CacheHint;
@@ -0,0 +1,25 @@
package seng302.visualiser.fxObjects.assets_2D;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Polyline;
import javafx.scene.shape.StrokeLineCap;
import javafx.scene.shape.StrokeLineJoin;
/**
* Created by cir27 on 5/09/17.
*/
public class WindArrow extends Polyline {
public WindArrow(Paint fill) {
this.getPoints().addAll(
-10d, 15d,
0d, 25d,
0d, -25d,
0d, 25d,
10d, 15d
);
this.setStrokeLineCap(StrokeLineCap.ROUND);
this.setStroke(fill);
this.setStrokeWidth(5);
this.setStrokeLineJoin(StrokeLineJoin.ROUND);
}
}
@@ -0,0 +1,22 @@
package seng302.visualiser.fxObjects.assets_3D;
/**
* Enum for boat meshes. Enum values should be of the form :
* ENUM_VALUE (hull file, mast file, X offset of mast CoR from origin, sail file, X offset of sail CoR from origin)
* Files must be valid .stl files.
*/
public enum BoatMeshType {
DINGHY ("dinghy_hull.stl", "dinghy_mast.stl", -1.36653, "dinghy_sail.stl", -1.36653);
final String hullFile, mastFile, sailFile;
final double mastOffset, sailOffset;
BoatMeshType(String hullFile, String mastFile, double mastOffset, String sailFile, double sailOffset) {
this.hullFile = hullFile;
this.mastFile = mastFile;
this.mastOffset = mastOffset;
this.sailFile = sailFile;
this.sailOffset = sailOffset;
}
}
@@ -0,0 +1,72 @@
package seng302.visualiser.fxObjects.assets_3D;
import javafx.animation.AnimationTimer;
import javafx.geometry.Point3D;
import javafx.scene.Group;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.MeshView;
import javafx.scene.transform.Rotate;
/**
* Container class for a group of 3d objects representing a boat and it's animation.
*/
public class BoatModel extends Model {
private static final int HULL_INDEX = 0;
private static final int MAST_INDEX = 1;
private static final int SAIL_INDEX = 2;
private BoatMeshType meshType;
/**
* Stores a model and it's optional animation.
* @param boatAssets The group with 3d assets for the boat.
* @param animation Animation, can be null.
*/
BoatModel(Group boatAssets, AnimationTimer animation, BoatMeshType meshType) {
super(boatAssets, animation);
this.meshType = meshType;
}
/**
* Rotates the sail of this model by the given amount.
* @param degrees The rotation of the sail in degrees
*/
public void rotateSail(double degrees) {
MeshView mast = getMeshViewChild(MAST_INDEX);
MeshView sail = getMeshViewChild(SAIL_INDEX);
mast.getTransforms().setAll(
new Rotate(degrees, -meshType.mastOffset, 0,0, new Point3D(0, 0, 1))
);
sail.getTransforms().setAll(
new Rotate(degrees, -meshType.sailOffset, 0,0, new Point3D(0, 0, 1))
);
}
public void hideSail() {
getMeshViewChild(SAIL_INDEX).setVisible(false);
}
public void showSail() {
getMeshViewChild(SAIL_INDEX).setVisible(true);
}
/**
* Changes the colour of the model in this class.
* @param newColour the new colour for the boat.
*/
public void changeColour(Color newColour) {
changeColourChild(HULL_INDEX, newColour);
changeColourChild(SAIL_INDEX, newColour);
}
private void changeColourChild(int index, Color newColour) {
MeshView meshView = getMeshViewChild(index);
meshView.setMaterial(new PhongMaterial(newColour));
}
private MeshView getMeshViewChild(int index) {
return (MeshView) assets.getChildren().get(index);
}
}
@@ -0,0 +1,42 @@
package seng302.visualiser.fxObjects.assets_3D;
import javafx.animation.AnimationTimer;
import javafx.scene.Group;
/**
* Created by CJIRWIN on 7/09/2017.
*/
public class Model {
AnimationTimer animationTimer;
Group assets;
Model (Group assets, AnimationTimer animation) {
this.assets = assets;
this.animationTimer = animation;
if (animation != null) {
animation.start();
}
}
void setAnimation(AnimationTimer animation) {
animationTimer = animation;
if (animation != null) {
animation.start();
}
}
/**
* Stops the animation of this model.
*/
public void stopAnimation() {
if (animationTimer != null) {
animationTimer.stop();
animationTimer = null;
}
}
public Group getAssets() {
return this.assets;
}
}
@@ -0,0 +1,178 @@
package seng302.visualiser.fxObjects.assets_3D;
import com.interactivemesh.jfx.importer.col.ColModelImporter;
import com.interactivemesh.jfx.importer.stl.StlMeshImporter;
import javafx.animation.AnimationTimer;
import javafx.geometry.Point3D;
import javafx.scene.AmbientLight;
import javafx.scene.Group;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.Circle;
import javafx.scene.shape.MeshView;
import javafx.scene.transform.Rotate;
import javafx.scene.transform.Scale;
import javafx.scene.transform.Translate;
/**
* Factory class for creating 3D models of boats.
*/
public class ModelFactory {
public static BoatModel boatIconView(BoatMeshType boatType, Color primaryColour) {
Group boatAssets = getUnmodifiedBoatModel(boatType, primaryColour);
boatAssets.getTransforms().addAll(
new Scale(20, 20, 20),
new Rotate(90, new Point3D(0,0,1)),
new Rotate(90, new Point3D(0, 1, 0))
);
boatAssets.getChildren().add(new AmbientLight(new Color(1, 1, 1, 0.01)));
return new BoatModel(boatAssets, null, boatType);
}
public static BoatModel boatRotatingView(BoatMeshType boatType, Color primaryColour) {
Group boatAssets = getUnmodifiedBoatModel(boatType, primaryColour);
boatAssets.getTransforms().addAll(
new Scale(40, 40, 40),
new Rotate(90, new Point3D(0,0,1)),
new Rotate(90, new Point3D(0, 1, 0)),
new Rotate(0, new Point3D(1,1,1))
);
// TODO: 7/09/17 This seems like it will never be garbage claimed. Might have to call BoatModel.stopAnimation();
return new BoatModel(boatAssets, new AnimationTimer() {
private double rotation = 0;
private final Group group = boatAssets;
@Override
public void handle(long now) {
rotation += 0.5;
((Rotate) group.getTransforms().get(3)).setAngle(rotation);
}
}, boatType);
}
public static BoatModel boatGameView(BoatMeshType boatType, Color primaryColour) {
Group boatAssets = getUnmodifiedBoatModel(boatType, primaryColour);
boatAssets.getTransforms().setAll(
new Rotate(-90, new Point3D(0,0,1)),
new Scale(0.05, 0.05, 0.05)
);
return new BoatModel(boatAssets, null, boatType);
}
private static Group getUnmodifiedBoatModel(BoatMeshType boatType, Color primaryColour) {
Group boatAssets = new Group();
MeshView hull = importFile(boatType.hullFile);
hull.setMaterial(new PhongMaterial(primaryColour));
MeshView mast = importFile(boatType.mastFile);
mast.setMaterial(new PhongMaterial(primaryColour));
MeshView sail = importFile(boatType.sailFile);
sail.setMaterial(new PhongMaterial(Color.WHITE));
boatAssets.getChildren().addAll(hull, mast, sail);
return boatAssets;
}
private static MeshView importFile(String fileName) {
StlMeshImporter importer = new StlMeshImporter();
importer.read(ModelFactory.class.getResource("/meshes/" + fileName));
return new MeshView(importer.getImport());
}
public static Model importModel(ModelType tokenType) {
Group assets;
if (tokenType.filename == null) {
assets = new Group();
} else {
ColModelImporter importer = new ColModelImporter();
importer.read(ModelFactory.class.getResource("/meshes/" + tokenType.filename));
assets = new Group(importer.getImport());
}
switch (tokenType) {
case VELOCITY_PICKUP:
return makeCoinPickup(assets);
case FINISH_MARKER:
case PLAIN_MARKER:
case START_MARKER:
return makeMarker(assets);
case OCEAN:
return makeOcean(assets);
case BORDER_PYLON:
case BORDER_BARRIER:
return makeBarrier(assets);
case FINISH_LINE:
case START_LINE:
case GATE_LINE:
return makeGate(assets);
case WAKE:
return makeWake(assets);
default:
return new Model(new Group(assets), null);
}
}
private static Model makeCoinPickup(Group assets){
assets.setRotationAxis(new Point3D(1,0,0));
assets.setRotate(90);
assets.setTranslateX(0.2);
assets.setTranslateY(1);
assets.getTransforms().addAll(
new Translate(0,-1,0),
new Rotate(0 ,new Point3D(1,1,1))
);
return new Model(new Group(assets), new AnimationTimer() {
private double rotation = 0;
private Group group = assets;
@Override
public void handle(long now) {
rotation += 1;
((Rotate) group.getTransforms().get(1)).setAngle(rotation);
}
});
}
private static Model makeMarker(Group marker) {
ColModelImporter importer = new ColModelImporter();
importer.read(ModelFactory.class.getResource("/meshes/" + ModelType.MARK_AREA.filename));
Group area = new Group(importer.getImport());
area.getChildren().add(marker);
area.getTransforms().add(new Rotate(90, new Point3D(1, 0, 0)));
return new Model(new Group(area), null);
}
private static Model makeOcean(Group group) {
// group.setScaleY(Double.MAX_VALUE);
// group.setScaleX(Double.MAX_VALUE);
// group.getTransforms().add(new Rotate(90, new Point3D(1, 0, 0)));
Circle ocean = new Circle(0,0,1000, Color.DARKSEAGREEN);
ocean.setStroke(Color.TRANSPARENT);
group.getChildren().add(ocean);
return new Model(group, null);
}
private static Model makeBarrier(Group assets) {
assets.getTransforms().addAll(
new Rotate(90, new Point3D(1,0,0)),
new Scale(1.5,1.5,1.5)
);
return new Model(new Group(assets), null);
}
private static Model makeGate(Group assets) {
assets.getTransforms().addAll(
new Rotate(90, new Point3D(1,0,0))
);
return new Model(new Group(assets), null);
}
private static Model makeWake(Group assets) {
assets.getTransforms().setAll(
new Rotate(-90, new Point3D(0,0,1)),
new Rotate(90, new Point3D(1,0,0)),
new Scale(0.5, 0.5, 0.5)
);
return new Model(new Group(assets), null);
}
}
@@ -0,0 +1,28 @@
package seng302.visualiser.fxObjects.assets_3D;
/**
* Enum for models. Values should be the name of the file and files should be .dae files with texture
* information included. Can be null in which case assets are assumed to be empty.
*/
public enum ModelType {
VELOCITY_PICKUP("velocity_pickup.dae"),
FINISH_MARKER ("finish_marker.dae"),
START_MARKER ("start_marker.dae"),
PLAIN_MARKER ("plain_marker.dae"),
MARK_AREA ("mark_area.dae"),
OCEAN (null),
BORDER_PYLON ("barrier_pole.dae"),
BORDER_BARRIER ("barrier_segment.dae"),
FINISH_LINE ("finish_line.dae"),
START_LINE ("start_line.dae"),
GATE_LINE ("gate_line.dae"),
WAKE ("wake.dae");
final String filename;
ModelType(String filename) {
this.filename = filename;
}
}
@@ -0,0 +1,108 @@
package seng302.visualiser;
import com.interactivemesh.jfx.importer.stl.StlMeshImporter;
import javafx.animation.AnimationTimer;
import javafx.application.Application;
import javafx.geometry.Point3D;
import javafx.scene.Camera;
import javafx.scene.Group;
import javafx.scene.PerspectiveCamera;
import javafx.scene.Scene;
import javafx.scene.SceneAntialiasing;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.MeshView;
import javafx.scene.transform.Rotate;
import javafx.scene.transform.Scale;
import javafx.scene.transform.Translate;
import javafx.stage.Stage;
/**
* Created by cir27 on 7/09/17.
*/
public class test3d extends Application {
Group root = new Group();
Scene scene;
@Override
public void start(Stage primaryStage) throws Exception {
// camera = new PerspectiveCamera();
// gameObjects = new Group();
// root3D = new Group(camera, gameObjects);
scene = new Scene(
root, 1000, 1000, true, SceneAntialiasing.BALANCED
);
gameView3DTest();
primaryStage.setScene(scene);
primaryStage.show();
// scene.setCamera(camera);
// primaryStage.setScene(scene);
// primaryStage.show();
//
// StlMeshImporter importer = new StlMeshImporter();
// importer.read(test3d.class.getResource("/meshes/dinghy_hull.stl").toString());
// MeshView boat = new MeshView(importer.getImport());
// boat.setMaterial(new PhongMaterial(Color.GREENYELLOW));
//
// importer = new StlMeshImporter();
// importer.read(getClass().getResource("/meshes/dinghy_mast.stl").toString());
// MeshView mast = new MeshView(importer.getImport());
// mast.setMaterial(new PhongMaterial(Color.GREENYELLOW));
//
// importer = new StlMeshImporter();
// importer.read(getClass().getResource("/meshes/dinghy_sail.stl").toString());
// MeshView sail = new MeshView(importer.getImport());
// sail.setMaterial(new PhongMaterial(Color.LIGHTGREY));
//
// gameObjects.getChildren().addAll(boat, mast, sail);
//
// gameObjects.getTransforms().add(new Scale(25, 25,25));
// gameObjects.getTransforms().add(new Translate(15, 20,0));
// gameObjects.getTransforms().addAll(
// new Rotate(90, new Point3D(0,0,1)),
// new Rotate(90, new Point3D(0, 1, 0))
// );
//
//// PointLight light = new PointLight();
//// light.setLightOn(true);
//// light.getTransforms().add(new Translate(15, 20, 0));
////
//// PointLight light2 = new PointLight();
//// light2.setLightOn(true);
//// light2.getTransforms().add(new Translate(30, 40, 0));
//
//// root3D.getChildren().addAll(light);
//
// scene.setOnKeyPressed(event -> {
// switch (event.getCode()) {
// case UP:
// gameObjects.getTransforms().add(new Rotate(5, new Point3D(0,0,1)));
// break;
// case DOWN:
// gameObjects.getTransforms().add(new Rotate(-5, new Point3D(0,0,1)));
// break;
// case LEFT:
// gameObjects.getTransforms().add(new Rotate(-5, new Point3D(0,1,0)));
// break;
// case RIGHT:
// gameObjects.getTransforms().add(new Rotate(5, new Point3D(0,1,0)));
// break;
// }
// });
//
// AnimationTimer animationTimer = new AnimationTimer() {
// @Override
// public void handle(long now) {
// sail.getTransforms().add(new Rotate(0.5, 0, -1.36653, 0, new Point3D(0, 0, 1)));
// }
// };
//
//// animationTimer.start();
}
private void gameView3DTest() {
GameView3D gameView3D = new GameView3D();
root.getChildren().add(gameView3D.getAssets());
}
}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
+100
View File
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
<asset>
<contributor>
<author>Blender User</author>
<authoring_tool>Blender 2.78.0 commit date:2016-09-26, commit time:12:42, hash:4bb1e22</authoring_tool>
</contributor>
<created>2017-09-11T10:59:51</created>
<modified>2017-09-11T10:59:51</modified>
<unit name="meter" meter="1"/>
<up_axis>Z_UP</up_axis>
</asset>
<library_images/>
<library_effects>
<effect id="Material_001-effect">
<profile_COMMON>
<technique sid="common">
<phong>
<emission>
<color sid="emission">0 0 0 1</color>
</emission>
<ambient>
<color sid="ambient">0 0 0 1</color>
</ambient>
<diffuse>
<color sid="diffuse">0.64 0 0.01304383 1</color>
</diffuse>
<specular>
<color sid="specular">0 0 0 1</color>
</specular>
<shininess>
<float sid="shininess">50</float>
</shininess>
<index_of_refraction>
<float sid="index_of_refraction">1</float>
</index_of_refraction>
</phong>
</technique>
</profile_COMMON>
</effect>
</library_effects>
<library_materials>
<material id="Material_001-material" name="Material_001">
<instance_effect url="#Material_001-effect"/>
</material>
</library_materials>
<library_geometries>
<geometry id="Plane-mesh" name="Plane">
<mesh>
<source id="Plane-mesh-positions">
<float_array id="Plane-mesh-positions-array" count="192">-1 1 0 1 1 0 -1 0 0 1 0 0 -1 -0.5 0 1 0.5 0 -1 0.5 0 1 -0.5 0 -1 -0.75 0 1 0.75 0 -1 0.25 0 1 -0.25 0 -1 -0.25 0 1 0.25 0 -1 0.75 0 1 -0.75 0 -1 -0.875 0 1 0.875 0 -1 0.125 0 1 -0.125 0 -1 -0.375 0 1 0.375 0 -1 0.625 0 1 -0.625 0 -1 -0.625 0 1 0.625 0 -1 0.375 0 1 -0.375 0 -1 -0.125 0 1 0.125 0 -1 0.875 0 1 -0.875 0 1 0.875 0.04037588 1 1 0.04037588 -1 1 0.04037588 1 -0.125 0.04037588 1 0 0.04037588 -1 0 0.04037588 1 0.375 0.04037588 1 0.5 0.04037588 1 -0.625 0.04037588 1 -0.5 0.04037588 -1 -0.5 0.04037588 -1 0.5 0.04037588 1 0.625 0.04037588 1 0.75 0.04037588 1 -0.375 0.04037588 1 -0.25 0.04037588 1 0.125 0.04037588 1 0.25 0.04037588 1 -0.875 0.04037588 1 -0.75 0.04037588 -1 0.25 0.04037588 -1 -0.75 0.04037588 -1 -0.25 0.04037588 -1 0.75 0.04037588 -1 -0.875 0.04037588 -1 0.125 0.04037588 -1 -0.375 0.04037588 -1 0.625 0.04037588 -1 -0.625 0.04037588 -1 0.375 0.04037588 -1 -0.125 0.04037588 -1 0.875 0.04037588</float_array>
<technique_common>
<accessor source="#Plane-mesh-positions-array" count="64" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Plane-mesh-normals">
<float_array id="Plane-mesh-normals-array" count="18">0 0 -1 0 0 1 0 -1 0 0 1 0 1 0 0 -1 0 0</float_array>
<technique_common>
<accessor source="#Plane-mesh-normals-array" count="6" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="Plane-mesh-vertices">
<input semantic="POSITION" source="#Plane-mesh-positions"/>
</vertices>
<polylist material="Material_001-material" count="96">
<input semantic="VERTEX" source="#Plane-mesh-vertices" offset="0"/>
<input semantic="NORMAL" source="#Plane-mesh-normals" offset="1"/>
<vcount>3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 </vcount>
<p>0 0 17 0 30 0 2 0 19 0 28 0 4 0 23 0 24 0 6 0 21 0 26 0 10 0 29 0 18 0 8 0 31 0 16 0 12 0 27 0 20 0 14 0 25 0 22 0 32 1 34 1 63 1 35 1 37 1 62 1 40 1 42 1 60 1 38 1 43 1 61 1 48 1 52 1 57 1 50 1 53 1 56 1 46 1 54 1 58 1 44 1 55 1 59 1 27 2 58 2 20 2 10 3 49 3 13 3 31 2 56 2 16 2 8 3 51 3 15 3 1 4 32 4 17 4 29 2 57 2 18 2 12 3 47 3 11 3 0 3 33 3 1 3 21 2 61 2 26 2 14 3 45 3 9 3 3 4 35 4 19 4 23 2 60 2 24 2 16 5 53 5 8 5 2 3 36 3 3 3 19 2 62 2 28 2 18 5 52 5 10 5 5 4 38 4 21 4 17 2 63 2 30 2 20 5 54 5 12 5 7 4 40 4 23 4 22 5 55 5 14 5 4 3 41 3 7 3 24 5 42 5 4 5 6 3 39 3 5 3 26 5 43 5 6 5 9 4 44 4 25 4 28 5 37 5 2 5 11 4 46 4 27 4 30 5 34 5 0 5 13 4 48 4 29 4 25 2 59 2 22 2 15 4 50 4 31 4 0 0 1 0 17 0 2 0 3 0 19 0 4 0 7 0 23 0 6 0 5 0 21 0 10 0 13 0 29 0 8 0 15 0 31 0 12 0 11 0 27 0 14 0 9 0 25 0 32 1 33 1 34 1 35 1 36 1 37 1 40 1 41 1 42 1 38 1 39 1 43 1 48 1 49 1 52 1 50 1 51 1 53 1 46 1 47 1 54 1 44 1 45 1 55 1 27 2 46 2 58 2 10 3 52 3 49 3 31 2 50 2 56 2 8 3 53 3 51 3 1 4 33 4 32 4 29 2 48 2 57 2 12 3 54 3 47 3 0 3 34 3 33 3 21 2 38 2 61 2 14 3 55 3 45 3 3 4 36 4 35 4 23 2 40 2 60 2 16 5 56 5 53 5 2 3 37 3 36 3 19 2 35 2 62 2 18 5 57 5 52 5 5 4 39 4 38 4 17 2 32 2 63 2 20 5 58 5 54 5 7 4 41 4 40 4 22 5 59 5 55 5 4 3 42 3 41 3 24 5 60 5 42 5 6 3 43 3 39 3 26 5 61 5 43 5 9 4 45 4 44 4 28 5 62 5 37 5 11 4 47 4 46 4 30 5 63 5 34 5 13 4 49 4 48 4 25 2 44 2 59 2 15 4 51 4 50 4</p>
</polylist>
</mesh>
</geometry>
</library_geometries>
<library_controllers/>
<library_visual_scenes>
<visual_scene id="Scene" name="Scene">
<node id="Plane" name="Plane" type="NODE">
<matrix sid="transform">0.125 0 0 0 0 5.333333 0 -0.3333333 0 0 1 0.01986987 0 0 0 1</matrix>
<instance_geometry url="#Plane-mesh" name="Plane">
<bind_material>
<technique_common>
<instance_material symbol="Material_001-material" target="#Material_001-material"/>
</technique_common>
</bind_material>
</instance_geometry>
</node>
</visual_scene>
</library_visual_scenes>
<scene>
<instance_visual_scene url="#Scene"/>
</scene>
</COLLADA>
File diff suppressed because one or more lines are too long
+100
View File
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
<asset>
<contributor>
<author>Blender User</author>
<authoring_tool>Blender 2.78.0 commit date:2016-09-26, commit time:12:42, hash:4bb1e22</authoring_tool>
</contributor>
<created>2017-09-11T11:00:38</created>
<modified>2017-09-11T11:00:38</modified>
<unit name="meter" meter="1"/>
<up_axis>Z_UP</up_axis>
</asset>
<library_images/>
<library_effects>
<effect id="Material_001_002-effect">
<profile_COMMON>
<technique sid="common">
<phong>
<emission>
<color sid="emission">0 0 0 1</color>
</emission>
<ambient>
<color sid="ambient">0 0 0 1</color>
</ambient>
<diffuse>
<color sid="diffuse">0.09194811 0.08404596 0.08642986 1</color>
</diffuse>
<specular>
<color sid="specular">0 0 0 1</color>
</specular>
<shininess>
<float sid="shininess">50</float>
</shininess>
<index_of_refraction>
<float sid="index_of_refraction">1</float>
</index_of_refraction>
</phong>
</technique>
</profile_COMMON>
</effect>
</library_effects>
<library_materials>
<material id="Material_001_002-material" name="Material_001_002">
<instance_effect url="#Material_001_002-effect"/>
</material>
</library_materials>
<library_geometries>
<geometry id="Plane_003-mesh" name="Plane.003">
<mesh>
<source id="Plane_003-mesh-positions">
<float_array id="Plane_003-mesh-positions-array" count="192">-1 1 0 1 1 0 -1 0 0 1 0 0 -1 -0.5 0 1 0.5 0 -1 0.5 0 1 -0.5 0 -1 -0.75 0 1 0.75 0 -1 0.25 0 1 -0.25 0 -1 -0.25 0 1 0.25 0 -1 0.75 0 1 -0.75 0 -1 -0.875 0 1 0.875 0 -1 0.125 0 1 -0.125 0 -1 -0.375 0 1 0.375 0 -1 0.625 0 1 -0.625 0 -1 -0.625 0 1 0.625 0 -1 0.375 0 1 -0.375 0 -1 -0.125 0 1 0.125 0 -1 0.875 0 1 -0.875 0 1 0.875 0.04037588 1 1 0.04037588 -1 1 0.04037588 1 -0.125 0.04037588 1 0 0.04037588 -1 0 0.04037588 1 0.375 0.04037588 1 0.5 0.04037588 1 -0.625 0.04037588 1 -0.5 0.04037588 -1 -0.5 0.04037588 -1 0.5 0.04037588 1 0.625 0.04037588 1 0.75 0.04037588 1 -0.375 0.04037588 1 -0.25 0.04037588 1 0.125 0.04037588 1 0.25 0.04037588 1 -0.875 0.04037588 1 -0.75 0.04037588 -1 0.25 0.04037588 -1 -0.75 0.04037588 -1 -0.25 0.04037588 -1 0.75 0.04037588 -1 -0.875 0.04037588 -1 0.125 0.04037588 -1 -0.375 0.04037588 -1 0.625 0.04037588 -1 -0.625 0.04037588 -1 0.375 0.04037588 -1 -0.125 0.04037588 -1 0.875 0.04037588</float_array>
<technique_common>
<accessor source="#Plane_003-mesh-positions-array" count="64" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Plane_003-mesh-normals">
<float_array id="Plane_003-mesh-normals-array" count="18">0 0 -1 0 0 1 0 -1 0 0 1 0 1 0 0 -1 0 0</float_array>
<technique_common>
<accessor source="#Plane_003-mesh-normals-array" count="6" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="Plane_003-mesh-vertices">
<input semantic="POSITION" source="#Plane_003-mesh-positions"/>
</vertices>
<polylist material="Material_001_002-material" count="96">
<input semantic="VERTEX" source="#Plane_003-mesh-vertices" offset="0"/>
<input semantic="NORMAL" source="#Plane_003-mesh-normals" offset="1"/>
<vcount>3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 </vcount>
<p>0 0 17 0 30 0 2 0 19 0 28 0 4 0 23 0 24 0 6 0 21 0 26 0 10 0 29 0 18 0 8 0 31 0 16 0 12 0 27 0 20 0 14 0 25 0 22 0 32 1 34 1 63 1 35 1 37 1 62 1 40 1 42 1 60 1 38 1 43 1 61 1 48 1 52 1 57 1 50 1 53 1 56 1 46 1 54 1 58 1 44 1 55 1 59 1 27 2 58 2 20 2 10 3 49 3 13 3 31 2 56 2 16 2 8 3 51 3 15 3 1 4 32 4 17 4 29 2 57 2 18 2 12 3 47 3 11 3 0 3 33 3 1 3 21 2 61 2 26 2 14 3 45 3 9 3 3 4 35 4 19 4 23 2 60 2 24 2 16 5 53 5 8 5 2 3 36 3 3 3 19 2 62 2 28 2 18 5 52 5 10 5 5 4 38 4 21 4 17 2 63 2 30 2 20 5 54 5 12 5 7 4 40 4 23 4 22 5 55 5 14 5 4 3 41 3 7 3 24 5 42 5 4 5 6 3 39 3 5 3 26 5 43 5 6 5 9 4 44 4 25 4 28 5 37 5 2 5 11 4 46 4 27 4 30 5 34 5 0 5 13 4 48 4 29 4 25 2 59 2 22 2 15 4 50 4 31 4 0 0 1 0 17 0 2 0 3 0 19 0 4 0 7 0 23 0 6 0 5 0 21 0 10 0 13 0 29 0 8 0 15 0 31 0 12 0 11 0 27 0 14 0 9 0 25 0 32 1 33 1 34 1 35 1 36 1 37 1 40 1 41 1 42 1 38 1 39 1 43 1 48 1 49 1 52 1 50 1 51 1 53 1 46 1 47 1 54 1 44 1 45 1 55 1 27 2 46 2 58 2 10 3 52 3 49 3 31 2 50 2 56 2 8 3 53 3 51 3 1 4 33 4 32 4 29 2 48 2 57 2 12 3 54 3 47 3 0 3 34 3 33 3 21 2 38 2 61 2 14 3 55 3 45 3 3 4 36 4 35 4 23 2 40 2 60 2 16 5 56 5 53 5 2 3 37 3 36 3 19 2 35 2 62 2 18 5 57 5 52 5 5 4 39 4 38 4 17 2 32 2 63 2 20 5 58 5 54 5 7 4 41 4 40 4 22 5 59 5 55 5 4 3 42 3 41 3 24 5 60 5 42 5 6 3 43 3 39 3 26 5 61 5 43 5 9 4 45 4 44 4 28 5 62 5 37 5 11 4 47 4 46 4 30 5 63 5 34 5 13 4 49 4 48 4 25 2 44 2 59 2 15 4 51 4 50 4</p>
</polylist>
</mesh>
</geometry>
</library_geometries>
<library_controllers/>
<library_visual_scenes>
<visual_scene id="Scene" name="Scene">
<node id="Plane" name="Plane" type="NODE">
<matrix sid="transform">0.125 0 0 0 0 5.333333 0 -0.3333333 0 0 1 0.01986987 0 0 0 1</matrix>
<instance_geometry url="#Plane_003-mesh" name="Plane">
<bind_material>
<technique_common>
<instance_material symbol="Material_001_002-material" target="#Material_001_002-material"/>
</technique_common>
</bind_material>
</instance_geometry>
</node>
</visual_scene>
</library_visual_scenes>
<scene>
<instance_visual_scene url="#Scene"/>
</scene>
</COLLADA>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+100
View File
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
<asset>
<contributor>
<author>Blender User</author>
<authoring_tool>Blender 2.78.0 commit date:2016-09-26, commit time:12:42, hash:4bb1e22</authoring_tool>
</contributor>
<created>2017-09-11T11:00:07</created>
<modified>2017-09-11T11:00:07</modified>
<unit name="meter" meter="1"/>
<up_axis>Z_UP</up_axis>
</asset>
<library_images/>
<library_effects>
<effect id="Material_001_001-effect">
<profile_COMMON>
<technique sid="common">
<phong>
<emission>
<color sid="emission">0 0 0 1</color>
</emission>
<ambient>
<color sid="ambient">0 0 0 1</color>
</ambient>
<diffuse>
<color sid="diffuse">0 0.2611 7.78272e-5 1</color>
</diffuse>
<specular>
<color sid="specular">0 0 0 1</color>
</specular>
<shininess>
<float sid="shininess">50</float>
</shininess>
<index_of_refraction>
<float sid="index_of_refraction">1</float>
</index_of_refraction>
</phong>
</technique>
</profile_COMMON>
</effect>
</library_effects>
<library_materials>
<material id="Material_001_001-material" name="Material_001_001">
<instance_effect url="#Material_001_001-effect"/>
</material>
</library_materials>
<library_geometries>
<geometry id="Plane_001-mesh" name="Plane.001">
<mesh>
<source id="Plane_001-mesh-positions">
<float_array id="Plane_001-mesh-positions-array" count="192">-1 1 0 1 1 0 -1 0 0 1 0 0 -1 -0.5 0 1 0.5 0 -1 0.5 0 1 -0.5 0 -1 -0.75 0 1 0.75 0 -1 0.25 0 1 -0.25 0 -1 -0.25 0 1 0.25 0 -1 0.75 0 1 -0.75 0 -1 -0.875 0 1 0.875 0 -1 0.125 0 1 -0.125 0 -1 -0.375 0 1 0.375 0 -1 0.625 0 1 -0.625 0 -1 -0.625 0 1 0.625 0 -1 0.375 0 1 -0.375 0 -1 -0.125 0 1 0.125 0 -1 0.875 0 1 -0.875 0 1 0.875 0.04037588 1 1 0.04037588 -1 1 0.04037588 1 -0.125 0.04037588 1 0 0.04037588 -1 0 0.04037588 1 0.375 0.04037588 1 0.5 0.04037588 1 -0.625 0.04037588 1 -0.5 0.04037588 -1 -0.5 0.04037588 -1 0.5 0.04037588 1 0.625 0.04037588 1 0.75 0.04037588 1 -0.375 0.04037588 1 -0.25 0.04037588 1 0.125 0.04037588 1 0.25 0.04037588 1 -0.875 0.04037588 1 -0.75 0.04037588 -1 0.25 0.04037588 -1 -0.75 0.04037588 -1 -0.25 0.04037588 -1 0.75 0.04037588 -1 -0.875 0.04037588 -1 0.125 0.04037588 -1 -0.375 0.04037588 -1 0.625 0.04037588 -1 -0.625 0.04037588 -1 0.375 0.04037588 -1 -0.125 0.04037588 -1 0.875 0.04037588</float_array>
<technique_common>
<accessor source="#Plane_001-mesh-positions-array" count="64" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Plane_001-mesh-normals">
<float_array id="Plane_001-mesh-normals-array" count="18">0 0 -1 0 0 1 0 -1 0 0 1 0 1 0 0 -1 0 0</float_array>
<technique_common>
<accessor source="#Plane_001-mesh-normals-array" count="6" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="Plane_001-mesh-vertices">
<input semantic="POSITION" source="#Plane_001-mesh-positions"/>
</vertices>
<polylist material="Material_001_001-material" count="96">
<input semantic="VERTEX" source="#Plane_001-mesh-vertices" offset="0"/>
<input semantic="NORMAL" source="#Plane_001-mesh-normals" offset="1"/>
<vcount>3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 </vcount>
<p>0 0 17 0 30 0 2 0 19 0 28 0 4 0 23 0 24 0 6 0 21 0 26 0 10 0 29 0 18 0 8 0 31 0 16 0 12 0 27 0 20 0 14 0 25 0 22 0 32 1 34 1 63 1 35 1 37 1 62 1 40 1 42 1 60 1 38 1 43 1 61 1 48 1 52 1 57 1 50 1 53 1 56 1 46 1 54 1 58 1 44 1 55 1 59 1 27 2 58 2 20 2 10 3 49 3 13 3 31 2 56 2 16 2 8 3 51 3 15 3 1 4 32 4 17 4 29 2 57 2 18 2 12 3 47 3 11 3 0 3 33 3 1 3 21 2 61 2 26 2 14 3 45 3 9 3 3 4 35 4 19 4 23 2 60 2 24 2 16 5 53 5 8 5 2 3 36 3 3 3 19 2 62 2 28 2 18 5 52 5 10 5 5 4 38 4 21 4 17 2 63 2 30 2 20 5 54 5 12 5 7 4 40 4 23 4 22 5 55 5 14 5 4 3 41 3 7 3 24 5 42 5 4 5 6 3 39 3 5 3 26 5 43 5 6 5 9 4 44 4 25 4 28 5 37 5 2 5 11 4 46 4 27 4 30 5 34 5 0 5 13 4 48 4 29 4 25 2 59 2 22 2 15 4 50 4 31 4 0 0 1 0 17 0 2 0 3 0 19 0 4 0 7 0 23 0 6 0 5 0 21 0 10 0 13 0 29 0 8 0 15 0 31 0 12 0 11 0 27 0 14 0 9 0 25 0 32 1 33 1 34 1 35 1 36 1 37 1 40 1 41 1 42 1 38 1 39 1 43 1 48 1 49 1 52 1 50 1 51 1 53 1 46 1 47 1 54 1 44 1 45 1 55 1 27 2 46 2 58 2 10 3 52 3 49 3 31 2 50 2 56 2 8 3 53 3 51 3 1 4 33 4 32 4 29 2 48 2 57 2 12 3 54 3 47 3 0 3 34 3 33 3 21 2 38 2 61 2 14 3 55 3 45 3 3 4 36 4 35 4 23 2 40 2 60 2 16 5 56 5 53 5 2 3 37 3 36 3 19 2 35 2 62 2 18 5 57 5 52 5 5 4 39 4 38 4 17 2 32 2 63 2 20 5 58 5 54 5 7 4 41 4 40 4 22 5 59 5 55 5 4 3 42 3 41 3 24 5 60 5 42 5 6 3 43 3 39 3 26 5 61 5 43 5 9 4 45 4 44 4 28 5 62 5 37 5 11 4 47 4 46 4 30 5 63 5 34 5 13 4 49 4 48 4 25 2 44 2 59 2 15 4 51 4 50 4</p>
</polylist>
</mesh>
</geometry>
</library_geometries>
<library_controllers/>
<library_visual_scenes>
<visual_scene id="Scene" name="Scene">
<node id="Plane" name="Plane" type="NODE">
<matrix sid="transform">0.125 0 0 0 0 5.333333 0 -0.3333333 0 0 1 0.01986987 0 0 0 1</matrix>
<instance_geometry url="#Plane_001-mesh" name="Plane">
<bind_material>
<technique_common>
<instance_material symbol="Material_001_001-material" target="#Material_001_001-material"/>
</technique_common>
</bind_material>
</instance_geometry>
</node>
</visual_scene>
</library_visual_scenes>
<scene>
<instance_visual_scene url="#Scene"/>
</scene>
</COLLADA>
File diff suppressed because one or more lines are too long
@@ -0,0 +1,147 @@
<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
<asset>
<contributor>
<author>Blender User</author>
<authoring_tool>Blender 2.78.0 commit date:2017-02-24, commit time:14:33, hash:e92f235283</authoring_tool>
</contributor>
<created>2017-09-11T03:01:23</created>
<modified>2017-09-11T03:01:23</modified>
<unit name="meter" meter="1"/>
<up_axis>Z_UP</up_axis>
</asset>
<library_images/>
<library_effects>
<effect id="Material_001-effect">
<profile_COMMON>
<technique sid="common">
<phong>
<emission>
<color sid="emission">0 0 0 1</color>
</emission>
<ambient>
<color sid="ambient">0 0 0 1</color>
</ambient>
<diffuse>
<color sid="diffuse">0.64 0.005094456 0 1</color>
</diffuse>
<specular>
<color sid="specular">0.5 0.5 0.5 1</color>
</specular>
<shininess>
<float sid="shininess">50</float>
</shininess>
<index_of_refraction>
<float sid="index_of_refraction">1</float>
</index_of_refraction>
</phong>
</technique>
</profile_COMMON>
</effect>
<effect id="Material_002-effect">
<profile_COMMON>
<technique sid="common">
<phong>
<emission>
<color sid="emission">0 0 0 1</color>
</emission>
<ambient>
<color sid="ambient">0 0 0 1</color>
</ambient>
<diffuse>
<color sid="diffuse">0.64 0.3778509 0 1</color>
</diffuse>
<specular>
<color sid="specular">0.5 0.5 0.5 1</color>
</specular>
<shininess>
<float sid="shininess">50</float>
</shininess>
<index_of_refraction>
<float sid="index_of_refraction">1</float>
</index_of_refraction>
</phong>
</technique>
</profile_COMMON>
</effect>
</library_effects>
<library_materials>
<material id="Material_001-material" name="Material_001">
<instance_effect url="#Material_001-effect"/>
</material>
<material id="Material_002-material" name="Material_002">
<instance_effect url="#Material_002-effect"/>
</material>
</library_materials>
<library_geometries>
<geometry id="Icosphere-mesh" name="Icosphere">
<mesh>
<source id="Icosphere-mesh-positions">
<float_array id="Icosphere-mesh-positions-array" count="126">0 0 -1 0.7236073 -0.5257253 -0.4472195 -0.276388 -0.8506492 -0.4472199 -0.8944262 0 -0.4472156 -0.276388 0.8506492 -0.4472199 0.7236073 0.5257253 -0.4472195 0.276388 -0.8506492 0.4472199 -0.7236073 -0.5257253 0.4472195 -0.7236073 0.5257253 0.4472195 0.276388 0.8506492 0.4472199 0.8944262 0 0.4472156 0 0 1 -0.1624555 -0.4999952 -0.8506544 0.4253227 -0.3090114 -0.8506542 0.2628688 -0.8090116 -0.5257377 0.8506479 0 -0.5257359 0.4253227 0.3090114 -0.8506542 -0.5257298 0 -0.8506517 -0.6881894 -0.4999969 -0.5257362 -0.1624555 0.4999952 -0.8506544 -0.6881894 0.4999969 -0.5257362 0.2628688 0.8090116 -0.5257377 0.9510579 -0.3090126 0 0.9510579 0.3090126 0 0 -1 0 0.5877856 -0.8090167 0 -0.9510579 -0.3090126 0 -0.5877856 -0.8090167 0 -0.5877856 0.8090167 0 -0.9510579 0.3090126 0 0.5877856 0.8090167 0 0 1 0 0.6881894 -0.4999969 0.5257362 -0.2628688 -0.8090116 0.5257377 -0.8506479 0 0.5257359 -0.2628688 0.8090116 0.5257377 0.6881894 0.4999969 0.5257362 0.1624555 -0.4999952 0.8506544 0.5257298 0 0.8506517 -0.4253227 -0.3090114 0.8506542 -0.4253227 0.3090114 0.8506542 0.1624555 0.4999952 0.8506544</float_array>
<technique_common>
<accessor source="#Icosphere-mesh-positions-array" count="42" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Icosphere-mesh-normals">
<float_array id="Icosphere-mesh-normals-array" count="240">0.1023808 -0.3150898 -0.9435235 0.7002239 -0.2680318 -0.6616989 -0.2680341 -0.1947365 -0.9435229 -0.2680341 0.1947365 -0.9435229 0.1023808 0.3150898 -0.9435235 0.9049892 -0.2680314 -0.3303846 0.02474659 -0.9435213 -0.3303864 -0.8896974 -0.3150947 -0.3303847 -0.574602 0.7487835 -0.3303876 0.534576 0.7778645 -0.3303867 0.802609 -0.5831265 -0.1256273 -0.3065689 -0.9435216 -0.125629 -0.9920774 0 -0.1256283 -0.3065689 0.9435216 -0.125629 0.802609 0.5831265 -0.1256273 0.408946 -0.6284251 0.6616986 -0.4712998 -0.5831221 0.6616986 -0.7002239 0.2680318 0.6616989 0.03853034 0.7487791 0.6616988 0.7240421 0.1947361 0.6616955 0.2680341 0.1947365 0.9435229 0.4911195 0.356821 0.7946575 0.408946 0.6284253 0.6616986 -0.1023808 0.3150899 0.9435235 -0.1875938 0.5773454 0.7946577 -0.4712998 0.5831222 0.6616986 -0.3313045 0 0.9435239 -0.6070606 0 0.7946557 -0.7002239 -0.2680319 0.6616989 -0.1023808 -0.3150899 0.9435235 -0.1875939 -0.5773454 0.7946577 0.03853034 -0.7487791 0.6616988 0.2680341 -0.1947366 0.9435229 0.4911196 -0.356821 0.7946575 0.7240421 -0.1947361 0.6616955 0.8896973 0.3150947 0.3303848 0.7946557 0.5773479 0.187595 0.574602 0.7487835 0.3303875 -0.02474659 0.9435213 0.3303865 -0.3035309 0.9341715 0.1875973 -0.534576 0.7778646 0.3303866 -0.9049891 0.2680313 0.3303845 -0.9822458 0 0.1875985 -0.9049891 -0.2680313 0.3303845 -0.534576 -0.7778646 0.3303866 -0.3035309 -0.9341715 0.1875974 -0.02474659 -0.9435213 0.3303865 0.574602 -0.7487835 0.3303875 0.7946557 -0.5773479 0.1875951 0.8896973 -0.3150947 0.3303848 0.3065689 0.9435216 0.1256287 0.3035309 0.9341715 -0.1875974 0.02474659 0.9435213 -0.3303864 -0.802609 0.5831265 0.1256273 -0.7946557 0.5773479 -0.1875951 -0.8896974 0.3150947 -0.3303847 -0.802609 -0.5831265 0.1256273 -0.7946557 -0.5773479 -0.187595 -0.574602 -0.7487835 -0.3303875 0.3065689 -0.9435216 0.1256287 0.3035309 -0.9341715 -0.1875973 0.5345759 -0.7778645 -0.3303867 0.9920774 0 0.1256283 0.9822458 0 -0.1875985 0.9049891 0.2680313 -0.3303845 0.4712998 0.5831221 -0.6616986 0.1875942 0.5773454 -0.7946577 -0.03853058 0.7487792 -0.6616986 -0.408946 0.6284253 -0.6616986 -0.4911196 0.356821 -0.7946575 -0.7240421 0.1947361 -0.6616955 -0.7240421 -0.1947361 -0.6616955 -0.4911196 -0.356821 -0.7946575 -0.408946 -0.6284253 -0.6616986 0.7002239 0.2680319 -0.6616989 0.6070606 0 -0.7946556 0.3313045 0 -0.9435239 -0.03853058 -0.7487792 -0.6616986 0.1875942 -0.5773454 -0.7946577 0.4712998 -0.5831221 -0.6616986</float_array>
<technique_common>
<accessor source="#Icosphere-mesh-normals-array" count="80" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Icosphere-mesh-map-0">
<float_array id="Icosphere-mesh-map-0-array" count="480">0.2038319 0.6020938 0.07803589 0.775239 2.88122e-4 0.5359594 0.1891562 0.4353454 0.2201194 0.3408505 0.2923961 0.4111046 0.2038319 0.6020938 2.88122e-4 0.5359594 0.2038319 0.3880734 0.2038319 0.6020938 0.2038319 0.3880734 0.4073758 0.5359594 0.2038319 0.6020938 0.4073758 0.5359594 0.329628 0.775239 0.1891562 0.4353454 0.2923961 0.4111046 0.2610388 0.5272238 0.06585121 0.2636542 0.1202549 0.3546833 1.02655e-4 0.3599037 0.1891675 0.09197556 0.120263 0.1726311 0.07693755 0.06042814 0.3900915 0.1577098 0.2924051 0.1162222 0.3863589 0.0410583 0.3900838 0.3696232 0.3989981 0.2636671 0.4998953 0.3296785 0.8690316 0.364753 0.791095 0.5663278 0.6529134 0.364753 0.5301482 0.1791203 0.6523408 0.3573763 0.407952 0.3573763 0.5301446 0.5663277 0.407952 0.3880734 0.6523372 0.3880734 0.20244 0.9919336 0.20244 0.7758153 0.4040137 0.9139961 0.4079523 0.566904 0.6095281 0.6448412 0.407952 0.7830209 0.6099237 0.1577003 0.7076132 0.1162198 0.6911104 0.216345 0.6099155 0.3696137 0.6010091 0.2636568 0.6911069 0.3109756 0.8108381 0.4353509 0.7076001 0.4111025 0.779882 0.3408538 0.934156 0.263669 0.8797454 0.354694 0.833759 0.263666 0.8108526 0.09198099 0.8797511 0.1726418 0.7798885 0.1864736 0.203883 2.88122e-4 0.4073758 0.1482443 0.2038091 0.2143085 0.7798885 0.1864736 0.8797511 0.1726418 0.833759 0.263666 0.8797511 0.1726418 0.934156 0.263669 0.833759 0.263666 0.4073758 0.1482443 0.3295453 0.3874972 0.2038091 0.2143085 0.833759 0.263666 0.8797454 0.354694 0.779882 0.3408538 0.8797454 0.354694 0.8108381 0.4353509 0.779882 0.3408538 0.3295453 0.3874972 0.07795333 0.3874103 0.2038091 0.2143085 0.779882 0.3408538 0.7076001 0.4111025 0.6911069 0.3109756 0.7076001 0.4111025 0.6099155 0.3696137 0.6911069 0.3109756 0.07795333 0.3874103 2.88122e-4 0.1481037 0.2038091 0.2143085 0.6911069 0.3109756 0.6010091 0.2636568 0.6911104 0.216345 0.6010091 0.2636568 0.6099237 0.1577003 0.6911104 0.216345 2.88122e-4 0.1481037 0.203883 2.88122e-4 0.2038091 0.2143085 0.6911104 0.216345 0.7076132 0.1162198 0.7798885 0.1864736 0.7076132 0.1162198 0.8108526 0.09198099 0.7798885 0.1864736 0.923085 0.06044203 0.8797511 0.1726418 0.8108526 0.09198099 0.923085 0.06044203 0.9998974 0.16742 0.8797511 0.1726418 0.9998974 0.16742 0.934156 0.263669 0.8797511 0.1726418 0.9998974 0.3599234 0.8797454 0.354694 0.934156 0.263669 0.9998974 0.3599234 0.923074 0.4668999 0.8797454 0.354694 0.923074 0.4668999 0.8108381 0.4353509 0.8797454 0.354694 0.7389487 0.527224 0.7076001 0.4111025 0.8108381 0.4353509 0.7389487 0.527224 0.6136447 0.4862654 0.7076001 0.4111025 0.6136447 0.4862654 0.6099155 0.3696137 0.7076001 0.4111025 0.5001069 0.3296607 0.6010091 0.2636568 0.6099155 0.3696137 0.5001069 0.3296607 0.5001106 0.1976431 0.6010091 0.2636568 0.5001106 0.1976431 0.6099237 0.1577003 0.6010091 0.2636568 0.613665 0.041049 0.7076132 0.1162198 0.6099237 0.1577003 0.613665 0.041049 0.7389741 1.02655e-4 0.7076132 0.1162198 0.7389741 1.02655e-4 0.8108526 0.09198099 0.7076132 0.1162198 0.6523409 0.178544 0.407952 0.1785441 0.5301446 2.88122e-4 0.4998953 0.3296785 0.3989981 0.2636671 0.4999017 0.1976609 0.3989981 0.2636671 0.3900915 0.1577098 0.4999017 0.1976609 0.7910969 0.2018641 0.6529171 2.88122e-4 0.8690339 2.88122e-4 0.3863589 0.0410583 0.2924051 0.1162222 0.2610529 1.02655e-4 0.2924051 0.1162222 0.1891675 0.09197556 0.2610529 1.02655e-4 0.8116793 0.6448401 0.6101047 0.7830221 0.6101044 0.566904 0.07693755 0.06042814 0.120263 0.1726311 1.17172e-4 0.1674003 0.120263 0.1726311 0.06585121 0.2636542 1.17172e-4 0.1674003 2.88169e-4 0.7758153 0.2018638 0.9139932 2.88122e-4 0.9919315 1.02655e-4 0.3599037 0.1202549 0.3546833 0.07691794 0.466886 0.1202549 0.3546833 0.1891562 0.4353454 0.07691794 0.466886 0.407952 0.7835971 0.6095241 0.9217739 0.407952 0.999712 0.2610388 0.5272238 0.2923961 0.4111046 0.3863458 0.4862747 0.2923961 0.4111046 0.3900838 0.3696232 0.3863458 0.4862747 0.3088967 0.3109791 0.3989981 0.2636671 0.3900838 0.3696232 0.3088967 0.3109791 0.3089004 0.2163485 0.3989981 0.2636671 0.3089004 0.2163485 0.3900915 0.1577098 0.3989981 0.2636671 0.3089004 0.2163485 0.2924051 0.1162222 0.3900915 0.1577098 0.3089004 0.2163485 0.2201245 0.1864705 0.2924051 0.1162222 0.2201245 0.1864705 0.1891675 0.09197556 0.2924051 0.1162222 0.2201245 0.1864705 0.120263 0.1726311 0.1891675 0.09197556 0.2201245 0.1864705 0.1662483 0.2636588 0.120263 0.1726311 0.1662483 0.2636588 0.06585121 0.2636542 0.120263 0.1726311 0.2923961 0.4111046 0.3088967 0.3109791 0.3900838 0.3696232 0.2923961 0.4111046 0.2201194 0.3408505 0.3088967 0.3109791 0.07803589 0.775239 0.2038319 0.6020938 0.329628 0.775239 0.1662483 0.2636588 0.1202549 0.3546833 0.06585121 0.2636542 0.1662483 0.2636588 0.2201194 0.3408505 0.1202549 0.3546833 0.2201194 0.3408505 0.1891562 0.4353454 0.1202549 0.3546833</float_array>
<technique_common>
<accessor source="#Icosphere-mesh-map-0-array" count="240" stride="2">
<param name="S" type="float"/>
<param name="T" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="Icosphere-mesh-vertices">
<input semantic="POSITION" source="#Icosphere-mesh-positions"/>
</vertices>
<polylist material="Material_001-material" count="60">
<input semantic="VERTEX" source="#Icosphere-mesh-vertices" offset="0"/>
<input semantic="NORMAL" source="#Icosphere-mesh-normals" offset="1"/>
<input semantic="TEXCOORD" source="#Icosphere-mesh-map-0" offset="2" set="0"/>
<vcount>3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 </vcount>
<p>1 1 3 13 1 4 15 1 5 1 5 15 15 5 16 22 5 17 2 6 18 14 6 19 24 6 20 3 7 21 18 7 22 26 7 23 4 8 24 20 8 25 28 8 26 5 9 27 21 9 28 30 9 29 6 15 45 32 15 46 37 15 47 7 16 48 33 16 49 39 16 50 8 17 51 34 17 52 40 17 53 9 18 54 35 18 55 41 18 56 10 19 57 36 19 58 38 19 59 38 21 63 36 21 64 41 21 65 36 22 66 9 22 67 41 22 68 41 24 72 35 24 73 40 24 74 35 25 75 8 25 76 40 25 77 40 27 81 34 27 82 39 27 83 34 28 84 7 28 85 39 28 86 39 30 90 33 30 91 37 30 92 33 31 93 6 31 94 37 31 95 37 33 99 32 33 100 38 33 101 32 34 102 10 34 103 38 34 104 23 35 105 36 35 106 10 35 107 23 36 108 30 36 109 36 36 110 30 37 111 9 37 112 36 37 113 31 38 114 35 38 115 9 38 116 31 39 117 28 39 118 35 39 119 28 40 120 8 40 121 35 40 122 29 41 123 34 41 124 8 41 125 29 42 126 26 42 127 34 42 128 26 43 129 7 43 130 34 43 131 27 44 132 33 44 133 7 44 134 27 45 135 24 45 136 33 45 137 24 46 138 6 46 139 33 46 140 25 47 141 32 47 142 6 47 143 25 48 144 22 48 145 32 48 146 22 49 147 10 49 148 32 49 149 30 51 153 21 51 154 31 51 155 21 52 156 4 52 157 31 52 158 28 54 162 20 54 163 29 54 164 20 55 165 3 55 166 29 55 167 26 57 171 18 57 172 27 57 173 18 58 174 2 58 175 27 58 176 24 60 180 14 60 181 25 60 182 14 61 183 1 61 184 25 61 185 22 63 189 15 63 190 23 63 191 15 64 192 5 64 193 23 64 194 16 65 195 21 65 196 5 65 197 16 66 198 19 66 199 21 66 200 19 67 201 4 67 202 21 67 203 19 68 204 20 68 205 4 68 206 19 69 207 17 69 208 20 69 209 17 70 210 3 70 211 20 70 212 17 71 213 18 71 214 3 71 215 17 72 216 12 72 217 18 72 218 12 73 219 2 73 220 18 73 221 15 74 222 16 74 223 5 74 224 15 75 225 13 75 226 16 75 227 12 77 231 14 77 232 2 77 233 12 78 234 13 78 235 14 78 236 13 79 237 1 79 238 14 79 239</p>
</polylist>
<polylist material="Material_002-material" count="20">
<input semantic="VERTEX" source="#Icosphere-mesh-vertices" offset="0"/>
<input semantic="NORMAL" source="#Icosphere-mesh-normals" offset="1"/>
<input semantic="TEXCOORD" source="#Icosphere-mesh-map-0" offset="2" set="0"/>
<vcount>3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 </vcount>
<p>0 0 0 13 0 1 12 0 2 0 2 6 12 2 7 17 2 8 0 3 9 17 3 10 19 3 11 0 4 12 19 4 13 16 4 14 1 10 30 22 10 31 25 10 32 2 11 33 24 11 34 27 11 35 3 12 36 26 12 37 29 12 38 4 13 39 28 13 40 31 13 41 5 14 42 30 14 43 23 14 44 38 20 60 41 20 61 11 20 62 41 23 69 40 23 70 11 23 71 40 26 78 39 26 79 11 26 80 39 29 87 37 29 88 11 29 89 37 32 96 38 32 97 11 32 98 30 50 150 31 50 151 9 50 152 28 53 159 29 53 160 8 53 161 26 56 168 27 56 169 7 56 170 24 59 177 25 59 178 6 59 179 22 62 186 23 62 187 10 62 188 13 76 228 0 76 229 16 76 230</p>
</polylist>
</mesh>
</geometry>
</library_geometries>
<library_controllers/>
<library_visual_scenes>
<visual_scene id="Scene" name="Scene">
<node id="Icosphere" name="Icosphere" type="NODE">
<matrix sid="transform">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix>
<instance_geometry url="#Icosphere-mesh" name="Icosphere">
<bind_material>
<technique_common>
<instance_material symbol="Material_001-material" target="#Material_001-material"/>
<instance_material symbol="Material_002-material" target="#Material_002-material"/>
</technique_common>
</bind_material>
</instance_geometry>
</node>
</visual_scene>
</library_visual_scenes>
<scene>
<instance_visual_scene url="#Scene"/>
</scene>
</COLLADA>
File diff suppressed because one or more lines are too long
@@ -12,6 +12,8 @@
<Yacht SourceID="105" />
<Yacht SourceID="106" />
</Participants>
<Tokens>
</Tokens>
<Course>
<CompoundMark CompoundMarkID="1" Name="Mark0">
<Mark SeqID="1" Name="Start Line 1" TargetLat="57.6703330" TargetLng="11.8278330" SourceID="122" />
@@ -4,13 +4,16 @@
<RaceStartTime Start="${raceStartTime}" Postpone="False" />
<RaceID>15082901</RaceID>
<RaceType>Fleet</RaceType>
<Participants>
<#list boats as boat>
<Yacht SourceID="${boat.sourceId}"/>
</#list>
</Participants>
<Tokens>
<#list tokens as token>
<Token TokenType="${token.tokenType}" TargetLat="${token.lat?c}" TargetLng="${token.lng?c}"/>
</#list>
</Tokens>
<Course>
<CompoundMark CompoundMarkID="1" Name="Mark0">
<Mark SeqID="1" Name="Start Line 1" TargetLat="57.670603" TargetLng="11.828262" SourceID="122" />