Search in sources :

Example 6 with MutableQuad

use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.

the class LensPluggableModel method bakeCutout.

private List<BakedQuad> bakeCutout(boolean isFilter, EnumFacing face, VertexFormat format) {
    IModel model = isFilter ? modelCutoutFilter() : modelCutoutLens();
    TextureAtlasSprite sprite = isFilter ? spriteFilterCutout : spriteLensCutout;
    List<BakedQuad> quads = Lists.newArrayList();
    List<BakedQuad> bakedQuads = renderLens(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 7 with MutableQuad

use of buildcraft.lib.client.model.MutableQuad in project BuildCraft by BuildCraft.

the class LensPluggableModel method bakeTransclucent.

private List<BakedQuad> bakeTransclucent(EnumDyeColor colour, boolean isFilter, EnumFacing face, VertexFormat format) {
    TextureAtlasSprite sprite = spriteTranslucent;
    int shade = -1;
    if (colour == null) {
        if (isFilter)
            return Collections.emptyList();
        sprite = spriteWaterFlow;
    } else {
        shade = ColorUtils.getLightHex(colour);
    }
    List<BakedQuad> quads = Lists.newArrayList();
    List<BakedQuad> bakedQuads = renderLens(modelTranslucent(), sprite, format);
    Matrix4f matrix = MatrixUtil.rotateTowardsFace(face);
    for (BakedQuad quad : bakedQuads) {
        MutableQuad mutable = MutableQuad.create(quad);
        mutable.setTint(shade);
        mutable.transform(matrix);
        ModelUtil.appendBakeQuads(quads, format, mutable);
    }
    return quads;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Matrix4f(javax.vecmath.Matrix4f) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 8 with MutableQuad

use of buildcraft.lib.client.model.MutableQuad 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 9 with MutableQuad

use of buildcraft.lib.client.model.MutableQuad 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 10 with MutableQuad

use of buildcraft.lib.client.model.MutableQuad 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)

Aggregations

MutableQuad (buildcraft.lib.client.model.MutableQuad)31 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)19 Matrix4f (javax.vecmath.Matrix4f)11 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)10 Vector3f (javax.vecmath.Vector3f)8 IModel (net.minecraftforge.client.model.IModel)8 EnumFacing (net.minecraft.util.EnumFacing)7 IFlexibleBakedModel (net.minecraftforge.client.model.IFlexibleBakedModel)6 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 Vec3d (net.minecraft.util.math.Vec3d)3 UvFaceData (buildcraft.lib.client.model.ModelUtil.UvFaceData)2 Tuple3f (javax.vecmath.Tuple3f)2 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)2 Profiler (net.minecraft.profiler.Profiler)2 Axis (net.minecraft.util.EnumFacing.Axis)2 ItemLayerModel (net.minecraftforge.client.model.ItemLayerModel)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 EnumPipePart (buildcraft.api.core.EnumPipePart)1 EntityResizableCuboid (buildcraft.core.lib.EntityResizableCuboid)1