Search in sources :

Example 21 with IVertexOperation

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

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

the class TileEntityCrusherBladeRenderer method draw.

@Override
protected void draw(TileEntityCrusherBlade tileEntity, CCRenderState renderState, Matrix4 translation, float partialTicks) {
    translation.translate(0.5, 0.5, 0.5);
    IBlockState blockState = tileEntity.getBlockState();
    switch(blockState.getValue(BlockCrusherBlade.AXIS)) {
        case Y:
            break;
        case X:
            translation.rotate(Math.toRadians(90.0), Rotation.axes[3]);
            break;
        case Z:
            translation.rotate(Math.toRadians(90.0), Rotation.axes[5]);
            break;
    }
    if (blockState.getValue(BlockCrusherBlade.ACTIVE)) {
        long currentWorldTime = tileEntity.hasWorld() ? tileEntity.getWorld().getTotalWorldTime() : 0;
        translation.rotate(Math.toRadians(currentWorldTime * 12.0 % 180), Rotation.axes[1]);
    }
    translation.translate(-0.5, -0.5, -0.5);
    TextureAtlasSprite ironBlockTexture = TextureUtils.getBlockTexture("iron_block");
    IVertexOperation[] operations = {};
    for (Cuboid6 cuboid6 : BlockCrusherBlade.basicModel) {
        for (EnumFacing renderSide : EnumFacing.VALUES) {
            Textures.renderFace(renderState, translation, operations, renderSide, cuboid6, ironBlockTexture);
        }
    }
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) IBlockState(net.minecraft.block.state.IBlockState) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) Cuboid6(codechicken.lib.vec.Cuboid6)

Example 23 with IVertexOperation

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

the class Model3D method renderToQuads.

@Override
@SideOnly(Side.CLIENT)
@SneakyThrows({ IllegalAccessException.class })
public List<BakedQuad> renderToQuads(VertexFormat format, I3DOperation... i3dOperations) {
    List<IVertexOperation> list = new ArrayList<>();
    Set<String> hash = new HashSet<>();
    hash.add(String.valueOf(format.hashCode()));
    boolean cachable = true;
    for (I3DOperation op : i3dOperations) {
        IVertexOperation iVertexOperation = (IVertexOperation) op.getOriginal();
        list.add(iVertexOperation);
        if (iVertexOperation instanceof IconTransformation) {
            hash.add(((IconTransformation) iVertexOperation).icon.toString());
        } else if (iVertexOperation instanceof Rotation) {
            hash.add(iVertexOperation.toString());
        } else if (iVertexOperation instanceof Scale) {
            hash.add(iVertexOperation.toString());
        } else if (iVertexOperation instanceof Translation) {
            hash.add(iVertexOperation.toString());
        } else {
            cachable = false;
        }
    }
    if (cachable) {
        List<BakedQuad> content = renderCache.getIfPresent(hash.hashCode());
        if (content != null) {
            return content;
        }
    }
    BakingVertexBuffer buffer = BakingVertexBuffer.create();
    CCRenderState ccrs = CCRenderState.instance();
    ccrs.reset();
    ccrs.startDrawing(0x7, format, buffer);
    model.render(ccrs, list.toArray(new IVertexOperation[0]));
    buffer.finishDrawing();
    emptyHashMap.clear();
    if (spiteMap != null) {
        spiteMap.set(buffer, emptyHashMap);
    }
    List<BakedQuad> quads = buffer.bake();
    if (cachable) {
        renderCache.put(hash.hashCode(), quads);
    }
    return quads;
}
Also used : IVertexOperation(codechicken.lib.render.pipeline.IVertexOperation) BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Translation(codechicken.lib.vec.Translation) ArrayList(java.util.ArrayList) Scale(codechicken.lib.vec.Scale) I3DOperation(logisticspipes.proxy.object3d.interfaces.I3DOperation) Rotation(codechicken.lib.vec.Rotation) BakingVertexBuffer(codechicken.lib.render.buffer.BakingVertexBuffer) CCRenderState(codechicken.lib.render.CCRenderState) HashSet(java.util.HashSet) IconTransformation(codechicken.lib.vec.uv.IconTransformation) SneakyThrows(lombok.SneakyThrows) 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