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