Search in sources :

Example 1 with FieldFacet2D

use of org.terasology.world.generation.facets.base.FieldFacet2D in project Terasology by MovingBlocks.

the class FieldFacetLayer method render.

@Override
public void render(BufferedImage img, Region region) {
    FieldFacet2D facet = region.getFacet(clazz);
    int width = img.getWidth();
    int height = img.getHeight();
    ColorModel colorModel = img.getColorModel();
    ColorBlender blender = ColorBlenders.forColorModel(ColorModels.RGBA, colorModel);
    DataBufferInt dataBuffer = (DataBufferInt) img.getRaster().getDataBuffer();
    for (int z = 0; z < height; z++) {
        for (int x = 0; x < width; x++) {
            Color col = getColor(facet, x, z);
            int src = col.rgba();
            int dst = dataBuffer.getElem(z * width + x);
            int mix = blender.add(src, dst);
            dataBuffer.setElem(z * width + x, mix);
        }
    }
}
Also used : FieldFacet2D(org.terasology.world.generation.facets.base.FieldFacet2D) ColorBlender(org.terasology.world.viewer.color.ColorBlender) ColorModel(java.awt.image.ColorModel) Color(org.terasology.rendering.nui.Color) DataBufferInt(java.awt.image.DataBufferInt)

Example 2 with FieldFacet2D

use of org.terasology.world.generation.facets.base.FieldFacet2D in project Terasology by MovingBlocks.

the class FieldFacetLayer method getWorldText.

@Override
public String getWorldText(Region region, int wx, int wy) {
    FieldFacet2D facet = region.getFacet(clazz);
    double value = facet.getWorld(wx, wy);
    return String.format("%.2f", value);
}
Also used : FieldFacet2D(org.terasology.world.generation.facets.base.FieldFacet2D)

Aggregations

FieldFacet2D (org.terasology.world.generation.facets.base.FieldFacet2D)2 ColorModel (java.awt.image.ColorModel)1 DataBufferInt (java.awt.image.DataBufferInt)1 Color (org.terasology.rendering.nui.Color)1 ColorBlender (org.terasology.world.viewer.color.ColorBlender)1