Search in sources :

Example 1 with SurfaceHumidityFacet

use of org.terasology.world.generation.facets.SurfaceHumidityFacet in project Terasology by MovingBlocks.

the class PerlinHumidityProvider method process.

@Override
public void process(GeneratingRegion region) {
    Border3D border = region.getBorderForFacet(SurfaceHumidityFacet.class);
    SurfaceHumidityFacet facet = new SurfaceHumidityFacet(region.getRegion(), border);
    float[] noise = humidityNoise.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(SurfaceHumidityFacet.class, facet);
}
Also used : SurfaceHumidityFacet(org.terasology.world.generation.facets.SurfaceHumidityFacet) Border3D(org.terasology.world.generation.Border3D)

Example 2 with SurfaceHumidityFacet

use of org.terasology.world.generation.facets.SurfaceHumidityFacet 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);
}
Also used : SurfaceHeightFacet(org.terasology.world.generation.facets.SurfaceHeightFacet) SurfaceHumidityFacet(org.terasology.world.generation.facets.SurfaceHumidityFacet) Border3D(org.terasology.world.generation.Border3D) BaseVector2i(org.terasology.math.geom.BaseVector2i) SeaLevelFacet(org.terasology.world.generation.facets.SeaLevelFacet) BiomeFacet(org.terasology.core.world.generator.facets.BiomeFacet) SurfaceTemperatureFacet(org.terasology.world.generation.facets.SurfaceTemperatureFacet)

Example 3 with SurfaceHumidityFacet

use of org.terasology.world.generation.facets.SurfaceHumidityFacet 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;
    }
}
Also used : SurfaceHeightFacet(org.terasology.world.generation.facets.SurfaceHeightFacet) SurfaceHumidityFacet(org.terasology.world.generation.facets.SurfaceHumidityFacet) Vector2f(org.terasology.math.geom.Vector2f) BaseVector2i(org.terasology.math.geom.BaseVector2i) SurfaceTemperatureFacet(org.terasology.world.generation.facets.SurfaceTemperatureFacet)

Aggregations

SurfaceHumidityFacet (org.terasology.world.generation.facets.SurfaceHumidityFacet)3 BaseVector2i (org.terasology.math.geom.BaseVector2i)2 Border3D (org.terasology.world.generation.Border3D)2 SurfaceHeightFacet (org.terasology.world.generation.facets.SurfaceHeightFacet)2 SurfaceTemperatureFacet (org.terasology.world.generation.facets.SurfaceTemperatureFacet)2 BiomeFacet (org.terasology.core.world.generator.facets.BiomeFacet)1 Vector2f (org.terasology.math.geom.Vector2f)1 SeaLevelFacet (org.terasology.world.generation.facets.SeaLevelFacet)1