use of org.terasology.math.geom.BaseVector3i in project Terasology by MovingBlocks.
the class Region3i method move.
/**
* @param offset
* @return A copy of the region offset by the given value
*/
public Region3i move(BaseVector3i offset) {
Vector3i newMin = min();
newMin.add(offset);
return Region3i.createFromMinAndSize(newMin, size);
}
use of org.terasology.math.geom.BaseVector3i in project Terasology by MovingBlocks.
the class Region3i method createFromCenterExtents.
/**
* Create a region with center point and x,y,z coordinate extents size
* @param center the center point of region
* @param extents the extents size of each side of region
* @return a new region base on the center point and extents size
*/
public static Region3i createFromCenterExtents(BaseVector3i center, BaseVector3i extents) {
Vector3i min = new Vector3i(center.x() - extents.x(), center.y() - extents.y(), center.z() - extents.z());
Vector3i max = new Vector3i(center.x() + extents.x(), center.y() + extents.y(), center.z() + extents.z());
return createFromMinMax(min, max);
}
use of org.terasology.math.geom.BaseVector3i in project Terasology by MovingBlocks.
the class Region3i method getNearestPointTo.
/**
* @param pos
* @return The nearest position within the region to the given pos.
*/
public Vector3i getNearestPointTo(BaseVector3i pos) {
Vector3i result = new Vector3i(pos);
result.min(max());
result.max(min);
return result;
}
use of org.terasology.math.geom.BaseVector3i in project Terasology by MovingBlocks.
the class TreeRasterizer method generateChunk.
@Override
public void generateChunk(CoreChunk chunk, Region chunkRegion) {
TreeFacet facet = chunkRegion.getFacet(TreeFacet.class);
for (Map.Entry<BaseVector3i, TreeGenerator> entry : facet.getRelativeEntries().entrySet()) {
BaseVector3i pos = entry.getKey();
TreeGenerator treeGen = entry.getValue();
int seed = relativeToWorld(facet, pos).hashCode();
Random random = new FastRandom(seed);
treeGen.generate(blockManager, chunk, random, pos.x(), pos.y(), pos.z());
}
}
use of org.terasology.math.geom.BaseVector3i in project Terasology by MovingBlocks.
the class FloraFacetLayer method render.
@Override
public void render(BufferedImage img, Region region) {
FloraFacet treeFacet = region.getFacet(FloraFacet.class);
Graphics2D g = img.createGraphics();
int width = img.getWidth();
ColorModel colorModel = img.getColorModel();
ColorBlender blender = ColorBlenders.forColorModel(ColorModels.RGBA, colorModel);
DataBufferInt dataBuffer = (DataBufferInt) img.getRaster().getDataBuffer();
for (Entry<BaseVector3i, FloraType> entry : treeFacet.getRelativeEntries().entrySet()) {
FloraType treeGen = entry.getValue();
int wx = entry.getKey().getX();
int wz = entry.getKey().getZ();
Color color = colorFunc.apply(treeGen);
int src = color.rgba();
int dst = dataBuffer.getElem(wz * width + wx);
int mix = blender.blend(src, dst);
dataBuffer.setElem(wz * width + wx, mix);
}
g.dispose();
}
Aggregations