Search in sources :

Example 11 with Matrix4

use of codechicken.lib.vec.Matrix4 in project GregTech by GregTechCE.

the class CTCubeRenderer method render.

@SideOnly(Side.CLIENT)
public void render(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline, int connectionMask) {
    for (EnumFacing renderSide : EnumFacing.VALUES) {
        if (hasFaceBit(connectionMask, renderSide)) {
            // do not render faces occluded by connections
            continue;
        }
        int resultTextureMask = 0b1111;
        if (renderSide.getAxis().isHorizontal()) {
            if (hasFaceBit(connectionMask, EnumFacing.UP))
                resultTextureMask &= ~TextureDirection.TOP;
            if (hasFaceBit(connectionMask, EnumFacing.DOWN))
                resultTextureMask &= ~TextureDirection.BOTTOM;
            EnumFacing leftFacing = renderSide.rotateY();
            EnumFacing rightFacing = renderSide.rotateYCCW();
            if (hasFaceBit(connectionMask, leftFacing))
                resultTextureMask &= ~TextureDirection.LEFT;
            if (hasFaceBit(connectionMask, rightFacing))
                resultTextureMask &= ~TextureDirection.RIGHT;
        } else {
            if (hasFaceBit(connectionMask, EnumFacing.NORTH))
                resultTextureMask &= ~TextureDirection.TOP;
            if (hasFaceBit(connectionMask, EnumFacing.SOUTH))
                resultTextureMask &= ~TextureDirection.BOTTOM;
            if (hasFaceBit(connectionMask, EnumFacing.WEST))
                resultTextureMask &= ~TextureDirection.LEFT;
            if (hasFaceBit(connectionMask, EnumFacing.EAST))
                resultTextureMask &= ~TextureDirection.RIGHT;
        }
        TextureAtlasSprite sideSprite = ctSprites[resultTextureMask];
        Textures.renderFace(renderState, translation, pipeline, renderSide, Cuboid6.full, sideSprite);
        Matrix4 backTranslation = translation.copy();
        backTranslation.translate(renderSide.getXOffset(), renderSide.getYOffset() * 0.999, renderSide.getZOffset());
        int backFaceTextureMask;
        if (renderSide.getAxis().isHorizontal()) {
            backFaceTextureMask = resultTextureMask & ~(TextureDirection.RIGHT | TextureDirection.LEFT);
            if ((resultTextureMask & TextureDirection.RIGHT) > 0)
                backFaceTextureMask |= TextureDirection.LEFT;
            if ((resultTextureMask & TextureDirection.LEFT) > 0)
                backFaceTextureMask |= TextureDirection.RIGHT;
        } else {
            backFaceTextureMask = resultTextureMask;
        }
        TextureAtlasSprite backSideSprite = ctSprites[backFaceTextureMask];
        Textures.renderFace(renderState, backTranslation, pipeline, renderSide.getOpposite(), Cuboid6.full, backSideSprite);
    }
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) Matrix4(codechicken.lib.vec.Matrix4) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 12 with Matrix4

use of codechicken.lib.vec.Matrix4 in project GregTech by GregTechCE.

the class InvPipeRenderer 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) };
    BlockInventoryPipe block = (BlockInventoryPipe) state.getBlock();
    TileEntityInventoryPipe tileEntity = (TileEntityInventoryPipe) block.getPipeTileEntity(world, pos);
    if (tileEntity == null) {
        return false;
    }
    int paintingColor = tileEntity.getInsulationColor();
    int connectedSidesMask = block.getActualConnections(tileEntity, world);
    BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer();
    if (renderLayer == BlockRenderLayer.SOLID) {
        renderPipe(renderState, pipeline, paintingColor, connectedSidesMask);
    }
    ICoverable coverable = tileEntity.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) TileEntityInventoryPipe(gregtech.common.pipelike.inventory.tile.TileEntityInventoryPipe) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) CCRenderState(codechicken.lib.render.CCRenderState) BlockInventoryPipe(gregtech.common.pipelike.inventory.BlockInventoryPipe) Matrix4(codechicken.lib.vec.Matrix4)

Example 13 with Matrix4

use of codechicken.lib.vec.Matrix4 in project GregTech by GregTechCE.

the class TileEntityRendererBase method renderTileEntityFast.

@Override
public void renderTileEntityFast(T te, double x, double y, double z, float partialTicks, int destroyStage, float partial, BufferBuilder buffer) {
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.bind(buffer);
    if (te.getWorld() != null) {
        renderState.setBrightness(te.getWorld(), te.getPos());
    }
    Matrix4 translation = new Matrix4().translate(x, y, z);
    draw(te, renderState, translation, partialTicks);
}
Also used : CCRenderState(codechicken.lib.render.CCRenderState) Matrix4(codechicken.lib.vec.Matrix4)

Aggregations

Matrix4 (codechicken.lib.vec.Matrix4)13 CCRenderState (codechicken.lib.render.CCRenderState)9 IVertexOperation (codechicken.lib.render.pipeline.IVertexOperation)6 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)5 EnumFacing (net.minecraft.util.EnumFacing)5 IFastRenderMetaTileEntity (gregtech.api.metatileentity.IFastRenderMetaTileEntity)4 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)4 Translation (codechicken.lib.vec.Translation)3 ICoverable (gregtech.api.cover.ICoverable)3 IRenderMetaTileEntity (gregtech.api.metatileentity.IRenderMetaTileEntity)3 MetaTileEntity (gregtech.api.metatileentity.MetaTileEntity)3 Material (gregtech.api.unification.material.type.Material)3 ColourMultiplier (codechicken.lib.render.pipeline.ColourMultiplier)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 CCModel (codechicken.lib.render.CCModel)1 CCQuad (codechicken.lib.render.CCQuad)1 TransformationList (codechicken.lib.vec.TransformationList)1 IconTransformation (codechicken.lib.vec.uv.IconTransformation)1 MachineItemBlock (gregtech.api.block.machines.MachineItemBlock)1 BlockSurfaceRock (gregtech.common.blocks.surfacerock.BlockSurfaceRock)1