Search in sources :

Example 1 with SumHeightMap

use of org.pepsoft.worldpainter.heightMaps.SumHeightMap in project WorldPainter by Captain-Chaos.

the class NoiseTileFactory method readObject.

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    // Legacy support
    if (!beachesMigrated) {
        setBeaches(beaches);
        setRandomise(true);
        beachesMigrated = true;
    }
    if (range == 0) {
        baseHeight++;
        range = 20;
        scale = 1.0;
    }
    if (getHeightMap() == null) {
        setHeightMap(new SumHeightMap(new ConstantHeightMap(baseHeight), new NoiseHeightMap(range, scale, 1)));
    }
    perlinNoise = null;
}
Also used : SumHeightMap(org.pepsoft.worldpainter.heightMaps.SumHeightMap) NoiseHeightMap(org.pepsoft.worldpainter.heightMaps.NoiseHeightMap) ConstantHeightMap(org.pepsoft.worldpainter.heightMaps.ConstantHeightMap)

Example 2 with SumHeightMap

use of org.pepsoft.worldpainter.heightMaps.SumHeightMap in project WorldPainter by Captain-Chaos.

the class TileFactoryFactory method createFancyTileFactory.

public static HeightMapTileFactory createFancyTileFactory(long seed, Terrain terrain, int maxHeight, int baseHeight, int waterLevel, boolean floodWithLava, float range, double scale) {
    // final HeightMapTileFactory tileFactory = TileFactoryFactory.createNoiseTileFactory(Terrain.GRASS, World2.DEFAULT_MAX_HEIGHT, 58, 62, false, true, 20.0f, 1.0);
    HeightMap oceanFloor = new ConstantHeightMap("Ocean Floor", waterLevel - 22);
    HeightMap continent;
    // continent = new NinePatchHeightMap(200, 100, 50, 58f);
    continent = new NinePatchHeightMap("Continent", 0, 500, 50, baseHeight - (waterLevel - 22));
    Random random = new Random(seed);
    HeightMap hills = new ProductHeightMap("Hills", new NoiseHeightMap(1.0f, 10f, 1, random.nextLong()), new NoiseHeightMap(range, scale, 2, random.nextLong()));
    // new SumHeightMap(
    // new NoiseHeightMap(range, scale, 2),
    // new ConstantHeightMap(-5f)));
    continent = new SumHeightMap(new SumHeightMap(oceanFloor, continent), hills);
    HeightMap mountainsLimit = new NinePatchHeightMap(0, 500, 200, 1f);
    HeightMap mountainsHeight = new ProductHeightMap(new ProductHeightMap(new NoiseHeightMap(1.0f, 10f, 1, random.nextLong()), mountainsLimit), new NoiseHeightMap(256f, 5f, 5, random.nextLong()));
    HeightMap mountainsAngleMap = new NoiseHeightMap((float) (Math.PI * 2), 2.5, 1, random.nextLong());
    HeightMap mountainsDistanceMap = new NoiseHeightMap(25f, 2.5, 1, random.nextLong());
    HeightMap mountains = new DisplacementHeightMap("Mountains", mountainsHeight, mountainsAngleMap, mountainsDistanceMap);
    HeightMap heightMap = new MaximisingHeightMap(continent, mountains);
    return new HeightMapTileFactory(seed, heightMap, 256, false, new FancyTheme(maxHeight, 62, heightMap, terrain));
}
Also used : SumHeightMap(org.pepsoft.worldpainter.heightMaps.SumHeightMap) NinePatchHeightMap(org.pepsoft.worldpainter.heightMaps.NinePatchHeightMap) ConstantHeightMap(org.pepsoft.worldpainter.heightMaps.ConstantHeightMap) NinePatchHeightMap(org.pepsoft.worldpainter.heightMaps.NinePatchHeightMap) ProductHeightMap(org.pepsoft.worldpainter.heightMaps.ProductHeightMap) SumHeightMap(org.pepsoft.worldpainter.heightMaps.SumHeightMap) NoiseHeightMap(org.pepsoft.worldpainter.heightMaps.NoiseHeightMap) MaximisingHeightMap(org.pepsoft.worldpainter.heightMaps.MaximisingHeightMap) DisplacementHeightMap(org.pepsoft.worldpainter.heightMaps.DisplacementHeightMap) Random(java.util.Random) ProductHeightMap(org.pepsoft.worldpainter.heightMaps.ProductHeightMap) DisplacementHeightMap(org.pepsoft.worldpainter.heightMaps.DisplacementHeightMap) NoiseHeightMap(org.pepsoft.worldpainter.heightMaps.NoiseHeightMap) FancyTheme(org.pepsoft.worldpainter.themes.impl.fancy.FancyTheme) MaximisingHeightMap(org.pepsoft.worldpainter.heightMaps.MaximisingHeightMap) ConstantHeightMap(org.pepsoft.worldpainter.heightMaps.ConstantHeightMap)

Example 3 with SumHeightMap

use of org.pepsoft.worldpainter.heightMaps.SumHeightMap in project WorldPainter by Captain-Chaos.

the class RepairHeightMap method repairDimension.

private static final boolean repairDimension(Dimension dimension) {
    TileFactory tileFactory = dimension.getTileFactory();
    if (tileFactory instanceof HeightMapTileFactory) {
        HeightMap heightMap = ((HeightMapTileFactory) tileFactory).getHeightMap();
        if ((heightMap instanceof SumHeightMap) && ((((SumHeightMap) heightMap).getHeightMap1() == null) || (((SumHeightMap) heightMap).getHeightMap2() == null))) {
            System.out.println("Broken height map found in dimension " + dimension.getName() + "; replacing with default height map");
            heightMap = new ConstantHeightMap(46);
            // heightMap = new SumHeightMap(new ConstantHeightMap(58), new NoiseHeightMap(20, 1.0, 1));
            ((HeightMapTileFactory) tileFactory).setHeightMap(heightMap);
            return true;
        }
    }
    return false;
}
Also used : SumHeightMap(org.pepsoft.worldpainter.heightMaps.SumHeightMap) ConstantHeightMap(org.pepsoft.worldpainter.heightMaps.ConstantHeightMap) HeightMap(org.pepsoft.worldpainter.HeightMap) SumHeightMap(org.pepsoft.worldpainter.heightMaps.SumHeightMap) HeightMapTileFactory(org.pepsoft.worldpainter.HeightMapTileFactory) ConstantHeightMap(org.pepsoft.worldpainter.heightMaps.ConstantHeightMap) TileFactory(org.pepsoft.worldpainter.TileFactory) HeightMapTileFactory(org.pepsoft.worldpainter.HeightMapTileFactory)

Aggregations

ConstantHeightMap (org.pepsoft.worldpainter.heightMaps.ConstantHeightMap)3 SumHeightMap (org.pepsoft.worldpainter.heightMaps.SumHeightMap)3 NoiseHeightMap (org.pepsoft.worldpainter.heightMaps.NoiseHeightMap)2 Random (java.util.Random)1 HeightMap (org.pepsoft.worldpainter.HeightMap)1 HeightMapTileFactory (org.pepsoft.worldpainter.HeightMapTileFactory)1 TileFactory (org.pepsoft.worldpainter.TileFactory)1 DisplacementHeightMap (org.pepsoft.worldpainter.heightMaps.DisplacementHeightMap)1 MaximisingHeightMap (org.pepsoft.worldpainter.heightMaps.MaximisingHeightMap)1 NinePatchHeightMap (org.pepsoft.worldpainter.heightMaps.NinePatchHeightMap)1 ProductHeightMap (org.pepsoft.worldpainter.heightMaps.ProductHeightMap)1 FancyTheme (org.pepsoft.worldpainter.themes.impl.fancy.FancyTheme)1