From d502a889a67ce51494c5e62317214561b6255540 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 7 Nov 2023 20:54:45 -0600 Subject: [PATCH] shape --- src/engine/gameManager/BuildingManager.java | 28 ++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index c467e305..318b3ffb 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -984,19 +984,29 @@ public enum BuildingManager { return; } - if(building.meshUUID == 24000){ - int i = 0; - } - for (ArrayList meshEntry : convexHullList) { + ArrayList rotatedPoints = new ArrayList<>(); + for (Vector2f vect : meshEntry) { + Vector3fImmutable offsetVect = new Vector3fImmutable(vect.x + building.loc.x, building.loc.y,vect.y + building.loc.z); + Vector3fImmutable rotatedVect = Vector3fImmutable.rotateAroundPoint(offsetVect,building.loc,building.getRot().y); + rotatedPoints.add(rotatedVect); + } Path2D.Float meshBound = new Path2D.Float(); - Vector3fImmutable start = Vector3fImmutable.rotateAroundPoint(new Vector3fImmutable(meshEntry.get(0).x,building.loc.y,meshEntry.get(0).y),building.loc,building.getRot().getRotation()); - meshBound.moveTo(start.x,start.z); + Polygon poly = new Polygon(); + Vector3fImmutable offsetVect = new Vector3fImmutable(meshEntry.get(0).x + building.loc.x, building.loc.y,meshEntry.get(0).y + building.loc.z); + Vector3fImmutable rotatedStart = Vector3fImmutable.rotateAroundPoint(offsetVect,building.loc,building.getRot().getRotation()); + meshBound.moveTo(rotatedStart.x,rotatedStart.z); for (Vector2f vect : meshEntry) { - Vector3fImmutable pos = Vector3fImmutable.rotateAroundPoint(new Vector3fImmutable(vect.x,building.loc.y,vect.y),building.loc,building.getRot().getRotation()); - meshBound.lineTo(pos.x,pos.z); + if(meshEntry.indexOf(vect) == 0){ + continue; + } + Vector3fImmutable pos = new Vector3fImmutable(vect.x + building.loc.x, building.loc.y,vect.y + building.loc.z); + Vector3fImmutable rotatedPos = Vector3fImmutable.rotateAroundPoint(pos,building.loc,building.getRot().getRotation()); + poly.addPoint((int)rotatedPos.x,(int)rotatedPos.z); + meshBound.lineTo(rotatedPos.x,rotatedPos.z); } - meshBound.lineTo(start.x,start.z); + Area area = new Area(poly); + meshBound.lineTo(rotatedStart.x,rotatedStart.z); meshBound.closePath(); building.meshes.add(meshBound); }