Search in sources :

Example 21 with Point3i

use of javax.vecmath.Point3i in project WorldPainter by Captain-Chaos.

the class EditObjectAttributes method editOffset.

private void editOffset() {
    if (objects.size() > 1) {
        return;
    }
    WPObject object = objects.iterator().next();
    Point3i offset = offsets.get(object);
    OffsetEditor dialog = new OffsetEditor(this, (offset != null) ? offset : new Point3i(), object, colourScheme);
    dialog.setVisible(true);
    if (!dialog.isCancelled()) {
        offset = dialog.getOffset();
        offsets.put(object, offset);
        String offsetStr = "<html><u>" + offset.x + ", " + offset.y + ", " + offset.z + "</u></html>";
        labelOffset.setText(offsetStr);
    }
}
Also used : Point3i(javax.vecmath.Point3i) WPObject(org.pepsoft.worldpainter.objects.WPObject)

Example 22 with Point3i

use of javax.vecmath.Point3i in project WorldPainter by Captain-Chaos.

the class OffsetViewer method paintComponent.

@Override
protected void paintComponent(Graphics g) {
    if ((object == null) || (offset == null)) {
        return;
    }
    Graphics2D g2 = (Graphics2D) g;
    int baseLine = getHeight() * 3 / 4;
    int middle = getWidth() / 2;
    Point3i dim = object.getDimensions();
    switch(direction) {
        case X_ASC:
            for (int y = 0; y <= Math.min(-offset.y, dim.y - 1); y++) {
                for (int x = 0; x < dim.x; x++) {
                    for (int z = 0; z < dim.z; z++) {
                        if (object.getMask(x, y, z)) {
                            paintBlock(g2, baseLine, middle, x + offset.x, z + offset.z, -offset.y - y, object.getMaterial(x, y, z));
                        }
                    }
                }
            }
            g2.drawImage(IMAGE_X_ASC, middle + 10, getHeight() - IMAGE_X_ASC.getHeight() - 2, null);
            break;
        case Y_ASC:
            for (int x = 0; x <= Math.min(-offset.x, dim.x - 1); x++) {
                for (int y = 0; y < dim.y; y++) {
                    for (int z = 0; z < dim.z; z++) {
                        if (object.getMask(x, y, z)) {
                            paintBlock(g2, baseLine, middle, y + offset.y, z + offset.z, -offset.x - x, object.getMaterial(x, y, z));
                        }
                    }
                }
            }
            g2.drawImage(IMAGE_Y_ASC, middle + 10, getHeight() - IMAGE_Y_ASC.getHeight() - 2, null);
            break;
        case X_DESC:
            for (int y = dim.y - 1; y >= Math.max(-offset.y, 0); y--) {
                for (int x = 0; x < dim.x; x++) {
                    for (int z = 0; z < dim.z; z++) {
                        if (object.getMask(x, y, z)) {
                            paintBlock(g2, baseLine, middle, -x - offset.x, z + offset.z, y - -offset.y, object.getMaterial(x, y, z));
                        }
                    }
                }
            }
            g2.drawImage(IMAGE_X_DESC, middle - IMAGE_X_DESC.getWidth() - 10, getHeight() - IMAGE_X_DESC.getHeight() - 2, null);
            break;
        case Y_DESC:
            for (int x = dim.x - 1; x >= Math.max(-offset.x, 0); x--) {
                for (int y = 0; y < dim.y; y++) {
                    for (int z = 0; z < dim.z; z++) {
                        if (object.getMask(x, y, z)) {
                            paintBlock(g2, baseLine, middle, -y - offset.y, z + offset.z, x - -offset.x, object.getMaterial(x, y, z));
                        }
                    }
                }
            }
            g2.drawImage(IMAGE_Y_DESC, middle - IMAGE_Y_DESC.getWidth() - 10, getHeight() - IMAGE_Y_DESC.getHeight() - 2, null);
            break;
    }
    g2.setColor(Color.BLACK);
    g2.setStroke(STROKE);
    g2.drawRect(middle - 8, baseLine - 8, 16, 16);
    g2.drawLine(middle - 8, baseLine + 8, 0, baseLine + 8);
    g2.drawLine(middle + 7, baseLine + 8, getWidth() - 1, baseLine + 8);
}
Also used : Point3i(javax.vecmath.Point3i) Graphics2D(java.awt.Graphics2D)

Aggregations

Point3i (javax.vecmath.Point3i)22 Material (org.pepsoft.minecraft.Material)3 Box (org.pepsoft.util.Box)3 WPObject (org.pepsoft.worldpainter.objects.WPObject)3 HashMap (java.util.HashMap)2 TileEntity (org.pepsoft.minecraft.TileEntity)2 DefaultMaterial (com.khorn.terraincontrol.util.minecraftTypes.DefaultMaterial)1 Graphics2D (java.awt.Graphics2D)1 BufferedImage (java.awt.image.BufferedImage)1 File (java.io.File)1 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Random (java.util.Random)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 NBTOutputStream (org.jnbt.NBTOutputStream)1 Block (org.pepsoft.minecraft.Block)1 Chunk (org.pepsoft.minecraft.Chunk)1 Entity (org.pepsoft.minecraft.Entity)1