Scaffolding navmesh
This commit is contained in:
parent
8cc5098928
commit
3185866fa4
@ -0,0 +1,35 @@
|
||||
package electrosphere.game.server.pathfinding;
|
||||
|
||||
import electrosphere.game.server.pathfinding.navmesh.NavMesh;
|
||||
import electrosphere.game.server.terrain.manager.ServerTerrainChunk;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author satellite
|
||||
*/
|
||||
public class ChunkMeshList {
|
||||
|
||||
ServerTerrainChunk chunk;
|
||||
List<NavMesh> meshes = new LinkedList();
|
||||
|
||||
public ChunkMeshList(ServerTerrainChunk parent){
|
||||
chunk = parent;
|
||||
}
|
||||
|
||||
public void addMesh(NavMesh mesh){
|
||||
meshes.add(mesh);
|
||||
}
|
||||
|
||||
public List<NavMesh> getMeshes(){
|
||||
return meshes;
|
||||
}
|
||||
|
||||
public ServerTerrainChunk getChunk(){
|
||||
return chunk;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package electrosphere.game.server.pathfinding;
|
||||
|
||||
import electrosphere.game.server.pathfinding.navmesh.NavMesh;
|
||||
import electrosphere.game.server.terrain.manager.ServerTerrainChunk;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author satellite
|
||||
*/
|
||||
public class NavMeshManager {
|
||||
|
||||
List<NavMesh> meshes = new LinkedList();
|
||||
Map<ServerTerrainChunk,ChunkMeshList> chunkToMeshListMap = new HashMap();
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package electrosphere.game.server.pathfinding;
|
||||
|
||||
import electrosphere.game.server.pathfinding.navmesh.NavMesh;
|
||||
import electrosphere.game.server.terrain.manager.ServerTerrainChunk;
|
||||
import electrosphere.main.Globals;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author satellite
|
||||
*/
|
||||
public class NavMeshUtils {
|
||||
|
||||
public static NavMesh createMeshFromChunk(ServerTerrainChunk chunk){
|
||||
NavMesh rVal = new NavMesh();
|
||||
float[][] heightMap = chunk.getHeightMap();
|
||||
for(int x = 0; x < Globals.serverTerrainManager.getChunkWidth(); x++){
|
||||
for(int y = 0; y < Globals.serverTerrainManager.getChunkWidth(); y++){
|
||||
//create node
|
||||
|
||||
if(x > 0){
|
||||
//add back neighbor
|
||||
}
|
||||
if(y > 0){
|
||||
//add back neighbor
|
||||
}
|
||||
}
|
||||
}
|
||||
return rVal;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package electrosphere.game.server.pathfinding.navmesh;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author satellite
|
||||
*/
|
||||
|
||||
/**
|
||||
* Axis aligned bounding boxes used as nodes in pathfinding navmeshes
|
||||
* Inclusive of boundary points on both minimum and maximum
|
||||
*/
|
||||
|
||||
public class NavCube extends NavShape {
|
||||
|
||||
Vector3d minPoint;
|
||||
Vector3d maxPoint;
|
||||
|
||||
List<NavCube> neighbors = new LinkedList();
|
||||
|
||||
|
||||
public NavCube(double minX, double minY, double minZ, double maxX, double maxY, double maxZ){
|
||||
minPoint = new Vector3d(minX, minY, minZ);
|
||||
maxPoint = new Vector3d(maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNeighbor(NavCube neighbor){
|
||||
neighbors.add(neighbor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NavCube> getNeighbors(){
|
||||
return neighbors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsPoint(double x, double y, double z){
|
||||
return x >= minPoint.x && y >= minPoint.y && z >= minPoint.z && x <= maxPoint.x && y <= maxPoint.y && z <= maxPoint.z;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package electrosphere.game.server.pathfinding.navmesh;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author satellite
|
||||
*/
|
||||
public class NavMesh {
|
||||
|
||||
//nav method, ie walking, flying, climbing, swimming, etc
|
||||
String method;
|
||||
|
||||
List<NavShape> navNodes = new LinkedList();
|
||||
List<NavMesh> neighbors = new LinkedList();
|
||||
|
||||
public void addNeighbor(NavMesh neighbor){
|
||||
neighbors.add(neighbor);
|
||||
}
|
||||
|
||||
public List<NavMesh> getNeighbors(){
|
||||
return neighbors;
|
||||
}
|
||||
|
||||
public void addNode(NavShape node){
|
||||
navNodes.add(node);
|
||||
}
|
||||
|
||||
public List<NavShape> getNodes(){
|
||||
return navNodes;
|
||||
}
|
||||
|
||||
public boolean containsPoint(double x, double y, double z){
|
||||
for(NavShape shape : navNodes){
|
||||
if(shape.containsPoint(x, y, z)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package electrosphere.game.server.pathfinding.navmesh;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author satellite
|
||||
*/
|
||||
public abstract class NavShape {
|
||||
|
||||
public abstract void addNeighbor(NavCube neighbor);
|
||||
|
||||
public abstract List<NavCube> getNeighbors();
|
||||
|
||||
public abstract boolean containsPoint(double x, double y, double z);
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package electrosphere.game.server.pathfinding.path;
|
||||
|
||||
import org.joml.Vector3d;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author satellite
|
||||
*/
|
||||
public class Waypoint {
|
||||
String method; //ie walking, flying, climbing, swimming, etc
|
||||
Vector3d position;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user