use of org.terasology.world.generation.facets.SurfaceTemperatureFacet in project Terasology by MovingBlocks.
the class PerlinSurfaceTemperatureProvider method process.
@Override
public void process(GeneratingRegion region) {
SurfaceTemperatureFacet facet = new SurfaceTemperatureFacet(region.getRegion(), region.getBorderForFacet(SurfaceTemperatureFacet.class));
float[] noise = this.temperatureNoise.noise(facet.getWorldRegion());
for (int i = 0; i < noise.length; ++i) {
noise[i] = TeraMath.clamp((noise[i] * 2.11f + 1f) * 0.5f);
}
facet.set(noise);
region.setRegionFacet(SurfaceTemperatureFacet.class, facet);
}
use of org.terasology.world.generation.facets.SurfaceTemperatureFacet 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.world.generation.facets.SurfaceTemperatureFacet in project Terasology by MovingBlocks.
the class PerlinHillsAndMountainsProvider method process.
@Override
public void process(GeneratingRegion region) {
SurfaceHeightFacet facet = region.getRegionFacet(SurfaceHeightFacet.class);
float[] mountainData = mountainNoise.noise(facet.getWorldRegion());
float[] hillData = hillNoise.noise(facet.getWorldRegion());
SurfaceTemperatureFacet temperatureData = region.getRegionFacet(SurfaceTemperatureFacet.class);
SurfaceHumidityFacet humidityData = region.getRegionFacet(SurfaceHumidityFacet.class);
float[] heightData = facet.getInternal();
Iterator<BaseVector2i> positionIterator = facet.getRelativeRegion().contents().iterator();
for (int i = 0; i < heightData.length; ++i) {
BaseVector2i pos = positionIterator.next();
float temp = temperatureData.get(pos);
float tempHumid = temp * humidityData.get(pos);
Vector2f distanceToMountainBiome = new Vector2f(temp - 0.25f, tempHumid - 0.35f);
float mIntens = TeraMath.clamp(1.0f - distanceToMountainBiome.length() * 3.0f);
float densityMountains = Math.max(mountainData[i] * 2.12f, 0) * mIntens * configuration.mountainAmplitude;
float densityHills = Math.max(hillData[i] * 2.12f - 0.1f, 0) * (1.0f - mIntens) * configuration.hillAmplitude;
heightData[i] = heightData[i] + 1024 * densityMountains + 128 * densityHills;
}
}
Aggregations