Search in sources :

Example 1 with IFlexibleBakedModel

use of net.minecraftforge.client.model.IFlexibleBakedModel in project BuildCraft by BuildCraft.

the class LensPluggableModel method renderLens.

public static List<BakedQuad> renderLens(IModel model, TextureAtlasSprite sprite, VertexFormat format) {
    List<BakedQuad> quads = Lists.newArrayList();
    IFlexibleBakedModel baked = model.bake(ModelRotation.X0_Y0, format, singleTextureFunction(sprite));
    for (BakedQuad quad : baked.getGeneralQuads()) {
        MutableQuad mutable = MutableQuad.create(quad);
        mutable.colouri(0xFF_FF_FF_FF);
        ModelUtil.appendBakeQuads(quads, format, mutable);
    }
    return quads;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IFlexibleBakedModel(net.minecraftforge.client.model.IFlexibleBakedModel) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 2 with IFlexibleBakedModel

use of net.minecraftforge.client.model.IFlexibleBakedModel in project BuildCraft by BuildCraft.

the class FacadePluggableModel method bake.

public List<BakedQuad> bake(EnumWorldBlockLayer layer, EnumFacing face, boolean hollow, IBlockState state, VertexFormat format) {
    List<BakedQuad> quads = Lists.newArrayList();
    Matrix4f matrix = MatrixUtil.rotateTowardsFace(face);
    if (layer == EnumWorldBlockLayer.TRANSLUCENT) {
        if (!state.getBlock().canRenderInLayer(EnumWorldBlockLayer.TRANSLUCENT)) {
            return quads;
        }
    } else {
        if (!hollow && !ItemFacade.isTransparentFacade(state)) {
            IModel connector = modelConnector();
            TextureAtlasSprite structure = PipeIconProvider.TYPE.PipeStructureCobblestone.getIcon();
            IFlexibleBakedModel baked = connector.bake(ModelRotation.X0_Y0, format, singleTextureFunction(structure));
            for (BakedQuad quad : baked.getGeneralQuads()) {
                MutableQuad mutable = MutableQuad.create(quad);
                mutable.transform(matrix);
                mutable.setCalculatedDiffuse();
                ModelUtil.appendBakeQuads(quads, mutable);
            }
        }
        if (!state.getBlock().canRenderInLayer(EnumWorldBlockLayer.SOLID) && !state.getBlock().canRenderInLayer(EnumWorldBlockLayer.CUTOUT) && !state.getBlock().canRenderInLayer(EnumWorldBlockLayer.CUTOUT_MIPPED)) {
            return quads;
        }
    }
    // FIXME: Use the model bisector to cut a model down + squish one side down so it looks right
    final TextureAtlasSprite sprite = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(state);
    IModel model;
    if (hollow) {
        model = modelHollow();
    } else {
        model = modelFilled();
    }
    if (model != null) {
        IFlexibleBakedModel baked = model.bake(ModelRotation.X0_Y0, format, singleTextureFunction(sprite));
        for (BakedQuad quad : baked.getGeneralQuads()) {
            MutableQuad mutable = MutableQuad.create(quad);
            mutable.transform(matrix);
            mutable.setCalculatedDiffuse();
            ModelUtil.appendBakeQuads(quads, mutable);
        }
    }
    return quads;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Matrix4f(javax.vecmath.Matrix4f) IModel(net.minecraftforge.client.model.IModel) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IFlexibleBakedModel(net.minecraftforge.client.model.IFlexibleBakedModel) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 3 with IFlexibleBakedModel

use of net.minecraftforge.client.model.IFlexibleBakedModel in project BuildCraft by BuildCraft.

the class GatePluggableModel method renderGate.

public List<MutableQuad> renderGate(KeyPlugGate gate, VertexFormat format) {
    TextureAtlasSprite logicSprite = gate.lit ? gate.logic.getIconLit() : gate.logic.getIconDark();
    TextureAtlasSprite materialSprite = gate.material.getIconBlock();
    IModel main = modelMain();
    IModel material = modelMaterial();
    List<MutableQuad> quads = Lists.newArrayList();
    IFlexibleBakedModel baked = main.bake(ModelRotation.X0_Y0, format, singleTextureFunction(logicSprite));
    for (BakedQuad quad : baked.getGeneralQuads()) {
        MutableQuad mutable = MutableQuad.create(quad, format);
        quads.add(mutable);
    }
    if (materialSprite != null) {
        // Its null for redstone (As we don't render any material for redstone gates)
        baked = material.bake(ModelRotation.X0_Y0, format, singleTextureFunction(materialSprite));
        for (BakedQuad quad : baked.getGeneralQuads()) {
            quads.add(MutableQuad.create(quad, format));
        }
    }
    for (GateExpansionModelKey<?> expansion : gate.expansions) {
        generate(quads, expansion);
    }
    return quads;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IModel(net.minecraftforge.client.model.IModel) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IFlexibleBakedModel(net.minecraftforge.client.model.IFlexibleBakedModel) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 4 with IFlexibleBakedModel

use of net.minecraftforge.client.model.IFlexibleBakedModel in project BuildCraft by BuildCraft.

the class ModelPowerAdapter method renderAdapter.

public static List<BakedQuad> renderAdapter(IModel model, TextureAtlasSprite sprite, VertexFormat format) {
    List<BakedQuad> quads = Lists.newArrayList();
    IFlexibleBakedModel baked = model.bake(ModelRotation.X0_Y0, format, singleTextureFunction(sprite));
    for (BakedQuad quad : baked.getGeneralQuads()) {
        MutableQuad mutable = MutableQuad.create(quad);
        mutable.colouri(0xFF_FF_FF_FF);
        ModelUtil.appendBakeQuads(quads, format, mutable);
    }
    return quads;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IFlexibleBakedModel(net.minecraftforge.client.model.IFlexibleBakedModel) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 5 with IFlexibleBakedModel

use of net.minecraftforge.client.model.IFlexibleBakedModel in project BuildCraft by BuildCraft.

the class PlugPluggableModel method renderPlug.

public static List<BakedQuad> renderPlug(IModel model, TextureAtlasSprite sprite, VertexFormat format) {
    List<BakedQuad> quads = Lists.newArrayList();
    IFlexibleBakedModel baked = model.bake(ModelRotation.X0_Y0, format, singleTextureFunction(sprite));
    for (BakedQuad quad : baked.getGeneralQuads()) {
        MutableQuad mutable = MutableQuad.create(quad);
        mutable.colouri(0xFF_FF_FF_FF);
        ModelUtil.appendBakeQuads(quads, format, mutable);
    }
    return quads;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IFlexibleBakedModel(net.minecraftforge.client.model.IFlexibleBakedModel) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Aggregations

MutableQuad (buildcraft.lib.client.model.MutableQuad)6 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)6 IFlexibleBakedModel (net.minecraftforge.client.model.IFlexibleBakedModel)6 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)3 IModel (net.minecraftforge.client.model.IModel)3 Matrix4f (javax.vecmath.Matrix4f)1 ResourceLocation (net.minecraft.util.ResourceLocation)1