Search in sources :

Example 1 with DynMapColourScheme

use of org.pepsoft.worldpainter.colourschemes.DynMapColourScheme in project WorldPainter by Captain-Chaos.

the class WPObjectRenderer method main.

public static void main(String[] args) throws IOException {
    WPObject object = Bo2Object.load(new File("/home/pepijn/NetBeansProjects/Minecraft/BOBPlugins/wessex_tallredwood.bo2"));
    // WPObject object = new WPObject() {
    // public Point3i getDimensions() {
    // return new Point3i(3, 3, 1);
    // }
    // 
    // public Point3i getOrigin() {
    // return new Point3i(1, 1, 0);
    // }
    // 
    // public int getBlockID(int x, int y, int z) {
    // //                if (x == 2 - y) {
    // return Constants.BLK_STONE;
    // //                } else {
    // //                    return Constants.BLK_AIR;
    // //                }
    // }
    // 
    // public int getData(int x, int y, int z) {
    // return 0;
    // }
    // 
    // public boolean getMask(int x, int y, int z) {
    // //                return (x == 2 - y);
    // return true;
    // }
    // };
    ColourScheme colourScheme = new DynMapColourScheme("default", true);
    WPObjectRenderer renderer = new WPObjectRenderer(object, colourScheme, 10);
    BufferedImage image = renderer.render();
    ImageIcon icon = new ImageIcon(image);
    JLabel label = new JLabel(icon);
    JFrame frame = new JFrame("WPObjectRenderer Test");
    frame.getContentPane().add(label, BorderLayout.CENTER);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}
Also used : ImageIcon(javax.swing.ImageIcon) DynMapColourScheme(org.pepsoft.worldpainter.colourschemes.DynMapColourScheme) ColourScheme(org.pepsoft.worldpainter.ColourScheme) JFrame(javax.swing.JFrame) JLabel(javax.swing.JLabel) DynMapColourScheme(org.pepsoft.worldpainter.colourschemes.DynMapColourScheme) File(java.io.File) BufferedImage(java.awt.image.BufferedImage)

Example 2 with DynMapColourScheme

use of org.pepsoft.worldpainter.colourschemes.DynMapColourScheme in project WorldPainter by Captain-Chaos.

the class TileFactoryPreviewer method main.

public static void main(String[] args) {
    final long seed;
    if (args.length > 0) {
        seed = Long.parseLong(args[0]);
    } else {
        seed = new Random().nextLong();
    }
    // final ExperimentalTileFactory tileFactory = new ExperimentalTileFactory(DEFAULT_MAX_HEIGHT_2);
    // final HeightMapTileFactory tileFactory = TileFactoryFactory.createNoiseTileFactory(Terrain.GRASS, World2.DEFAULT_MAX_HEIGHT, 58, 62, false, true, 20.0f, 1.0);
    // HeightMap oceanFloor = new ConstantHeightMap(40f);
    // HeightMap continent;
    // //        continent = new NinePatchHeightMap(200, 100, 50, 58f);
    // continent = new NinePatchHeightMap(0, 1000, 50, 22f);
    // HeightMap hills = new ProductHeightMap(
    // new NoiseHeightMap(1.0f, 10f, 1),
    // new SumHeightMap(
    // new NoiseHeightMap(20.0f, 1.0f, 2),
    // new ConstantHeightMap(-5f)));
    // continent = new SumHeightMap(
    // new SumHeightMap(
    // oceanFloor,
    // continent),
    // hills);
    // HeightMap mountainsLimit = new NinePatchHeightMap(0, 1000, 200, 1f);
    // HeightMap mountains = new ProductHeightMap(
    // new ProductHeightMap(
    // new NoiseHeightMap(1.0f, 10f, 1),
    // mountainsLimit),
    // new NoiseHeightMap(256f, 5f, 4));
    // HeightMap heightMap = new MaximisingHeightMap(continent, mountains);
    // final HeightMapTileFactory tileFactory = new HeightMapTileFactory(seed, heightMap, 256, false, new FancyTheme(256, 62, heightMap));
    final HeightMapTileFactory tileFactory = TileFactoryFactory.createFancyTileFactory(seed, Terrain.GRASS, Constants.DEFAULT_MAX_HEIGHT_2, 62, 58, false, 20f, 1.0);
    // SortedMap<Integer, Terrain> terrainRanges = tileFactory.getTerrainRanges();
    // terrainRanges.clear();
    // terrainRanges.put( -1, Terrain.DIRT);
    // terrainRanges.put( 64, Terrain.GRASS);
    // terrainRanges.put(128, Terrain.ROCK);
    // terrainRanges.put(192, Terrain.DEEP_SNOW);
    // tileFactory.setTerrainRanges(terrainRanges);
    final org.pepsoft.worldpainter.TileProvider tileProvider = new org.pepsoft.worldpainter.TileProvider() {

        @Override
        public Rectangle getExtent() {
            // Tile factories are endless
            return null;
        }

        @Override
        public boolean isTilePresent(int x, int y) {
            // Tile factories are endless and have no holes
            return true;
        }

        @Override
        public Tile getTile(int x, int y) {
            Point coords = new Point(x, y);
            synchronized (cache) {
                Tile tile = cache.get(coords);
                if (tile == null) {
                    tile = tileFactory.createTile(x, y);
                    cache.put(coords, tile);
                }
                return tile;
            }
        }

        private final Map<Point, Tile> cache = new HashMap<>();
    };
    Terrain.setCustomMaterial(0, new MixedMaterial("Dirt/Gravel", new Row[] { new Row(Material.DIRT, 750, 1.0f), new Row(Material.GRAVEL, 250, 1.0f) }, Minecraft1_2BiomeScheme.BIOME_PLAINS, null, 1.0f));
    Terrain.setCustomMaterial(1, new MixedMaterial("Stone/Gravel", new Row[] { new Row(Material.STONE, 750, 1.0f), new Row(Material.GRAVEL, 250, 1.0f) }, Minecraft1_2BiomeScheme.BIOME_PLAINS, null, 1.0f));
    TiledImageViewer viewer = new TiledImageViewer();
    JFrame frame = new JFrame("TileFactory Previewer");
    viewer.setTileProvider(new WPTileProvider(tileProvider, new DynMapColourScheme("default", true), new AutoBiomeScheme(null), null, Collections.singleton((Layer) Biome.INSTANCE), true, 10, TileRenderer.LightOrigin.NORTHWEST, false, null));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(viewer, BorderLayout.CENTER);
    frame.setSize(1000, 800);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}
Also used : AutoBiomeScheme(org.pepsoft.worldpainter.biomeschemes.AutoBiomeScheme) TiledImageViewer(org.pepsoft.util.swing.TiledImageViewer) Tile(org.pepsoft.worldpainter.Tile) Point(java.awt.Point) DynMapColourScheme(org.pepsoft.worldpainter.colourschemes.DynMapColourScheme) WPTileProvider(org.pepsoft.worldpainter.WPTileProvider) Random(java.util.Random) JFrame(javax.swing.JFrame) HeightMapTileFactory(org.pepsoft.worldpainter.HeightMapTileFactory) Row(org.pepsoft.worldpainter.MixedMaterial.Row) WPTileProvider(org.pepsoft.worldpainter.WPTileProvider) HashMap(java.util.HashMap) Map(java.util.Map) MixedMaterial(org.pepsoft.worldpainter.MixedMaterial)

Example 3 with DynMapColourScheme

use of org.pepsoft.worldpainter.colourschemes.DynMapColourScheme in project WorldPainter by Captain-Chaos.

the class WorldMorph method main.

public static void main(String[] args) {
    SwingUtilities.invokeLater(() -> {
        final WorldPainter view = new WorldPainter(createNewWorld().getDimension(0), new DynMapColourScheme("default", true), null, null);
        JFrame frame = new JFrame("WorldMorph");
        frame.getContentPane().add(view, BorderLayout.CENTER);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        Timer timer = new Timer(2000, e -> view.setDimension(createNewWorld().getDimension(0)));
        timer.start();
    });
}
Also used : Timer(javax.swing.Timer) JFrame(javax.swing.JFrame) DynMapColourScheme(org.pepsoft.worldpainter.colourschemes.DynMapColourScheme)

Example 4 with DynMapColourScheme

use of org.pepsoft.worldpainter.colourschemes.DynMapColourScheme in project WorldPainter by Captain-Chaos.

the class BiomesViewerMain method main.

public static void main(String[] args) throws IOException, ClassNotFoundException {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException | UnsupportedLookAndFeelException | InstantiationException | IllegalAccessException e) {
    // Oh well
    }
    Configuration config = Configuration.load();
    if (config == null) {
        config = new Configuration();
    }
    Configuration.setInstance(config);
    BiomesViewerFrame frame = new BiomesViewerFrame(new Random().nextLong(), Constants.BIOME_ALGORITHM_1_7_DEFAULT, new DynMapColourScheme("default", true), null);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}
Also used : UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) Configuration(org.pepsoft.worldpainter.Configuration) Random(java.util.Random) DynMapColourScheme(org.pepsoft.worldpainter.colourschemes.DynMapColourScheme)

Example 5 with DynMapColourScheme

use of org.pepsoft.worldpainter.colourschemes.DynMapColourScheme in project WorldPainter by Captain-Chaos.

the class Mapper method main.

public static void main(String[] args) throws IOException, InterruptedException {
    File worldDir = null;
    int dim = 0;
    String colourSchemeName = "classic";
    File output = null;
    for (int i = 0; i < args.length; i++) {
        String arg = args[i].trim();
        switch(arg) {
            case "-d":
                if (i < args.length - 1) {
                    i++;
                    try {
                        dim = Integer.parseInt(args[i].trim());
                    } catch (NumberFormatException e) {
                        error("Invalid argument to -d option: \"" + args[i] + "\"");
                    }
                } else {
                    error("Missing argument to -d option");
                }
                break;
            case "-c":
                if (i < args.length - 1) {
                    i++;
                    colourSchemeName = args[i].trim();
                } else {
                    error("Missing argument to -c option");
                }
                break;
            case "-o":
                if (i < args.length - 1) {
                    i++;
                    String outputName = args[i].trim();
                    if (!outputName.toLowerCase().endsWith(".png")) {
                        error("Only PNG format suppored for output file");
                    }
                    output = new File(outputName);
                    if (output.getParentFile() != null) {
                        if (!output.isDirectory()) {
                            error("Parent directory of output file does not exist or is not a directory: \"" + output.getParentFile() + "\"");
                        } else if (!output.canWrite()) {
                            error("Parent directory of output file is not writeable: \"" + output.getParentFile() + "\"");
                        }
                    }
                } else {
                    error("Missing argument to -o option");
                }
                break;
            default:
                if (worldDir != null) {
                    error("Unrecognised option: \"" + arg + "\"");
                } else {
                    worldDir = new File(arg);
                }
                break;
        }
    }
    if (worldDir == null) {
        error("Map directory not specified");
    } else if (!worldDir.isDirectory()) {
        error("Map directory does not exist or is not a directory: \"" + worldDir + "\"");
    }
    if ((dim < 0) || (dim > 2)) {
        error("Invalid dimension specified: " + dim);
    }
    System.out.println("WorldPainter Mapper tool - version " + Version.VERSION + " - © 2012 - 2014 pepsoft.org");
    ColourScheme colourScheme = new DynMapColourScheme(colourSchemeName, true);
    if (output == null) {
        output = new File(worldDir.getName().toLowerCase() + ".png");
    }
    map(worldDir, dim, colourScheme, output);
}
Also used : DynMapColourScheme(org.pepsoft.worldpainter.colourschemes.DynMapColourScheme) ColourScheme(org.pepsoft.worldpainter.ColourScheme) DynMapColourScheme(org.pepsoft.worldpainter.colourschemes.DynMapColourScheme) File(java.io.File) RegionFile(org.pepsoft.minecraft.RegionFile)

Aggregations

DynMapColourScheme (org.pepsoft.worldpainter.colourschemes.DynMapColourScheme)6 JFrame (javax.swing.JFrame)3 File (java.io.File)2 Random (java.util.Random)2 ColourScheme (org.pepsoft.worldpainter.ColourScheme)2 AutoBiomeScheme (org.pepsoft.worldpainter.biomeschemes.AutoBiomeScheme)2 Point (java.awt.Point)1 BufferedImage (java.awt.image.BufferedImage)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ImageIcon (javax.swing.ImageIcon)1 JLabel (javax.swing.JLabel)1 Timer (javax.swing.Timer)1 UnsupportedLookAndFeelException (javax.swing.UnsupportedLookAndFeelException)1 RegionFile (org.pepsoft.minecraft.RegionFile)1 TiledImageViewer (org.pepsoft.util.swing.TiledImageViewer)1 org.pepsoft.worldpainter (org.pepsoft.worldpainter)1 Configuration (org.pepsoft.worldpainter.Configuration)1 HeightMapTileFactory (org.pepsoft.worldpainter.HeightMapTileFactory)1 MixedMaterial (org.pepsoft.worldpainter.MixedMaterial)1