Search in sources :

Example 1 with IVertexOperation

use of codechicken.lib.render.pipeline.IVertexOperation in project GregTech by GregTechCE.

the class TieredMetaTileEntity method renderMetaTileEntity.

@Override
public void renderMetaTileEntity(CCRenderState renderState, IVertexOperation[] pipeline) {
    IVertexOperation[] colouredPipeline = ArrayUtils.add(pipeline, new ColourMultiplier(paintingColor));
    Textures.VOLTAGE_CASINGS[tier].render(renderState, colouredPipeline);
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) ColourMultiplier(codechicken.lib.render.pipeline.ColourMultiplier)

Example 2 with IVertexOperation

use of codechicken.lib.render.pipeline.IVertexOperation in project LogisticsPipes by RS485.

the class Model3D method render.

@Override
public void render(I3DOperation... i3dOperations) {
    List<IVertexOperation> list = new ArrayList<>();
    for (I3DOperation op : i3dOperations) {
        list.add((IVertexOperation) op.getOriginal());
    }
    model.render(CCRenderState.instance(), list.toArray(new IVertexOperation[0]));
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) ArrayList(java.util.ArrayList) I3DOperation(logisticspipes.proxy.object3d.interfaces.I3DOperation)

Example 3 with IVertexOperation

use of codechicken.lib.render.pipeline.IVertexOperation in project GregTech by GregTechCE.

the class ICoverable method renderCovers.

@SideOnly(Side.CLIENT)
default void renderCovers(CCRenderState renderState, Matrix4 translation, BlockRenderLayer layer) {
    renderState.lightMatrix.locate(getWorld(), getPos());
    double coverPlateThickness = getCoverPlateThickness();
    IVertexOperation[] platePipeline = new IVertexOperation[] { new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(getPaintingColor())) };
    IVertexOperation[] coverPipeline = new IVertexOperation[] { renderState.lightMatrix };
    for (EnumFacing sideFacing : EnumFacing.values()) {
        CoverBehavior coverBehavior = getCoverAtSide(sideFacing);
        if (coverBehavior == null)
            continue;
        Cuboid6 plateBox = getCoverPlateBox(sideFacing, coverPlateThickness);
        if (coverBehavior.canRenderInLayer(layer) && coverPlateThickness > 0) {
            renderState.preRenderWorld(getWorld(), getPos());
            coverBehavior.renderCoverPlate(renderState, translation, platePipeline, plateBox, layer);
        }
        if (coverBehavior.canRenderInLayer(layer)) {
            coverBehavior.renderCover(renderState, translation.copy(), coverPipeline, plateBox, layer);
            if (coverPlateThickness == 0.0 && shouldRenderBackSide() && coverBehavior.canRenderBackside()) {
                // machine is full block, but still not opaque - render cover on the back side too
                Matrix4 backTranslation = translation.copy();
                if (sideFacing.getAxis().isVertical()) {
                    REVERSE_VERTICAL_ROTATION.apply(backTranslation);
                } else {
                    REVERSE_HORIZONTAL_ROTATION.apply(backTranslation);
                }
                backTranslation.translate(-sideFacing.getXOffset(), -sideFacing.getYOffset(), -sideFacing.getZOffset());
                coverBehavior.renderCover(renderState, backTranslation, coverPipeline, plateBox, layer);
            }
        }
    }
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) EnumFacing(net.minecraft.util.EnumFacing) IndexedCuboid6(codechicken.lib.raytracer.IndexedCuboid6) ColourMultiplier(codechicken.lib.render.pipeline.ColourMultiplier) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with IVertexOperation

use of codechicken.lib.render.pipeline.IVertexOperation in project GregTech by GregTechCE.

the class CableRenderer method renderCableBlock.

public void renderCableBlock(Material material, Insulation insulation1, int insulationColor1, CCRenderState state, IVertexOperation[] pipeline, int connectMask) {
    int wireColor = GTUtility.convertRGBtoOpaqueRGBA_CL(material.materialRGB);
    float thickness = insulation1.thickness;
    IVertexOperation[] wire = ArrayUtils.addAll(pipeline, new IconTransformation(wireTexture), new ColourMultiplier(wireColor));
    IVertexOperation[] overlays = wire;
    IVertexOperation[] insulation = wire;
    if (insulation1.insulationLevel != -1) {
        int insulationColor = GTUtility.convertRGBtoOpaqueRGBA_CL(insulationColor1);
        ColourMultiplier multiplier = new ColourMultiplier(insulationColor);
        insulation = ArrayUtils.addAll(pipeline, new IconTransformation(insulationTextures[5]), multiplier);
        overlays = ArrayUtils.addAll(pipeline, new IconTransformation(insulationTextures[insulation1.insulationLevel]), multiplier);
    }
    Cuboid6 cuboid6 = BlockCable.getSideBox(null, thickness);
    for (EnumFacing renderedSide : EnumFacing.VALUES) {
        if ((connectMask & 1 << renderedSide.getIndex()) == 0) {
            int oppositeIndex = renderedSide.getOpposite().getIndex();
            if ((connectMask & 1 << oppositeIndex) > 0 && (connectMask & ~(1 << oppositeIndex)) == 0) {
                // if there is something on opposite side, render overlay + wire
                renderCableSide(state, wire, renderedSide, cuboid6);
                renderCableSide(state, overlays, renderedSide, cuboid6);
            } else {
                renderCableSide(state, insulation, renderedSide, cuboid6);
            }
        }
    }
    renderCableCube(connectMask, state, insulation, wire, overlays, EnumFacing.DOWN, thickness);
    renderCableCube(connectMask, state, insulation, wire, overlays, EnumFacing.UP, thickness);
    renderCableCube(connectMask, state, insulation, wire, overlays, EnumFacing.WEST, thickness);
    renderCableCube(connectMask, state, insulation, wire, overlays, EnumFacing.EAST, thickness);
    renderCableCube(connectMask, state, insulation, wire, overlays, EnumFacing.NORTH, thickness);
    renderCableCube(connectMask, state, insulation, wire, overlays, EnumFacing.SOUTH, thickness);
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) EnumFacing(net.minecraft.util.EnumFacing) Cuboid6(codechicken.lib.vec.Cuboid6) IconTransformation(codechicken.lib.vec.uv.IconTransformation) ColourMultiplier(codechicken.lib.render.pipeline.ColourMultiplier)

Example 5 with IVertexOperation

use of codechicken.lib.render.pipeline.IVertexOperation in project GregTech by GregTechCE.

the class CableRenderer method renderBlock.

@Override
public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) {
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.bind(buffer);
    renderState.setBrightness(world, pos);
    IVertexOperation[] pipeline = { new Translation(pos) };
    BlockCable blockCable = (BlockCable) state.getBlock();
    TileEntityCable tileEntityCable = (TileEntityCable) blockCable.getPipeTileEntity(world, pos);
    if (tileEntityCable == null)
        return false;
    int paintingColor = tileEntityCable.getInsulationColor();
    int connectedSidesMask = blockCable.getActualConnections(tileEntityCable, world);
    Insulation insulation = tileEntityCable.getPipeType();
    Material material = tileEntityCable.getPipeMaterial();
    if (insulation != null && material != null) {
        BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer();
        if (renderLayer == BlockRenderLayer.CUTOUT) {
            renderCableBlock(material, insulation, paintingColor, renderState, pipeline, connectedSidesMask);
        }
        ICoverable coverable = tileEntityCable.getCoverableImplementation();
        coverable.renderCovers(renderState, new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()), renderLayer);
    }
    return true;
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) Insulation(gregtech.common.pipelike.cable.Insulation) ICoverable(gregtech.api.cover.ICoverable) Translation(codechicken.lib.vec.Translation) TileEntityCable(gregtech.common.pipelike.cable.tile.TileEntityCable) Material(gregtech.api.unification.material.type.Material) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) CCRenderState(codechicken.lib.render.CCRenderState) ItemBlockCable(gregtech.common.pipelike.cable.ItemBlockCable) BlockCable(gregtech.common.pipelike.cable.BlockCable) Matrix4(codechicken.lib.vec.Matrix4)

Aggregations

IVertexOperation (codechicken.lib.render.pipeline.IVertexOperation)23 ColourMultiplier (codechicken.lib.render.pipeline.ColourMultiplier)16 EnumFacing (net.minecraft.util.EnumFacing)8 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)8 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)7 CCRenderState (codechicken.lib.render.CCRenderState)6 Matrix4 (codechicken.lib.vec.Matrix4)6 Cuboid6 (codechicken.lib.vec.Cuboid6)4 Translation (codechicken.lib.vec.Translation)4 IconTransformation (codechicken.lib.vec.uv.IconTransformation)4 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)4 ICoverable (gregtech.api.cover.ICoverable)3 Material (gregtech.api.unification.material.type.Material)3 CCModel (codechicken.lib.render.CCModel)2 ArrayList (java.util.ArrayList)2 I3DOperation (logisticspipes.proxy.object3d.interfaces.I3DOperation)2 IndexedCuboid6 (codechicken.lib.raytracer.IndexedCuboid6)1 BakingVertexBuffer (codechicken.lib.render.buffer.BakingVertexBuffer)1 Rotation (codechicken.lib.vec.Rotation)1 Scale (codechicken.lib.vec.Scale)1