use of org.terasology.core.world.generator.facets.BiomeFacet in project Terasology by MovingBlocks.
the class DefaultTreeProvider method process.
@Override
public void process(GeneratingRegion region) {
SurfaceHeightFacet surface = region.getRegionFacet(SurfaceHeightFacet.class);
BiomeFacet biome = region.getRegionFacet(BiomeFacet.class);
List<Predicate<Vector3i>> filters = getFilters(region);
// these value are derived from the maximum tree extents as
// computed by the TreeTests class. Birch is the highest with 32
// and Pine has 13 radius.
// These values must be identical in the class annotations.
int maxRad = 13;
int maxHeight = 32;
Border3D borderForTreeFacet = region.getBorderForFacet(TreeFacet.class);
TreeFacet facet = new TreeFacet(region.getRegion(), borderForTreeFacet.extendBy(0, maxHeight, maxRad));
populateFacet(facet, surface, biome, filters);
region.setRegionFacet(TreeFacet.class, facet);
}
use of org.terasology.core.world.generator.facets.BiomeFacet in project Terasology by MovingBlocks.
the class SolidRasterizer method generateChunk.
@Override
public void generateChunk(CoreChunk chunk, Region chunkRegion) {
LiquidData waterLiquid = new LiquidData(LiquidType.WATER, LiquidData.MAX_LIQUID_DEPTH);
DensityFacet solidityFacet = chunkRegion.getFacet(DensityFacet.class);
SurfaceHeightFacet surfaceFacet = chunkRegion.getFacet(SurfaceHeightFacet.class);
SurfaceDepthFacet surfaceDepthFacet = chunkRegion.getFacet(SurfaceDepthFacet.class);
BiomeFacet biomeFacet = chunkRegion.getFacet(BiomeFacet.class);
SeaLevelFacet seaLevelFacet = chunkRegion.getFacet(SeaLevelFacet.class);
int seaLevel = seaLevelFacet.getSeaLevel();
Vector2i pos2d = new Vector2i();
for (Vector3i pos : ChunkConstants.CHUNK_REGION) {
pos2d.set(pos.x, pos.z);
int posY = pos.y + chunk.getChunkWorldOffsetY();
// Check for an optional depth for this layer - if defined stop generating below that level
if (surfaceDepthFacet != null && posY < surfaceDepthFacet.get(pos2d)) {
continue;
}
Biome biome = biomeFacet.get(pos2d);
chunk.setBiome(pos.x, pos.y, pos.z, biome);
float density = solidityFacet.get(pos);
if (density >= 32) {
chunk.setBlock(pos, stone);
} else if (density >= 0) {
int depth = TeraMath.floorToInt(surfaceFacet.get(pos2d)) - posY;
Block block = getSurfaceBlock(depth, posY, biome, seaLevel);
chunk.setBlock(pos, block);
} else {
// fill up terrain up to sealevel height with water or ice
if (posY == seaLevel && CoreBiome.SNOW == biome) {
chunk.setBlock(pos, ice);
} else if (posY <= seaLevel) {
// either OCEAN or SNOW
chunk.setBlock(pos, water);
chunk.setLiquid(pos, waterLiquid);
}
}
}
}
use of org.terasology.core.world.generator.facets.BiomeFacet in project Terasology by MovingBlocks.
the class BiomeProvider method process.
@Override
public void process(GeneratingRegion region) {
SeaLevelFacet seaLevelFacet = region.getRegionFacet(SeaLevelFacet.class);
SurfaceHeightFacet heightFacet = region.getRegionFacet(SurfaceHeightFacet.class);
SurfaceTemperatureFacet temperatureFacet = region.getRegionFacet(SurfaceTemperatureFacet.class);
SurfaceHumidityFacet humidityFacet = region.getRegionFacet(SurfaceHumidityFacet.class);
Border3D border = region.getBorderForFacet(BiomeFacet.class);
BiomeFacet biomeFacet = new BiomeFacet(region.getRegion(), border);
int seaLevel = seaLevelFacet.getSeaLevel();
for (BaseVector2i pos : biomeFacet.getRelativeRegion().contents()) {
float temp = temperatureFacet.get(pos);
float hum = temp * humidityFacet.get(pos);
float height = heightFacet.get(pos);
if (height <= seaLevel) {
biomeFacet.set(pos, CoreBiome.OCEAN);
} else if (height <= seaLevel + 2) {
biomeFacet.set(pos, CoreBiome.BEACH);
} else if (temp >= 0.5f && hum < 0.3f) {
biomeFacet.set(pos, CoreBiome.DESERT);
} else if (hum >= 0.3f && hum <= 0.6f && temp >= 0.5f) {
biomeFacet.set(pos, CoreBiome.PLAINS);
} else if (temp <= 0.3f && hum > 0.5f) {
biomeFacet.set(pos, CoreBiome.SNOW);
} else if (hum >= 0.2f && hum <= 0.6f && temp < 0.5f) {
biomeFacet.set(pos, CoreBiome.MOUNTAINS);
} else {
biomeFacet.set(pos, CoreBiome.FOREST);
}
}
region.setRegionFacet(BiomeFacet.class, biomeFacet);
}
use of org.terasology.core.world.generator.facets.BiomeFacet in project Terasology by MovingBlocks.
the class DefaultFloraProvider method process.
@Override
public void process(GeneratingRegion region) {
SurfaceHeightFacet surface = region.getRegionFacet(SurfaceHeightFacet.class);
BiomeFacet biomeFacet = region.getRegionFacet(BiomeFacet.class);
FloraFacet facet = new FloraFacet(region.getRegion(), region.getBorderForFacet(FloraFacet.class));
List<Predicate<Vector3i>> filters = getFilters(region);
populateFacet(facet, surface, biomeFacet, filters);
region.setRegionFacet(FloraFacet.class, facet);
}
Aggregations