Search in sources :

Example 1 with Matrix4

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

the class MetaTileEntityRenderer method renderBlock.

@Override
public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) {
    MetaTileEntity metaTileEntity = BlockMachine.getMetaTileEntity(world, pos);
    if (metaTileEntity == null) {
        return false;
    }
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.bind(buffer);
    Matrix4 translation = new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ());
    BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer();
    if (metaTileEntity.canRenderInLayer(renderLayer)) {
        renderState.lightMatrix.locate(world, pos);
        IVertexOperation[] pipeline = new IVertexOperation[] { renderState.lightMatrix };
        metaTileEntity.renderMetaTileEntity(renderState, translation.copy(), pipeline);
    }
    Matrix4 coverTranslation = new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ());
    metaTileEntity.renderCovers(renderState, coverTranslation, renderLayer);
    if (metaTileEntity.isFragile() && renderLayer == BlockRenderLayer.CUTOUT) {
        TextureMap textureMap = Minecraft.getMinecraft().getTextureMapBlocks();
        Random posRand = new Random(MathHelper.getPositionRandom(pos));
        int destroyStage = posRand.nextInt(10);
        TextureAtlasSprite atlasSprite = textureMap.getAtlasSprite("minecraft:blocks/destroy_stage_" + destroyStage);
        for (EnumFacing face : EnumFacing.VALUES) {
            Textures.renderFace(renderState, translation, new IVertexOperation[0], face, Cuboid6.full, atlasSprite);
        }
    }
    return true;
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) TextureMap(net.minecraft.client.renderer.texture.TextureMap) Random(java.util.Random) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) IRenderMetaTileEntity(gregtech.api.metatileentity.IRenderMetaTileEntity) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) IFastRenderMetaTileEntity(gregtech.api.metatileentity.IFastRenderMetaTileEntity) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) CCRenderState(codechicken.lib.render.CCRenderState) Matrix4(codechicken.lib.vec.Matrix4)

Example 2 with Matrix4

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

the class MetaTileEntityTESR method renderCoverFast.

/**
 * Used Specifically to render covers that are IFastRenderMetaTileEntity
 * Adapted from renderTileEntityFastPart
 * *
 */
private void renderCoverFast(MetaTileEntityHolder te, double x, double y, double z, float partialTicks, int destroyStage, float alpha, List<Tuple<IFastRenderMetaTileEntity, EnumFacing>> coverList) {
    Matrix4 translation = (new Matrix4()).translate(x, y, z);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.enableBlend();
    if (Minecraft.isAmbientOcclusionEnabled()) {
        GlStateManager.shadeModel(GL11.GL_SMOOTH);
    } else {
        GlStateManager.shadeModel(GL11.GL_FLAT);
    }
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    for (Tuple<IFastRenderMetaTileEntity, EnumFacing> tuple : coverList) {
        CCRenderState renderState = CCRenderState.instance();
        renderState.reset();
        renderState.bind(buffer);
        renderState.setBrightness(te.getWorld(), te.getPos().offset(tuple.getSecond()));
        tuple.getFirst().renderMetaTileEntityFast(renderState, translation, partialTicks);
    }
    buffer.setTranslation(0, 0, 0);
    tessellator.draw();
    RenderHelper.enableStandardItemLighting();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) EnumFacing(net.minecraft.util.EnumFacing) IFastRenderMetaTileEntity(gregtech.api.metatileentity.IFastRenderMetaTileEntity) CCRenderState(codechicken.lib.render.CCRenderState) Matrix4(codechicken.lib.vec.Matrix4)

Example 3 with Matrix4

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

the class MetaTileEntityTESR method renderTileEntityFast.

@Override
public void renderTileEntityFast(MetaTileEntityHolder te, double x, double y, double z, float partialTicks, int destroyStage, float partial, BufferBuilder buffer) {
    MetaTileEntity metaTileEntity = te.getMetaTileEntity();
    if (metaTileEntity instanceof IFastRenderMetaTileEntity) {
        CCRenderState renderState = CCRenderState.instance();
        renderState.reset();
        renderState.bind(buffer);
        renderState.setBrightness(te.getWorld(), te.getPos());
        Matrix4 translation = new Matrix4().translate(x, y, z);
        ((IFastRenderMetaTileEntity) metaTileEntity).renderMetaTileEntityFast(renderState, translation, partialTicks);
    }
}
Also used : MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) IFastRenderMetaTileEntity(gregtech.api.metatileentity.IFastRenderMetaTileEntity) IRenderMetaTileEntity(gregtech.api.metatileentity.IRenderMetaTileEntity) IFastRenderMetaTileEntity(gregtech.api.metatileentity.IFastRenderMetaTileEntity) CCRenderState(codechicken.lib.render.CCRenderState) Matrix4(codechicken.lib.vec.Matrix4)

Example 4 with Matrix4

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

the class LargeTurbineRenderer method renderSided.

@SideOnly(Side.CLIENT)
public void renderSided(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline, EnumFacing side, boolean hasBase, boolean hasRotor, boolean isActive, int rotorRGB) {
    Matrix4 cornerOffset = null;
    switch(side.getAxis()) {
        case X:
            cornerOffset = translation.copy().translate(0.01 * side.getXOffset(), -1.0, -1.0);
            cornerOffset.scale(1.0, 3.0, 3.0);
            break;
        case Z:
            cornerOffset = translation.copy().translate(-1.0, -1.0, 0.01 * side.getZOffset());
            cornerOffset.scale(3.0, 3.0, 1.0);
            break;
        case Y:
            cornerOffset = translation.copy().translate(-1.0, 0.01 * side.getYOffset(), -1.0);
            cornerOffset.scale(3.0, 1.0, 3.0);
            break;
    }
    if (hasBase) {
        Textures.renderFace(renderState, cornerOffset, pipeline, side, Cuboid6.full, baseRingSprite);
        renderState.brightness = 0xF000F0;
        renderState.colour = 0xFFFFFFFF;
        Textures.renderFace(renderState, cornerOffset, new IVertexOperation[0], side, Cuboid6.full, baseBackgroundSprite);
    }
    if (hasRotor) {
        TextureAtlasSprite sprite = isActive ? activeBladeSprite : idleBladeSprite;
        IVertexOperation[] color = ArrayUtils.add(pipeline, new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(rotorRGB)));
        Textures.renderFace(renderState, cornerOffset, color, side, Cuboid6.full, sprite);
    }
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Matrix4(codechicken.lib.vec.Matrix4) ColourMultiplier(codechicken.lib.render.pipeline.ColourMultiplier) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with Matrix4

use of codechicken.lib.vec.Matrix4 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

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