road macro data
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
139a5a11d3
commit
531781dd54
@ -1877,6 +1877,7 @@ AIs build structures based on their character's race
|
|||||||
Scaffolding jobs assigned by town to characters
|
Scaffolding jobs assigned by town to characters
|
||||||
Fix character position not saving on creating a player's character for the first time
|
Fix character position not saving on creating a player's character for the first time
|
||||||
Server utility to move entities scans to see if it needs to create macro data if moving a player's entity
|
Server utility to move entities scans to see if it needs to create macro data if moving a player's entity
|
||||||
|
Road macro data generation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import electrosphere.server.macro.character.Character;
|
|||||||
import electrosphere.server.macro.character.data.CharacterDataStrings;
|
import electrosphere.server.macro.character.data.CharacterDataStrings;
|
||||||
import electrosphere.server.macro.civilization.Civilization;
|
import electrosphere.server.macro.civilization.Civilization;
|
||||||
import electrosphere.server.macro.civilization.CivilizationGenerator;
|
import electrosphere.server.macro.civilization.CivilizationGenerator;
|
||||||
|
import electrosphere.server.macro.civilization.road.Road;
|
||||||
import electrosphere.server.macro.race.Race;
|
import electrosphere.server.macro.race.Race;
|
||||||
import electrosphere.server.macro.race.RaceMap;
|
import electrosphere.server.macro.race.RaceMap;
|
||||||
import electrosphere.server.macro.spatial.MacroAreaObject;
|
import electrosphere.server.macro.spatial.MacroAreaObject;
|
||||||
@ -51,6 +52,11 @@ public class MacroData {
|
|||||||
*/
|
*/
|
||||||
List<VirtualStructure> structures = new LinkedList<VirtualStructure>();
|
List<VirtualStructure> structures = new LinkedList<VirtualStructure>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of roads
|
||||||
|
*/
|
||||||
|
List<Road> roads = new LinkedList<Road>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a world
|
* Generates a world
|
||||||
* @param seed The seed for the world
|
* @param seed The seed for the world
|
||||||
@ -240,6 +246,23 @@ public class MacroData {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a road
|
||||||
|
* @param road The road
|
||||||
|
*/
|
||||||
|
public void addRoad(Road road){
|
||||||
|
road.setId(this.roads.size());
|
||||||
|
this.roads.add(road);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the roads in the macro data
|
||||||
|
* @return The list of roads
|
||||||
|
*/
|
||||||
|
public List<Road> getRoads(){
|
||||||
|
return this.roads;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the list of structures
|
* Gets the list of structures
|
||||||
* @return The list of structures
|
* @return The list of structures
|
||||||
|
|||||||
@ -5,9 +5,11 @@ import org.joml.Vector3d;
|
|||||||
import electrosphere.data.Config;
|
import electrosphere.data.Config;
|
||||||
import electrosphere.server.datacell.ServerWorldData;
|
import electrosphere.server.datacell.ServerWorldData;
|
||||||
import electrosphere.server.macro.MacroData;
|
import electrosphere.server.macro.MacroData;
|
||||||
|
import electrosphere.server.macro.civilization.road.Road;
|
||||||
import electrosphere.server.macro.race.Race;
|
import electrosphere.server.macro.race.Race;
|
||||||
import electrosphere.server.macro.town.Town;
|
import electrosphere.server.macro.town.Town;
|
||||||
import electrosphere.server.physics.terrain.manager.ServerTerrainChunk;
|
import electrosphere.server.physics.terrain.manager.ServerTerrainChunk;
|
||||||
|
import electrosphere.util.ds.Spline3d;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates civilizations
|
* Generates civilizations
|
||||||
@ -34,6 +36,11 @@ public class CivilizationGenerator {
|
|||||||
newCiv.addRace(race);
|
newCiv.addRace(race);
|
||||||
Town startingTown = macroData.addTown(spawnPoint, INITIAL_TOWN_RADIUS, newCiv.getId());
|
Town startingTown = macroData.addTown(spawnPoint, INITIAL_TOWN_RADIUS, newCiv.getId());
|
||||||
newCiv.addTown(startingTown);
|
newCiv.addTown(startingTown);
|
||||||
|
Road.createRoad(macroData, Spline3d.createCatmullRom(new Vector3d[]{
|
||||||
|
new Vector3d(spawnPoint).add(-10,0,0),
|
||||||
|
new Vector3d(spawnPoint),
|
||||||
|
new Vector3d(spawnPoint).add( 10,0,0),
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,161 @@
|
|||||||
|
package electrosphere.server.macro.civilization.road;
|
||||||
|
|
||||||
|
import org.joml.AABBd;
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
|
||||||
|
import electrosphere.server.macro.MacroData;
|
||||||
|
import electrosphere.util.ds.Spline3d;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A road
|
||||||
|
*/
|
||||||
|
public class Road {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default radius
|
||||||
|
*/
|
||||||
|
public static final double DEFAULT_RADIUS = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default material
|
||||||
|
*/
|
||||||
|
public static final String defaultMaterial = "dirt";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The id of the road
|
||||||
|
*/
|
||||||
|
int id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The spline that the road is aligned along
|
||||||
|
*/
|
||||||
|
Spline3d spline;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The radius of the road
|
||||||
|
*/
|
||||||
|
double radius = Road.DEFAULT_RADIUS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The aabb of the road
|
||||||
|
*/
|
||||||
|
AABBd aabb;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The material that the road is made out of
|
||||||
|
*/
|
||||||
|
String roadMaterial = Road.defaultMaterial;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private contructor
|
||||||
|
*/
|
||||||
|
private Road(){ }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a road
|
||||||
|
* @param macroData The macro data
|
||||||
|
* @param spline The spline
|
||||||
|
* @param material The material for the road
|
||||||
|
* @return The road
|
||||||
|
*/
|
||||||
|
public static Road createRoad(MacroData macroData, Spline3d spline){
|
||||||
|
Road road = new Road();
|
||||||
|
road.setSpline(spline);
|
||||||
|
macroData.addRoad(road);
|
||||||
|
return road;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the id of the road
|
||||||
|
* @return The id
|
||||||
|
*/
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the id of the road
|
||||||
|
* @param id The id
|
||||||
|
*/
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the spline that the road is aligned along
|
||||||
|
* @return The spline
|
||||||
|
*/
|
||||||
|
public Spline3d getSpline() {
|
||||||
|
return spline;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the spline that the road is aligned along
|
||||||
|
* @param spline The spline
|
||||||
|
*/
|
||||||
|
public void setSpline(Spline3d spline) {
|
||||||
|
this.spline = spline;
|
||||||
|
this.computeAABB();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the radius of the road
|
||||||
|
* @return The radius
|
||||||
|
*/
|
||||||
|
public double getRadius() {
|
||||||
|
return radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the radius of the road
|
||||||
|
* @param radius The radius
|
||||||
|
*/
|
||||||
|
public void setRadius(double radius) {
|
||||||
|
this.radius = radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the road material
|
||||||
|
* @return The material
|
||||||
|
*/
|
||||||
|
public String getRoadMaterial() {
|
||||||
|
return roadMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the road material
|
||||||
|
* @param roadMaterial The material
|
||||||
|
*/
|
||||||
|
public void setRoadMaterial(String roadMaterial) {
|
||||||
|
this.roadMaterial = roadMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes the aabb of the road
|
||||||
|
*/
|
||||||
|
private void computeAABB(){
|
||||||
|
this.aabb = new AABBd();
|
||||||
|
for(Vector3d point : this.spline.getPoints()){
|
||||||
|
if(this.aabb.minX > point.x){
|
||||||
|
this.aabb.minX = point.x;
|
||||||
|
}
|
||||||
|
if(this.aabb.minY > point.y){
|
||||||
|
this.aabb.minY = point.y;
|
||||||
|
}
|
||||||
|
if(this.aabb.minZ > point.z){
|
||||||
|
this.aabb.minZ = point.z;
|
||||||
|
}
|
||||||
|
if(this.aabb.maxX < point.x){
|
||||||
|
this.aabb.maxX = point.x;
|
||||||
|
}
|
||||||
|
if(this.aabb.maxY < point.y){
|
||||||
|
this.aabb.maxY = point.y;
|
||||||
|
}
|
||||||
|
if(this.aabb.maxZ < point.z){
|
||||||
|
this.aabb.maxZ = point.z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user