Search in sources :

Example 1 with BaseVector3i

use of org.terasology.math.geom.BaseVector3i 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 2 with BaseVector3i

use of org.terasology.math.geom.BaseVector3i 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 3 with BaseVector3i

use of org.terasology.math.geom.BaseVector3i 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 4 with BaseVector3i

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

Example 5 with BaseVector3i

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

the class FloraRasterizer method generateChunk.

@Override
public void generateChunk(CoreChunk chunk, Region chunkRegion) {
    FloraFacet facet = chunkRegion.getFacet(FloraFacet.class);
    WhiteNoise noise = new WhiteNoise(chunk.getPosition().hashCode());
    Map<BaseVector3i, FloraType> entries = facet.getRelativeEntries();
    // check if some other rasterizer has already placed something here
    entries.keySet().stream().filter(pos -> chunk.getBlock(pos).equals(air)).forEach(pos -> {
        FloraType type = entries.get(pos);
        List<Block> list = flora.get(type);
        int blockIdx = Math.abs(noise.intNoise(pos.x(), pos.y(), pos.z())) % list.size();
        Block block = list.get(blockIdx);
        chunk.setBlock(pos, block);
    });
}
Also used : BlockManager(org.terasology.world.block.BlockManager) Region(org.terasology.world.generation.Region) WorldRasterizer(org.terasology.world.generation.WorldRasterizer) Maps(com.google.common.collect.Maps) FloraFacet(org.terasology.core.world.generator.facets.FloraFacet) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) BaseVector3i(org.terasology.math.geom.BaseVector3i) Block(org.terasology.world.block.Block) CoreChunk(org.terasology.world.chunks.CoreChunk) Map(java.util.Map) CoreRegistry(org.terasology.registry.CoreRegistry) WhiteNoise(org.terasology.utilities.procedural.WhiteNoise) FloraFacet(org.terasology.core.world.generator.facets.FloraFacet) WhiteNoise(org.terasology.utilities.procedural.WhiteNoise) BaseVector3i(org.terasology.math.geom.BaseVector3i) Block(org.terasology.world.block.Block)

Aggregations

BaseVector3i (org.terasology.math.geom.BaseVector3i)15 Vector3i (org.terasology.math.geom.Vector3i)8 Graphics2D (java.awt.Graphics2D)3 Map (java.util.Map)3 FloraFacet (org.terasology.core.world.generator.facets.FloraFacet)3 TreeFacet (org.terasology.core.world.generator.facets.TreeFacet)3 TreeGenerator (org.terasology.core.world.generator.trees.TreeGenerator)3 Region3i (org.terasology.math.Region3i)3 Color (java.awt.Color)2 FloraType (org.terasology.core.world.generator.rasterizers.FloraType)2 Region (org.terasology.world.generation.Region)2 ImmutableList (com.google.common.collect.ImmutableList)1 Maps (com.google.common.collect.Maps)1 RenderingHints (java.awt.RenderingHints)1 BufferedImage (java.awt.image.BufferedImage)1 ColorModel (java.awt.image.ColorModel)1 DataBufferInt (java.awt.image.DataBufferInt)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1