Search in sources :

Example 11 with Region3i

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

the class WorldBuilderTest method testBorderCalculation.

@Test
public void testBorderCalculation() {
    WorldBuilder worldBuilder = new WorldBuilder(context.get(WorldGeneratorPluginLibrary.class));
    worldBuilder.setSeed(12);
    worldBuilder.addProvider(new Facet1Provider());
    worldBuilder.addProvider(new Facet2Provider());
    World world = worldBuilder.build();
    Region3i regionToGenerate = Region3i.createFromCenterExtents(new Vector3i(), 1);
    Region regionData = world.getWorldData(regionToGenerate);
    Facet1 facet1 = regionData.getFacet(Facet1.class);
    assertEquals(regionToGenerate, facet1.getWorldRegion());
    Facet2 facet2 = regionData.getFacet(Facet2.class);
    assertEquals(Region3i.createFromMinAndSize(new Vector3i(-3, -1, -3), new Vector3i(7, 3, 7)), 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)

Example 12 with Region3i

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

the class WorldBuilderTest method testMultiplePathsBorderCalculation.

@Test
public void testMultiplePathsBorderCalculation() {
    WorldBuilder worldBuilder = new WorldBuilder(context.get(WorldGeneratorPluginLibrary.class));
    worldBuilder.setSeed(12);
    worldBuilder.addProvider(new Facet1Provider());
    worldBuilder.addProvider(new Facet2Provider());
    worldBuilder.addProvider(new Facet4Provider());
    World world = worldBuilder.build();
    Region3i regionToGenerate = Region3i.createFromCenterExtents(new Vector3i(), 1);
    Region regionData = world.getWorldData(regionToGenerate);
    Facet1 facet1 = regionData.getFacet(Facet1.class);
    assertEquals(regionToGenerate, facet1.getWorldRegion());
    Facet4 facet4 = regionData.getFacet(Facet4.class);
    assertEquals(regionToGenerate, facet4.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)

Example 13 with Region3i

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

the class WorldBuilderTest method testUpdating.

@Test
public void testUpdating() {
    WorldBuilder worldBuilder = new WorldBuilder(context.get(WorldGeneratorPluginLibrary.class));
    worldBuilder.setSeed(12);
    worldBuilder.addProvider(new Facet1Provider());
    worldBuilder.addProvider(new Facet2Provider());
    worldBuilder.addProvider(new Facet3Provider());
    worldBuilder.addProvider(new Facet4Provider());
    worldBuilder.addProvider(new FacetUpdater());
    Region3i regionToGenerate = Region3i.createFromCenterExtents(new Vector3i(), 1);
    World world;
    Region regionData;
    // try checking updated facet
    world = worldBuilder.build();
    regionData = world.getWorldData(regionToGenerate);
    assertTrue(regionData.getFacet(Facet1.class).updated);
    assertTrue(regionData.getFacet(Facet4.class).updated);
    // try checking generated facet
    world = worldBuilder.build();
    regionData = world.getWorldData(regionToGenerate);
    assertNotNull(regionData.getFacet(Facet3.class));
    assertTrue(regionData.getFacet(Facet4.class).updated);
}
Also used : WorldGeneratorPluginLibrary(org.terasology.world.generator.plugin.WorldGeneratorPluginLibrary) Vector3i(org.terasology.math.geom.Vector3i) Region3i(org.terasology.math.Region3i) Test(org.junit.Test)

Example 14 with Region3i

use of org.terasology.math.Region3i 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 15 with Region3i

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

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