Search in sources :

Example 1 with Border3D

use of org.terasology.world.generation.Border3D 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);
}
Also used : SurfaceHeightFacet(org.terasology.world.generation.facets.SurfaceHeightFacet) Border3D(org.terasology.world.generation.Border3D) TreeFacet(org.terasology.core.world.generator.facets.TreeFacet) BiomeFacet(org.terasology.core.world.generator.facets.BiomeFacet) Predicate(com.google.common.base.Predicate)

Example 2 with Border3D

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

the class PerlinBaseSurfaceProvider method process.

@Override
public void process(GeneratingRegion region) {
    Border3D border = region.getBorderForFacet(SurfaceHeightFacet.class);
    SurfaceHeightFacet facet = new SurfaceHeightFacet(region.getRegion(), border);
    SeaLevelFacet seaLevelFacet = region.getRegionFacet(SeaLevelFacet.class);
    float seaLevel = seaLevelFacet.getSeaLevel();
    Rect2i processRegion = facet.getWorldRegion();
    float[] noise = surfaceNoise.noise(processRegion);
    for (int i = 0; i < noise.length; ++i) {
        noise[i] = seaLevel + seaLevel * ((noise[i] * 2.11f + 1f) / 2f);
    }
    facet.set(noise);
    region.setRegionFacet(SurfaceHeightFacet.class, facet);
}
Also used : SurfaceHeightFacet(org.terasology.world.generation.facets.SurfaceHeightFacet) Rect2i(org.terasology.math.geom.Rect2i) Border3D(org.terasology.world.generation.Border3D) SeaLevelFacet(org.terasology.world.generation.facets.SeaLevelFacet)

Example 3 with Border3D

use of org.terasology.world.generation.Border3D 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 4 with Border3D

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

the class FieldFacetTest method setup.

@Before
public void setup() {
    Border3D border = new Border3D(0, 0, 0).extendBy(0, 15, 10);
    Vector3i min = new Vector3i(10, 20, 30);
    Vector3i size = new Vector3i(40, 50, 60);
    Region3i region = Region3i.createFromMinAndSize(min, size);
    facet = createFacet(region, border);
// facet = [worldMin=(0, 5, 20), relativeMin=(-10, -15, -10), size=(60, 65, 80)]
}
Also used : Border3D(org.terasology.world.generation.Border3D) Vector3i(org.terasology.math.geom.Vector3i) Region3i(org.terasology.math.Region3i) Before(org.junit.Before)

Example 5 with Border3D

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

the class ObjectFacetTest method setup.

@Before
public void setup() {
    Border3D border = new Border3D(0, 0, 0).extendBy(0, 15, 10);
    Vector3i min = new Vector3i(10, 20, 30);
    Vector3i size = new Vector3i(40, 50, 60);
    Region3i region = Region3i.createFromMinAndSize(min, size);
    facet = createFacet(region, border);
// facet = [worldMin=(0, 5, 20), relativeMin=(-10, -15, -10), size=(60, 65, 80)]
}
Also used : Border3D(org.terasology.world.generation.Border3D) Vector3i(org.terasology.math.geom.Vector3i) Region3i(org.terasology.math.Region3i) Before(org.junit.Before)

Aggregations

Border3D (org.terasology.world.generation.Border3D)11 SurfaceHeightFacet (org.terasology.world.generation.facets.SurfaceHeightFacet)6 Before (org.junit.Before)4 BaseVector2i (org.terasology.math.geom.BaseVector2i)4 Vector3i (org.terasology.math.geom.Vector3i)4 Region3i (org.terasology.math.Region3i)3 SeaLevelFacet (org.terasology.world.generation.facets.SeaLevelFacet)3 BiomeFacet (org.terasology.core.world.generator.facets.BiomeFacet)2 Rect2i (org.terasology.math.geom.Rect2i)2 SurfaceHumidityFacet (org.terasology.world.generation.facets.SurfaceHumidityFacet)2 Predicate (com.google.common.base.Predicate)1 HashMap (java.util.HashMap)1 TreeFacet (org.terasology.core.world.generator.facets.TreeFacet)1 FacetProvider (org.terasology.world.generation.FacetProvider)1 RegionImpl (org.terasology.world.generation.RegionImpl)1 WorldFacet (org.terasology.world.generation.WorldFacet)1 SurfaceTemperatureFacet (org.terasology.world.generation.facets.SurfaceTemperatureFacet)1 LayeredZoneRegionFunction (org.terasology.world.zones.LayeredZoneRegionFunction)1 MinMaxLayerThickness (org.terasology.world.zones.MinMaxLayerThickness)1 Zone (org.terasology.world.zones.Zone)1