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();
}
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);
}
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();
}
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));
}
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;
}
Aggregations