Search in sources :

Example 41 with Vector2f

use of org.terasology.math.geom.Vector2f 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

Vector2f (org.terasology.math.geom.Vector2f)41 Vector3f (org.terasology.math.geom.Vector3f)8 IOException (java.io.IOException)5 TIntList (gnu.trove.list.TIntList)4 Vector2i (org.terasology.math.geom.Vector2i)4 TFloatList (gnu.trove.list.TFloatList)3 Map (java.util.Map)3 Test (org.junit.Test)3 Name (org.terasology.naming.Name)3 SubtextureData (org.terasology.rendering.assets.texture.subtexture.SubtextureData)3 BrownianNoise (org.terasology.utilities.procedural.BrownianNoise)3 PerlinNoise (org.terasology.utilities.procedural.PerlinNoise)3 SubSampledNoise (org.terasology.utilities.procedural.SubSampledNoise)3 TIntArrayList (gnu.trove.list.array.TIntArrayList)2 InputStream (java.io.InputStream)2 Vector4f (org.terasology.math.geom.Vector4f)2 Bone (org.terasology.rendering.assets.skeletalmesh.Bone)2 BoneWeight (org.terasology.rendering.assets.skeletalmesh.BoneWeight)2 SkeletalMeshDataBuilder (org.terasology.rendering.assets.skeletalmesh.SkeletalMeshDataBuilder)2 BlockAppearance (org.terasology.world.block.BlockAppearance)2