Max biomes

This commit is contained in:
Daniel Mills 2020-03-21 03:26:55 -04:00
parent cecbad2eb9
commit a82ba6503f
12 changed files with 432 additions and 168 deletions

View File

@ -5,36 +5,32 @@ import java.io.File;
import org.bukkit.World.Environment;
import org.bukkit.block.Biome;
import com.google.gson.Gson;
import lombok.Getter;
import ninja.bytecode.iris.object.Dispersion;
import lombok.Data;
import ninja.bytecode.iris.object.IrisBiome;
import ninja.bytecode.iris.object.IrisBiomePaletteLayer;
import ninja.bytecode.iris.object.IrisDimension;
import ninja.bytecode.iris.object.IrisRegion;
import ninja.bytecode.iris.util.IO;
import ninja.bytecode.iris.util.JSONObject;
import ninja.bytecode.iris.util.ResourceLoader;
@Data
public class IrisDataManager
{
private File dataFolder;
private File packs;
@Getter
private ResourceLoader<IrisBiome> biomeLoader;
@Getter
private ResourceLoader<IrisRegion> regionLoader;
private ResourceLoader<IrisDimension> dimensionLoader;
public void hotloaded()
{
packs.mkdirs();
this.regionLoader = new ResourceLoader<>(packs, "regions", "Region", IrisRegion.class);
this.biomeLoader = new ResourceLoader<>(packs, "biomes", "Biome", IrisBiome.class);
this.dimensionLoader = new ResourceLoader<>(packs, "dimensions", "Dimension", IrisDimension.class);
writeExamples();
}
public IrisDataManager(File dataFolder)
{
this.dataFolder = dataFolder;
@ -46,32 +42,6 @@ public class IrisDataManager
{
File examples = new File(dataFolder, "example");
examples.mkdirs();
IrisBiome biome = new IrisBiome();
biome.getLayers().clear();
IrisBiomePaletteLayer grass = new IrisBiomePaletteLayer();
grass.add("GRASS_BLOCK");
grass.setDispersion(Dispersion.SCATTER);
grass.setMinHeight(1);
grass.setMaxHeight(1);
IrisBiomePaletteLayer dirt = new IrisBiomePaletteLayer();
grass.add("DIRT");
grass.setDispersion(Dispersion.SCATTER);
grass.setMinHeight(1);
grass.setMaxHeight(2);
IrisBiomePaletteLayer dirtThick = new IrisBiomePaletteLayer();
grass.add("DIRT");
grass.add("COARSE_DIRT");
grass.setDispersion(Dispersion.WISPY);
grass.setMinHeight(1);
grass.setMaxHeight(3);
biome.getLayers().add(dirtThick);
biome.getLayers().add(dirt);
biome.getLayers().add(grass);
IrisDimension dim = new IrisDimension();
dim.getBiomes().add("a_biome");
String biomes = "";
String envs = "";
@ -91,14 +61,11 @@ public class IrisDataManager
new File(examples, "example-pack/dimensions").mkdirs();
IO.writeAll(new File(examples, "biome-list.txt"), biomes);
IO.writeAll(new File(examples, "environment-list.txt"), envs);
IO.writeAll(new File(examples, "example-pack/biomes/a_biome.json"), new JSONObject(new Gson().toJson(biome)).toString(4));
IO.writeAll(new File(examples, "example-pack/dimensions/a_dimension.json"), new JSONObject(new Gson().toJson(dim)).toString(4));
}
catch(Throwable e)
{
}
}
}

View File

@ -15,6 +15,7 @@ import org.bukkit.generator.ChunkGenerator;
import ninja.bytecode.iris.layer.GenLayerBiome;
import ninja.bytecode.iris.object.IrisBiome;
import ninja.bytecode.iris.object.IrisDimension;
import ninja.bytecode.iris.object.IrisRegion;
import ninja.bytecode.iris.util.BiomeResult;
import ninja.bytecode.iris.util.CNG;
import ninja.bytecode.iris.util.IrisInterpolation;
@ -25,6 +26,7 @@ public class IrisGenerator extends ChunkGenerator
{
// TODO REMOVE OR FIND A BETTER PLACE
private BlockData STONE = Material.STONE.createBlockData();
private BlockData WATER = Material.WATER.createBlockData();
private String dimensionName;
private GenLayerBiome glBiome;
private CNG terrainNoise;
@ -64,44 +66,74 @@ public class IrisGenerator extends ChunkGenerator
{
Iris.hotloader.check();
int i, j, k, height, depth;
double wx, wz, rx, rz, heightLow, heightHigh, heightExponent;
double wx, wz, rx, rz, noise, ox, oz;
boolean underwater;
BlockData block;
int fluidHeight = getDimension().getFluidHeight();
BiomeResult biomeResult;
IrisBiome biome;
IrisRegion region;
RNG random = new RNG(world.getSeed());
onInit(world, random.nextParallelRNG(0));
ChunkData data = Bukkit.createChunkData(world);
for(i = 0; i < 16; i++)
{
rx = (x * 16) + i;
wx = ((double) (x * 16) + i) / getDimension().getTerrainZoom();
for(j = 0; j < 16; j++)
{
rx = (x * 16) + i;
rz = (z * 16) + j;
wz = ((double) (z * 16) + j) / getDimension().getTerrainZoom();
ox = (getDimension().cosRotate() * rx) + (-getDimension().sinRotate() * rz) + getDimension().getCoordFracture(random, 39392).fitDoubleD(-getDimension().getCoordFractureDistance() / 2, getDimension().getCoordFractureDistance() / 2, rx, rz);
oz = (getDimension().sinRotate() * rx) + (getDimension().cosRotate() * rz) + getDimension().getCoordFracture(random, 39392).fitDoubleD(-getDimension().getCoordFractureDistance() / 2, getDimension().getCoordFractureDistance() / 2, rx, rz);
wx = (double) (ox) / getDimension().getTerrainZoom();
wz = (double) (oz) / getDimension().getTerrainZoom();
depth = 0;
biomeResult = glBiome.generateData(wx, wz);
region = glBiome.getRegion(wx, wz);
biomeResult = glBiome.generateRegionData(wx, wz, region);
biome = biomeResult.getBiome();
heightLow = interpolate(rx, rz, (b) -> b.getLowHeight());
heightHigh = interpolate(rx, rz, (b) -> b.getHighHeight());
heightExponent = interpolate(rx, rz, (b) -> b.getHeightExponent());
height = (int) Math.round(terrainNoise.fitDoubleExponent(heightLow, heightHigh, heightExponent, wx, wz)) + fluidHeight;
double lo = interpolateHeight(ox, oz, (b) -> b.getLowHeight());
double hi = interpolateSurface(ox, oz, (b) -> b.getHighHeight());
noise = lo + (terrainNoise.fitDoubleD(0, hi - lo, wx, wz));
height = (int) Math.round(noise) + fluidHeight;
// Remove Land biome surfaces from underwater
if(height < fluidHeight + 1)
{
if(biome.isLand())
{
biome = glBiome.generateShoreData(wx, wz, region).getBiome();
}
}
KList<BlockData> layers = biome.generateLayers(wx, wz, random, height);
for(k = Math.max(height, fluidHeight); k >= 0; k--)
{
underwater = k > height && k <= fluidHeight;
biomeGrid.setBiome(i, k, j, biome.getDerivative());
data.setBlock(i, k, j, layers.hasIndex(depth) ? layers.get(depth) : STONE);
depth++;
if(underwater)
{
block = WATER;
}
else
{
block = layers.hasIndex(depth) ? layers.get(depth) : STONE;
depth++;
}
data.setBlock(i, k, j, block);
}
}
}
Iris.verbose("Generated " + x + " " + z);
return data;
}
public double interpolate(double rx, double rz, Function<IrisBiome, Double> property)
public double interpolateHeight(double rx, double rz, Function<IrisBiome, Double> property)
{
return IrisInterpolation.getNoise(getDimension().getInterpolationFunction(), (int) Math.round(rx), (int) Math.round(rz), getDimension().getInterpolationScale(), (xx, zz) ->
{
@ -110,6 +142,15 @@ public class IrisGenerator extends ChunkGenerator
});
}
public double interpolateSurface(double rx, double rz, Function<IrisBiome, Double> property)
{
return IrisInterpolation.getNoise(getDimension().getInterpolationSurfaceFunction(), (int) Math.round(rx), (int) Math.round(rz), getDimension().getInterpolationSurfaceScale(), (xx, zz) ->
{
BiomeResult neighborResult = glBiome.generateData(xx / getDimension().getTerrainZoom(), zz / getDimension().getTerrainZoom());
return property.apply(neighborResult.getBiome());
});
}
@Override
public List<BlockPopulator> getDefaultPopulators(World world)
{

View File

@ -1,31 +1,141 @@
package ninja.bytecode.iris.layer;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.IrisGenerator;
import ninja.bytecode.iris.object.InferredType;
import ninja.bytecode.iris.object.IrisBiome;
import ninja.bytecode.iris.object.IrisRegion;
import ninja.bytecode.iris.util.BiomeResult;
import ninja.bytecode.iris.util.CellGenerator2D;
import ninja.bytecode.iris.util.CellGenerator;
import ninja.bytecode.iris.util.GenLayer;
import ninja.bytecode.iris.util.KList;
import ninja.bytecode.iris.util.RNG;
public class GenLayerBiome extends GenLayer
{
private CellGenerator2D cells;
private CellGenerator region;
private CellGenerator bridge;
private CellGenerator land;
private CellGenerator shore;
private CellGenerator sea;
public GenLayerBiome(IrisGenerator iris, RNG rng)
{
super(iris, rng);
cells = new CellGenerator2D(rng.nextParallelRNG(2045662));
region = new CellGenerator(rng.nextParallelRNG(1188519));
bridge = new CellGenerator(rng.nextParallelRNG(1541462));
land = new CellGenerator(rng.nextParallelRNG(9045162));
shore = new CellGenerator(rng.nextParallelRNG(2342812));
sea = new CellGenerator(rng.nextParallelRNG(6135621));
}
public KList<IrisBiome> getBiomes()
public IrisRegion getRegion(double bx, double bz)
{
return iris.getDimension().buildBiomeList();
region.setShuffle(32);
region.setCellScale(0.33 / iris.getDimension().getRegionZoom());
double x = bx / iris.getDimension().getBiomeZoom();
double z = bz / iris.getDimension().getBiomeZoom();
String regionId = iris.getDimension().getRegions().get(region.getIndex(x, z, iris.getDimension().getRegions().size()));
return Iris.data.getRegionLoader().load(regionId);
}
public BiomeResult generateData(double x, double z)
public BiomeResult generateData(double bx, double bz)
{
return new BiomeResult(getBiomes().get(cells.getIndex(x / iris.getDimension().getBiomeZoom(), z / iris.getDimension().getBiomeZoom(), getBiomes().size())), cells.getDistance(x / iris.getDimension().getBiomeZoom(), z / iris.getDimension().getBiomeZoom()));
return generateRegionData(bx, bz, getRegion(bx, bz));
}
public BiomeResult generateRegionData(double bx, double bz, IrisRegion regionData)
{
bridge.setShuffle(32);
bridge.setCellScale(0.33 / iris.getDimension().getContinentZoom());
double x = bx / iris.getDimension().getBiomeZoom();
double z = bz / iris.getDimension().getBiomeZoom();
// Beach
if(bridge.getDistance(x, z) < regionData.getShoreRatio())
{
return generateShoreData(bx, bz, regionData);
}
// Sea
else if(bridge.getIndex(x, z, 5) == 1)
{
return generateSeaData(bx, bz, regionData);
}
// Land
else
{
return generateLandData(bx, bz, regionData);
}
}
public BiomeResult generateBiomeData(double bx, double bz, IrisRegion regionData, CellGenerator cell, KList<String> biomes, InferredType inferredType)
{
double x = bx / iris.getDimension().getBiomeZoom();
double z = bz / iris.getDimension().getBiomeZoom();
IrisBiome biome = Iris.data.getBiomeLoader().load(biomes.get(sea.getIndex(x, z, biomes.size())));
biome.setInferredType(inferredType);
return implode(bx, bz, regionData, cell, new BiomeResult(biome, cell.getDistance(x, z)));
}
public BiomeResult generateSeaData(double bx, double bz, IrisRegion regionData)
{
sea.setShuffle(32);
sea.setCellScale(0.56 / iris.getDimension().getSeaZoom());
return generateBiomeData(bx, bz, regionData, sea, regionData.getSeaBiomes(), InferredType.SEA);
}
public BiomeResult generateLandData(double bx, double bz, IrisRegion regionData)
{
land.setShuffle(32);
land.setCellScale(0.6 / iris.getDimension().getLandZoom());
return generateBiomeData(bx, bz, regionData, land, regionData.getLandBiomes(), InferredType.LAND);
}
public BiomeResult generateShoreData(double bx, double bz, IrisRegion regionData)
{
shore.setShuffle(32);
shore.setCellScale(0.8 / iris.getDimension().getShoreZoom());
return generateBiomeData(bx, bz, regionData, shore, regionData.getShoreBiomes(), InferredType.SHORE);
}
public BiomeResult implode(double bx, double bz, IrisRegion regionData, CellGenerator parentCell, BiomeResult parent)
{
return implode(bx, bz, regionData, parentCell, parent, 1);
}
public BiomeResult implode(double bx, double bz, IrisRegion regionData, CellGenerator parentCell, BiomeResult parent, int hits)
{
if(hits > 9)
{
return parent;
}
double x = bx / iris.getDimension().getBiomeZoom();
double z = bz / iris.getDimension().getBiomeZoom();
if(parent.getDistance() > regionData.getBiomeImplosionRatio())
{
if(!parent.getBiome().getChildren().isEmpty())
{
CellGenerator childCell = parent.getBiome().getChildrenGenerator(rng, 123, parentCell.getCellScale() * parent.getBiome().getChildShrinkFactor());
int r = childCell.getIndex(x, z, parent.getBiome().getChildren().size() + 1);
if(r == parent.getBiome().getChildren().size())
{
return new BiomeResult(parent.getBiome(), childCell.getDistance(x, z));
}
IrisBiome biome = Iris.data.getBiomeLoader().load(parent.getBiome().getChildren().get(r));
biome.setInferredType(parent.getBiome().getInferredType());
return implode(bx, bz, regionData, childCell, new BiomeResult(biome, childCell.getDistance(x, z)), hits + 1);
}
}
return parent;
}
@Override

View File

@ -0,0 +1,8 @@
package ninja.bytecode.iris.object;
public enum InferredType
{
SHORE,
LAND,
SEA
}

View File

@ -7,6 +7,7 @@ import org.bukkit.block.data.BlockData;
import lombok.Data;
import ninja.bytecode.iris.util.CNG;
import ninja.bytecode.iris.util.CellGenerator;
import ninja.bytecode.iris.util.KList;
import ninja.bytecode.iris.util.RNG;
@ -17,12 +18,27 @@ public class IrisBiome
private Biome derivative = Biome.THE_VOID;
private double highHeight = 7;
private double lowHeight = 1;
private double heightExponent = 1;
private double childShrinkFactor = 1.5;
private KList<String> children = new KList<>();
private KList<IrisBiomePaletteLayer> layers = new KList<IrisBiomePaletteLayer>().qadd(new IrisBiomePaletteLayer());
private KList<IrisBiomeDecorator> decorators = new KList<IrisBiomeDecorator>();
private transient CellGenerator childrenCell;
private transient InferredType inferredType;
private transient KList<CNG> layerHeightGenerators;
private transient KList<CNG> layerSurfaceGenerators;
public CellGenerator getChildrenGenerator(RNG random, int sig, double scale)
{
if(childrenCell == null)
{
childrenCell = new CellGenerator(random.nextParallelRNG(sig * 213));
childrenCell.setCellScale(scale);
}
return childrenCell;
}
public KList<BlockData> generateLayers(double wx, double wz, RNG random, int maxDepth)
{
KList<BlockData> data = new KList<>();
@ -61,21 +77,15 @@ public class IrisBiome
public KList<CNG> getLayerSurfaceGenerators(RNG rng)
{
synchronized(this)
if(layerSurfaceGenerators == null)
{
if(layerSurfaceGenerators == null)
layerSurfaceGenerators = new KList<>();
int m = 91235;
for(IrisBiomePaletteLayer i : getLayers())
{
layerSurfaceGenerators = new KList<>();
synchronized(layerSurfaceGenerators)
{
int m = 91235;
for(IrisBiomePaletteLayer i : getLayers())
{
layerSurfaceGenerators.add(i.getGenerator(rng.nextParallelRNG((m += 3) * m * m * m)));
}
}
layerSurfaceGenerators.add(i.getGenerator(rng.nextParallelRNG((m += 3) * m * m * m)));
}
}
@ -84,24 +94,33 @@ public class IrisBiome
public KList<CNG> getLayerHeightGenerators(RNG rng)
{
synchronized(this)
if(layerHeightGenerators == null)
{
if(layerHeightGenerators == null)
layerHeightGenerators = new KList<>();
int m = 7235;
for(IrisBiomePaletteLayer i : getLayers())
{
layerHeightGenerators = new KList<>();
synchronized(layerHeightGenerators)
{
int m = 7235;
for(IrisBiomePaletteLayer i : getLayers())
{
layerHeightGenerators.add(i.getGenerator(rng.nextParallelRNG((m++) * m * m * m)));
}
}
layerHeightGenerators.add(i.getGenerator(rng.nextParallelRNG((m++) * m * m * m)));
}
}
return layerHeightGenerators;
}
public boolean isLand()
{
return inferredType.equals(InferredType.LAND);
}
public boolean isSea()
{
return inferredType.equals(InferredType.SEA);
}
public boolean isShore()
{
return inferredType.equals(InferredType.SHORE);
}
}

View File

@ -0,0 +1,72 @@
package ninja.bytecode.iris.object;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import lombok.Data;
import ninja.bytecode.iris.util.CNG;
import ninja.bytecode.iris.util.KList;
import ninja.bytecode.iris.util.KMap;
import ninja.bytecode.iris.util.RNG;
@Data
public class IrisBiomeDecorator
{
private Dispersion dispersion = Dispersion.ZEBRA;
private int iterations = 5;
private double zoom = 1;
private KList<String> palette = new KList<String>().qadd("GRASS");
private transient KMap<Long, CNG> layerGenerators;
private transient KList<BlockData> blockData;
public CNG getGenerator(RNG rng)
{
long key = rng.nextParallelRNG(1).nextLong();
if(layerGenerators == null)
{
layerGenerators = new KMap<>();
}
if(!layerGenerators.containsKey(key))
{
layerGenerators.put(key, CNG.signature(rng.nextParallelRNG(iterations + getBlockData().size())));
}
return layerGenerators.get(key);
}
public KList<String> add(String b)
{
palette.add(b);
return palette;
}
public KList<BlockData> getBlockData()
{
if(blockData == null)
{
blockData = new KList<>();
for(String i : palette)
{
try
{
Material m = Material.valueOf(i);
if(m != null)
{
blockData.add(m.createBlockData());
}
}
catch(Throwable e)
{
}
}
}
return blockData;
}
}

View File

@ -23,25 +23,19 @@ public class IrisBiomePaletteLayer
public CNG getGenerator(RNG rng)
{
synchronized(this)
long key = rng.nextParallelRNG(1).nextLong();
if(layerGenerators == null)
{
long key = rng.nextParallelRNG(1).nextLong();
if(layerGenerators == null)
{
layerGenerators = new KMap<>();
}
if(!layerGenerators.containsKey(key))
{
synchronized(layerGenerators)
{
layerGenerators.put(key, CNG.signature(rng.nextParallelRNG(minHeight + maxHeight + getBlockData().size())));
}
}
return layerGenerators.get(key);
layerGenerators = new KMap<>();
}
if(!layerGenerators.containsKey(key))
{
layerGenerators.put(key, CNG.signature(rng.nextParallelRNG(minHeight + maxHeight + getBlockData().size())));
}
return layerGenerators.get(key);
}
public KList<String> add(String b)
@ -53,30 +47,24 @@ public class IrisBiomePaletteLayer
public KList<BlockData> getBlockData()
{
synchronized(this)
if(blockData == null)
{
if(blockData == null)
blockData = new KList<>();
for(String i : palette)
{
blockData = new KList<>();
synchronized(blockData)
try
{
for(String i : palette)
Material m = Material.valueOf(i);
if(m != null)
{
try
{
Material m = Material.valueOf(i);
if(m != null)
{
blockData.add(m.createBlockData());
}
}
catch(Throwable e)
{
}
blockData.add(m.createBlockData());
}
}
catch(Throwable e)
{
}
}
}

View File

@ -3,46 +3,77 @@ package ninja.bytecode.iris.object;
import org.bukkit.World.Environment;
import lombok.Data;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.util.CNG;
import ninja.bytecode.iris.util.KList;
import ninja.bytecode.iris.util.RNG;
@Data
public class IrisDimension
{
private String name = "A Dimension";
private InterpolationMethod interpolationFunction = InterpolationMethod.BILINEAR;
private double interpolationScale = 5.6;
private InterpolationMethod interpolationFunction = InterpolationMethod.BICUBIC;
private double interpolationScale = 63;
private InterpolationMethod interpolationSurfaceFunction = InterpolationMethod.BICUBIC;
private double interpolationSurfaceScale = 4;
private Environment environment = Environment.NORMAL;
private KList<String> biomes = new KList<>();
private KList<String> regions = new KList<>();
private int fluidHeight = 127;
private double biomeZoom = 5D;
private double terrainZoom = 2D;
private double dimensionAngleDeg = 0;
private double roughnessZoom = 2D;
private int roughnessHeight = 3;
private transient KList<IrisBiome> biomeCache;
private double coordFractureDistance = 20;
private double coordFractureZoom = 8;
private double landZoom = 1;
private double shoreZoom = 1;
private double seaZoom = 1;
private double continentZoom = 1;
private double regionZoom = 1;
public KList<IrisBiome> buildBiomeList()
private transient CNG coordFracture;
private transient Double sinr;
private transient Double cosr;
private transient Double rad;
public CNG getCoordFracture(RNG rng, int signature)
{
if(biomeCache == null)
if(coordFracture == null)
{
synchronized(this)
{
biomeCache = new KList<>();
synchronized(biomeCache)
{
for(String i : biomes)
{
IrisBiome biome = Iris.data.getBiomeLoader().load(i);
if(biome != null)
{
biomeCache.add(biome);
}
}
}
}
coordFracture = CNG.signature(rng.nextParallelRNG(signature));
coordFracture.scale(0.012 / coordFractureZoom);
}
return biomeCache;
return coordFracture;
}
public double getDimensionAngle()
{
if(rad == null)
{
rad = Math.toRadians(dimensionAngleDeg);
}
return rad;
}
public double sinRotate()
{
if(sinr == null)
{
sinr = Math.sin(getDimensionAngle());
}
return sinr;
}
public double cosRotate()
{
if(cosr == null)
{
cosr = Math.cos(getDimensionAngle());
}
return cosr;
}
}

View File

@ -0,0 +1,15 @@
package ninja.bytecode.iris.object;
import lombok.Data;
import ninja.bytecode.iris.util.KList;
@Data
public class IrisRegion
{
private String name = "A Region";
private double shoreRatio = 0.13;
private double biomeImplosionRatio = 0.4;
private KList<String> landBiomes = new KList<>();
private KList<String> seaBiomes = new KList<>();
private KList<String> shoreBiomes = new KList<>();
}

View File

@ -166,6 +166,18 @@ public class CNG
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
}
public double fitDoubleD(double min, double max, double... dim)
{
if(min == max)
{
return min;
}
double noise = noise(dim);
return IrisInterpolation.lerp(min, max, noise);
}
public int fitDoubleExponent(double min, double max, double exponent, double... dim)
{
if(min == max)

View File

@ -6,7 +6,7 @@ import ninja.bytecode.iris.util.FastNoise.CellularDistanceFunction;
import ninja.bytecode.iris.util.FastNoise.CellularReturnType;
import ninja.bytecode.iris.util.FastNoise.NoiseType;
public class CellGenerator2D
public class CellGenerator
{
private FastNoise fn;
private FastNoise fd;
@ -20,7 +20,7 @@ public class CellGenerator2D
@Setter
private double shuffle;
public CellGenerator2D(RNG rng)
public CellGenerator(RNG rng)
{
shuffle = 128;
cellScale = 0.73;

View File

@ -1,6 +1,7 @@
package ninja.bytecode.iris.util;
import ninja.bytecode.iris.object.InterpolationMethod;
import ninja.bytecode.iris.object.IrisDimension;
public class IrisInterpolation
{
@ -188,26 +189,6 @@ public class IrisInterpolation
//@done
}
public static double getNoise(InterpolationMethod method, int x, int z, double rad, NoiseProvider n)
{
if(method.equals(InterpolationMethod.BILINEAR))
{
return getBilinearNoise(x, z, rad, n);
}
else if(method.equals(InterpolationMethod.BICUBIC))
{
return getBicubicNoise(x, z, rad, n);
}
else if(method.equals(InterpolationMethod.HERMITE))
{
return getHermiteNoise(x, z, rad, n);
}
return n.noise(x, z);
}
public static double getHermiteNoise(int x, int z, double rad, NoiseProvider n)
{
int fx = (int) Math.floor(x / rad);
@ -240,10 +221,30 @@ public class IrisInterpolation
n.noise(x3, z1),
n.noise(x3, z2),
n.noise(x3, z3),
px, pz, 0.00001, 0.5);
px, pz, 0.0000000001, 0.5);
//@done
}
public static double getNoise(InterpolationMethod method, int x, int z, double rad, NoiseProvider n)
{
if(method.equals(InterpolationMethod.BILINEAR))
{
return getBilinearNoise(x, z, rad, n);
}
else if(method.equals(InterpolationMethod.BICUBIC))
{
return getBicubicNoise(x, z, rad, n);
}
else if(method.equals(InterpolationMethod.HERMITE))
{
return getHermiteNoise(x, z, rad, n);
}
return n.noise(x, z);
}
public static double rangeScale(double amin, double amax, double bmin, double bmax, double b)
{
return amin + ((amax - amin) * ((b - bmin) / (bmax - bmin)));