Search in sources :

Example 1 with MutableQuad

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

the class RenderEngine_BC8 method renderTileEntityFast.

// TODO: Cache the model!
@Override
public void renderTileEntityFast(@Nonnull T engine, double x, double y, double z, float partialTicks, int destroyStage, float partial, @Nonnull BufferBuilder vb) {
    Profiler profiler = Minecraft.getMinecraft().mcProfiler;
    profiler.startSection("bc");
    profiler.startSection("engine");
    profiler.startSection("compute");
    vb.setTranslation(x, y, z);
    MutableQuad[] quads = getEngineModel(engine, partialTicks);
    profiler.endStartSection("render");
    MutableQuad copy = new MutableQuad(0, null);
    int lightc = engine.getWorld().getCombinedLight(engine.getPos(), 0);
    int light_block = (lightc >> 4) & 15;
    int light_sky = (lightc >> 20) & 15;
    for (MutableQuad q : quads) {
        copy.copyFrom(q);
        copy.maxLighti(light_block, light_sky);
        copy.multShade();
        copy.render(vb);
    }
    vb.setTranslation(0, 0, 0);
    profiler.endSection();
    profiler.endSection();
    profiler.endSection();
}
Also used : Profiler(net.minecraft.profiler.Profiler) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 2 with MutableQuad

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

the class ChuteRenderModel method create.

public static ChuteRenderModel create(IBakedModel parent) {
    if (parent == null) {
        /* The "chute.json" block model file contains the top and bottom boxes, so it will look strange if it
             * doesn't exist. Just print out a warning to make sure they know that this is why. Print out a full stack
             * trace because this really shouldn't happen, and it makes it much more obvious in the logfile where the
             * error message is. */
        throw new IllegalStateException("For some reason, the block model for the chute block was missing!" + "\nThis is not meant to happen, you have a bad JAR file!");
    }
    List<BakedQuad> lst = Lists.newArrayList(parent.getGeneralQuads());
    Vector3f eastSouthUp__ = new Vector3f(15 / 16F, 9 / 16F, 15 / 16F);
    Vector3f eastSouthDown = new Vector3f(11 / 16F, 3 / 16F, 11 / 16F);
    Vector3f eastNorthUp__ = new Vector3f(15 / 16F, 9 / 16F, 1 / 16F);
    Vector3f eastNorthDown = new Vector3f(11 / 16F, 3 / 16F, 5 / 16F);
    Vector3f westSouthUp__ = new Vector3f(1 / 16F, 9 / 16F, 15 / 16F);
    Vector3f westSouthDown = new Vector3f(5 / 16F, 3 / 16F, 11 / 16F);
    Vector3f westNorthUp__ = new Vector3f(1 / 16F, 9 / 16F, 1 / 16F);
    Vector3f westNorthDown = new Vector3f(5 / 16F, 3 / 16F, 5 / 16F);
    float[] uvs = new float[4];
    uvs[U_MIN] = sideTexture.getMinU();
    uvs[U_MAX] = sideTexture.getMaxU();
    uvs[V_MIN] = sideTexture.getMinV();
    uvs[V_MAX] = sideTexture.getInterpolatedV(8);
    MutableQuad[] quads = { // 
    ModelUtil.createFace(EnumFacing.EAST, eastNorthDown, eastNorthUp__, eastSouthUp__, eastSouthDown, uvs), // 
    ModelUtil.createFace(EnumFacing.WEST, westSouthDown, westSouthUp__, westNorthUp__, westNorthDown, uvs), // 
    ModelUtil.createFace(EnumFacing.NORTH, westNorthDown, westNorthUp__, eastNorthUp__, eastNorthDown, uvs), // 
    ModelUtil.createFace(EnumFacing.SOUTH, eastSouthDown, eastSouthUp__, westSouthUp__, westSouthDown, uvs) };
    for (MutableQuad q : quads) {
        q.setCalculatedDiffuse();
    }
    ModelUtil.appendBakeQuads(lst, MutableQuad.ITEM_BLOCK_PADDING, quads);
    return new ChuteRenderModel(ImmutableList.copyOf(lst), parent);
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Vector3f(javax.vecmath.Vector3f) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 3 with MutableQuad

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

the class RenderDistiller method render.

@Override
public void render(TileDistiller_BC8 tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    super.render(tile, x, y, z, partialTicks, destroyStage, alpha);
    IBlockState state = tile.getWorld().getBlockState(tile.getPos());
    if (state.getBlock() != BCFactoryBlocks.distiller) {
        return;
    }
    Profiler profiler = Minecraft.getMinecraft().mcProfiler;
    profiler.startSection("bc");
    profiler.startSection("distiller");
    int combinedLight = tile.getWorld().getCombinedLight(tile.getPos(), 0);
    EnumFacing face = state.getValue(BlockBCBase_Neptune.PROP_FACING);
    TankRenderSizes sizes = TANK_SIZES.get(face);
    // gl state setup
    RenderHelper.disableStandardItemLighting();
    Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
    // buffer setup
    BufferBuilder bb = Tessellator.getInstance().getBuffer();
    bb.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    bb.setTranslation(x, y, z);
    profiler.startSection("model");
    profiler.startSection("compute");
    if (tile.clientModelData.hasNoNodes()) {
        tile.clientModelData.setNodes(BCFactoryModels.DISTILLER.createTickableNodes());
    }
    tile.setClientModelVariables(partialTicks);
    tile.clientModelData.refresh();
    MutableQuad[] quads = BCFactoryModels.DISTILLER.getCutoutQuads();
    profiler.endStartSection("render");
    MutableQuad copy = new MutableQuad(0, null);
    int lightc = combinedLight;
    int light_block = (lightc >> 4) & 15;
    int light_sky = (lightc >> 20) & 15;
    for (MutableQuad q : quads) {
        copy.copyFrom(q);
        copy.maxLighti(light_block, light_sky);
        copy.multShade();
        copy.render(bb);
    }
    profiler.endSection();
    profiler.endStartSection("fluid");
    renderTank(sizes.tankIn, tile.smoothedTankIn, combinedLight, partialTicks, bb);
    renderTank(sizes.tankOutGas, tile.smoothedTankGasOut, combinedLight, partialTicks, bb);
    renderTank(sizes.tankOutLiquid, tile.smoothedTankLiquidOut, combinedLight, partialTicks, bb);
    // buffer finish
    bb.setTranslation(0, 0, 0);
    profiler.endStartSection("draw");
    Tessellator.getInstance().draw();
    // gl state finish
    RenderHelper.enableStandardItemLighting();
    profiler.endSection();
    profiler.endSection();
    profiler.endSection();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Profiler(net.minecraft.profiler.Profiler) EnumFacing(net.minecraft.util.EnumFacing) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 4 with MutableQuad

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

the class BCFactoryModels method onModelBake.

@SubscribeEvent
public static void onModelBake(ModelBakeEvent event) {
    event.getModelRegistry().putObject(new ModelResourceLocation("buildcraftfactory:heat_exchange#normal"), new ModelHeatExchange());
    event.getModelRegistry().putObject(new ModelResourceLocation("buildcraftfactory:heat_exchange#inventory"), new ModelItemSimple(Arrays.stream(BCFactoryModels.HEAT_EXCHANGE_STATIC.getCutoutQuads()).map(MutableQuad::multShade).map(MutableQuad::toBakedItem).collect(Collectors.toList()), ModelItemSimple.TRANSFORM_BLOCK, true));
}
Also used : ModelHeatExchange(buildcraft.factory.client.model.ModelHeatExchange) ModelItemSimple(buildcraft.lib.client.model.ModelItemSimple) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) MutableQuad(buildcraft.lib.client.model.MutableQuad) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with MutableQuad

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

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