Search in sources :

Example 11 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)

Example 12 with IVertexOperation

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

the class FluidPipeRenderer 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);
    BlockFluidPipe blockPipe = ((BlockFluidPipe) state.getBlock());
    TileEntityFluidPipe tileEntityPipe = (TileEntityFluidPipe) blockPipe.getPipeTileEntity(world, pos);
    if (tileEntityPipe == null) {
        return false;
    }
    FluidPipeType fluidPipeType = tileEntityPipe.getPipeType();
    Material pipeMaterial = tileEntityPipe.getPipeMaterial();
    int paintingColor = tileEntityPipe.getInsulationColor();
    if (fluidPipeType != null && pipeMaterial != null) {
        BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer();
        if (renderLayer == BlockRenderLayer.CUTOUT) {
            int connectedSidesMask = blockPipe.getActualConnections(tileEntityPipe, world);
            IVertexOperation[] pipeline = new IVertexOperation[] { new Translation(pos) };
            renderPipeBlock(pipeMaterial, fluidPipeType, paintingColor, renderState, pipeline, connectedSidesMask);
        }
        ICoverable coverable = tileEntityPipe.getCoverableImplementation();
        coverable.renderCovers(renderState, new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()), renderLayer);
    }
    return true;
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) ICoverable(gregtech.api.cover.ICoverable) Translation(codechicken.lib.vec.Translation) ItemBlockFluidPipe(gregtech.common.pipelike.fluidpipe.ItemBlockFluidPipe) BlockFluidPipe(gregtech.common.pipelike.fluidpipe.BlockFluidPipe) FluidPipeType(gregtech.common.pipelike.fluidpipe.FluidPipeType) Material(gregtech.api.unification.material.type.Material) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) CCRenderState(codechicken.lib.render.CCRenderState) TileEntityFluidPipe(gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe) Matrix4(codechicken.lib.vec.Matrix4)

Example 13 with IVertexOperation

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

the class FluidPipeRenderer method renderPipeBlock.

public boolean renderPipeBlock(Material material, FluidPipeType pipeType, int insulationColor, CCRenderState state, IVertexOperation[] pipeline, int connectMask) {
    int pipeColor = GTUtility.convertRGBtoOpaqueRGBA_CL(getPipeColor(material, insulationColor));
    ColourMultiplier multiplier = new ColourMultiplier(pipeColor);
    PipeTextureInfo textureInfo = this.pipeTextures.get(pipeType);
    PipeModelInfo modelInfo = this.pipeModels.get(pipeType);
    IVertexOperation[] openingTexture = ArrayUtils.addAll(pipeline, new IconTransformation(textureInfo.inTexture), multiplier);
    IVertexOperation[] sideTexture = ArrayUtils.addAll(pipeline, new IconTransformation(textureInfo.sideTexture), multiplier);
    int sidedConnMask = connectMask & 0b111111;
    CCModel fullBlockModel = null;
    if (sidedConnMask == 0b000011) {
        fullBlockModel = modelInfo.fullBlockModels[0];
    } else if (sidedConnMask == 0b001100) {
        fullBlockModel = modelInfo.fullBlockModels[1];
    } else if (sidedConnMask == 0b110000) {
        fullBlockModel = modelInfo.fullBlockModels[2];
    }
    if (fullBlockModel != null) {
        state.setPipeline(fullBlockModel, 0, fullBlockModel.verts.length, sideTexture);
        state.render();
        return true;
    }
    Cuboid6 centerCuboid = BlockFluidPipe.getSideBox(null, pipeType.getThickness());
    state.setPipeline(openingTexture);
    BlockRenderer.renderCuboid(state, centerCuboid, 0);
    for (EnumFacing side : EnumFacing.VALUES) {
        if ((connectMask & 1 << side.getIndex()) > 0) {
            CCModel model = modelInfo.connectionModels[side.getIndex()];
            state.setPipeline(model, 0, model.verts.length, sideTexture);
            state.render();
        }
    }
    return true;
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) EnumFacing(net.minecraft.util.EnumFacing) Cuboid6(codechicken.lib.vec.Cuboid6) CCModel(codechicken.lib.render.CCModel) ColourMultiplier(codechicken.lib.render.pipeline.ColourMultiplier) IconTransformation(codechicken.lib.vec.uv.IconTransformation)

Example 14 with IVertexOperation

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

the class StoneRenderer method renderBlock.

@Override
public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) {
    // otherwise, we are in solid rendering layer and render primary stone
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.bind(buffer);
    Matrix4 translation = new Matrix4();
    translation.translate(pos.getX(), pos.getY(), pos.getZ());
    TextureAtlasSprite stoneSprite = TextureUtils.getBlockTexture("stone");
    Material material = ((BlockSurfaceRock) state.getBlock()).getStoneMaterial(world, pos, state);
    int renderingColor = GTUtility.convertRGBtoOpaqueRGBA_CL(material.materialRGB);
    IVertexOperation[] operations = new IVertexOperation[] { new IconTransformation(stoneSprite), new ColourMultiplier(renderingColor), new TransformationList(translation) };
    if (world != null) {
        renderState.setBrightness(world, pos);
    }
    renderState.setPipeline(operations);
    CCModel actualModel = getActualModel(world, pos);
    renderState.setModel(actualModel);
    renderState.render();
    return true;
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) BlockSurfaceRock(gregtech.common.blocks.surfacerock.BlockSurfaceRock) Material(gregtech.api.unification.material.type.Material) CCRenderState(codechicken.lib.render.CCRenderState) TransformationList(codechicken.lib.vec.TransformationList) Matrix4(codechicken.lib.vec.Matrix4) CCModel(codechicken.lib.render.CCModel) IconTransformation(codechicken.lib.vec.uv.IconTransformation) ColourMultiplier(codechicken.lib.render.pipeline.ColourMultiplier)

Example 15 with IVertexOperation

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

the class MetaTileEntity method renderMetaTileEntity.

/**
 * Renders this meta tile entity
 * Note that you shouldn't refer to world-related information in this method, because it
 * will be called on ItemStacks too
 * @param renderState render state (either chunk batched or item)
 * @param pipeline default set of pipeline transformations
 */
@SideOnly(Side.CLIENT)
public void renderMetaTileEntity(CCRenderState renderState, IVertexOperation[] pipeline) {
    TextureAtlasSprite atlasSprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/stone");
    IVertexOperation[] renderPipeline = ArrayUtils.add(pipeline, new ColourMultiplier(paintingColor));
    for (EnumFacing face : EnumFacing.VALUES) {
        renderFace(renderState, face, Cuboid6.full, atlasSprite, renderPipeline);
    }
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) ColourMultiplier(codechicken.lib.render.pipeline.ColourMultiplier) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

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