use of net.glowstone.util.noise.PerlinOctaveGenerator in project Glowstone by GlowstoneMC.
the class NetherGenerator method createWorldOctaves.
@Override
protected void createWorldOctaves(World world, Map<String, OctaveGenerator> octaves) {
Random seed = new Random(world.getSeed());
OctaveGenerator gen = new PerlinOctaveGenerator(seed, 16, 5, 5);
gen.setXScale(heightNoiseScaleX);
gen.setZScale(heightNoiseScaleZ);
octaves.put("height", gen);
gen = new PerlinOctaveGenerator(seed, 16, 5, 17, 5);
gen.setXScale(coordinateScale);
gen.setYScale(heightScale);
gen.setZScale(coordinateScale);
octaves.put("roughness", gen);
gen = new PerlinOctaveGenerator(seed, 16, 5, 17, 5);
gen.setXScale(coordinateScale);
gen.setYScale(heightScale);
gen.setZScale(coordinateScale);
octaves.put("roughness2", gen);
gen = new PerlinOctaveGenerator(seed, 8, 5, 17, 5);
gen.setXScale(coordinateScale / detailNoiseScaleX);
gen.setYScale(heightScale / detailNoiseScaleY);
gen.setZScale(coordinateScale / detailNoiseScaleZ);
octaves.put("detail", gen);
gen = new PerlinOctaveGenerator(seed, 4, 16, 16, 1);
gen.setScale(surfaceScale);
octaves.put("surface", gen);
gen = new PerlinOctaveGenerator(seed, 4, 16, 16, 1);
gen.setXScale(surfaceScale / 2.0);
gen.setYScale(surfaceScale / 2.0);
octaves.put("soulsand", gen);
gen = new PerlinOctaveGenerator(seed, 4, 16, 1, 16);
gen.setXScale(surfaceScale / 2.0);
gen.setZScale(surfaceScale / 2.0);
octaves.put("gravel", gen);
}
use of net.glowstone.util.noise.PerlinOctaveGenerator in project Glowstone by GlowstoneMC.
the class TheEndGenerator method createWorldOctaves.
@Override
protected void createWorldOctaves(World world, Map<String, OctaveGenerator> octaves) {
Random seed = new Random(world.getSeed());
OctaveGenerator gen = new PerlinOctaveGenerator(seed, 16, 3, 33, 3);
gen.setXScale(coordinateScale);
gen.setYScale(heightScale);
gen.setZScale(coordinateScale);
octaves.put("roughness", gen);
gen = new PerlinOctaveGenerator(seed, 16, 3, 33, 3);
gen.setXScale(coordinateScale);
gen.setYScale(heightScale);
gen.setZScale(coordinateScale);
octaves.put("roughness2", gen);
gen = new PerlinOctaveGenerator(seed, 8, 3, 33, 3);
gen.setXScale(coordinateScale / detailNoiseScaleX);
gen.setYScale(heightScale / detailNoiseScaleY);
gen.setZScale(coordinateScale / detailNoiseScaleZ);
octaves.put("detail", gen);
}
use of net.glowstone.util.noise.PerlinOctaveGenerator in project Glowstone by GlowstoneMC.
the class OverworldGenerator method createWorldOctaves.
@Override
protected void createWorldOctaves(World world, Map<String, OctaveGenerator> octaves) {
Random seed = new Random(world.getSeed());
OctaveGenerator gen = new PerlinOctaveGenerator(seed, 16, 5, 5);
gen.setXScale(heightNoiseScaleX);
gen.setZScale(heightNoiseScaleZ);
octaves.put("height", gen);
gen = new PerlinOctaveGenerator(seed, 16, 5, 33, 5);
gen.setXScale(coordinateScale);
gen.setYScale(heightScale);
gen.setZScale(coordinateScale);
octaves.put("roughness", gen);
gen = new PerlinOctaveGenerator(seed, 16, 5, 33, 5);
gen.setXScale(coordinateScale);
gen.setYScale(heightScale);
gen.setZScale(coordinateScale);
octaves.put("roughness2", gen);
gen = new PerlinOctaveGenerator(seed, 8, 5, 33, 5);
gen.setXScale(coordinateScale / detailNoiseScaleX);
gen.setYScale(heightScale / detailNoiseScaleY);
gen.setZScale(coordinateScale / detailNoiseScaleZ);
octaves.put("detail", gen);
gen = new SimplexOctaveGenerator(seed, 4, 16, 16);
gen.setScale(surfaceScale);
octaves.put("surface", gen);
}
use of net.glowstone.util.noise.PerlinOctaveGenerator in project Glowstone by GlowstoneMC.
the class OverworldGenerator method generateTerrainDensity.
private void generateTerrainDensity(World world, int x, int z) {
WorldType type = world.getWorldType();
// Scaling chunk x and z coordinates (4x, see below)
x <<= 2;
z <<= 2;
// Get biome grid data at lower res (scaled 4x, at this scale a chunk is 4x4 columns of
// the biome grid),
// we are loosing biome detail but saving huge amount of computation.
// We need 1 chunk (4 columns) + 1 column for later needed outer edges (1 column) and at
// least 2 columns
// on each side to be able to cover every value.
// 4 + 1 + 2 + 2 = 9 columns but the biomegrid generator needs a multiple of 2 so we ask
// 10 columns wide
// to the biomegrid generator.
// This gives a total of 81 biome grid columns to work with, and this includes the chunk
// neighborhood.
int[] biomeGrid = ((GlowWorld) world).getChunkManager().getBiomeGridAtLowerRes(x - 2, z - 2, 10, 10);
Map<String, OctaveGenerator> octaves = getWorldOctaves(world);
double[] heightNoise = ((PerlinOctaveGenerator) octaves.get("height")).getFractalBrownianMotion(x, z, 0.5D, 2.0D);
double[] roughnessNoise = ((PerlinOctaveGenerator) octaves.get("roughness")).getFractalBrownianMotion(x, 0, z, 0.5D, 2.0D);
double[] roughnessNoise2 = ((PerlinOctaveGenerator) octaves.get("roughness2")).getFractalBrownianMotion(x, 0, z, 0.5D, 2.0D);
double[] detailNoise = ((PerlinOctaveGenerator) octaves.get("detail")).getFractalBrownianMotion(x, 0, z, 0.5D, 2.0D);
int index = 0;
int indexHeight = 0;
// terrain.
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
double avgHeightScale = 0;
double avgHeightBase = 0;
double totalWeight = 0;
Biome biome = GlowBiome.getBiome(biomeGrid[i + 2 + (j + 2) * 10]).getType();
BiomeHeight biomeHeight = HEIGHT_MAP.getOrDefault(biome, defaultHeight);
// of the current biomegrid column.
for (int m = 0; m < 5; m++) {
for (int n = 0; n < 5; n++) {
Biome nearBiome = GlowBiome.getBiome(biomeGrid[i + m + (j + n) * 10]).getType();
BiomeHeight nearBiomeHeight = HEIGHT_MAP.getOrDefault(nearBiome, defaultHeight);
double heightBase = biomeHeightOffset + nearBiomeHeight.getHeight() * biomeHeightWeight;
double heightScale = biomeScaleOffset + nearBiomeHeight.getScale() * biomeScaleWeight;
if (type == WorldType.AMPLIFIED && heightBase > 0) {
heightBase = 1.0D + heightBase * 2.0D;
heightScale = 1.0D + heightScale * 4.0D;
}
double weight = ELEVATION_WEIGHT[m][n] / (heightBase + 2.0D);
if (nearBiomeHeight.getHeight() > biomeHeight.getHeight()) {
weight *= 0.5D;
}
avgHeightScale += heightScale * weight;
avgHeightBase += heightBase * weight;
totalWeight += weight;
}
}
avgHeightScale /= totalWeight;
avgHeightBase /= totalWeight;
avgHeightScale = avgHeightScale * 0.9D + 0.1D;
avgHeightBase = (avgHeightBase * 4.0D - 1.0D) / 8.0D;
double noiseH = heightNoise[indexHeight++] / 8000.0D;
if (noiseH < 0) {
noiseH = Math.abs(noiseH) * 0.3D;
}
noiseH = noiseH * 3.0D - 2.0D;
if (noiseH < 0) {
noiseH = Math.max(noiseH * 0.5D, -1) / 1.4D * 0.5D;
} else {
noiseH = Math.min(noiseH, 1) / 8.0D;
}
noiseH = (noiseH * 0.2D + avgHeightBase) * baseSize / 8.0D * 4.0D + baseSize;
for (int k = 0; k < 33; k++) {
// density should be lower and lower as we climb up, this gets a height value to
// subtract from the noise.
double nh = (k - noiseH) * stretchY * 128.0D / 256.0D / avgHeightScale;
if (nh < 0.0D) {
nh *= 4.0D;
}
double noiseR = roughnessNoise[index] / 512.0D;
double noiseR2 = roughnessNoise2[index] / 512.0D;
double noiseD = (detailNoise[index] / 10.0D + 1.0D) / 2.0D;
// linear interpolation
double dens = noiseD < 0 ? noiseR : noiseD > 1 ? noiseR2 : noiseR + (noiseR2 - noiseR) * noiseD;
dens -= nh;
index++;
if (k > 29) {
double lowering = (k - 29) / 3.0D;
// linear interpolation
dens = dens * (1.0D - lowering) + -10.0D * lowering;
}
density[i][j][k] = dens;
}
}
}
}
use of net.glowstone.util.noise.PerlinOctaveGenerator in project Glowstone by GlowstoneMC.
the class SurfaceCaveDecorator method decorate.
@Override
public void decorate(World world, Random random, Chunk c) {
if (random.nextInt(8) != 0) {
return;
}
GlowChunk chunk = (GlowChunk) c;
final int startCx = random.nextInt(16);
final int startCz = random.nextInt(16);
final int startY = chunk.getHeight(startCx, startCz);
final GlowBlock startBlock = chunk.getBlock(startCx, startY, startCz);
if (startY > 128) {
return;
}
PerlinOctaveGenerator octaves = new PerlinOctaveGenerator(random, 3, 4, 2, 4);
int cx = c.getX() << 4;
int cz = c.getZ() << 4;
double[] noise = octaves.getFractalBrownianMotion(cx, cz, 0, 0.5D, 0.2D);
double[] angles = new double[noise.length];
for (int i = 0; i < noise.length; i++) {
angles[i] = 360.0 * noise[i];
}
int sectionCount = angles.length / 2;
List<BlockVector> nodes = new ArrayList<>();
BlockVector currentNode = new BlockVector(startBlock.getX(), startBlock.getY(), startBlock.getZ());
nodes.add(currentNode.clone());
int length = 5;
for (int i = 0; i < sectionCount; i++) {
double yaw = angles[i + sectionCount];
int deltaY = -Math.abs(NumberConversions.floor(noise[i] * length));
int deltaX = NumberConversions.floor((double) length * Math.cos(Math.toRadians(yaw)));
int deltaZ = NumberConversions.floor((double) length * Math.sin(Math.toRadians(yaw)));
currentNode.add(new Vector(deltaX, deltaY, deltaZ));
nodes.add(new BlockVector(currentNode.getBlockX(), currentNode.getBlockY(), currentNode.getBlockZ()));
}
for (BlockVector node : nodes) {
if (node.getBlockY() < 4) {
continue;
}
GlowBlock block = (GlowBlock) world.getBlockAt(node.getBlockX(), node.getBlockY(), node.getBlockZ());
caveAroundRay(block, random);
}
}
Aggregations