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);
}
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);
}
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);
}
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);
}
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);
});
}
Aggregations