Search in sources :

Example 31 with BakedQuad

use of net.minecraft.client.renderer.block.model.BakedQuad 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 32 with BakedQuad

use of net.minecraft.client.renderer.block.model.BakedQuad in project BuildCraft by BuildCraft.

the class GatePluggableModel method bakeCutout.

public List<BakedQuad> bakeCutout(KeyPlugGate key, VertexFormat format) {
    List<BakedQuad> quads = Lists.newArrayList();
    List<MutableQuad> bakedQuads = renderGate(key, format);
    Matrix4f matrix = MatrixUtil.rotateTowardsFace(key.side);
    for (MutableQuad quad : bakedQuads) {
        quad.transform(matrix);
        quad.setCalculatedDiffuse();
        quads.add(quad.toUnpacked());
    }
    return quads;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Matrix4f(javax.vecmath.Matrix4f) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 33 with BakedQuad

use of net.minecraft.client.renderer.block.model.BakedQuad in project BuildCraft by BuildCraft.

the class ModelPowerAdapter method create.

public static PerspAwareModelBase create() {
    ImmutableList.Builder<BakedQuad> quads = ImmutableList.builder();
    VertexFormat format = DefaultVertexFormats.ITEM;
    quads.addAll(INSTANCE.bakeCutout(EnumFacing.EAST, format));
    return new PerspAwareModelBase(format, quads.build(), spritePowerAdapter, getBlockTransforms());
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ImmutableList(com.google.common.collect.ImmutableList) PerspAwareModelBase(buildcraft.core.lib.client.model.PerspAwareModelBase) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat)

Example 34 with BakedQuad

use of net.minecraft.client.renderer.block.model.BakedQuad in project BuildCraft by BuildCraft.

the class PlugPluggableModel method bakeCutout.

private List<BakedQuad> bakeCutout(EnumFacing face, VertexFormat format) {
    IModel model = modelPlug();
    TextureAtlasSprite sprite = spritePlug;
    List<BakedQuad> quads = Lists.newArrayList();
    List<BakedQuad> bakedQuads = renderPlug(model, sprite, format);
    Matrix4f matrix = MatrixUtil.rotateTowardsFace(face);
    for (BakedQuad quad : bakedQuads) {
        MutableQuad mutable = MutableQuad.create(quad);
        mutable.transform(matrix);
        ModelUtil.appendBakeQuads(quads, format, mutable);
    }
    return quads;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IModel(net.minecraftforge.client.model.IModel) Matrix4f(javax.vecmath.Matrix4f) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 35 with BakedQuad

use of net.minecraft.client.renderer.block.model.BakedQuad in project BuildCraft by BuildCraft.

the class PlugPluggableModel method create.

public static PerspAwareModelBase create() {
    ImmutableList.Builder<BakedQuad> quads = ImmutableList.builder();
    VertexFormat format = DefaultVertexFormats.ITEM;
    quads.addAll(INSTANCE.bakeCutout(EnumFacing.SOUTH, format));
    return new PerspAwareModelBase(format, quads.build(), spritePlug, getPluggableTransforms());
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ImmutableList(com.google.common.collect.ImmutableList) PerspAwareModelBase(buildcraft.core.lib.client.model.PerspAwareModelBase) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat)

Aggregations

BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)137 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)43 EnumFacing (net.minecraft.util.EnumFacing)40 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)36 ArrayList (java.util.ArrayList)29 IBlockState (net.minecraft.block.state.IBlockState)24 ResourceLocation (net.minecraft.util.ResourceLocation)23 ImmutableList (com.google.common.collect.ImmutableList)22 MutableQuad (buildcraft.lib.client.model.MutableQuad)19 UnpackedBakedQuad (net.minecraftforge.client.model.pipeline.UnpackedBakedQuad)17 TRSRTransformation (net.minecraftforge.common.model.TRSRTransformation)16 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)15 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)15 Tessellator (net.minecraft.client.renderer.Tessellator)14 TransformType (net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType)14 List (java.util.List)13 IModel (net.minecraftforge.client.model.IModel)13 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)13 Matrix4f (javax.vecmath.Matrix4f)12 ItemLayerModel (net.minecraftforge.client.model.ItemLayerModel)12