Search in sources :

Example 11 with ColourMultiplier

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

the class WorldSceneRenderer method render.

/**
 * Renders scene on given coordinates with given width and height, and RGB background color
 * Note that this will ignore any transformations applied currently to projection/view matrix,
 * so specified coordinates are scaled MC gui coordinates.
 * It will return matrices of projection and view in previous state after rendering
 */
public void render(int x, int y, int width, int height, int backgroundColor) {
    Vec2f mousePosition = setupCamera(x, y, width, height, backgroundColor);
    if (renderCallback != null) {
        renderCallback.preRenderScene(this);
    }
    Minecraft minecraft = Minecraft.getMinecraft();
    minecraft.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    BlockRendererDispatcher dispatcher = minecraft.getBlockRendererDispatcher();
    BlockRenderLayer oldRenderLayer = MinecraftForgeClient.getRenderLayer();
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferBuilder = tessellator.getBuffer();
    bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    for (BlockPos pos : renderedBlocks) {
        if (renderFilter != null && !renderFilter.test(pos))
            // do not render if position is skipped
            continue;
        IBlockState blockState = world.getBlockState(pos);
        for (BlockRenderLayer renderLayer : BlockRenderLayer.values()) {
            if (!blockState.getBlock().canRenderInLayer(blockState, renderLayer))
                continue;
            ForgeHooksClient.setRenderLayer(renderLayer);
            dispatcher.renderBlock(blockState, pos, world, bufferBuilder);
        }
    }
    tessellator.draw();
    ForgeHooksClient.setRenderLayer(oldRenderLayer);
    if (mousePosition != null) {
        this.lastHitBlock = handleMouseHit(mousePosition);
    } else {
        this.lastHitBlock = null;
    }
    if (lastHitBlock != null) {
        GlStateManager.disableTexture2D();
        CCRenderState renderState = CCRenderState.instance();
        renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR, tessellator.getBuffer());
        ColourMultiplier multiplier = new ColourMultiplier(0);
        renderState.setPipeline(new Translation(lastHitBlock), multiplier);
        BlockFace blockFace = new BlockFace();
        renderState.setModel(blockFace);
        for (EnumFacing renderSide : EnumFacing.VALUES) {
            float diffuse = LightUtil.diffuseLight(renderSide);
            int color = (int) (255 * diffuse);
            multiplier.colour = RenderUtil.packColor(color, color, color, 100);
            blockFace.loadCuboidFace(Cuboid6.full, renderSide.getIndex());
            renderState.render();
        }
        renderState.draw();
        GlStateManager.enableTexture2D();
    }
    resetCamera();
}
Also used : Translation(codechicken.lib.vec.Translation) Vec2f(net.minecraft.util.math.Vec2f) IBlockState(net.minecraft.block.state.IBlockState) BlockFace(codechicken.lib.render.BlockRenderer.BlockFace) EnumFacing(net.minecraft.util.EnumFacing) Minecraft(net.minecraft.client.Minecraft) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) BlockPos(net.minecraft.util.math.BlockPos) CCRenderState(codechicken.lib.render.CCRenderState) ColourMultiplier(codechicken.lib.render.pipeline.ColourMultiplier)

Example 12 with ColourMultiplier

use of codechicken.lib.render.pipeline.ColourMultiplier 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 13 with ColourMultiplier

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

the class SteamBoiler method renderMetaTileEntity.

@Override
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
    IVertexOperation[] colouredPipeline = ArrayUtils.add(pipeline, new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(getPaintingColorForRendering())));
    getBaseRenderer().render(renderState, translation, colouredPipeline);
    renderer.render(renderState, translation, pipeline, getFrontFacing(), isBurning());
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) ColourMultiplier(codechicken.lib.render.pipeline.ColourMultiplier)

Example 14 with ColourMultiplier

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

the class MetaTileEntityMagicEnergyAbsorber method renderMetaTileEntity.

@Override
@SideOnly(Side.CLIENT)
public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) {
    IVertexOperation[] colouredPipeline = ArrayUtils.add(pipeline, new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(getPaintingColorForRendering())));
    getRenderer().render(renderState, translation, colouredPipeline);
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) ColourMultiplier(codechicken.lib.render.pipeline.ColourMultiplier) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 15 with ColourMultiplier

use of codechicken.lib.render.pipeline.ColourMultiplier 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

ColourMultiplier (codechicken.lib.render.pipeline.ColourMultiplier)21 IVertexOperation (codechicken.lib.render.pipeline.IVertexOperation)16 EnumFacing (net.minecraft.util.EnumFacing)7 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)7 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)5 Cuboid6 (codechicken.lib.vec.Cuboid6)3 IconTransformation (codechicken.lib.vec.uv.IconTransformation)3 CCModel (codechicken.lib.render.CCModel)2 CCRenderState (codechicken.lib.render.CCRenderState)2 Matrix4 (codechicken.lib.vec.Matrix4)2 Vector3 (codechicken.lib.vec.Vector3)2 IndexedCuboid6 (codechicken.lib.raytracer.IndexedCuboid6)1 BlockFace (codechicken.lib.render.BlockRenderer.BlockFace)1 TransformationList (codechicken.lib.vec.TransformationList)1 Translation (codechicken.lib.vec.Translation)1 Material (gregtech.api.unification.material.type.Material)1 BlockSurfaceRock (gregtech.common.blocks.surfacerock.BlockSurfaceRock)1 IBlockState (net.minecraft.block.state.IBlockState)1 Minecraft (net.minecraft.client.Minecraft)1 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)1