Search in sources :

Example 81 with BakedQuad

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

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

the class GatePluggableModel method generate.

private static <K extends GateExpansionModelKey<K>> void generate(List<MutableQuad> quads, GateExpansionModelKey<K> expansion) {
    IExpansionBaker<K> baker = expansion.baker;
    VertexFormat format = baker.getVertexFormat();
    for (BakedQuad q : baker.bake((K) expansion)) {
        quads.add(MutableQuad.create(q, format));
    }
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat)

Example 83 with BakedQuad

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

the class ModelPowerAdapter method bakeCutout.

private List<BakedQuad> bakeCutout(EnumFacing face, VertexFormat format) {
    IModel model = modelPowerAdapter();
    TextureAtlasSprite sprite = spritePowerAdapter;
    List<BakedQuad> quads = Lists.newArrayList();
    List<BakedQuad> bakedQuads = renderAdapter(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 84 with BakedQuad

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

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

the class PipeItemModel method create.

public static PipeItemModel create(ItemPipe item, int colorIndex) {
    TextureAtlasSprite sprite = item.getSprite();
    if (sprite == null) {
        sprite = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
    }
    Vec3d center = Utils.VEC_HALF;
    Vec3d radius = new Vec3d(0.25, 0.5, 0.25);
    EntityResizableCuboid cuboid = new EntityResizableCuboid(null);
    cuboid.texture = sprite;
    cuboid.setTextureOffset(new Vec3d(4, 0, 4));
    cuboid.setPosition(center.subtract(radius));
    cuboid.setSize(Utils.multiply(radius, 2));
    List<MutableQuad> unprocessed = Lists.newArrayList();
    List<BakedQuad> quads = Lists.newArrayList();
    RenderResizableCuboid.bakeCube(unprocessed, cuboid, true, false);
    for (MutableQuad quad : unprocessed) {
        quad.normalf(0, 1, 0);
        ModelUtil.appendBakeQuads(quads, DefaultVertexFormats.ITEM, quad);
    }
    unprocessed.clear();
    // Set up the colour
    if (colorIndex != 0) {
        // Very sligthly smaller
        radius = new Vec3d(0.249, 0.499, 0.249);
        cuboid = new EntityResizableCuboid(null);
        cuboid.setTextureOffset(new Vec3d(4, 0, 4));
        cuboid.texture = PipeIconProvider.TYPE.PipeStainedOverlay.getIcon();
        cuboid.setPosition(center.subtract(radius));
        cuboid.setSize(Utils.multiply(radius, 2));
        // Render it into a different list
        RenderResizableCuboid.bakeCube(unprocessed, cuboid, true, false);
        EnumDyeColor dye = EnumDyeColor.byDyeDamage(colorIndex - 1);
        int quadColor = ColorUtils.getLightHex(dye);
        // Add all of the quads we just rendered to the main list
        for (MutableQuad quad : unprocessed) {
            quad.normalf(0, 1, 0);
            quad.setTint(quadColor);
            ModelUtil.appendBakeQuads(quads, DefaultVertexFormats.ITEM, quad);
        }
        unprocessed.clear();
    }
    return new PipeItemModel(ImmutableList.copyOf(quads), sprite);
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EntityResizableCuboid(buildcraft.core.lib.EntityResizableCuboid) EnumDyeColor(net.minecraft.item.EnumDyeColor) Vec3d(net.minecraft.util.math.Vec3d) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Aggregations

BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)130 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)43 EnumFacing (net.minecraft.util.EnumFacing)39 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)36 ArrayList (java.util.ArrayList)27 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 TransformType (net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType)14 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)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 Tessellator (net.minecraft.client.renderer.Tessellator)12 ItemLayerModel (net.minecraftforge.client.model.ItemLayerModel)12