Search in sources :

Example 1 with CCModel

use of codechicken.lib.render.CCModel 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 2 with CCModel

use of codechicken.lib.render.CCModel in project GregTech by GregTechCE.

the class FluidPipeRenderer method registerIcons.

public void registerIcons(TextureMap map) {
    for (FluidPipeType fluidPipeType : FluidPipeType.values()) {
        ResourceLocation inLocation = new ResourceLocation(GTValues.MODID, String.format("blocks/pipe/pipe_%s_in", fluidPipeType.name));
        ResourceLocation sideLocation = new ResourceLocation(GTValues.MODID, String.format("blocks/pipe/pipe_%s_side", fluidPipeType.name));
        TextureAtlasSprite inTexture = map.registerSprite(inLocation);
        TextureAtlasSprite sideTexture = map.registerSprite(sideLocation);
        this.pipeTextures.put(fluidPipeType, new PipeTextureInfo(inTexture, sideTexture));
    }
    for (FluidPipeType fluidPipeType : FluidPipeType.values()) {
        float thickness = fluidPipeType.getThickness();
        double height = (1.0f - thickness) / 2.0f;
        int angles = 5 + fluidPipeType.ordinal();
        CCModel model = ShapeModelGenerator.generateModel(angles, height, thickness / 3.0f, height);
        CCModel fullBlockModel = ShapeModelGenerator.generateModel(angles, 1.0f, thickness / 3.0f, height);
        CCModel[] rotatedVariants = ShapeModelGenerator.generateRotatedVariants(model);
        CCModel[] fullBlockVariants = ShapeModelGenerator.generateFullBlockVariants(fullBlockModel);
        this.pipeModels.put(fluidPipeType, new PipeModelInfo(rotatedVariants, fullBlockVariants));
    }
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) FluidPipeType(gregtech.common.pipelike.fluidpipe.FluidPipeType) CCModel(codechicken.lib.render.CCModel)

Example 3 with CCModel

use of codechicken.lib.render.CCModel in project GregTech by GregTechCE.

the class InvPipeRenderer method registerIcons.

public void registerIcons(TextureMap map) {
    this.jointTextureSprite = map.registerSprite(new ResourceLocation(GTValues.MODID, "blocks/inv_pipe/joint"));
    this.pipeTextureSprite = map.registerSprite(new ResourceLocation(GTValues.MODID, "blocks/inv_pipe/pipe"));
    InventoryPipeType pipeType = InventoryPipeType.NORMAL;
    float thickness = pipeType.getThickness();
    double height = (1.0f - thickness) / 2.0f;
    CCModel connectionModel = ShapeModelGenerator.generateModel(3, height, thickness / 3.0f, height);
    CCModel fullBlockModel = ShapeModelGenerator.generateModel(3, 1.0f, thickness / 3.0f, height);
    this.fullBlockVariants = ShapeModelGenerator.generateFullBlockVariants(fullBlockModel);
    this.connectionModels = ShapeModelGenerator.generateRotatedVariants(connectionModel);
}
Also used : InventoryPipeType(gregtech.common.pipelike.inventory.InventoryPipeType) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) CCModel(codechicken.lib.render.CCModel)

Example 4 with CCModel

use of codechicken.lib.render.CCModel in project GregTech by GregTechCE.

the class StonePileModelGenerator method generatePebblePileModel.

public static CCModel generatePebblePileModel(Random random) {
    List<IndexedCuboid6> cuboid6s = generateCuboidList(random);
    CCModel ccModel = CCModel.quadModel(cuboid6s.size() * 24);
    for (int i = 0; i < cuboid6s.size(); i++) {
        IndexedCuboid6 cuboid6 = cuboid6s.get(i);
        ccModel.generateBlock(i * 24, cuboid6);
        int b = (int) cuboid6.data;
        int[] colours = ccModel.getOrAllocate(ColourAttribute.attributeKey);
        int color = (b & 0xFF) << 24 | (b & 0xFF) << 16 | (b & 0xFF) << 8 | (0xFF);
        Arrays.fill(colours, i * 24, i * 24 + 24, color);
    }
    return ccModel.computeNormals();
}
Also used : IndexedCuboid6(codechicken.lib.raytracer.IndexedCuboid6) CCModel(codechicken.lib.render.CCModel)

Example 5 with CCModel

use of codechicken.lib.render.CCModel 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)

Aggregations

CCModel (codechicken.lib.render.CCModel)9 ColourMultiplier (codechicken.lib.render.pipeline.ColourMultiplier)2 IVertexOperation (codechicken.lib.render.pipeline.IVertexOperation)2 IconTransformation (codechicken.lib.vec.uv.IconTransformation)2 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 EnumFacing (net.minecraft.util.EnumFacing)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 IndexedCuboid6 (codechicken.lib.raytracer.IndexedCuboid6)1 CCRenderState (codechicken.lib.render.CCRenderState)1 Cuboid6 (codechicken.lib.vec.Cuboid6)1 Matrix4 (codechicken.lib.vec.Matrix4)1 TransformationList (codechicken.lib.vec.TransformationList)1 Material (gregtech.api.unification.material.type.Material)1 BlockSurfaceRock (gregtech.common.blocks.surfacerock.BlockSurfaceRock)1 TileEntitySurfaceRock (gregtech.common.blocks.surfacerock.TileEntitySurfaceRock)1 FluidPipeType (gregtech.common.pipelike.fluidpipe.FluidPipeType)1 InventoryPipeType (gregtech.common.pipelike.inventory.InventoryPipeType)1 Random (java.util.Random)1