Я работаю над рендерингом полигонов на моем экране, но когда я очищаю BufferedImage в начале метода с использованием fillRect, ничего не появляется. Вещи обнаруживаются с методом fillRect в одном из моих объектов того же типа, но не в другом с тем же типом.
Я уже пытался поместить метод w / fillPolygon в тот же метод, что и метод filLRect, но он не работал. Я попытался удалить RenderingHints из моего объекта Graphics2D и альфа-композиции.
private void projectMap() {
// Makes the entire screen black before reprojecting!
g2d.setColor(Color.BLACK);
g2d.fillRect(0,0,image.getWidth(), image.getHeight());
for(int i = 0; i < orderedChunks.size(); i++) {
Chunk ic = orderedChunks.get(i);
orderParts(ic);
for(int j = 0; j < orderedParts.size(); j++) {
Part ip = orderedParts.get(j);
projectPart(ic.getX(), ic.getZ(), ip);
}
}
}
// Assuming that projCornersX and projCornersY have values stored in them. Many lines of this code have been removed.
private void projectPart(int chunkX, int chunkZ, Part part) {
BufferedImage image = part.getImage();
int orient = part.getOrient();
int x = part.getX();
int y = part.getY();
int width = part.getWidth();
int length = part.getLength();
int displacement = part.getDisplacement();
int componentIndex = part.getComponentIndex();
int curX = 0;
int curY = 0;
int curZ = 0;
if(orient==0) {
curY = componentIndex * Main.IMAGE_SIZE + displacement;
}
for(int ix = 0; ix < width; ix++) {
if(orient==0) {
curX = chunkX * Main.IMAGE_SIZE + x + ix;
}
for(int iy = 0; iy < length; iy++) {
if(hasIndexWithinImage(projCornersX, projCornersY)) {
g2d.setColor(new Color(image.getRGB(ix, iy)));
g2d.fillPolygon(projCornersX, projCornersY, 4);
}
}
}
}
Я бы получил черный фон, но я хочу, чтобы полигоны отображались, потому что методы fillPolygon следуют за методом fillRect.
Обратите внимание, что все объекты инициализированы.