|
|
@ -984,39 +984,48 @@ public enum BuildingManager { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (ArrayList<Vector2f> meshEntry : convexHullList) { |
|
|
|
Area footprint = new Area(new Rectangle((int) building.loc.x, (int) building.loc.z, (int) (building.getBounds().getHalfExtents().x * 2), (int) (building.getBounds().getHalfExtents().y * 2))); |
|
|
|
|
|
|
|
building.parentZone.navMesh.subtract(footprint); |
|
|
|
|
|
|
|
|
|
|
|
Path2D.Float stencilPath = new Path2D.Float(); |
|
|
|
for (ArrayList<Vector2f> meshEntry : convexHullList) { |
|
|
|
|
|
|
|
Polygon poly = new Polygon(); |
|
|
|
|
|
|
|
for(Vector2f vect : meshEntry){ |
|
|
|
|
|
|
|
Vector3fImmutable rotationPoint = Vector3fImmutable.rotateAroundPoint(new Vector3fImmutable(vect.x + building.loc.x,0,vect.y + building.loc.z),building.loc,building.getRot().getRotation()); |
|
|
|
|
|
|
|
poly.addPoint((int) rotationPoint.x, (int) rotationPoint.z); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
footprint.subtract(new Area(poly)); |
|
|
|
|
|
|
|
//Path2D.Float stencilPath = new Path2D.Float();
|
|
|
|
|
|
|
|
|
|
|
|
// Add building offset and rotation to vertices
|
|
|
|
// Add building offset and rotation to vertices
|
|
|
|
|
|
|
|
|
|
|
|
for (Vector2f vertex : meshEntry) { |
|
|
|
//for (Vector2f vertex : meshEntry) {
|
|
|
|
vertex.addLocal(building.getLoc().x, building.getLoc().z); |
|
|
|
// vertex.addLocal(building.getLoc().x, building.getLoc().z);
|
|
|
|
Vector3fImmutable rotatedPoint = new Vector3fImmutable(vertex.x, 0, vertex.y); |
|
|
|
// Vector3fImmutable rotatedPoint = new Vector3fImmutable(vertex.x, 0, vertex.y);
|
|
|
|
rotatedPoint = Vector3fImmutable.rotateAroundPoint(building.getLoc(), rotatedPoint, building.getBounds().getQuaternion().angleY); |
|
|
|
// rotatedPoint = Vector3fImmutable.rotateAroundPoint(building.getLoc(), rotatedPoint, building.getBounds().getQuaternion().angleY);
|
|
|
|
vertex.set(rotatedPoint.x, rotatedPoint.z); |
|
|
|
// vertex.set(rotatedPoint.x, rotatedPoint.z);
|
|
|
|
} |
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
// Move to start of path
|
|
|
|
// Move to start of path
|
|
|
|
|
|
|
|
|
|
|
|
stencilPath.moveTo(meshEntry.get(0).x, meshEntry.get(0).y); |
|
|
|
//stencilPath.moveTo(meshEntry.get(0).x, meshEntry.get(0).y);
|
|
|
|
|
|
|
|
|
|
|
|
// Draw path
|
|
|
|
// Draw path
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i < meshEntry.size(); i++) |
|
|
|
//for (int i = 1; i < meshEntry.size(); i++)
|
|
|
|
stencilPath.lineTo(meshEntry.get(i).x, meshEntry.get(i).y); |
|
|
|
// stencilPath.lineTo(meshEntry.get(i).x, meshEntry.get(i).y);
|
|
|
|
|
|
|
|
|
|
|
|
// enclose the path
|
|
|
|
// enclose the path
|
|
|
|
|
|
|
|
|
|
|
|
stencilPath.closePath(); |
|
|
|
//stencilPath.closePath();
|
|
|
|
|
|
|
|
|
|
|
|
// subtract stencil from zone navmesh
|
|
|
|
// subtract stencil from zone navmesh
|
|
|
|
|
|
|
|
|
|
|
|
Area stencilArea = new Area(stencilPath); |
|
|
|
//Area stencilArea = new Area(stencilPath);
|
|
|
|
AffineTransform at = new AffineTransform(); |
|
|
|
//AffineTransform at = new AffineTransform();
|
|
|
|
at.createTransformedShape(new Polygon()); |
|
|
|
//at.createTransformedShape(new Polygon());
|
|
|
|
building.parentZone.navMesh.subtract(stencilArea.createTransformedArea(at)); |
|
|
|
//building.parentZone.navMesh.subtract(stencilArea.createTransformedArea(at));
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
building.parentZone.navMesh.add(footprint); |
|
|
|
|
|
|
|
|
|
|
|
//add in all the regions to the navMesh
|
|
|
|
//add in all the regions to the navMesh
|
|
|
|
|
|
|
|
|
|
|
|