|
|
|
@ -978,63 +978,68 @@ public enum BuildingManager {
@@ -978,63 +978,68 @@ public enum BuildingManager {
|
|
|
|
|
|
|
|
|
|
public static void BakeBuildingMeshes(Building building){ |
|
|
|
|
|
|
|
|
|
if(building == null) |
|
|
|
|
return; |
|
|
|
|
try { |
|
|
|
|
if (building == null) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
building.buildingMeshes = new ArrayList<>(); |
|
|
|
|
float rotation = building.getRot().getRotation(); |
|
|
|
|
Vector3f buildingLoc = new Vector3f(building.loc.x,building.loc.y,building.loc.z); |
|
|
|
|
if(!prop_meshes.containsKey(building.getBlueprint().getMeshForRank(building.getRank()))) |
|
|
|
|
return; //no data for this prop ID
|
|
|
|
|
ArrayList<Integer> meshes = prop_meshes.get(building.getBlueprint().getMeshForRank(building.getRank())); |
|
|
|
|
for(int mesh : meshes){ |
|
|
|
|
|
|
|
|
|
if(!mesh_heights.containsKey(mesh) || !mesh_triangle_points.containsKey(mesh)) |
|
|
|
|
return; //no data for this mesh
|
|
|
|
|
|
|
|
|
|
Mesh generatedMesh = new Mesh(); |
|
|
|
|
generatedMesh.meshHeight = mesh_heights.get(mesh); |
|
|
|
|
ArrayList<ArrayList<Vector3f>> triPoints = mesh_triangle_points.get(mesh); |
|
|
|
|
|
|
|
|
|
if(mesh_bounding_boxes.containsKey(mesh)){ |
|
|
|
|
Rectangle2D boundingBox = mesh_bounding_boxes.get(mesh); |
|
|
|
|
generatedMesh.BoundingLines = new ArrayList<>(); |
|
|
|
|
float maxX = building.loc.x + (float)boundingBox.getMaxX(); |
|
|
|
|
float minX = building.loc.x + (float)boundingBox.getMinX(); |
|
|
|
|
float maxY = building.loc.z + (float)boundingBox.getMaxY(); |
|
|
|
|
float minY = building.loc.z + (float)boundingBox.getMinY(); |
|
|
|
|
|
|
|
|
|
Point2D.Float p1 = new Point2D.Float(minX,maxY); |
|
|
|
|
Point2D.Float p2 = new Point2D.Float(maxX,maxY); |
|
|
|
|
Point2D.Float p3 = new Point2D.Float(maxX,minY); |
|
|
|
|
Point2D.Float p4 = new Point2D.Float(minX,minY); |
|
|
|
|
generatedMesh.BoundingLines.add(new Line2D.Float(p1,p2)); |
|
|
|
|
generatedMesh.BoundingLines.add(new Line2D.Float(p2,p3)); |
|
|
|
|
generatedMesh.BoundingLines.add(new Line2D.Float(p3,p4)); |
|
|
|
|
generatedMesh.BoundingLines.add(new Line2D.Float(p4,p1)); |
|
|
|
|
} |
|
|
|
|
building.buildingMeshes = new ArrayList<>(); |
|
|
|
|
float rotation = building.getRot().getRotation(); |
|
|
|
|
Vector3f buildingLoc = new Vector3f(building.loc.x, building.loc.y, building.loc.z); |
|
|
|
|
if (!prop_meshes.containsKey(building.getBlueprint().getMeshForRank(building.getRank()))) |
|
|
|
|
return; //no data for this prop ID
|
|
|
|
|
ArrayList<Integer> meshes = prop_meshes.get(building.getBlueprint().getMeshForRank(building.getRank())); |
|
|
|
|
for (int mesh : meshes) { |
|
|
|
|
|
|
|
|
|
if (!mesh_heights.containsKey(mesh) || !mesh_triangle_points.containsKey(mesh)) |
|
|
|
|
return; //no data for this mesh
|
|
|
|
|
|
|
|
|
|
Mesh generatedMesh = new Mesh(); |
|
|
|
|
generatedMesh.meshHeight = mesh_heights.get(mesh); |
|
|
|
|
ArrayList<ArrayList<Vector3f>> triPoints = mesh_triangle_points.get(mesh); |
|
|
|
|
|
|
|
|
|
if (mesh_bounding_boxes.containsKey(mesh)) { |
|
|
|
|
Rectangle2D boundingBox = mesh_bounding_boxes.get(mesh); |
|
|
|
|
generatedMesh.BoundingLines = new ArrayList<>(); |
|
|
|
|
float maxX = building.loc.x + (float) boundingBox.getMaxX(); |
|
|
|
|
float minX = building.loc.x + (float) boundingBox.getMinX(); |
|
|
|
|
float maxY = building.loc.z + (float) boundingBox.getMaxY(); |
|
|
|
|
float minY = building.loc.z + (float) boundingBox.getMinY(); |
|
|
|
|
|
|
|
|
|
Point2D.Float p1 = new Point2D.Float(minX, maxY); |
|
|
|
|
Point2D.Float p2 = new Point2D.Float(maxX, maxY); |
|
|
|
|
Point2D.Float p3 = new Point2D.Float(maxX, minY); |
|
|
|
|
Point2D.Float p4 = new Point2D.Float(minX, minY); |
|
|
|
|
generatedMesh.BoundingLines.add(new Line2D.Float(p1, p2)); |
|
|
|
|
generatedMesh.BoundingLines.add(new Line2D.Float(p2, p3)); |
|
|
|
|
generatedMesh.BoundingLines.add(new Line2D.Float(p3, p4)); |
|
|
|
|
generatedMesh.BoundingLines.add(new Line2D.Float(p4, p1)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for(ArrayList<Vector3f> pointList : triPoints){ |
|
|
|
|
for (ArrayList<Vector3f> pointList : triPoints) { |
|
|
|
|
|
|
|
|
|
ArrayList<Vector3f> rotatedPoints = new ArrayList<>(); |
|
|
|
|
for(Vector3f point : pointList) |
|
|
|
|
rotatedPoints.add(Vector3f.rotateAroundPoint(buildingLoc,point,rotation)); |
|
|
|
|
ArrayList<Vector3f> rotatedPoints = new ArrayList<>(); |
|
|
|
|
for (Vector3f point : pointList) |
|
|
|
|
rotatedPoints.add(Vector3f.rotateAroundPoint(buildingLoc, point, rotation)); |
|
|
|
|
|
|
|
|
|
Point2D.Float p1 = new Point2D.Float(rotatedPoints.get(0).x,rotatedPoints.get(0).z); |
|
|
|
|
Point2D.Float p2 = new Point2D.Float(rotatedPoints.get(1).x,rotatedPoints.get(1).z); |
|
|
|
|
Point2D.Float p3 = new Point2D.Float(rotatedPoints.get(2).x,rotatedPoints.get(2).z); |
|
|
|
|
Point2D.Float p1 = new Point2D.Float(rotatedPoints.get(0).x, rotatedPoints.get(0).z); |
|
|
|
|
Point2D.Float p2 = new Point2D.Float(rotatedPoints.get(1).x, rotatedPoints.get(1).z); |
|
|
|
|
Point2D.Float p3 = new Point2D.Float(rotatedPoints.get(2).x, rotatedPoints.get(2).z); |
|
|
|
|
|
|
|
|
|
Triangle tri = new Triangle(); |
|
|
|
|
tri.sides = new ArrayList<>(); |
|
|
|
|
tri.sides.add(new Line2D.Float(p1,p2)); |
|
|
|
|
tri.sides.add(new Line2D.Float(p2,p3)); |
|
|
|
|
tri.sides.add(new Line2D.Float(p3,p1)); |
|
|
|
|
generatedMesh.triangles.add(tri); |
|
|
|
|
} |
|
|
|
|
if(BuildingManager.mesh_bounding_boxes.containsKey(mesh)){ |
|
|
|
|
generatedMesh.boundsRect = BuildingManager.mesh_bounding_boxes.get(mesh); |
|
|
|
|
Triangle tri = new Triangle(); |
|
|
|
|
tri.sides = new ArrayList<>(); |
|
|
|
|
tri.sides.add(new Line2D.Float(p1, p2)); |
|
|
|
|
tri.sides.add(new Line2D.Float(p2, p3)); |
|
|
|
|
tri.sides.add(new Line2D.Float(p3, p1)); |
|
|
|
|
generatedMesh.triangles.add(tri); |
|
|
|
|
} |
|
|
|
|
if (BuildingManager.mesh_bounding_boxes.containsKey(mesh)) { |
|
|
|
|
generatedMesh.boundsRect = BuildingManager.mesh_bounding_boxes.get(mesh); |
|
|
|
|
} |
|
|
|
|
building.buildingMeshes.add(generatedMesh); |
|
|
|
|
} |
|
|
|
|
building.buildingMeshes.add(generatedMesh); |
|
|
|
|
} |
|
|
|
|
catch(Exception e){ |
|
|
|
|
Logger.info("Failed TO Bake Building Mesh Data: " + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|