Terrain streaming, begin work on world gen/sim
This commit is contained in:
parent
c13f137f68
commit
2926f8b49b
@ -76,7 +76,7 @@ public class DrawCell {
|
|||||||
Model terrainModel = ModelUtils.createTerrainModelPrecomputedShader(heightmap, program, stride);
|
Model terrainModel = ModelUtils.createTerrainModelPrecomputedShader(heightmap, program, stride);
|
||||||
String terrainModelPath = Globals.assetManager.registerModel(terrainModel);
|
String terrainModelPath = Globals.assetManager.registerModel(terrainModel);
|
||||||
modelEntity = EntityUtils.spawnDrawableEntity(terrainModelPath);
|
modelEntity = EntityUtils.spawnDrawableEntity(terrainModelPath);
|
||||||
// System.out.println("New cell @ " + cellX * cellWidth + "," + cellY * cellWidth);
|
System.out.println("New cell @ " + cellX * dynamicInterpolationRatio + "," + cellY * dynamicInterpolationRatio);
|
||||||
EntityUtils.getEntityPosition(modelEntity).set(new Vector3f(cellX * dynamicInterpolationRatio, 0.01f, cellY * dynamicInterpolationRatio));
|
EntityUtils.getEntityPosition(modelEntity).set(new Vector3f(cellX * dynamicInterpolationRatio, 0.01f, cellY * dynamicInterpolationRatio));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -58,7 +58,7 @@ public class DrawCellManager {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public DrawCellManager(ClientWorldData clientWorldData, ClientTerrainManager clientTerrainManager, float realX, float realY){
|
public DrawCellManager(ClientWorldData clientWorldData, ClientTerrainManager clientTerrainManager, int discreteX, int discreteY){
|
||||||
this.clientWorldData = clientWorldData;
|
this.clientWorldData = clientWorldData;
|
||||||
this.clientTerrainManager = clientTerrainManager;
|
this.clientTerrainManager = clientTerrainManager;
|
||||||
this.miniCellWidth = miniCellWidth;
|
this.miniCellWidth = miniCellWidth;
|
||||||
@ -75,8 +75,8 @@ public class DrawCellManager {
|
|||||||
hasRequested[x][y] = false;
|
hasRequested[x][y] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cellX = transformRealSpaceToCellSpace(realX);
|
cellX = discreteX;
|
||||||
cellY = transformRealSpaceToCellSpace(realY);
|
cellY = discreteY;
|
||||||
|
|
||||||
program = Globals.defaultMeshShader;
|
program = Globals.defaultMeshShader;
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ public class DrawCellManager {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(found){
|
if(found){
|
||||||
int currentCellX = cellX - drawRadius + targetX;
|
int currentCellX = cellX - drawRadius + targetX;
|
||||||
int currentCellY = cellY - drawRadius + targetY;
|
int currentCellY = cellY - drawRadius + targetY;
|
||||||
@ -187,11 +187,13 @@ public class DrawCellManager {
|
|||||||
currentCellY >= 0 &&
|
currentCellY >= 0 &&
|
||||||
currentCellY < clientWorldData.getWorldDiscreteSize()
|
currentCellY < clientWorldData.getWorldDiscreteSize()
|
||||||
){
|
){
|
||||||
|
//calculation for stride
|
||||||
int dist = (int)Math.sqrt((targetX - drawRadius)*(targetX - drawRadius) + (targetY - drawRadius) * (targetY - drawRadius));//Math.abs(targetX - drawRadius) * Math.abs(targetY - drawRadius);
|
int dist = (int)Math.sqrt((targetX - drawRadius)*(targetX - drawRadius) + (targetY - drawRadius) * (targetY - drawRadius));//Math.abs(targetX - drawRadius) * Math.abs(targetY - drawRadius);
|
||||||
int stride = Math.min(clientWorldData.getDynamicInterpolationRatio()/2, Math.max(1, dist / drawStepdownInterval * drawStepdownValue));
|
int stride = Math.min(clientWorldData.getDynamicInterpolationRatio()/2, Math.max(1, dist / drawStepdownInterval * drawStepdownValue));
|
||||||
while(clientWorldData.getDynamicInterpolationRatio() % stride != 0){
|
while(clientWorldData.getDynamicInterpolationRatio() % stride != 0){
|
||||||
stride = stride + 1;
|
stride = stride + 1;
|
||||||
}
|
}
|
||||||
|
//make drawable entity
|
||||||
cells[targetX][targetY].generateDrawableEntity(stride);
|
cells[targetX][targetY].generateDrawableEntity(stride);
|
||||||
}
|
}
|
||||||
drawable[targetX][targetY] = true;
|
drawable[targetX][targetY] = true;
|
||||||
|
|||||||
@ -0,0 +1,31 @@
|
|||||||
|
package electrosphere.game.client.player;
|
||||||
|
|
||||||
|
public class ClientPlayerData {
|
||||||
|
int initialDiscretePositionX;
|
||||||
|
int initialDiscretePositionY;
|
||||||
|
|
||||||
|
boolean loaded = false;
|
||||||
|
|
||||||
|
public ClientPlayerData(){
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasLoaded(){
|
||||||
|
return loaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInitialDiscretePosition(int x, int y){
|
||||||
|
initialDiscretePositionX = x;
|
||||||
|
initialDiscretePositionY = y;
|
||||||
|
loaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInitialDiscretePositionX() {
|
||||||
|
return initialDiscretePositionX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInitialDiscretePositionY() {
|
||||||
|
return initialDiscretePositionY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package electrosphere.game.server.character;
|
||||||
|
|
||||||
|
public class AdvancedPersonality {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package electrosphere.game.server.character;
|
||||||
|
|
||||||
|
public class BasicPersonality {
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,9 +1,15 @@
|
|||||||
package electrosphere.game.server.character;
|
package electrosphere.game.server.character;
|
||||||
|
|
||||||
/**
|
import electrosphere.game.server.character.diety.Diety;
|
||||||
*
|
|
||||||
* @author amaterasu
|
|
||||||
*/
|
|
||||||
public class Character {
|
public class Character {
|
||||||
|
boolean isDiety;
|
||||||
|
Diety diety;
|
||||||
|
boolean hasBasicPersonality;
|
||||||
|
BasicPersonality basicPersonality;
|
||||||
|
boolean hasAdvancedPersonality;
|
||||||
|
AdvancedPersonality advancedPersonality;
|
||||||
|
int discreteX;
|
||||||
|
int discreteY;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,26 @@
|
|||||||
|
package electrosphere.game.server.character;
|
||||||
|
|
||||||
|
import electrosphere.game.server.culture.Culture;
|
||||||
|
import electrosphere.game.server.character.Character;
|
||||||
|
import electrosphere.game.server.creature.type.CreatureType;
|
||||||
|
|
||||||
|
public class CharacterGenerator {
|
||||||
|
|
||||||
|
public static Character generateCharacter(CreatureType creature, Culture culture){
|
||||||
|
Character character = new Character();
|
||||||
|
|
||||||
|
return character;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void positionCharacter(Character c, int x, int y){
|
||||||
|
c.discreteX = x;
|
||||||
|
c.discreteY = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Character generateDietyOfArchetype(){
|
||||||
|
Character character = new Character();
|
||||||
|
|
||||||
|
return character;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package electrosphere.game.server.character.diety;
|
||||||
|
|
||||||
|
public class Diety {
|
||||||
|
|
||||||
|
int godlyPower;
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package electrosphere.game.server.civilization;
|
||||||
|
|
||||||
|
public class Civilization {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package electrosphere.game.server.civilization.model;
|
||||||
|
|
||||||
|
public class CivilizationMap {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package electrosphere.game.server.creature.type;
|
||||||
|
|
||||||
|
public class BodyPart {
|
||||||
|
int bodyPartClass;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package electrosphere.game.server.creature.type;
|
||||||
|
|
||||||
|
public class CreatureType {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package electrosphere.game.server.creature.type.model;
|
||||||
|
|
||||||
|
public class CreatureTypeMap {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package electrosphere.game.server.culture;
|
||||||
|
|
||||||
|
public class Culture {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package electrosphere.game.server.culture;
|
||||||
|
|
||||||
|
public class Ritual {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package electrosphere.game.server.culture.religion;
|
||||||
|
|
||||||
|
public class Religion {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package electrosphere.game.server.settlement;
|
||||||
|
|
||||||
|
public class Settlement {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
package electrosphere.game.server.simulation;
|
||||||
|
|
||||||
|
import electrosphere.game.server.civilization.Civilization;
|
||||||
|
import electrosphere.game.server.civilization.model.CivilizationMap;
|
||||||
|
import electrosphere.game.server.creature.type.CreatureType;
|
||||||
|
import electrosphere.game.server.creature.type.model.CreatureTypeMap;
|
||||||
|
import electrosphere.game.server.culture.Culture;
|
||||||
|
import electrosphere.game.server.culture.religion.Religion;
|
||||||
|
import electrosphere.util.Utilities;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Simulation {
|
||||||
|
|
||||||
|
List<Civilization> civilizationList = new LinkedList();
|
||||||
|
List<Culture> cultureList = new LinkedList();
|
||||||
|
List<Religion> religionList = new LinkedList();
|
||||||
|
List<CreatureType> creatureList = new LinkedList();
|
||||||
|
List<Character> characterList = new LinkedList();
|
||||||
|
|
||||||
|
public Simulation(){
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void init(){
|
||||||
|
CreatureTypeMap creatureTypeMap = Utilities.loadObjectFromBakedJsonFile("Data/creatures.json", CreatureTypeMap.class);
|
||||||
|
CivilizationMap civilizationMap = Utilities.loadObjectFromBakedJsonFile("Data/civilization.json", CivilizationMap.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void simulate(){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -14,9 +14,9 @@ class InterpolationDisplay extends JPanel{
|
|||||||
if(TerrainGen.display_toggle == 0) {
|
if(TerrainGen.display_toggle == 0) {
|
||||||
for (int x = 0; x < TerrainGen.DIMENSION; x++) {
|
for (int x = 0; x < TerrainGen.DIMENSION; x++) {
|
||||||
for (int y = 0; y < TerrainGen.DIMENSION; y++) {
|
for (int y = 0; y < TerrainGen.DIMENSION; y++) {
|
||||||
if (TerrainGen.mountain_parsed[x][y] > TerrainGen.mountain_Threshold - 1) {
|
if (TerrainGen.mountainParsed[x][y] > TerrainGen.MOUNTAIN_THRESHOLD - 1) {
|
||||||
g.setColor(new Color((int) (TerrainGen.elevation[x][y] / 100.0 * 254 * (TerrainGen.brightness / 100.0)), 1, 1));
|
g.setColor(new Color((int) (TerrainGen.elevation[x][y] / 100.0 * 254 * (TerrainGen.brightness / 100.0)), 1, 1));
|
||||||
} else if (TerrainGen.ocean_parsed[x][y] > TerrainGen.ocean_Threshold - 1) {
|
} else if (TerrainGen.oceanParsed[x][y] > TerrainGen.OCEAN_THRESHOLD - 1) {
|
||||||
g.setColor(
|
g.setColor(
|
||||||
new Color(
|
new Color(
|
||||||
1,
|
1,
|
||||||
@ -33,7 +33,7 @@ class InterpolationDisplay extends JPanel{
|
|||||||
} else if(TerrainGen.display_toggle == 1){
|
} else if(TerrainGen.display_toggle == 1){
|
||||||
for (int x = 0; x < TerrainGen.DIMENSION; x++) {
|
for (int x = 0; x < TerrainGen.DIMENSION; x++) {
|
||||||
for (int y = 0; y < TerrainGen.DIMENSION; y++) {
|
for (int y = 0; y < TerrainGen.DIMENSION; y++) {
|
||||||
if (TerrainGen.precipitation_Chart[x][y] > 0) {
|
if (TerrainGen.precipitationChart[x][y] > 0) {
|
||||||
g.setColor(
|
g.setColor(
|
||||||
new Color(
|
new Color(
|
||||||
1,
|
1,
|
||||||
@ -53,7 +53,7 @@ class InterpolationDisplay extends JPanel{
|
|||||||
// if (TerrainInterpolator.precipitation_Chart[x][y] > 0) {
|
// if (TerrainInterpolator.precipitation_Chart[x][y] > 0) {
|
||||||
g.setColor(
|
g.setColor(
|
||||||
new Color(
|
new Color(
|
||||||
(int) ((TerrainGen.temperature_Chart[x][y]) / 100.0 * 254 * (TerrainGen.brightness / 100.0)),
|
(int) ((TerrainGen.temperatureChart[x][y]) / 100.0 * 254 * (TerrainGen.brightness / 100.0)),
|
||||||
(int) ((TerrainGen.elevation[x][y]) / 100.0 * 254 * (TerrainGen.brightness / 100.0)),
|
(int) ((TerrainGen.elevation[x][y]) / 100.0 * 254 * (TerrainGen.brightness / 100.0)),
|
||||||
1
|
1
|
||||||
)
|
)
|
||||||
@ -67,7 +67,7 @@ class InterpolationDisplay extends JPanel{
|
|||||||
} else if(TerrainGen.display_toggle == 3){
|
} else if(TerrainGen.display_toggle == 3){
|
||||||
for (int x = 0; x < TerrainGen.DIMENSION; x++) {
|
for (int x = 0; x < TerrainGen.DIMENSION; x++) {
|
||||||
for (int y = 0; y < TerrainGen.DIMENSION; y++) {
|
for (int y = 0; y < TerrainGen.DIMENSION; y++) {
|
||||||
if (TerrainGen.climate_category[x][y] == 0) {
|
if (TerrainGen.climateCategory[x][y] == 0) {
|
||||||
g.setColor(Color.BLUE);
|
g.setColor(Color.BLUE);
|
||||||
// g.setColor(
|
// g.setColor(
|
||||||
// new Color(
|
// new Color(
|
||||||
@ -76,7 +76,7 @@ class InterpolationDisplay extends JPanel{
|
|||||||
// (int) ((TerrainInterpolator.elevation[x][y]) / 100.0 * 254 * (TerrainInterpolator.brightness / 100.0))
|
// (int) ((TerrainInterpolator.elevation[x][y]) / 100.0 * 254 * (TerrainInterpolator.brightness / 100.0))
|
||||||
// )
|
// )
|
||||||
// );
|
// );
|
||||||
} else if(TerrainGen.climate_category[x][y] == 1){
|
} else if(TerrainGen.climateCategory[x][y] == 1){
|
||||||
g.setColor(Color.RED);
|
g.setColor(Color.RED);
|
||||||
// g.setColor(
|
// g.setColor(
|
||||||
// new Color(
|
// new Color(
|
||||||
@ -85,7 +85,7 @@ class InterpolationDisplay extends JPanel{
|
|||||||
// 1
|
// 1
|
||||||
// )
|
// )
|
||||||
// );
|
// );
|
||||||
} else if(TerrainGen.climate_category[x][y] == 2){
|
} else if(TerrainGen.climateCategory[x][y] == 2){
|
||||||
g.setColor(Color.GREEN);
|
g.setColor(Color.GREEN);
|
||||||
// g.setColor(
|
// g.setColor(
|
||||||
// new Color(
|
// new Color(
|
||||||
@ -94,7 +94,7 @@ class InterpolationDisplay extends JPanel{
|
|||||||
// 1
|
// 1
|
||||||
// )
|
// )
|
||||||
// );
|
// );
|
||||||
} else if(TerrainGen.climate_category[x][y] == 3){
|
} else if(TerrainGen.climateCategory[x][y] == 3){
|
||||||
g.setColor(Color.YELLOW);
|
g.setColor(Color.YELLOW);
|
||||||
// g.setColor(
|
// g.setColor(
|
||||||
// new Color(
|
// new Color(
|
||||||
@ -103,7 +103,7 @@ class InterpolationDisplay extends JPanel{
|
|||||||
// (int) ((TerrainInterpolator.elevation[x][y]) / 100.0 * 254 * (TerrainInterpolator.brightness / 100.0))
|
// (int) ((TerrainInterpolator.elevation[x][y]) / 100.0 * 254 * (TerrainInterpolator.brightness / 100.0))
|
||||||
// )
|
// )
|
||||||
// );
|
// );
|
||||||
} else if(TerrainGen.climate_category[x][y] == 4){
|
} else if(TerrainGen.climateCategory[x][y] == 4){
|
||||||
g.setColor(
|
g.setColor(
|
||||||
new Color(
|
new Color(
|
||||||
(int) ((TerrainGen.elevation[x][y]) / 100.0 * 254 * (TerrainGen.brightness / 100.0)),
|
(int) ((TerrainGen.elevation[x][y]) / 100.0 * 254 * (TerrainGen.brightness / 100.0)),
|
||||||
@ -112,7 +112,7 @@ class InterpolationDisplay extends JPanel{
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
g.setColor(Color.ORANGE);
|
g.setColor(Color.ORANGE);
|
||||||
} else if(TerrainGen.climate_category[x][y] == 5){
|
} else if(TerrainGen.climateCategory[x][y] == 5){
|
||||||
g.setColor(
|
g.setColor(
|
||||||
new Color(
|
new Color(
|
||||||
(int) ((TerrainGen.elevation[x][y]) / 100.0 * 254 * (TerrainGen.brightness / 100.0)),
|
(int) ((TerrainGen.elevation[x][y]) / 100.0 * 254 * (TerrainGen.brightness / 100.0)),
|
||||||
@ -121,7 +121,7 @@ class InterpolationDisplay extends JPanel{
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
g.setColor(Color.BLACK);
|
g.setColor(Color.BLACK);
|
||||||
} else if(TerrainGen.climate_category[x][y] == 6){
|
} else if(TerrainGen.climateCategory[x][y] == 6){
|
||||||
g.setColor(
|
g.setColor(
|
||||||
new Color(
|
new Color(
|
||||||
(int) ((TerrainGen.elevation[x][y]) / 100.0 * 254 * (TerrainGen.brightness / 100.0)),
|
(int) ((TerrainGen.elevation[x][y]) / 100.0 * 254 * (TerrainGen.brightness / 100.0)),
|
||||||
@ -138,23 +138,23 @@ class InterpolationDisplay extends JPanel{
|
|||||||
} else if(TerrainGen.display_toggle == 4){
|
} else if(TerrainGen.display_toggle == 4){
|
||||||
for (int x = 0; x < TerrainGen.DIMENSION; x++) {
|
for (int x = 0; x < TerrainGen.DIMENSION; x++) {
|
||||||
for (int y = 0; y < TerrainGen.DIMENSION; y++) {
|
for (int y = 0; y < TerrainGen.DIMENSION; y++) {
|
||||||
if (TerrainGen.continent_Number[x][y] > 8) {
|
if (TerrainGen.continentIdField[x][y] > 8) {
|
||||||
g.setColor(Color.PINK);
|
g.setColor(Color.PINK);
|
||||||
} else if (TerrainGen.continent_Number[x][y] > 7) {
|
} else if (TerrainGen.continentIdField[x][y] > 7) {
|
||||||
g.setColor(Color.DARK_GRAY);
|
g.setColor(Color.DARK_GRAY);
|
||||||
} else if (TerrainGen.continent_Number[x][y] > 6) {
|
} else if (TerrainGen.continentIdField[x][y] > 6) {
|
||||||
g.setColor(Color.CYAN);
|
g.setColor(Color.CYAN);
|
||||||
} else if (TerrainGen.continent_Number[x][y] > 5) {
|
} else if (TerrainGen.continentIdField[x][y] > 5) {
|
||||||
g.setColor(Color.GRAY);
|
g.setColor(Color.GRAY);
|
||||||
} else if (TerrainGen.continent_Number[x][y] > 4) {
|
} else if (TerrainGen.continentIdField[x][y] > 4) {
|
||||||
g.setColor(Color.orange);
|
g.setColor(Color.orange);
|
||||||
} else if (TerrainGen.continent_Number[x][y] > 3) {
|
} else if (TerrainGen.continentIdField[x][y] > 3) {
|
||||||
g.setColor(Color.green);
|
g.setColor(Color.green);
|
||||||
} else if (TerrainGen.continent_Number[x][y] > 2) {
|
} else if (TerrainGen.continentIdField[x][y] > 2) {
|
||||||
g.setColor(Color.yellow);
|
g.setColor(Color.yellow);
|
||||||
} else if (TerrainGen.continent_Number[x][y] > 1) {
|
} else if (TerrainGen.continentIdField[x][y] > 1) {
|
||||||
g.setColor(Color.blue);
|
g.setColor(Color.blue);
|
||||||
} else if (TerrainGen.continent_Number[x][y] > 0) {
|
} else if (TerrainGen.continentIdField[x][y] > 0) {
|
||||||
g.setColor(Color.red);
|
g.setColor(Color.red);
|
||||||
} else {
|
} else {
|
||||||
g.setColor(Color.BLACK);
|
g.setColor(Color.BLACK);
|
||||||
|
|||||||
@ -1,9 +0,0 @@
|
|||||||
package electrosphere.game.server.terrain.generation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author satellite
|
|
||||||
*/
|
|
||||||
class MidoceanicRidge {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -37,19 +37,19 @@ public class TerrainGen {
|
|||||||
public static int display_toggle = 0;
|
public static int display_toggle = 0;
|
||||||
static final int max_Display_Toggle = 6;
|
static final int max_Display_Toggle = 6;
|
||||||
|
|
||||||
public static int mountain_parsed[][];
|
public static int[][] mountainParsed;
|
||||||
static final int mountain_Threshold = 75;
|
static final int MOUNTAIN_THRESHOLD = 75;
|
||||||
static final int mountain_Range_Size_Minimum = 10;
|
static final int MOUNTAIN_RANGE_SIZE_MINIMUM = 10;
|
||||||
|
|
||||||
public static int ocean_parsed[][];
|
public static int[][] oceanParsed;
|
||||||
static final int ocean_Threshold = 25;
|
static final int OCEAN_THRESHOLD = 25;
|
||||||
|
|
||||||
static Vector wind_field[][];
|
static Vector wind_field[][];
|
||||||
|
|
||||||
public static int[][] precipitation_Chart;
|
public static int[][] precipitationChart;
|
||||||
static final int rain_Shadow_Blocker_Height = 80;
|
static final int RAIN_SHADOW_BLOCKER_HEIGHT = 80;
|
||||||
|
|
||||||
public static int[][] temperature_Chart;
|
public static int[][] temperatureChart;
|
||||||
|
|
||||||
public static long[][] chunkRandomizer;
|
public static long[][] chunkRandomizer;
|
||||||
|
|
||||||
@ -62,10 +62,10 @@ public class TerrainGen {
|
|||||||
5 - polar
|
5 - polar
|
||||||
6 - mountainous
|
6 - mountainous
|
||||||
*/
|
*/
|
||||||
public static int[][] climate_category;
|
public static int[][] climateCategory;
|
||||||
|
|
||||||
public static int num_Continents = 0;
|
public static int numberContinents = 0;
|
||||||
public static int[][] continent_Number;
|
public static int[][] continentIdField;
|
||||||
|
|
||||||
public static ArrayList<Continent> continents = new ArrayList();
|
public static ArrayList<Continent> continents = new ArrayList();
|
||||||
|
|
||||||
@ -100,21 +100,21 @@ public class TerrainGen {
|
|||||||
elevation = land_exponential_filter(elevation);
|
elevation = land_exponential_filter(elevation);
|
||||||
elevation = land_exponential_filter(elevation);
|
elevation = land_exponential_filter(elevation);
|
||||||
|
|
||||||
mountain_parsed = new int[DIMENSION][DIMENSION];
|
mountainParsed = new int[DIMENSION][DIMENSION];
|
||||||
ocean_parsed = new int[DIMENSION][DIMENSION];
|
oceanParsed = new int[DIMENSION][DIMENSION];
|
||||||
continent_Number = new int[DIMENSION][DIMENSION];
|
continentIdField = new int[DIMENSION][DIMENSION];
|
||||||
|
|
||||||
mountain_parsed = parse_Mountainscapes(elevation);
|
mountainParsed = parse_Mountainscapes(elevation);
|
||||||
|
|
||||||
ocean_parsed = parse_Oceans(elevation);
|
oceanParsed = parse_Oceans(elevation);
|
||||||
|
|
||||||
wind_field = map_Wind_Field();
|
wind_field = map_Wind_Field();
|
||||||
|
|
||||||
precipitation_Chart = calculate_Rain_Shadows(elevation,ocean_parsed,wind_field);
|
precipitationChart = calculate_Rain_Shadows(elevation,oceanParsed,wind_field);
|
||||||
|
|
||||||
temperature_Chart = generate_Temperature_Chart();
|
temperatureChart = generate_Temperature_Chart();
|
||||||
|
|
||||||
climate_category = infer_Climate_Category();
|
climateCategory = infer_Climate_Category();
|
||||||
|
|
||||||
determine_Continents();
|
determine_Continents();
|
||||||
|
|
||||||
@ -177,22 +177,24 @@ public class TerrainGen {
|
|||||||
elevation = land_exponential_filter(elevation);
|
elevation = land_exponential_filter(elevation);
|
||||||
elevation = land_exponential_filter(elevation);
|
elevation = land_exponential_filter(elevation);
|
||||||
elevation = land_exponential_filter(elevation);
|
elevation = land_exponential_filter(elevation);
|
||||||
|
elevation = land_exponential_filter(elevation);
|
||||||
|
elevation = land_exponential_filter(elevation);
|
||||||
|
|
||||||
mountain_parsed = new int[DIMENSION][DIMENSION];
|
mountainParsed = new int[DIMENSION][DIMENSION];
|
||||||
ocean_parsed = new int[DIMENSION][DIMENSION];
|
oceanParsed = new int[DIMENSION][DIMENSION];
|
||||||
continent_Number = new int[DIMENSION][DIMENSION];
|
continentIdField = new int[DIMENSION][DIMENSION];
|
||||||
|
|
||||||
mountain_parsed = parse_Mountainscapes(elevation);
|
mountainParsed = parse_Mountainscapes(elevation);
|
||||||
|
|
||||||
ocean_parsed = parse_Oceans(elevation);
|
oceanParsed = parse_Oceans(elevation);
|
||||||
|
|
||||||
wind_field = map_Wind_Field();
|
wind_field = map_Wind_Field();
|
||||||
|
|
||||||
precipitation_Chart = calculate_Rain_Shadows(elevation,ocean_parsed,wind_field);
|
precipitationChart = calculate_Rain_Shadows(elevation,oceanParsed,wind_field);
|
||||||
|
|
||||||
temperature_Chart = generate_Temperature_Chart();
|
temperatureChart = generate_Temperature_Chart();
|
||||||
|
|
||||||
climate_category = infer_Climate_Category();
|
climateCategory = infer_Climate_Category();
|
||||||
|
|
||||||
determine_Continents();
|
determine_Continents();
|
||||||
|
|
||||||
@ -204,7 +206,14 @@ public class TerrainGen {
|
|||||||
|
|
||||||
chunkRandomizer = getChunkRandomizer(modelInput, DIMENSION);
|
chunkRandomizer = getChunkRandomizer(modelInput, DIMENSION);
|
||||||
|
|
||||||
rVal = new TerrainModel(DIMENSION,modelInput,chunkRandomizer,dynamicInterpRatio);
|
rVal = new TerrainModel(
|
||||||
|
DIMENSION,
|
||||||
|
modelInput,
|
||||||
|
chunkRandomizer,
|
||||||
|
OCEAN_THRESHOLD * verticalInterpolationRatio,
|
||||||
|
MOUNTAIN_THRESHOLD * verticalInterpolationRatio,
|
||||||
|
dynamicInterpRatio
|
||||||
|
);
|
||||||
|
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
@ -359,7 +368,7 @@ public class TerrainGen {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sum_Array(int[][] arr, int dim_x, int dim_y){
|
static int sumIntegerArray(int[][] arr, int dim_x, int dim_y){
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for(int x = 0; x < dim_x; x++){
|
for(int x = 0; x < dim_x; x++){
|
||||||
for(int y = 0; y < dim_y; y++){
|
for(int y = 0; y < dim_y; y++){
|
||||||
@ -631,7 +640,7 @@ public class TerrainGen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void fill_Continents(){
|
static void fill_Continents(){
|
||||||
for(int i = 1; i < num_Continents + 1; i++){
|
for(int i = 1; i < numberContinents + 1; i++){
|
||||||
Continent current = new Continent();
|
Continent current = new Continent();
|
||||||
continents.add(current);
|
continents.add(current);
|
||||||
//find dimensions
|
//find dimensions
|
||||||
@ -641,7 +650,7 @@ public class TerrainGen {
|
|||||||
int max_y = -1;
|
int max_y = -1;
|
||||||
for(int x = 0; x < DIMENSION; x++){
|
for(int x = 0; x < DIMENSION; x++){
|
||||||
for(int y = 0; y < DIMENSION; y++){
|
for(int y = 0; y < DIMENSION; y++){
|
||||||
if(continent_Number[x][y] == i){
|
if(continentIdField[x][y] == i){
|
||||||
if(min_x == -1){
|
if(min_x == -1){
|
||||||
min_x = x;
|
min_x = x;
|
||||||
min_y = y;
|
min_y = y;
|
||||||
@ -686,12 +695,12 @@ public class TerrainGen {
|
|||||||
//fill continent level arrays
|
//fill continent level arrays
|
||||||
for(int x = 0; x < DIMENSION; x++){
|
for(int x = 0; x < DIMENSION; x++){
|
||||||
for(int y = 0; y < DIMENSION; y++){
|
for(int y = 0; y < DIMENSION; y++){
|
||||||
if(continent_Number[x][y] == i){
|
if(continentIdField[x][y] == i){
|
||||||
current.size++;
|
current.size++;
|
||||||
current.elevation[x-min_x][y-min_y] = elevation[x][y];
|
current.elevation[x-min_x][y-min_y] = elevation[x][y];
|
||||||
current.chart_Climate[x-min_x][y-min_y] = climate_category[x][y];
|
current.chart_Climate[x-min_x][y-min_y] = climateCategory[x][y];
|
||||||
current.chart_Precipitation[x-min_x][y-min_y] = precipitation_Chart[x][y];
|
current.chart_Precipitation[x-min_x][y-min_y] = precipitationChart[x][y];
|
||||||
current.chart_Temperature[x-min_x][y-min_y] = temperature_Chart[x][y];
|
current.chart_Temperature[x-min_x][y-min_y] = temperatureChart[x][y];
|
||||||
current.chart_Wind_Macro[x-min_x][y-min_y] = wind_field[x][y].x;
|
current.chart_Wind_Macro[x-min_x][y-min_y] = wind_field[x][y].x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -700,7 +709,7 @@ public class TerrainGen {
|
|||||||
current.regions = new Region[dim_x][dim_y];
|
current.regions = new Region[dim_x][dim_y];
|
||||||
for(int x = 0; x < dim_x; x++){
|
for(int x = 0; x < dim_x; x++){
|
||||||
for(int y = 0; y < dim_y; y++){
|
for(int y = 0; y < dim_y; y++){
|
||||||
if(continent_Number[x+min_x][y+min_y] == i){
|
if(continentIdField[x+min_x][y+min_y] == i){
|
||||||
current.regions[x][y] = new Region();
|
current.regions[x][y] = new Region();
|
||||||
current.regions[x][y].elevation_Goal = current.elevation[x][y];
|
current.regions[x][y].elevation_Goal = current.elevation[x][y];
|
||||||
} else {
|
} else {
|
||||||
@ -713,14 +722,14 @@ public class TerrainGen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void floodfill_Continent_Number(int x, int y, int number){
|
static void floodfill_Continent_Number(int x, int y, int number){
|
||||||
continent_Number[x][y] = number;
|
continentIdField[x][y] = number;
|
||||||
int offset_X[] = {0,-1,0,1};
|
int offset_X[] = {0,-1,0,1};
|
||||||
int offset_Y[] = {1,0,-1,0};
|
int offset_Y[] = {1,0,-1,0};
|
||||||
for(int i = 0; i < 4; i++){
|
for(int i = 0; i < 4; i++){
|
||||||
if(x + offset_X[i] >= 0 && x + offset_Y[i] < DIMENSION){
|
if(x + offset_X[i] >= 0 && x + offset_Y[i] < DIMENSION){
|
||||||
if(y + offset_Y[i] >= 0 && y + offset_Y[i] < DIMENSION){
|
if(y + offset_Y[i] >= 0 && y + offset_Y[i] < DIMENSION){
|
||||||
if(ocean_parsed[x + offset_X[i]][y + offset_Y[i]] < 25){
|
if(oceanParsed[x + offset_X[i]][y + offset_Y[i]] < 25){
|
||||||
if(continent_Number[x + offset_X[i]][y + offset_Y[i]] == 0){
|
if(continentIdField[x + offset_X[i]][y + offset_Y[i]] == 0){
|
||||||
floodfill_Continent_Number(x + offset_X[i], y + offset_Y[i], number);
|
floodfill_Continent_Number(x + offset_X[i], y + offset_Y[i], number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -732,10 +741,10 @@ public class TerrainGen {
|
|||||||
static void determine_Continents(){
|
static void determine_Continents(){
|
||||||
for(int x = 0; x < DIMENSION; x++){
|
for(int x = 0; x < DIMENSION; x++){
|
||||||
for(int y = 0; y < DIMENSION; y++){
|
for(int y = 0; y < DIMENSION; y++){
|
||||||
if(ocean_parsed[x][y] < 25){
|
if(oceanParsed[x][y] < 25){
|
||||||
if(continent_Number[x][y] == 0){
|
if(continentIdField[x][y] == 0){
|
||||||
num_Continents++;
|
numberContinents++;
|
||||||
floodfill_Continent_Number(x,y,num_Continents);
|
floodfill_Continent_Number(x,y,numberContinents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -755,26 +764,26 @@ public class TerrainGen {
|
|||||||
int rVal[][] = new int[DIMENSION][DIMENSION];
|
int rVal[][] = new int[DIMENSION][DIMENSION];
|
||||||
for(int x = 0; x < DIMENSION; x++){
|
for(int x = 0; x < DIMENSION; x++){
|
||||||
for(int y = 0; y < DIMENSION; y++) {
|
for(int y = 0; y < DIMENSION; y++) {
|
||||||
if (elevation[x][y] > ocean_Threshold) {
|
if (elevation[x][y] > OCEAN_THRESHOLD) {
|
||||||
if (elevation[x][y] > mountain_Threshold) {
|
if (elevation[x][y] > MOUNTAIN_THRESHOLD) {
|
||||||
rVal[x][y] = 6;
|
rVal[x][y] = 6;
|
||||||
} else {
|
} else {
|
||||||
if (precipitation_Chart[x][y] > 0) {
|
if (precipitationChart[x][y] > 0) {
|
||||||
if (temperature_Chart[x][y] > 94) {
|
if (temperatureChart[x][y] > 94) {
|
||||||
rVal[x][y] = 1;
|
rVal[x][y] = 1;
|
||||||
} else if (temperature_Chart[x][y] > 80) {
|
} else if (temperatureChart[x][y] > 80) {
|
||||||
rVal[x][y] = 2;
|
rVal[x][y] = 2;
|
||||||
} else if (temperature_Chart[x][y] > 40) {
|
} else if (temperatureChart[x][y] > 40) {
|
||||||
rVal[x][y] = 3;
|
rVal[x][y] = 3;
|
||||||
} else {
|
} else {
|
||||||
rVal[x][y] = 5;
|
rVal[x][y] = 5;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (temperature_Chart[x][y] > 75) {
|
if (temperatureChart[x][y] > 75) {
|
||||||
rVal[x][y] = 4;
|
rVal[x][y] = 4;
|
||||||
} else if (temperature_Chart[x][y] > 40) {
|
} else if (temperatureChart[x][y] > 40) {
|
||||||
rVal[x][y] = 4;
|
rVal[x][y] = 4;
|
||||||
} else if (temperature_Chart[x][y] > 25) {
|
} else if (temperatureChart[x][y] > 25) {
|
||||||
rVal[x][y] = 5;
|
rVal[x][y] = 5;
|
||||||
} else {
|
} else {
|
||||||
rVal[x][y] = 5;
|
rVal[x][y] = 5;
|
||||||
@ -782,11 +791,11 @@ public class TerrainGen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (temperature_Chart[x][y] > 75) {
|
if (temperatureChart[x][y] > 75) {
|
||||||
rVal[x][y] = 0;
|
rVal[x][y] = 0;
|
||||||
} else if (temperature_Chart[x][y] > 40) {
|
} else if (temperatureChart[x][y] > 40) {
|
||||||
rVal[x][y] = 0;
|
rVal[x][y] = 0;
|
||||||
} else if (temperature_Chart[x][y] > 25) {
|
} else if (temperatureChart[x][y] > 25) {
|
||||||
rVal[x][y] = 0;
|
rVal[x][y] = 0;
|
||||||
} else {
|
} else {
|
||||||
rVal[x][y] = 5;
|
rVal[x][y] = 5;
|
||||||
@ -829,21 +838,21 @@ public class TerrainGen {
|
|||||||
if (rain_Particles[x][y] >= 1) {
|
if (rain_Particles[x][y] >= 1) {
|
||||||
if (wind_field[x][y].x == -1) {
|
if (wind_field[x][y].x == -1) {
|
||||||
if (x > 0) {
|
if (x > 0) {
|
||||||
if (elevation_raws[x - 1][y] < rain_Shadow_Blocker_Height) {
|
if (elevation_raws[x - 1][y] < RAIN_SHADOW_BLOCKER_HEIGHT) {
|
||||||
rain_Particles[x - 1][y] = 1;
|
rain_Particles[x - 1][y] = 1;
|
||||||
rVal[x - 1][y] = 1;
|
rVal[x - 1][y] = 1;
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
if (wind_field[x][y].y == -1) {
|
if (wind_field[x][y].y == -1) {
|
||||||
if (y > 0) {
|
if (y > 0) {
|
||||||
if (elevation_raws[x - 1][y - 1] < rain_Shadow_Blocker_Height) {
|
if (elevation_raws[x - 1][y - 1] < RAIN_SHADOW_BLOCKER_HEIGHT) {
|
||||||
rain_Particles[x - 1][y - 1] = 1;
|
rain_Particles[x - 1][y - 1] = 1;
|
||||||
rVal[x - 1][y - 1] = 1;
|
rVal[x - 1][y - 1] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (wind_field[x][y].y == 1) {
|
} else if (wind_field[x][y].y == 1) {
|
||||||
if (y < DIMENSION - 1) {
|
if (y < DIMENSION - 1) {
|
||||||
if (elevation_raws[x - 1][y + 1] < rain_Shadow_Blocker_Height) {
|
if (elevation_raws[x - 1][y + 1] < RAIN_SHADOW_BLOCKER_HEIGHT) {
|
||||||
rain_Particles[x - 1][y + 1] = 1;
|
rain_Particles[x - 1][y + 1] = 1;
|
||||||
rVal[x - 1][y + 1] = 1;
|
rVal[x - 1][y + 1] = 1;
|
||||||
}
|
}
|
||||||
@ -853,21 +862,21 @@ public class TerrainGen {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (x < DIMENSION - 1) {
|
if (x < DIMENSION - 1) {
|
||||||
if (elevation_raws[x + 1][y] < rain_Shadow_Blocker_Height) {
|
if (elevation_raws[x + 1][y] < RAIN_SHADOW_BLOCKER_HEIGHT) {
|
||||||
rain_Particles[x + 1][y] = 1;
|
rain_Particles[x + 1][y] = 1;
|
||||||
rVal[x + 1][y] = 1;
|
rVal[x + 1][y] = 1;
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
if (wind_field[x][y].y == -1) {
|
if (wind_field[x][y].y == -1) {
|
||||||
if (y > 0) {
|
if (y > 0) {
|
||||||
if (elevation_raws[x + 1][y - 1] < rain_Shadow_Blocker_Height) {
|
if (elevation_raws[x + 1][y - 1] < RAIN_SHADOW_BLOCKER_HEIGHT) {
|
||||||
rain_Particles[x + 1][y - 1] = 1;
|
rain_Particles[x + 1][y - 1] = 1;
|
||||||
rVal[x + 1][y - 1] = 1;
|
rVal[x + 1][y - 1] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (wind_field[x][y].y == 1) {
|
} else if (wind_field[x][y].y == 1) {
|
||||||
if (y < DIMENSION - 1) {
|
if (y < DIMENSION - 1) {
|
||||||
if (elevation_raws[x + 1][y + 1] < rain_Shadow_Blocker_Height) {
|
if (elevation_raws[x + 1][y + 1] < RAIN_SHADOW_BLOCKER_HEIGHT) {
|
||||||
rain_Particles[x + 1][y + 1] = 1;
|
rain_Particles[x + 1][y + 1] = 1;
|
||||||
rVal[x + 1][y + 1] = 1;
|
rVal[x + 1][y + 1] = 1;
|
||||||
}
|
}
|
||||||
@ -931,8 +940,8 @@ public class TerrainGen {
|
|||||||
int rVal[][] = new int[DIMENSION][DIMENSION];
|
int rVal[][] = new int[DIMENSION][DIMENSION];
|
||||||
for(int x = 0; x < DIMENSION; x++){
|
for(int x = 0; x < DIMENSION; x++){
|
||||||
for(int y = 0; y < DIMENSION; y++){
|
for(int y = 0; y < DIMENSION; y++){
|
||||||
if(data[x][y] < ocean_Threshold){
|
if(data[x][y] < OCEAN_THRESHOLD){
|
||||||
rVal[x][y] = ocean_Threshold;
|
rVal[x][y] = OCEAN_THRESHOLD;
|
||||||
} else {
|
} else {
|
||||||
rVal[x][y] = 0;
|
rVal[x][y] = 0;
|
||||||
}
|
}
|
||||||
@ -945,8 +954,8 @@ public class TerrainGen {
|
|||||||
int rVal[][] = new int[DIMENSION][DIMENSION];
|
int rVal[][] = new int[DIMENSION][DIMENSION];
|
||||||
for(int x = 0; x < DIMENSION; x++){
|
for(int x = 0; x < DIMENSION; x++){
|
||||||
for(int y = 0; y < DIMENSION; y++){
|
for(int y = 0; y < DIMENSION; y++){
|
||||||
if(data[x][y] > mountain_Threshold){
|
if(data[x][y] > MOUNTAIN_THRESHOLD){
|
||||||
rVal[x][y] = mountain_Threshold;
|
rVal[x][y] = MOUNTAIN_THRESHOLD;
|
||||||
} else {
|
} else {
|
||||||
rVal[x][y] = 0;
|
rVal[x][y] = 0;
|
||||||
}
|
}
|
||||||
@ -990,7 +999,7 @@ public class TerrainGen {
|
|||||||
for (int x = 0; x < DIMENSION; x++) {
|
for (int x = 0; x < DIMENSION; x++) {
|
||||||
for (int y = 0; y < DIMENSION; y++) {
|
for (int y = 0; y < DIMENSION; y++) {
|
||||||
rVal[x][y] = data[x][y];
|
rVal[x][y] = data[x][y];
|
||||||
if (data[x][y] > mountain_Threshold) {
|
if (data[x][y] > MOUNTAIN_THRESHOLD) {
|
||||||
rVal[x][y] = rVal[x][y] - 5;
|
rVal[x][y] = rVal[x][y] - 5;
|
||||||
// closed_Set = new int[DIMENSION][DIMENSION];
|
// closed_Set = new int[DIMENSION][DIMENSION];
|
||||||
// if (floodfill_Reach_Threshold(rVal, closed_Set, x, y, mountain_Threshold, 101) < mountain_Range_Size_Minimum) {
|
// if (floodfill_Reach_Threshold(rVal, closed_Set, x, y, mountain_Threshold, 101) < mountain_Range_Size_Minimum) {
|
||||||
@ -1194,16 +1203,16 @@ public class TerrainGen {
|
|||||||
int rVal[][] = new int[DIMENSION][DIMENSION];
|
int rVal[][] = new int[DIMENSION][DIMENSION];
|
||||||
for(int x = 0; x < DIMENSION; x++){
|
for(int x = 0; x < DIMENSION; x++){
|
||||||
for(int y = 0; y < DIMENSION; y++){
|
for(int y = 0; y < DIMENSION; y++){
|
||||||
if(data[x][y] > TerrainGen.ocean_Threshold && data[x][y] < 90){
|
if(data[x][y] > TerrainGen.OCEAN_THRESHOLD && data[x][y] < 90){
|
||||||
|
|
||||||
// System.out.print((data[x][y] - ocean_Threshold) + "/" + (100.0 - ocean_Threshold) + "=" + ((data[x][y] - ocean_Threshold) / (100.0 - ocean_Threshold)) + " ");
|
// System.out.print((data[x][y] - ocean_Threshold) + "/" + (100.0 - ocean_Threshold) + "=" + ((data[x][y] - ocean_Threshold) / (100.0 - ocean_Threshold)) + " ");
|
||||||
// System.out.print(data[x][y] + "->");
|
// System.out.print(data[x][y] + "->");
|
||||||
rVal[x][y] = (int)(data[x][y] * Math.exp(-(1.0 - ((data[x][y] - ocean_Threshold) / (100.0 - ocean_Threshold)))) * 0.2f + data[x][y] * 0.8f);
|
rVal[x][y] = (int)(data[x][y] * Math.exp(-(1.0 - ((data[x][y] - OCEAN_THRESHOLD) / (100.0 - OCEAN_THRESHOLD)))) * 0.2f + data[x][y] * 0.8f);
|
||||||
if(rVal[x][y] < TerrainGen.ocean_Threshold){
|
if(rVal[x][y] < TerrainGen.OCEAN_THRESHOLD){
|
||||||
rVal[x][y] = TerrainGen.ocean_Threshold + 1;
|
rVal[x][y] = TerrainGen.OCEAN_THRESHOLD + 1;
|
||||||
}
|
}
|
||||||
// System.out.println(rVal[x][y]);
|
// System.out.println(rVal[x][y]);
|
||||||
if(Math.exp(-(1.0 - ((data[x][y] - ocean_Threshold) / (100.0 - ocean_Threshold)))) > 1.0){
|
if(Math.exp(-(1.0 - ((data[x][y] - OCEAN_THRESHOLD) / (100.0 - OCEAN_THRESHOLD)))) > 1.0){
|
||||||
System.out.println("WARNING!!");
|
System.out.println("WARNING!!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1377,12 +1386,12 @@ public class TerrainGen {
|
|||||||
|
|
||||||
public static void increment_Current_Continent(){
|
public static void increment_Current_Continent(){
|
||||||
current_Continent++;
|
current_Continent++;
|
||||||
if (current_Continent > num_Continents - 1) {
|
if (current_Continent > numberContinents - 1) {
|
||||||
current_Continent = 0;
|
current_Continent = 0;
|
||||||
}
|
}
|
||||||
while(continents.get(current_Continent).size < 50){
|
while(continents.get(current_Continent).size < 50){
|
||||||
current_Continent++;
|
current_Continent++;
|
||||||
if(current_Continent > num_Continents - 1){
|
if(current_Continent > numberContinents - 1){
|
||||||
current_Continent = 0;
|
current_Continent = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,9 @@ public class ServerTerrainManager {
|
|||||||
|
|
||||||
int dynamicInterpolationRatio;
|
int dynamicInterpolationRatio;
|
||||||
|
|
||||||
float randomDampener;
|
float interpolationRandomDampener;
|
||||||
|
|
||||||
|
long seed;
|
||||||
|
|
||||||
TerrainModel model;
|
TerrainModel model;
|
||||||
|
|
||||||
@ -41,13 +43,14 @@ public class ServerTerrainManager {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ServerTerrainManager(int worldSizeDiscrete, int verticalInterpolationRatio, int dynamicInterpolationRatio, float randomDampener){
|
public ServerTerrainManager(int worldSizeDiscrete, int verticalInterpolationRatio, int dynamicInterpolationRatio, float interpolationRandomDampener, long seed){
|
||||||
this.worldSizeDiscrete = worldSizeDiscrete;
|
this.worldSizeDiscrete = worldSizeDiscrete;
|
||||||
this.verticalInterpolationRatio = verticalInterpolationRatio;
|
this.verticalInterpolationRatio = verticalInterpolationRatio;
|
||||||
this.dynamicInterpolationRatio = dynamicInterpolationRatio;
|
this.dynamicInterpolationRatio = dynamicInterpolationRatio;
|
||||||
this.elevationMapCache = new HashMap();
|
this.elevationMapCache = new HashMap();
|
||||||
this.elevationMapCacheContents = new ArrayList();
|
this.elevationMapCacheContents = new ArrayList();
|
||||||
this.randomDampener = randomDampener;
|
this.interpolationRandomDampener = interpolationRandomDampener;
|
||||||
|
this.seed = seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerTerrainManager(){
|
ServerTerrainManager(){
|
||||||
@ -61,7 +64,7 @@ public class ServerTerrainManager {
|
|||||||
rVal.dynamicInterpolationRatio = 100;
|
rVal.dynamicInterpolationRatio = 100;
|
||||||
rVal.elevationMapCache = new HashMap();
|
rVal.elevationMapCache = new HashMap();
|
||||||
rVal.elevationMapCacheContents = new ArrayList();
|
rVal.elevationMapCacheContents = new ArrayList();
|
||||||
rVal.randomDampener = 0.0f;
|
rVal.interpolationRandomDampener = 0.0f;
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,9 +73,9 @@ public class ServerTerrainManager {
|
|||||||
terrainGen.setInterpolationRatio(worldSizeDiscrete/200);
|
terrainGen.setInterpolationRatio(worldSizeDiscrete/200);
|
||||||
terrainGen.setVerticalInterpolationRatio(verticalInterpolationRatio);
|
terrainGen.setVerticalInterpolationRatio(verticalInterpolationRatio);
|
||||||
terrainGen.setDynamicInterpolationRatio(dynamicInterpolationRatio);
|
terrainGen.setDynamicInterpolationRatio(dynamicInterpolationRatio);
|
||||||
terrainGen.setRandomSeed(0);
|
terrainGen.setRandomSeed(seed);
|
||||||
model = terrainGen.generateModel();
|
model = terrainGen.generateModel();
|
||||||
model.setRandomDampener(randomDampener);
|
model.setInterpolationRandomDampener(interpolationRandomDampener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(){
|
public void save(){
|
||||||
@ -219,5 +222,9 @@ public class ServerTerrainManager {
|
|||||||
return new long[3][3];
|
return new long[3][3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TerrainModel getModel() {
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,25 +5,35 @@ import java.util.Random;
|
|||||||
public class TerrainModel {
|
public class TerrainModel {
|
||||||
|
|
||||||
int dynamicInterpolationRatio;
|
int dynamicInterpolationRatio;
|
||||||
|
float interpolationRandomDampener = 0.4f;
|
||||||
|
|
||||||
int discreteArrayDimension;
|
int discreteArrayDimension;
|
||||||
|
|
||||||
float[][] elevation;
|
float[][] elevation;
|
||||||
|
|
||||||
long[][] chunkRandomizer;
|
long[][] chunkRandomizer;
|
||||||
|
|
||||||
float randomDampener = 0.4f;
|
float realMountainThreshold;
|
||||||
|
float realOceanThreshold;
|
||||||
|
|
||||||
|
|
||||||
TerrainModel() {
|
TerrainModel() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TerrainModel(int dimension, float[][] elevation, long[][] chunkRandomizer, int dynamicInterpolationRatio){
|
public TerrainModel(
|
||||||
|
int dimension,
|
||||||
|
float[][] elevation,
|
||||||
|
long[][] chunkRandomizer,
|
||||||
|
float realOceanThreshold,
|
||||||
|
float realMountainThreshold,
|
||||||
|
int dynamicInterpolationRatio
|
||||||
|
){
|
||||||
|
|
||||||
this.dynamicInterpolationRatio = dynamicInterpolationRatio;
|
this.dynamicInterpolationRatio = dynamicInterpolationRatio;
|
||||||
this.discreteArrayDimension = dimension;
|
this.discreteArrayDimension = dimension;
|
||||||
this.elevation = elevation;
|
this.elevation = elevation;
|
||||||
this.chunkRandomizer = chunkRandomizer;
|
this.chunkRandomizer = chunkRandomizer;
|
||||||
|
this.realMountainThreshold = realMountainThreshold;
|
||||||
|
this.realOceanThreshold = realOceanThreshold;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,8 +48,8 @@ public class TerrainModel {
|
|||||||
return elevation;
|
return elevation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRandomDampener(float f){
|
public void setInterpolationRandomDampener(float f){
|
||||||
randomDampener = f;
|
interpolationRandomDampener = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -306,11 +316,19 @@ public class TerrainModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float getRandomDampener(){
|
public float getRandomDampener(){
|
||||||
return randomDampener;
|
return interpolationRandomDampener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDynamicInterpolationRatio(){
|
public int getDynamicInterpolationRatio(){
|
||||||
return dynamicInterpolationRatio;
|
return dynamicInterpolationRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getRealMountainThreshold() {
|
||||||
|
return realMountainThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getRealOceanThreshold() {
|
||||||
|
return realOceanThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import electrosphere.game.collision.CollisionEngine;
|
|||||||
import electrosphere.entity.types.creature.CreatureUtils;
|
import electrosphere.entity.types.creature.CreatureUtils;
|
||||||
import electrosphere.entity.types.item.ItemUtils;
|
import electrosphere.entity.types.item.ItemUtils;
|
||||||
import electrosphere.game.client.drawcell.DrawCellManager;
|
import electrosphere.game.client.drawcell.DrawCellManager;
|
||||||
|
import electrosphere.game.client.player.ClientPlayerData;
|
||||||
import electrosphere.game.client.terrain.manager.ClientTerrainManager;
|
import electrosphere.game.client.terrain.manager.ClientTerrainManager;
|
||||||
import electrosphere.game.client.world.ClientWorldData;
|
import electrosphere.game.client.world.ClientWorldData;
|
||||||
import electrosphere.game.collision.CommonWorldData;
|
import electrosphere.game.collision.CommonWorldData;
|
||||||
@ -106,6 +107,7 @@ public class LoadingThread extends Thread {
|
|||||||
//initialize the client thread (client)
|
//initialize the client thread (client)
|
||||||
if(FLAG_INIT_CLIENT){
|
if(FLAG_INIT_CLIENT){
|
||||||
initClientThread();
|
initClientThread();
|
||||||
|
stallForClientPlayerData();
|
||||||
}
|
}
|
||||||
|
|
||||||
//init client terrain manager
|
//init client terrain manager
|
||||||
@ -168,6 +170,7 @@ public class LoadingThread extends Thread {
|
|||||||
//initialize the client thread (client)
|
//initialize the client thread (client)
|
||||||
if(FLAG_INIT_CLIENT){
|
if(FLAG_INIT_CLIENT){
|
||||||
initClientThread();
|
initClientThread();
|
||||||
|
stallForClientPlayerData();
|
||||||
}
|
}
|
||||||
|
|
||||||
//init client terrain manager
|
//init client terrain manager
|
||||||
@ -233,7 +236,7 @@ public class LoadingThread extends Thread {
|
|||||||
Actually initialize the terrain manager
|
Actually initialize the terrain manager
|
||||||
*/
|
*/
|
||||||
float[][] elevation;
|
float[][] elevation;
|
||||||
Globals.serverTerrainManager = new ServerTerrainManager(2000,200,100,0.25f);
|
Globals.serverTerrainManager = new ServerTerrainManager(2000,200,100,0.25f,0);
|
||||||
if(Globals.mainConfig.runServer){
|
if(Globals.mainConfig.runServer){
|
||||||
if(Globals.mainConfig.loadTerrain){
|
if(Globals.mainConfig.loadTerrain){
|
||||||
Globals.serverTerrainManager.load();
|
Globals.serverTerrainManager.load();
|
||||||
@ -331,15 +334,23 @@ public class LoadingThread extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void stallForClientPlayerData(){
|
||||||
|
while(!Globals.clientPlayerData.hasLoaded()){
|
||||||
|
try {
|
||||||
|
TimeUnit.MILLISECONDS.sleep(5);
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void initDynamicCellManager(){
|
static void initDynamicCellManager(){
|
||||||
Globals.drawCellManager = new DrawCellManager(
|
Globals.drawCellManager = new DrawCellManager(
|
||||||
Globals.clientWorldData,
|
Globals.clientWorldData,
|
||||||
Globals.clientTerrainManager,
|
Globals.clientTerrainManager,
|
||||||
Globals.spawnPoint.x,
|
Globals.clientPlayerData.getInitialDiscretePositionX(),
|
||||||
Globals.spawnPoint.z
|
Globals.clientPlayerData.getInitialDiscretePositionY()
|
||||||
// Globals.terrainManager.getDynamicInterpolationRatio(),
|
// Globals.terrainManager.getDynamicInterpolationRatio(),
|
||||||
// Globals.terrainManager.getRandomDampener()
|
// Globals.terrainManager.getRandomDampener()
|
||||||
);
|
);
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import electrosphere.entity.types.creature.creaturemap.CreatureType;
|
|||||||
import electrosphere.entity.types.creature.creaturemap.CreatureTypeList;
|
import electrosphere.entity.types.creature.creaturemap.CreatureTypeList;
|
||||||
import electrosphere.entity.types.hitbox.HitboxManager;
|
import electrosphere.entity.types.hitbox.HitboxManager;
|
||||||
import electrosphere.game.client.drawcell.DrawCellManager;
|
import electrosphere.game.client.drawcell.DrawCellManager;
|
||||||
|
import electrosphere.game.client.player.ClientPlayerData;
|
||||||
import electrosphere.game.client.terrain.manager.ClientTerrainManager;
|
import electrosphere.game.client.terrain.manager.ClientTerrainManager;
|
||||||
import electrosphere.game.client.world.ClientWorldData;
|
import electrosphere.game.client.world.ClientWorldData;
|
||||||
import electrosphere.game.collision.CommonWorldData;
|
import electrosphere.game.collision.CommonWorldData;
|
||||||
@ -182,6 +183,9 @@ public class Globals {
|
|||||||
//client terrain manager
|
//client terrain manager
|
||||||
public static ClientTerrainManager clientTerrainManager;
|
public static ClientTerrainManager clientTerrainManager;
|
||||||
|
|
||||||
|
//client player data
|
||||||
|
public static ClientPlayerData clientPlayerData = new ClientPlayerData();
|
||||||
|
|
||||||
//chunk stuff
|
//chunk stuff
|
||||||
//constant for how far in game units you have to move to load chunks
|
//constant for how far in game units you have to move to load chunks
|
||||||
public static DrawCellManager drawCellManager;
|
public static DrawCellManager drawCellManager;
|
||||||
|
|||||||
@ -113,7 +113,7 @@ public class Main {
|
|||||||
Globals.initGlobals();
|
Globals.initGlobals();
|
||||||
|
|
||||||
//debug: create terrain/world viewer
|
//debug: create terrain/world viewer
|
||||||
TerrainViewer.runViewer();
|
// TerrainViewer.runViewer();
|
||||||
|
|
||||||
//create the drawing context
|
//create the drawing context
|
||||||
Globals.renderingEngine = new RenderingEngine();
|
Globals.renderingEngine = new RenderingEngine();
|
||||||
|
|||||||
@ -86,6 +86,9 @@ public class ClientProtocol {
|
|||||||
Main.playerId = message.getplayerID();
|
Main.playerId = message.getplayerID();
|
||||||
System.out.println("Player ID is " + Main.playerId);
|
System.out.println("Player ID is " + Main.playerId);
|
||||||
break;
|
break;
|
||||||
|
case SETINITIALDISCRETEPOSITION:
|
||||||
|
Globals.clientPlayerData.setInitialDiscretePosition(message.getinitialDiscretePositionX(), message.getinitialDiscretePositionY());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -74,6 +74,11 @@ ENTITY_MESSAGE,
|
|||||||
rVal = PlayerMessage.parseSet_IDMessage(byteStream);
|
rVal = PlayerMessage.parseSet_IDMessage(byteStream);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case TypeBytes.PLAYER_MESSAGE_TYPE_SETINITIALDISCRETEPOSITION:
|
||||||
|
if(PlayerMessage.canParseMessage(byteStream,secondByte)){
|
||||||
|
rVal = PlayerMessage.parseSetInitialDiscretePositionMessage(byteStream);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TypeBytes.MESSAGE_TYPE_ENTITY:
|
case TypeBytes.MESSAGE_TYPE_ENTITY:
|
||||||
|
|||||||
@ -7,10 +7,13 @@ public class PlayerMessage extends NetworkMessage {
|
|||||||
|
|
||||||
public enum PlayerMessageType {
|
public enum PlayerMessageType {
|
||||||
SET_ID,
|
SET_ID,
|
||||||
|
SETINITIALDISCRETEPOSITION,
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerMessageType messageType;
|
PlayerMessageType messageType;
|
||||||
int playerID;
|
int playerID;
|
||||||
|
int initialDiscretePositionX;
|
||||||
|
int initialDiscretePositionY;
|
||||||
|
|
||||||
PlayerMessage(PlayerMessageType messageType){
|
PlayerMessage(PlayerMessageType messageType){
|
||||||
this.type = MessageType.PLAYER_MESSAGE;
|
this.type = MessageType.PLAYER_MESSAGE;
|
||||||
@ -29,6 +32,22 @@ public class PlayerMessage extends NetworkMessage {
|
|||||||
this.playerID = playerID;
|
this.playerID = playerID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getinitialDiscretePositionX() {
|
||||||
|
return initialDiscretePositionX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setinitialDiscretePositionX(int initialDiscretePositionX) {
|
||||||
|
this.initialDiscretePositionX = initialDiscretePositionX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getinitialDiscretePositionY() {
|
||||||
|
return initialDiscretePositionY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setinitialDiscretePositionY(int initialDiscretePositionY) {
|
||||||
|
this.initialDiscretePositionY = initialDiscretePositionY;
|
||||||
|
}
|
||||||
|
|
||||||
static void stripPacketHeader(List<Byte> byteStream){
|
static void stripPacketHeader(List<Byte> byteStream){
|
||||||
byteStream.remove(0);
|
byteStream.remove(0);
|
||||||
byteStream.remove(0);
|
byteStream.remove(0);
|
||||||
@ -42,6 +61,12 @@ public class PlayerMessage extends NetworkMessage {
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
case TypeBytes.PLAYER_MESSAGE_TYPE_SETINITIALDISCRETEPOSITION:
|
||||||
|
if(byteStream.size() >= TypeBytes.PLAYER_MESSAGE_TYPE_SETINITIALDISCRETEPOSITION_SIZE){
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -60,6 +85,22 @@ public class PlayerMessage extends NetworkMessage {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PlayerMessage parseSetInitialDiscretePositionMessage(List<Byte> byteStream){
|
||||||
|
PlayerMessage rVal = new PlayerMessage(PlayerMessageType.SETINITIALDISCRETEPOSITION);
|
||||||
|
stripPacketHeader(byteStream);
|
||||||
|
rVal.setinitialDiscretePositionX(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
||||||
|
rVal.setinitialDiscretePositionY(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PlayerMessage constructSetInitialDiscretePositionMessage(int initialDiscretePositionX,int initialDiscretePositionY){
|
||||||
|
PlayerMessage rVal = new PlayerMessage(PlayerMessageType.SETINITIALDISCRETEPOSITION);
|
||||||
|
rVal.setinitialDiscretePositionX(initialDiscretePositionX);
|
||||||
|
rVal.setinitialDiscretePositionY(initialDiscretePositionY);
|
||||||
|
rVal.serialize();
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void serialize(){
|
void serialize(){
|
||||||
byte[] intValues = new byte[8];
|
byte[] intValues = new byte[8];
|
||||||
@ -75,6 +116,21 @@ public class PlayerMessage extends NetworkMessage {
|
|||||||
rawBytes[2+i] = intValues[i];
|
rawBytes[2+i] = intValues[i];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case SETINITIALDISCRETEPOSITION:
|
||||||
|
rawBytes = new byte[TypeBytes.PLAYER_MESSAGE_TYPE_SETINITIALDISCRETEPOSITION_SIZE];
|
||||||
|
//message header
|
||||||
|
rawBytes[0] = TypeBytes.MESSAGE_TYPE_PLAYER;
|
||||||
|
//entity messaage header
|
||||||
|
rawBytes[1] = TypeBytes.PLAYER_MESSAGE_TYPE_SETINITIALDISCRETEPOSITION;
|
||||||
|
intValues = ByteStreamUtils.serializeIntToBytes(initialDiscretePositionX);
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
rawBytes[2+i] = intValues[i];
|
||||||
|
}
|
||||||
|
intValues = ByteStreamUtils.serializeIntToBytes(initialDiscretePositionY);
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
rawBytes[6+i] = intValues[i];
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
serialized = true;
|
serialized = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,10 +35,12 @@ Message categories
|
|||||||
Player subcategories
|
Player subcategories
|
||||||
*/
|
*/
|
||||||
public static final byte PLAYER_MESSAGE_TYPE_SET_ID = 0;
|
public static final byte PLAYER_MESSAGE_TYPE_SET_ID = 0;
|
||||||
|
public static final byte PLAYER_MESSAGE_TYPE_SETINITIALDISCRETEPOSITION = 1;
|
||||||
/*
|
/*
|
||||||
Player packet sizes
|
Player packet sizes
|
||||||
*/
|
*/
|
||||||
public static final byte PLAYER_MESSAGE_TYPE_SET_ID_SIZE = 6;
|
public static final byte PLAYER_MESSAGE_TYPE_SET_ID_SIZE = 6;
|
||||||
|
public static final byte PLAYER_MESSAGE_TYPE_SETINITIALDISCRETEPOSITION_SIZE = 10;
|
||||||
/*
|
/*
|
||||||
Entity subcategories
|
Entity subcategories
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -14,11 +14,11 @@ public class ByteStreamUtils {
|
|||||||
public static int popIntFromByteQueue(List<Byte> queue){
|
public static int popIntFromByteQueue(List<Byte> queue){
|
||||||
int rVal = -1;
|
int rVal = -1;
|
||||||
integerCompactor.clear();
|
integerCompactor.clear();
|
||||||
integerCompactor.put(queue.remove(0));
|
integerCompactor.put(0,queue.remove(0));
|
||||||
integerCompactor.put(queue.remove(0));
|
integerCompactor.put(1,queue.remove(0));
|
||||||
integerCompactor.put(queue.remove(0));
|
integerCompactor.put(2,queue.remove(0));
|
||||||
integerCompactor.put(queue.remove(0));
|
integerCompactor.put(3,queue.remove(0));
|
||||||
integerCompactor.flip();
|
integerCompactor.position(0);
|
||||||
rVal = integerCompactor.getInt();
|
rVal = integerCompactor.getInt();
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
@ -26,11 +26,11 @@ public class ByteStreamUtils {
|
|||||||
public static float popFloatFromByteQueue(List<Byte> queue){
|
public static float popFloatFromByteQueue(List<Byte> queue){
|
||||||
float rVal = -1;
|
float rVal = -1;
|
||||||
integerCompactor.clear();
|
integerCompactor.clear();
|
||||||
integerCompactor.put(queue.remove(0));
|
integerCompactor.put(0,queue.remove(0));
|
||||||
integerCompactor.put(queue.remove(0));
|
integerCompactor.put(1,queue.remove(0));
|
||||||
integerCompactor.put(queue.remove(0));
|
integerCompactor.put(2,queue.remove(0));
|
||||||
integerCompactor.put(queue.remove(0));
|
integerCompactor.put(3,queue.remove(0));
|
||||||
integerCompactor.flip();
|
integerCompactor.position(0);
|
||||||
rVal = integerCompactor.getFloat();
|
rVal = integerCompactor.getFloat();
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
@ -38,15 +38,15 @@ public class ByteStreamUtils {
|
|||||||
public static long popLongFromByteQueue(List<Byte> queue){
|
public static long popLongFromByteQueue(List<Byte> queue){
|
||||||
long rVal = -1;
|
long rVal = -1;
|
||||||
integerCompactor.clear();
|
integerCompactor.clear();
|
||||||
integerCompactor.put(queue.remove(0));
|
integerCompactor.put(0,queue.remove(0));
|
||||||
integerCompactor.put(queue.remove(0));
|
integerCompactor.put(1,queue.remove(0));
|
||||||
integerCompactor.put(queue.remove(0));
|
integerCompactor.put(2,queue.remove(0));
|
||||||
integerCompactor.put(queue.remove(0));
|
integerCompactor.put(3,queue.remove(0));
|
||||||
integerCompactor.put(queue.remove(0));
|
integerCompactor.put(4,queue.remove(0));
|
||||||
integerCompactor.put(queue.remove(0));
|
integerCompactor.put(5,queue.remove(0));
|
||||||
integerCompactor.put(queue.remove(0));
|
integerCompactor.put(6,queue.remove(0));
|
||||||
integerCompactor.put(queue.remove(0));
|
integerCompactor.put(7,queue.remove(0));
|
||||||
integerCompactor.flip();
|
integerCompactor.position(0);
|
||||||
rVal = integerCompactor.getLong();
|
rVal = integerCompactor.getLong();
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
@ -55,11 +55,11 @@ public class ByteStreamUtils {
|
|||||||
byte[] rVal = new byte[4];
|
byte[] rVal = new byte[4];
|
||||||
integerCompactor.clear();
|
integerCompactor.clear();
|
||||||
integerCompactor.putInt(i);
|
integerCompactor.putInt(i);
|
||||||
integerCompactor.flip();
|
integerCompactor.position(0);
|
||||||
rVal[0] = integerCompactor.get();
|
rVal[0] = integerCompactor.get(0);
|
||||||
rVal[1] = integerCompactor.get();
|
rVal[1] = integerCompactor.get(1);
|
||||||
rVal[2] = integerCompactor.get();
|
rVal[2] = integerCompactor.get(2);
|
||||||
rVal[3] = integerCompactor.get();
|
rVal[3] = integerCompactor.get(3);
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,11 +67,11 @@ public class ByteStreamUtils {
|
|||||||
byte[] rVal = new byte[4];
|
byte[] rVal = new byte[4];
|
||||||
integerCompactor.clear();
|
integerCompactor.clear();
|
||||||
integerCompactor.putFloat(i);
|
integerCompactor.putFloat(i);
|
||||||
integerCompactor.flip();
|
integerCompactor.position(0);
|
||||||
rVal[0] = integerCompactor.get();
|
rVal[0] = integerCompactor.get(0);
|
||||||
rVal[1] = integerCompactor.get();
|
rVal[1] = integerCompactor.get(1);
|
||||||
rVal[2] = integerCompactor.get();
|
rVal[2] = integerCompactor.get(2);
|
||||||
rVal[3] = integerCompactor.get();
|
rVal[3] = integerCompactor.get(3);
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,15 +79,15 @@ public class ByteStreamUtils {
|
|||||||
byte[] rVal = new byte[8];
|
byte[] rVal = new byte[8];
|
||||||
integerCompactor.clear();
|
integerCompactor.clear();
|
||||||
integerCompactor.putLong(i);
|
integerCompactor.putLong(i);
|
||||||
integerCompactor.flip();
|
integerCompactor.position(0);
|
||||||
rVal[0] = integerCompactor.get();
|
rVal[0] = integerCompactor.get(0);
|
||||||
rVal[1] = integerCompactor.get();
|
rVal[1] = integerCompactor.get(1);
|
||||||
rVal[2] = integerCompactor.get();
|
rVal[2] = integerCompactor.get(2);
|
||||||
rVal[3] = integerCompactor.get();
|
rVal[3] = integerCompactor.get(3);
|
||||||
rVal[4] = integerCompactor.get();
|
rVal[4] = integerCompactor.get(4);
|
||||||
rVal[5] = integerCompactor.get();
|
rVal[5] = integerCompactor.get(5);
|
||||||
rVal[6] = integerCompactor.get();
|
rVal[6] = integerCompactor.get(6);
|
||||||
rVal[7] = integerCompactor.get();
|
rVal[7] = integerCompactor.get(7);
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -114,6 +114,13 @@ public class ServerConnectionHandler implements Runnable {
|
|||||||
(int)Globals.serverWorldData.getWorldBoundMax().z
|
(int)Globals.serverWorldData.getWorldBoundMax().z
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
//set client initial discrete position
|
||||||
|
networkParser.addOutgoingMessage(
|
||||||
|
PlayerMessage.constructSetInitialDiscretePositionMessage(
|
||||||
|
Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.x),
|
||||||
|
Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.z)
|
||||||
|
)
|
||||||
|
);
|
||||||
//tell them what player stats they are
|
//tell them what player stats they are
|
||||||
networkParser.addOutgoingMessage(PlayerMessage.constructSet_IDMessage(playerID));
|
networkParser.addOutgoingMessage(PlayerMessage.constructSet_IDMessage(playerID));
|
||||||
//figure out what chunk they're in
|
//figure out what chunk they're in
|
||||||
|
|||||||
@ -1,12 +1,21 @@
|
|||||||
package electrosphere.util.worldviewer;
|
package electrosphere.util.worldviewer;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import electrosphere.game.server.simulation.Simulation;
|
||||||
|
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
||||||
import electrosphere.game.server.terrain.models.TerrainModel;
|
import electrosphere.game.server.terrain.models.TerrainModel;
|
||||||
import electrosphere.main.Globals;
|
import electrosphere.main.Globals;
|
||||||
|
import electrosphere.main.Main;
|
||||||
import electrosphere.util.Utilities;
|
import electrosphere.util.Utilities;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -21,20 +30,30 @@ public class TerrainViewer {
|
|||||||
|
|
||||||
|
|
||||||
public static void runViewer(){
|
public static void runViewer(){
|
||||||
TerrainModel terrainModel = Utilities.loadObjectFromBakedJsonFile("/Config/terrain.json", TerrainModel.class);
|
|
||||||
float[][] elevationMacro = terrainModel.getElevation();
|
TerrainModel terrainModel;
|
||||||
|
|
||||||
|
// ServerTerrainManager terrainManager = new ServerTerrainManager(2000, 1000, 100, 0.05f, new Random().nextLong());
|
||||||
|
// terrainManager.generate();
|
||||||
|
// terrainModel = terrainManager.getModel();
|
||||||
|
|
||||||
|
// Utilities.saveObjectToBakedJsonFile("/Config/testingTerrain.json", terrainModel);
|
||||||
|
terrainModel = Utilities.loadObjectFromBakedJsonFile("/Config/testingTerrain.json", TerrainModel.class);
|
||||||
|
|
||||||
|
Simulation simulation = new Simulation();
|
||||||
|
|
||||||
JFrame frame = new JFrame();
|
JFrame frame = new JFrame();
|
||||||
TerrainViewerJComponent jComponent = new TerrainViewerJComponent(elevationMacro);
|
TerrainViewerJComponent jComponent = new TerrainViewerJComponent(terrainModel);
|
||||||
frame.add(jComponent);
|
frame.add(jComponent);
|
||||||
frame.addKeyListener(new TerrainViewerKeyListener(jComponent));
|
frame.addKeyListener(new TerrainViewerKeyListener(jComponent));
|
||||||
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
frame.setBounds(0, 0, 600, 600);
|
frame.setBounds(0, 0, 1050, 1050);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
|
|
||||||
while(true){
|
while(true){
|
||||||
frame.repaint();
|
frame.repaint();
|
||||||
|
simulation.simulate();
|
||||||
try {
|
try {
|
||||||
TimeUnit.MILLISECONDS.sleep(10);
|
TimeUnit.MILLISECONDS.sleep(10);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package electrosphere.util.worldviewer;
|
package electrosphere.util.worldviewer;
|
||||||
|
|
||||||
|
import electrosphere.game.server.terrain.models.TerrainModel;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
@ -10,39 +11,61 @@ import javax.swing.JComponent;
|
|||||||
*/
|
*/
|
||||||
public class TerrainViewerJComponent extends JComponent {
|
public class TerrainViewerJComponent extends JComponent {
|
||||||
|
|
||||||
|
TerrainModel model;
|
||||||
float elevationMap[][];
|
float elevationMap[][];
|
||||||
float maxHeight = 0;
|
float maxHeight = 0;
|
||||||
int dimX;
|
int dimX;
|
||||||
int dimY;
|
int dimY;
|
||||||
|
|
||||||
|
float oceanThreshold;
|
||||||
|
float mountainThreshold;
|
||||||
|
|
||||||
int viewerOffsetX = 0;
|
int viewerOffsetX = 0;
|
||||||
int viewerOffsetY = 0;
|
int viewerOffsetY = 0;
|
||||||
|
|
||||||
public TerrainViewerJComponent(float[][] elevationMap){
|
public TerrainViewerJComponent(TerrainModel model){
|
||||||
this.elevationMap = elevationMap;
|
this.model = model;
|
||||||
|
this.elevationMap = model.getElevation();
|
||||||
dimX = elevationMap.length;
|
dimX = elevationMap.length;
|
||||||
dimY = elevationMap[0].length;
|
dimY = elevationMap[0].length;
|
||||||
|
|
||||||
|
float counter = 0;
|
||||||
|
float average = 0;
|
||||||
for(int x = 0; x < dimX; x++){
|
for(int x = 0; x < dimX; x++){
|
||||||
for(int y = 0; y < dimY; y++){
|
for(int y = 0; y < dimY; y++){
|
||||||
|
counter++;
|
||||||
if(elevationMap[x][y] > maxHeight){
|
if(elevationMap[x][y] > maxHeight){
|
||||||
maxHeight = elevationMap[x][y];
|
maxHeight = elevationMap[x][y];
|
||||||
}
|
}
|
||||||
|
average = average + elevationMap[x][y] * 1.0f / counter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.oceanThreshold = model.getRealOceanThreshold();
|
||||||
|
this.mountainThreshold = model.getRealMountainThreshold();
|
||||||
|
|
||||||
|
System.out.println("Ocean Threshold: " + oceanThreshold);
|
||||||
|
System.out.println("Mountain Threshold: " + mountainThreshold);
|
||||||
|
System.out.println("Average: " + average);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g){
|
public void paint(Graphics g){
|
||||||
g.clearRect(0, 0, 600, 600);
|
g.clearRect(0, 0, 1050, 1050);
|
||||||
for(int x = 0; x < dimX/4; x++){
|
for(int x = 0; x < dimX/2; x++){
|
||||||
for(int y = 0; y < dimY/4; y++){
|
for(int y = 0; y < dimY/2; y++){
|
||||||
g.setColor(new Color(
|
g.setColor(new Color(
|
||||||
(int)(255 * elevationMap[x*4][y*4] / maxHeight),
|
(int)(50 + 205 * elevationMap[x*2][y*2] / maxHeight),
|
||||||
(int)(255 * elevationMap[x*4][y*4] / maxHeight),
|
(int)(100 + 155 * elevationMap[x*2][y*2] / maxHeight),
|
||||||
(int)(255 * elevationMap[x*4][y*4] / maxHeight)
|
(int)(255 * elevationMap[x*2][y*2] / maxHeight)
|
||||||
));
|
));
|
||||||
|
if(elevationMap[x*2][y*2] <= oceanThreshold){
|
||||||
|
g.setColor(new Color(
|
||||||
|
(int)(255 * elevationMap[x*2][y*2] / maxHeight),
|
||||||
|
(int)(100 + 155 * elevationMap[x*2][y*2] / maxHeight),
|
||||||
|
(int)(150 + 105 * elevationMap[x*2][y*2] / maxHeight)
|
||||||
|
));
|
||||||
|
}
|
||||||
g.drawRect(x - viewerOffsetX, y - viewerOffsetY, 1, 1);
|
g.drawRect(x - viewerOffsetX, y - viewerOffsetY, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
src/main/resources/Config/testingTerrain.json
Normal file
1
src/main/resources/Config/testingTerrain.json
Normal file
File diff suppressed because one or more lines are too long
10
src/main/resources/Data/civilizations.json
Normal file
10
src/main/resources/Data/civilizations.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"Civilizations" : [
|
||||||
|
{
|
||||||
|
"name" : "Humans",
|
||||||
|
"allowedCreatures" : [
|
||||||
|
"Human"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
39
src/main/resources/Data/creatures.json
Normal file
39
src/main/resources/Data/creatures.json
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"creatures" : [
|
||||||
|
{
|
||||||
|
"name" : "Human",
|
||||||
|
"bodyParts" : [
|
||||||
|
{
|
||||||
|
"name" : "Head",
|
||||||
|
"type" : "Head",
|
||||||
|
"size" : 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "Torso",
|
||||||
|
"type" : "Torso",
|
||||||
|
"size" : 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "ArmLeft",
|
||||||
|
"type" : "Arm",
|
||||||
|
"size" : 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "ArmRight",
|
||||||
|
"type" : "Arm",
|
||||||
|
"size" : 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "LegLeft",
|
||||||
|
"type" : "Leg",
|
||||||
|
"size" : 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "LegRight",
|
||||||
|
"type" : "Leg",
|
||||||
|
"size" : 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -220,6 +220,14 @@
|
|||||||
{
|
{
|
||||||
"name" : "playerID",
|
"name" : "playerID",
|
||||||
"type" : "FIXED_INT"
|
"type" : "FIXED_INT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "initialDiscretePositionX",
|
||||||
|
"type" : "FIXED_INT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "initialDiscretePositionY",
|
||||||
|
"type" : "FIXED_INT"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"messageTypes" : [
|
"messageTypes" : [
|
||||||
@ -228,8 +236,14 @@
|
|||||||
"data" : [
|
"data" : [
|
||||||
"playerID"
|
"playerID"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"messageName" : "SetInitialDiscretePosition",
|
||||||
|
"data" : [
|
||||||
|
"initialDiscretePositionX",
|
||||||
|
"initialDiscretePositionY"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user