|
|
@ -982,47 +982,51 @@ public enum BuildingManager { |
|
|
|
if (building == null) |
|
|
|
if (building == null) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
building.buildingTriangles = 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 (!mesh_triangle_points.containsKey(building.meshUUID)) |
|
|
|
if (!mesh_triangle_points.containsKey(building.meshUUID)) |
|
|
|
return; //no data for this prop ID
|
|
|
|
return; //no data for this prop ID
|
|
|
|
//ArrayList<Integer> meshes = prop_meshes.get(building.meshUUID);
|
|
|
|
ArrayList<Integer> meshes = prop_meshes.get(building.meshUUID); |
|
|
|
//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.maxY = building.loc.y + mesh_heights.get(mesh).x;
|
|
|
|
generatedMesh.maxY = building.loc.y + mesh_heights.get(mesh).x; |
|
|
|
//generatedMesh.minY = building.loc.y + mesh_heights.get(mesh).y;
|
|
|
|
generatedMesh.minY = building.loc.y + mesh_heights.get(mesh).y; |
|
|
|
ArrayList<ArrayList<Vector3f>> triPoints = mesh_triangle_points.get(building.meshUUID); |
|
|
|
ArrayList<ArrayList<Vector3f>> triPoints = mesh_triangle_points.get(building.meshUUID); |
|
|
|
|
|
|
|
|
|
|
|
//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); |
|
|
|
//Bounds buildingBounds = building.getBounds();
|
|
|
|
float halfX = (float) boundingBox.getWidth() * 0.5f; |
|
|
|
//float halfX = (float) boundingBox.getWidth() * 0.5f;
|
|
|
|
float halfZ = (float) boundingBox.getHeight() * 0.5f; |
|
|
|
//float halfZ = (float)boundingBox.getHeight() * 0.5f;
|
|
|
|
Vector3f bottomRight = new Vector3f(building.loc.x + halfX, building.loc.y, building.loc.z + halfZ); |
|
|
|
//Vector3f bottomRight = new Vector3f(building.loc.x + halfX,building.loc.y,building.loc.z + halfZ);
|
|
|
|
Vector3f topLeft = new Vector3f(building.loc.x - halfX, building.loc.y, building.loc.z - halfZ); |
|
|
|
//Vector3f topLeft = new Vector3f(building.loc.x - halfX,building.loc.y,building.loc.z - halfZ);
|
|
|
|
Vector3f topRight = new Vector3f(building.loc.x + halfX, building.loc.y, building.loc.z - halfZ); |
|
|
|
//Vector3f topRight = new Vector3f(building.loc.x + halfX,building.loc.y,building.loc.z - halfZ);
|
|
|
|
Vector3f bottomLeft = new Vector3f(building.loc.x - halfX, building.loc.y, building.loc.z + halfZ); |
|
|
|
//Vector3f bottomLeft = new Vector3f(building.loc.x - halfX,building.loc.y,building.loc.z + halfZ);
|
|
|
|
|
|
|
|
|
|
|
|
topLeft.x *= -1; |
|
|
|
//generatedMesh.BoundingLines = new ArrayList<>();
|
|
|
|
bottomLeft.x *= -1; |
|
|
|
//Point2D.Float p1 = new Point2D.Float(topLeft.x, topLeft.z);
|
|
|
|
topRight.x *= -1; |
|
|
|
//Point2D.Float p2 = new Point2D.Float(topRight.x, topRight.z);
|
|
|
|
bottomRight.x *= -1; |
|
|
|
//Point2D.Float p3 = new Point2D.Float(bottomRight.x, bottomRight.z);
|
|
|
|
|
|
|
|
//Point2D.Float p4 = new Point2D.Float(bottomLeft.x, bottomLeft.z);
|
|
|
|
generatedMesh.BoundingLines = new ArrayList<>(); |
|
|
|
//float rectWidth = topLeft.distance(topRight);
|
|
|
|
Point2D.Float p1 = new Point2D.Float(topLeft.x, topLeft.z); |
|
|
|
//float rectHeight = topLeft.distance(bottomLeft);
|
|
|
|
Point2D.Float p2 = new Point2D.Float(topRight.x, topRight.z); |
|
|
|
//boundingBox.setRect(p1.x,p1.y,rectWidth, rectHeight);
|
|
|
|
Point2D.Float p3 = new Point2D.Float(bottomRight.x, bottomRight.z); |
|
|
|
//generatedMesh.BoundingLines.add(new Line2D.Float(p1, p2));
|
|
|
|
Point2D.Float p4 = new Point2D.Float(bottomLeft.x, bottomLeft.z); |
|
|
|
//generatedMesh.BoundingLines.add(new Line2D.Float(p2, p3));
|
|
|
|
float rectWidth = topLeft.distance(topRight); |
|
|
|
//generatedMesh.BoundingLines.add(new Line2D.Float(p3, p4));
|
|
|
|
float rectHeight = topLeft.distance(bottomLeft); |
|
|
|
//generatedMesh.BoundingLines.add(new Line2D.Float(p4, p1));
|
|
|
|
boundingBox.setRect(p1.x, p1.y, rectWidth, rectHeight); |
|
|
|
//generatedMesh.boundsRect = boundingBox;
|
|
|
|
generatedMesh.BoundingLines.add(new Line2D.Float(p1, p2)); |
|
|
|
//}
|
|
|
|
generatedMesh.BoundingLines.add(new Line2D.Float(p2, p3)); |
|
|
|
//generatedMesh.triangles = new ArrayList<>();
|
|
|
|
generatedMesh.BoundingLines.add(new Line2D.Float(p3, p4)); |
|
|
|
|
|
|
|
generatedMesh.BoundingLines.add(new Line2D.Float(p4, p1)); |
|
|
|
|
|
|
|
generatedMesh.boundsRect = boundingBox; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
generatedMesh.triangles = new ArrayList<>(); |
|
|
|
for (ArrayList<Vector3f> pointList : triPoints) { |
|
|
|
for (ArrayList<Vector3f> pointList : triPoints) { |
|
|
|
|
|
|
|
|
|
|
|
ArrayList<Vector3f> rotatedPoints = new ArrayList<>(); |
|
|
|
ArrayList<Vector3f> rotatedPoints = new ArrayList<>(); |
|
|
@ -1040,12 +1044,12 @@ public enum BuildingManager { |
|
|
|
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); |
|
|
|
building.buildingTriangles.add(tri); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//building.buildingMeshes.add(generatedMesh);
|
|
|
|
building.buildingMeshes.add(generatedMesh); |
|
|
|
//}
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch(Exception e){ |
|
|
|
catch(Exception e){ |
|
|
|
Logger.info("Failed To Bake Building Mesh Data For Structure: " + building.meshUUID); |
|
|
|
Logger.info("Failed To Bake Building Mesh Data For Structure: " + building.meshUUID); |
|
|
|
} |
|
|
|
} |
|
|
|