Search in sources :

Example 16 with Vector3i

use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.

the class Region3i method createBounded.

/**
 * Create a region by two point
 * @param a vertex a
 * @param b the diagonal vertex of a
 * @return a new region base on vertex a and b
 */
public static Region3i createBounded(BaseVector3i a, BaseVector3i b) {
    Vector3i min = new Vector3i(a);
    min.min(b);
    Vector3i max = new Vector3i(a);
    max.max(b);
    return createFromMinMax(min, max);
}
Also used : BaseVector3i(org.terasology.math.geom.BaseVector3i) Vector3i(org.terasology.math.geom.Vector3i)

Example 17 with Vector3i

use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.

the class Region3i method createFromCenterExtents.

/**
 * Create a region with center point and extents size
 * @param center the center point of region
 * @param extents the extents size of region
 * @return a new region base on the center point and extents size
 */
public static Region3i createFromCenterExtents(BaseVector3i center, int extent) {
    Vector3i min = new Vector3i(center.x() - extent, center.y() - extent, center.z() - extent);
    Vector3i max = new Vector3i(center.x() + extent, center.y() + extent, center.z() + extent);
    return createFromMinMax(min, max);
}
Also used : BaseVector3i(org.terasology.math.geom.BaseVector3i) Vector3i(org.terasology.math.geom.Vector3i)

Example 18 with Vector3i

use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.

the class Region3i method expand.

public Region3i expand(BaseVector3i amount) {
    Vector3i expandedMin = min();
    expandedMin.sub(amount);
    Vector3i expandedMax = max();
    expandedMax.add(amount);
    return createFromMinMax(expandedMin, expandedMax);
}
Also used : BaseVector3i(org.terasology.math.geom.BaseVector3i) Vector3i(org.terasology.math.geom.Vector3i)

Example 19 with Vector3i

use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.

the class Region3i method intersect.

/**
 * @param other
 * @return The region that is encompassed by both this and other. If they
 * do not overlap then the empty region is returned
 */
public Region3i intersect(Region3i other) {
    Vector3i intersectMin = min();
    intersectMin.max(other.min());
    Vector3i intersectMax = max();
    intersectMax.min(other.max());
    return createFromMinMax(intersectMin, intersectMax);
}
Also used : BaseVector3i(org.terasology.math.geom.BaseVector3i) Vector3i(org.terasology.math.geom.Vector3i)

Example 20 with Vector3i

use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.

the class Region3i method expandToContain.

public Region3i expandToContain(BaseVector3i adjPos) {
    Vector3i expandedMin = min();
    expandedMin.min(adjPos);
    Vector3i expandedMax = max();
    expandedMax.max(adjPos);
    return createFromMinMax(expandedMin, expandedMax);
}
Also used : BaseVector3i(org.terasology.math.geom.BaseVector3i) Vector3i(org.terasology.math.geom.Vector3i)

Aggregations

Vector3i (org.terasology.math.geom.Vector3i)249 Test (org.junit.Test)94 EntityRef (org.terasology.entitySystem.entity.EntityRef)34 Block (org.terasology.world.block.Block)32 Chunk (org.terasology.world.chunks.Chunk)30 Vector3f (org.terasology.math.geom.Vector3f)21 ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)17 ChunkImpl (org.terasology.world.chunks.internal.ChunkImpl)17 Region3i (org.terasology.math.Region3i)15 BaseVector3i (org.terasology.math.geom.BaseVector3i)15 LocationComponent (org.terasology.logic.location.LocationComponent)14 BlockComponent (org.terasology.world.block.BlockComponent)10 Side (org.terasology.math.Side)9 ChunkViewCoreImpl (org.terasology.world.internal.ChunkViewCoreImpl)8 Before (org.junit.Before)7 Biome (org.terasology.world.biomes.Biome)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 CoreChunk (org.terasology.world.chunks.CoreChunk)6 RenderableChunk (org.terasology.world.chunks.RenderableChunk)6