Search in sources :

Example 16 with VertexFormat

use of net.minecraft.client.renderer.vertex.VertexFormat in project ImmersiveEngineering by BluSunrize.

the class BakedModelTransformer method transform.

private static BakedQuad transform(BakedQuad quad, IVertexTransformer transformer, Function<VertexFormat, VertexFormat> formatRemapper) {
    VertexFormat format = quad.getFormat();
    VertexFormat newFormat = formatRemapper.apply(format);
    UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(newFormat);
    if (quad.hasTintIndex())
        builder.setQuadTint(quad.getTintIndex());
    builder.setQuadOrientation(quad.getFace());
    LightUtil.putBakedQuad(builder, quad);
    UnpackedBakedQuad unpackedQuad = builder.build();
    try {
        float[][][] unpackedData = getUnpackedData(unpackedQuad);
        int count = newFormat.getElementCount();
        for (int v = 0; v < 4; v++) {
            for (int e = 0; e < count; e++) {
                VertexFormatElement element = newFormat.getElement(e);
                unpackedData[v][e] = transformer.transform(quad, element.getType(), element.getUsage(), unpackedData[v][e]);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return unpackedQuad;
}
Also used : UnpackedBakedQuad(net.minecraftforge.client.model.pipeline.UnpackedBakedQuad) VertexFormatElement(net.minecraft.client.renderer.vertex.VertexFormatElement) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat)

Example 17 with VertexFormat

use of net.minecraft.client.renderer.vertex.VertexFormat in project MinecraftForge by MinecraftForge.

the class LightUtil method putBakedQuad.

public static void putBakedQuad(IVertexConsumer consumer, BakedQuad quad) {
    consumer.setTexture(quad.getSprite());
    consumer.setQuadOrientation(quad.getFace());
    if (quad.hasTintIndex()) {
        consumer.setQuadTint(quad.getTintIndex());
    }
    consumer.setApplyDiffuseLighting(quad.shouldApplyDiffuseLighting());
    //int[] eMap = mapFormats(consumer.getVertexFormat(), DefaultVertexFormats.ITEM);
    float[] data = new float[4];
    VertexFormat formatFrom = consumer.getVertexFormat();
    VertexFormat formatTo = quad.getFormat();
    int countFrom = formatFrom.getElementCount();
    int countTo = formatTo.getElementCount();
    int[] eMap = formatMaps.getUnchecked(Pair.of(formatFrom, formatTo));
    for (int v = 0; v < 4; v++) {
        for (int e = 0; e < countFrom; e++) {
            if (eMap[e] != countTo) {
                unpack(quad.getVertexData(), data, quad.getFormat(), v, eMap[e]);
                consumer.put(e, data);
            } else {
                consumer.put(e);
            }
        }
    }
}
Also used : VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat)

Example 18 with VertexFormat

use of net.minecraft.client.renderer.vertex.VertexFormat in project MinecraftForge by MinecraftForge.

the class VertexLighterFlat method getVertexFormat.

private static VertexFormat getVertexFormat(IVertexConsumer parent) {
    VertexFormat format = parent.getVertexFormat();
    if (format.hasNormal())
        return format;
    format = new VertexFormat(format);
    format.addElement(new VertexFormatElement(0, VertexFormatElement.EnumType.FLOAT, VertexFormatElement.EnumUsage.NORMAL, 4));
    return format;
}
Also used : VertexFormatElement(net.minecraft.client.renderer.vertex.VertexFormatElement) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat)

Example 19 with VertexFormat

use of net.minecraft.client.renderer.vertex.VertexFormat in project MinecraftForge by MinecraftForge.

the class ForgeHooksClient method putQuadColor.

public static void putQuadColor(VertexBuffer renderer, BakedQuad quad, int color) {
    float cb = color & 0xFF;
    float cg = (color >>> 8) & 0xFF;
    float cr = (color >>> 16) & 0xFF;
    float ca = (color >>> 24) & 0xFF;
    VertexFormat format = quad.getFormat();
    int size = format.getIntegerSize();
    // assumes that color is aligned
    int offset = format.getColorOffset() / 4;
    for (int i = 0; i < 4; i++) {
        int vc = quad.getVertexData()[offset + size * i];
        float vcr = vc & 0xFF;
        float vcg = (vc >>> 8) & 0xFF;
        float vcb = (vc >>> 16) & 0xFF;
        float vca = (vc >>> 24) & 0xFF;
        int ncr = Math.min(0xFF, (int) (cr * vcr / 0xFF));
        int ncg = Math.min(0xFF, (int) (cg * vcg / 0xFF));
        int ncb = Math.min(0xFF, (int) (cb * vcb / 0xFF));
        int nca = Math.min(0xFF, (int) (ca * vca / 0xFF));
        renderer.putColorRGBA(renderer.getColorIndex(4 - i), ncr, ncg, ncb, nca);
    }
}
Also used : VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat)

Example 20 with VertexFormat

use of net.minecraft.client.renderer.vertex.VertexFormat in project ImmersiveEngineering by BluSunrize.

the class ClientUtils method renderModelTESR.

public static void renderModelTESR(List<BakedQuad> quads, VertexBuffer renderer, int brightness) {
    int l1 = (brightness >> 0x10) & 0xFFFF;
    int l2 = brightness & 0xFFFF;
    for (BakedQuad quad : quads) {
        int[] vData = quad.getVertexData();
        VertexFormat format = quad.getFormat();
        int size = format.getIntegerSize();
        int uv = format.getUvOffsetById(0) / 4;
        for (int i = 0; i < 4; ++i) {
            renderer.pos(Float.intBitsToFloat(vData[size * i]), Float.intBitsToFloat(vData[size * i + 1]), Float.intBitsToFloat(vData[size * i + 2])).color(255, 255, 255, 255).tex(Float.intBitsToFloat(vData[size * i + uv]), Float.intBitsToFloat(vData[size * i + uv + 1])).lightmap(l1, l2).endVertex();
        }
    }
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) UnpackedBakedQuad(net.minecraftforge.client.model.pipeline.UnpackedBakedQuad) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat)

Aggregations

VertexFormat (net.minecraft.client.renderer.vertex.VertexFormat)23 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)10 PerspAwareModelBase (buildcraft.core.lib.client.model.PerspAwareModelBase)4 ImmutableList (com.google.common.collect.ImmutableList)4 UnpackedBakedQuad (net.minecraftforge.client.model.pipeline.UnpackedBakedQuad)4 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)2 Tessellator (net.minecraft.client.renderer.Tessellator)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 VertexFormatElement (net.minecraft.client.renderer.vertex.VertexFormatElement)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 Matrix4 (blusunrize.immersiveengineering.common.util.chickenbones.Matrix4)1 MutableQuad (buildcraft.lib.client.model.MutableQuad)1 LensPluggable (buildcraft.transport.pluggable.LensPluggable)1 IWidgetIcon (com.enderio.core.api.client.render.IWidgetIcon)1 Vector4f (com.enderio.core.common.vecmath.Vector4f)1 Lists (com.google.common.collect.Lists)1 ConduitDisplayMode (crazypants.enderio.base.conduit.ConduitDisplayMode)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1