Chunking is complete
This commit is contained in:
parent
8ac86a0c84
commit
a87fcbed3a
8
pom.xml
8
pom.xml
@ -94,6 +94,14 @@
|
||||
<version>20101010-1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-crypto -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-crypto</artifactId>
|
||||
<version>1.1.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>electrosphere</groupId>
|
||||
|
||||
@ -44,7 +44,9 @@ public class EntityUtil {
|
||||
}
|
||||
|
||||
public static void cleanUpDrawableEntity(Entity e){
|
||||
Globals.entityManager.deregisterEntity(e);
|
||||
getEntityModel(e).free();
|
||||
if(e != null){
|
||||
Globals.entityManager.deregisterEntity(e);
|
||||
getEntityModel(e).free();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ public class CellManager {
|
||||
|
||||
|
||||
|
||||
int drawRadius = 15;
|
||||
int drawRadius = 5;
|
||||
int drawStepdownInterval = 2;
|
||||
int drawStepdownValue = 2;
|
||||
|
||||
@ -291,4 +291,12 @@ public class CellManager {
|
||||
}
|
||||
|
||||
|
||||
public void invalidateAllCells(){
|
||||
for(int x = 0; x < drawRadius * 2 + 1; x++){
|
||||
for(int y = 0; y < drawRadius * 2 + 1; y++){
|
||||
valid[x][y] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -59,7 +59,6 @@ public class TerrainManager {
|
||||
Gson gson = new Gson();
|
||||
String terrainOutRaw = gson.toJson(model);
|
||||
try {
|
||||
Files.createFile(new File(Globals.mainConfig.loadTerrainLocation).toPath());
|
||||
Files.write(new File(Globals.mainConfig.loadTerrainLocation).toPath(), terrainOutRaw.getBytes());
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
|
||||
@ -116,6 +116,9 @@ public class Main {
|
||||
|
||||
//run initialization stuff
|
||||
|
||||
initWorld();
|
||||
|
||||
|
||||
//Create opengl
|
||||
RenderUtils.createOpenglContext();
|
||||
|
||||
@ -127,6 +130,8 @@ public class Main {
|
||||
|
||||
initWorld();
|
||||
|
||||
initCellManager();
|
||||
|
||||
initSkybox();
|
||||
|
||||
initPlayer();
|
||||
@ -346,6 +351,14 @@ public class Main {
|
||||
terrainManager.save();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// elevation = terrainManager.getTerrainAtChunk(10, 10);
|
||||
// Model terrainModel = Utilities.create_terrain_model(elevation,10);
|
||||
// Entity terrainEntity = EntityUtil.spawnDrawableEntity(terrainModel);
|
||||
}
|
||||
|
||||
static void initCellManager(){
|
||||
Globals.cellManager = new CellManager(terrainManager, playerStartRealX, playerStartRealY);
|
||||
|
||||
|
||||
@ -356,16 +369,36 @@ public class Main {
|
||||
while(Globals.cellManager.containsUndrawableCell()){
|
||||
Globals.cellManager.makeCellDrawable();
|
||||
}
|
||||
|
||||
// elevation = terrainManager.getTerrainAtChunk(10, 10);
|
||||
// Model terrainModel = Utilities.create_terrain_model(elevation,10);
|
||||
// Entity terrainEntity = EntityUtil.spawnDrawableEntity(terrainModel);
|
||||
}
|
||||
|
||||
static void initPlayer(){
|
||||
Globals.player = new Entity();
|
||||
Globals.player.putData("position", new Vector3f(playerStartRealX,terrainManager.getHeightAtPosition(playerStartRealX, playerStartRealY),playerStartRealY));
|
||||
int playerStartX = 0;
|
||||
int playerStartY = 0;
|
||||
int discreteSize = terrainManager.getWorldDiscreteSize();
|
||||
int chunkSize = terrainManager.getChunkWidth();
|
||||
boolean found = false;
|
||||
for(int x = 0; x < discreteSize; x++){
|
||||
for(int y = 0; y < discreteSize; y++){
|
||||
if(terrainManager.getDiscreteValue(x, y)>0){
|
||||
playerStartX = x;
|
||||
playerStartY = y;
|
||||
found = true;
|
||||
}
|
||||
if(found){
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(found){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Globals.cellManager.setCellX(GL_S);
|
||||
Globals.player = new Entity();
|
||||
Globals.player.putData("position", new Vector3f(playerStartX*chunkSize,terrainManager.getHeightAtPosition(playerStartX*chunkSize, playerStartY*chunkSize),playerStartY*chunkSize));
|
||||
|
||||
Globals.cellManager.setCellX(Globals.cellManager.transformRealSpaceToCellSpace(playerStartX*chunkSize));
|
||||
Globals.cellManager.setCellY(Globals.cellManager.transformRealSpaceToCellSpace(playerStartY*chunkSize));
|
||||
|
||||
Globals.cellManager.invalidateAllCells();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package electrosphere.net;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class Client {
|
||||
|
||||
}
|
||||
9
src/main/java/electrosphere/net/Packet.java
Normal file
9
src/main/java/electrosphere/net/Packet.java
Normal file
@ -0,0 +1,9 @@
|
||||
package electrosphere.net;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author satellite
|
||||
*/
|
||||
public class Packet {
|
||||
byte[] rawBytes;
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package electrosphere.net;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class Server {
|
||||
|
||||
}
|
||||
19
src/main/java/electrosphere/net/client/Connection.java
Normal file
19
src/main/java/electrosphere/net/client/Connection.java
Normal file
@ -0,0 +1,19 @@
|
||||
package electrosphere.net.client;
|
||||
|
||||
import java.net.Socket;
|
||||
import org.apache.commons.crypto.stream.CryptoInputStream;
|
||||
import org.apache.commons.crypto.stream.CryptoOutputStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class Connection {
|
||||
Socket socket;
|
||||
|
||||
CryptoInputStream inputStream;
|
||||
|
||||
CryptoOutputStream outputStream;
|
||||
|
||||
|
||||
}
|
||||
20
src/main/java/electrosphere/net/server/Client.java
Normal file
20
src/main/java/electrosphere/net/server/Client.java
Normal file
@ -0,0 +1,20 @@
|
||||
package electrosphere.net.server;
|
||||
|
||||
import java.net.Socket;
|
||||
import org.apache.commons.crypto.stream.CryptoInputStream;
|
||||
import org.apache.commons.crypto.stream.CryptoOutputStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author satellite
|
||||
*/
|
||||
public class Client {
|
||||
|
||||
|
||||
Socket socket;
|
||||
|
||||
CryptoInputStream inputStream;
|
||||
|
||||
CryptoOutputStream outputStream;
|
||||
|
||||
}
|
||||
16
src/main/java/electrosphere/net/server/Server.java
Normal file
16
src/main/java/electrosphere/net/server/Server.java
Normal file
@ -0,0 +1,16 @@
|
||||
package electrosphere.net.server;
|
||||
|
||||
import java.net.ServerSocket;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class Server {
|
||||
|
||||
ServerSocket serverSocket;
|
||||
|
||||
public Server(int port){
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"projectMainDirectory" : "/Users/satellite/p/Renderer/src/main/resources/Config",
|
||||
"loadTerrain" : false,
|
||||
"loadTerrain" : true,
|
||||
"loadTerrainLocation" : "/Users/satellite/p/Renderer/src/main/resources/Config/terrain.json"
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user