OK, I wrote this:
public Rectangle newBounds2D(Camera theCamera, FrameBuffer buffer) {
PolygonManager polyManager = unitPlane.getPolygonManager();
SimpleVector[] vertices = new SimpleVector[polyManager.getMaxPolygonID()*3];
int currentPoly = 0;
float minX = Float.MAX_VALUE, minY = Float.MAX_VALUE, minZ = Float.MAX_VALUE;
float maxX = Float.MIN_VALUE, maxY = Float.MIN_VALUE, maxZ = Float.MIN_VALUE;
for (int i = 0; i < vertices.length; i+=3) {
vertices[i] = polyManager.getTransformedVertex(currentPoly, 0);
vertices[i+1] = polyManager.getTransformedVertex(currentPoly, 1);
vertices[i+2] = polyManager.getTransformedVertex(currentPoly++, 2);
if (minX > vertices[i].x)
minX = vertices[i].x;
if (minX > vertices[i+1].x)
minX = vertices[i+1].x;
if (minX > vertices[i+2].x)
minX = vertices[i+2].x;
if (maxX < vertices[i].x)
maxX = vertices[i].x;
if (maxX < vertices[i+1].x)
maxX = vertices[i+1].x;
if (maxX < vertices[i+2].x)
maxX = vertices[i+2].x;
if (minY > vertices[i].y)
minY = vertices[i].y;
if (minY > vertices[i+1].y)
minY = vertices[i+1].y;
if (minY > vertices[i+2].y)
minY = vertices[i+2].y;
if (maxY < vertices[i].y)
maxY = vertices[i].y;
if (maxY < vertices[i+1].y)
maxY = vertices[i+1].y;
if (maxY < vertices[i+2].y)
maxY = vertices[i+2].y;
if (minZ > vertices[i].z)
minZ = vertices[i].z;
if (minZ > vertices[i+1].z)
minZ = vertices[i+1].z;
if (minZ > vertices[i+2].z)
minZ = vertices[i+2].z;
if (maxZ < vertices[i].z)
maxZ = vertices[i].z;
if (maxZ < vertices[i+1].z)
maxZ = vertices[i+1].z;
if (maxZ < vertices[i+2].z)
maxZ = vertices[i+2].z;
}
return getBounds2D(theCamera, buffer, minX, minY, maxX, maxY);
}
public Rectangle getBounds2D(Camera theCamera, FrameBuffer buffer, float minX, float minY, float maxX, float maxY) {
SimpleVector minP = Interact2D.project3D2D(theCamera, buffer, new SimpleVector(minX, minY, 0));
SimpleVector maxP = Interact2D.project3D2D(theCamera, buffer, new SimpleVector(maxX, maxY, 0));
return new Rectangle((int)minP.x, (int)minP.y, (int)Math.abs(maxP.x-minP.x), (int)Math.abs(maxP.y-minP.y));
}
Exact same problem, though.