Search in sources :

Example 16 with Region3i

use of org.terasology.math.Region3i in project Terasology by MovingBlocks.

the class SubSampledNoise method noise.

public float[] noise(Region3i region) {
    Region3i fullRegion = determineRequiredRegion(region);
    float[] keyData = getKeyValues(fullRegion);
    float[] fullData = mapExpand(keyData, fullRegion);
    return getSubset(fullData, fullRegion, region);
}
Also used : Region3i(org.terasology.math.Region3i)

Example 17 with Region3i

use of org.terasology.math.Region3i in project Terasology by MovingBlocks.

the class EntityAwareWorldProvider method onBlockRegionDeactivated.

@ReceiveEvent(components = { BlockRegionComponent.class })
public void onBlockRegionDeactivated(BeforeDeactivateComponent event, EntityRef entity) {
    Region3i oldRegion = blockRegions.get(entity);
    for (Vector3i pos : oldRegion) {
        blockRegionLookup.remove(pos);
    }
    blockRegions.remove(entity);
}
Also used : Vector3i(org.terasology.math.geom.Vector3i) Region3i(org.terasology.math.Region3i) ReceiveEvent(org.terasology.entitySystem.event.ReceiveEvent)

Example 18 with Region3i

use of org.terasology.math.Region3i in project Terasology by MovingBlocks.

the class EntityAwareWorldProvider method onBlockRegionChanged.

@ReceiveEvent(components = { BlockRegionComponent.class })
public void onBlockRegionChanged(OnChangedComponent event, EntityRef entity) {
    Region3i oldRegion = blockRegions.get(entity);
    for (Vector3i pos : oldRegion) {
        blockRegionLookup.remove(pos);
    }
    BlockRegionComponent regionComp = entity.getComponent(BlockRegionComponent.class);
    blockRegions.put(entity, regionComp.region);
    for (Vector3i pos : regionComp.region) {
        blockRegionLookup.put(pos, entity);
    }
}
Also used : BlockRegionComponent(org.terasology.world.block.regions.BlockRegionComponent) Vector3i(org.terasology.math.geom.Vector3i) Region3i(org.terasology.math.Region3i) ReceiveEvent(org.terasology.entitySystem.event.ReceiveEvent)

Example 19 with Region3i

use of org.terasology.math.Region3i in project Terasology by MovingBlocks.

the class StandardBatchPropagator method propagateBetween.

@Override
public void propagateBetween(LitChunk chunk, LitChunk adjChunk, Side side, boolean propagateExternal) {
    IndexProvider indexProvider = createIndexProvider(side);
    Region3i edgeRegion = ChunkMath.getEdgeRegion(Region3i.createFromMinAndSize(Vector3i.zero(), ChunkConstants.CHUNK_SIZE), side);
    int edgeSize = edgeRegion.size().x * edgeRegion.size().y * edgeRegion.size().z;
    int[] depth = new int[edgeSize];
    propagateSide(chunk, adjChunk, side, indexProvider, edgeRegion, depth);
    propagateDepth(adjChunk, side, propagateExternal, indexProvider, edgeRegion, depth);
}
Also used : Region3i(org.terasology.math.Region3i)

Example 20 with Region3i

use of org.terasology.math.Region3i in project Terasology by MovingBlocks.

the class WorldBuilderTest method testCumulativeBorderCalculation.

@Test
public void testCumulativeBorderCalculation() {
    WorldBuilder worldBuilder = new WorldBuilder(context.get(WorldGeneratorPluginLibrary.class));
    worldBuilder.setSeed(12);
    worldBuilder.addProvider(new Facet1Provider());
    worldBuilder.addProvider(new Facet2Provider());
    worldBuilder.addProvider(new Facet3Provider());
    World world = worldBuilder.build();
    Region3i regionToGenerate = Region3i.createFromCenterExtents(new Vector3i(), 1);
    Region regionData = world.getWorldData(regionToGenerate);
    Facet3 facet3 = regionData.getFacet(Facet3.class);
    assertEquals(regionToGenerate, facet3.getWorldRegion());
    Facet1 facet1 = regionData.getFacet(Facet1.class);
    assertEquals(Region3i.createFromMinAndSize(new Vector3i(-2, -1, -2), new Vector3i(5, 3, 5)), facet1.getWorldRegion());
    Facet2 facet2 = regionData.getFacet(Facet2.class);
    assertEquals(Region3i.createFromMinAndSize(new Vector3i(-4, -1, -4), new Vector3i(9, 3, 9)), facet2.getWorldRegion());
}
Also used : WorldGeneratorPluginLibrary(org.terasology.world.generator.plugin.WorldGeneratorPluginLibrary) Vector3i(org.terasology.math.geom.Vector3i) Region3i(org.terasology.math.Region3i) Test(org.junit.Test)

Aggregations

Region3i (org.terasology.math.Region3i)23 Vector3i (org.terasology.math.geom.Vector3i)15 Test (org.junit.Test)4 WorldGeneratorPluginLibrary (org.terasology.world.generator.plugin.WorldGeneratorPluginLibrary)4 Before (org.junit.Before)3 BaseVector2i (org.terasology.math.geom.BaseVector2i)3 BaseVector3i (org.terasology.math.geom.BaseVector3i)3 Border3D (org.terasology.world.generation.Border3D)3 Region (org.terasology.world.generation.Region)3 SurfaceHeightFacet (org.terasology.world.generation.facets.SurfaceHeightFacet)3 ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)2 Rect2i (org.terasology.math.geom.Rect2i)2 Vector3f (org.terasology.math.geom.Vector3f)2 Color (java.awt.Color)1 Graphics2D (java.awt.Graphics2D)1 RenderingHints (java.awt.RenderingHints)1 BufferedImage (java.awt.image.BufferedImage)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1