use of com.enderio.core.client.render.BoundingBox in project EnderIO by SleepyTrousers.
the class InfinityParticle method renderParticle.
@Override
public void renderParticle(@Nonnull BufferBuilder worldRendererIn, @Nonnull Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
if (particleAge < 0) {
return;
}
GlStateManager.pushMatrix();
GlStateManager.enableLighting();
GlStateManager.disableLighting();
GlStateManager.disableCull();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
RenderUtil.bindBlockTexture();
GlStateManager.depthMask(false);
float scale = Math.min((particleAge + partialTicks) / INIT_TIME, 1);
float fade = particleAge < FADE_TIME ? 1f : ((particleMaxAge - particleAge) / (float) (particleMaxAge - FADE_TIME));
GlStateManager.translate(-interpPosX, -interpPosY, -interpPosZ);
GlStateManager.color(getRedColorF(), getGreenColorF(), getBlueColorF(), particleAlpha * fade);
RenderUtil.renderBoundingBox((new BoundingBox(getBoundingBox())).scale(scale), IconUtil.instance.whiteTexture);
GlStateManager.depthMask(true);
GlStateManager.disableBlend();
GlStateManager.enableCull();
GlStateManager.enableLighting();
GlStateManager.popMatrix();
}
use of com.enderio.core.client.render.BoundingBox in project EnderIO by SleepyTrousers.
the class TankRenderHelper method mkTank.
/**
* Generate a cube of liquid for a SmartTank.
*
* @param tank
* The tank that contains the liquid.
* @param xzBorder
* How many pixels of space to leave around the y and z sides. (0-7.99)
* @param miny
* Height to start the tank. (0-15.99)
* @param maxy
* Height to end the tank (0.01-16)
* @param renderBottom
* Render the bottom face?
* @return A HalfBakedList with the tank content or null if the tank is empty
*/
public static HalfBakedList mkTank(SmartTank tank, double xzBorder, double miny, double maxy, boolean renderBottom) {
if (tank != null) {
float ratio = tank.getFilledRatio();
final FluidStack fluid = tank.getFluid();
if (fluid != null && ratio > 0) {
float height = 1 - ratio;
ResourceLocation still = fluid.getFluid().getStill(fluid);
int color = fluid.getFluid().getColor(fluid);
Vector4f vecC = new Vector4f((color >> 16 & 0xFF) / 255d, (color >> 8 & 0xFF) / 255d, (color & 0xFF) / 255d, 1);
TextureAtlasSprite sprite = still == null ? null : Minecraft.getMinecraft().getTextureMapBlocks().getTextureExtry(still.toString());
if (sprite == null) {
sprite = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
vecC = null;
}
boolean gas = fluid.getFluid().isGaseous(fluid);
BoundingBox bb = gas ? new BoundingBox(xzBorder * px, (maxy - (maxy - miny) * ratio) * px, xzBorder * px, (16 - xzBorder) * px, maxy * px, (16 - xzBorder) * px) : new BoundingBox(xzBorder * px, miny * px, xzBorder * px, (16 - xzBorder) * px, ((maxy - miny) * ratio + miny) * px, (16 - xzBorder) * px);
HalfBakedList buffer = new HalfBakedList();
buffer.add(bb, EnumFacing.NORTH, 0f, 1f, height, 1f, sprite, vecC, gas);
buffer.add(bb, EnumFacing.EAST, 0f, 1f, height, 1f, sprite, vecC, gas);
buffer.add(bb, EnumFacing.SOUTH, 0f, 1f, height, 1f, sprite, vecC, gas);
buffer.add(bb, EnumFacing.WEST, 0f, 1f, height, 1f, sprite, vecC, gas);
if (!gas || renderBottom) {
buffer.add(bb, EnumFacing.UP, 0f, 1f, 0f, 1f, sprite, vecC);
}
if (gas || renderBottom) {
buffer.add(bb, EnumFacing.DOWN, 0f, 1f, 0f, 1f, sprite, vecC);
}
return buffer;
}
}
return null;
}
use of com.enderio.core.client.render.BoundingBox in project EnderIO by SleepyTrousers.
the class BlockConduitBundle method getSelectedBoundingBox.
@Override
@SideOnly(Side.CLIENT)
@Nonnull
public AxisAlignedBB getSelectedBoundingBox(@Nonnull IBlockState bs, @Nonnull World world, @Nonnull BlockPos pos) {
TileConduitBundle te = getTileEntity(world, pos);
EntityPlayer player = Minecraft.getMinecraft().player;
if (te == null) {
// FIXME is this valid?
return new AxisAlignedBB(0, 0, 0, 0, 0, 0);
}
IConduitBundle con = te;
BoundingBox minBB = null;
if (!YetaUtil.isSolidFacadeRendered(con, player)) {
List<RaytraceResult> results = doRayTraceAll(world, pos, player);
Iterator<RaytraceResult> iter = results.iterator();
while (iter.hasNext()) {
CollidableComponent component = iter.next().component;
if (component != null && component.conduitType == null && component.data != ConduitConnectorType.EXTERNAL) {
iter.remove();
}
}
// This is an ugly special case, TODO fix this
for (RaytraceResult hit : results) {
IRedstoneConduit cond = con.getConduit(IRedstoneConduit.class);
CollidableComponent component = hit.component;
EnumFacing dir = component == null ? null : component.dir;
if (cond != null && component != null && dir != null && cond.getExternalConnections().contains(dir) && component.data == InsulatedRedstoneConduit.COLOR_CONTROLLER_ID) {
minBB = component.bound;
}
}
if (minBB == null) {
RaytraceResult hit = RaytraceResult.getClosestHit(Util.getEyePosition(player), results);
CollidableComponent component = hit == null ? null : hit.component;
if (component != null) {
EnumFacing dir = component.dir;
minBB = component.bound;
if (dir != null && component.conduitType == null) {
dir = dir.getOpposite();
float trans = 0.0125f;
minBB = minBB.translate(dir.getFrontOffsetX() * trans, dir.getFrontOffsetY() * trans, dir.getFrontOffsetZ() * trans);
float scale = 0.7f;
minBB = minBB.scale(1 + Math.abs(dir.getFrontOffsetX()) * scale, 1 + Math.abs(dir.getFrontOffsetY()) * scale, 1 + Math.abs(dir.getFrontOffsetZ()) * scale);
} else {
minBB = minBB.scale(1.09, 1.09, 1.09);
}
}
}
} else {
minBB = new BoundingBox(0, 0, 0, 1, 1, 1);
}
if (minBB == null) {
minBB = new BoundingBox(0, 0, 0, 1, 1, 1);
}
return new AxisAlignedBB(pos.getX() + minBB.minX, pos.getY() + minBB.minY, pos.getZ() + minBB.minZ, pos.getX() + minBB.maxX, pos.getY() + minBB.maxY, pos.getZ() + minBB.maxZ);
}
use of com.enderio.core.client.render.BoundingBox in project EnderIO by SleepyTrousers.
the class AdvancedLiquidConduitRenderer method addConduitQuads.
@Override
protected void addConduitQuads(@Nonnull IConduitBundle bundle, @Nonnull IConduit conduit, @Nonnull TextureAtlasSprite tex, @Nonnull CollidableComponent component, float selfIllum, BlockRenderLayer layer, @Nonnull List<BakedQuad> quads) {
super.addConduitQuads(bundle, conduit, tex, component, selfIllum, layer, quads);
if (!isNSEWUD(component.dir)) {
return;
}
AdvancedLiquidConduit lc = (AdvancedLiquidConduit) conduit;
for (EnumFacing dir : conduit.getExternalConnections()) {
TextureAtlasSprite ioTex = null;
if (conduit.getConnectionMode(dir) == ConnectionMode.INPUT) {
ioTex = lc.getTextureForInputMode();
} else if (conduit.getConnectionMode(dir) == ConnectionMode.OUTPUT) {
ioTex = lc.getTextureForOutputMode();
}
if (ioTex != null) {
Offset offset = bundle.getOffset(ILiquidConduit.class, dir);
ConnectionModeGeometry.addModeConnectorQuads(dir, offset, ioTex, new Vector4f(1, 1, 1, 1), quads);
}
}
FluidStack fluid = lc.getFluidType();
@Nonnull TextureAtlasSprite texture = fluid != null ? RenderUtil.getStillTexture(fluid) : lc.getNotSetEdgeTexture();
float scaleFactor = 0.75f;
float xLen = Math.abs(component.dir.getFrontOffsetX()) == 1 ? 1 : scaleFactor;
float yLen = Math.abs(component.dir.getFrontOffsetY()) == 1 ? 1 : scaleFactor;
float zLen = Math.abs(component.dir.getFrontOffsetZ()) == 1 ? 1 : scaleFactor;
BoundingBox cube = component.bound;
BoundingBox bb = cube.scale(xLen, yLen, zLen);
List<Vertex> vertices = new ArrayList<Vertex>();
for (EnumFacing d : EnumFacing.VALUES) {
if (d != component.dir && d != component.dir.getOpposite()) {
EnumFacing vDir = RenderUtil.getVDirForFace(d);
if (component.dir == EnumFacing.UP || component.dir == EnumFacing.DOWN) {
vDir = RenderUtil.getUDirForFace(d);
} else if ((component.dir == EnumFacing.NORTH || component.dir == EnumFacing.SOUTH) && d.getFrontOffsetY() != 0) {
vDir = RenderUtil.getUDirForFace(d);
}
float minU = texture.getMinU();
float maxU = texture.getMaxU();
float minV = texture.getMinV();
float maxV = texture.getMaxV();
double sideScale = Math.max(bb.sizeX(), bb.sizeY()) * 2 / 16f;
sideScale = Math.max(sideScale, bb.sizeZ() * 2 / 16f);
double width = Math.min(bb.sizeX(), bb.sizeY()) * 15f / 16f;
List<Vertex> corners = bb.getCornersWithUvForFace(d, minU, maxU, minV, maxV);
moveEdgeCorners(corners, vDir, width);
moveEdgeCorners(corners, component.dir.getOpposite(), sideScale);
for (Vertex c : corners) {
vertices.add(c);
}
corners = bb.getCornersWithUvForFace(d, minU, maxU, minV, maxV);
moveEdgeCorners(corners, vDir.getOpposite(), width);
moveEdgeCorners(corners, component.dir.getOpposite(), sideScale);
for (Vertex c : corners) {
vertices.add(c);
}
}
}
if (conduit.getConnectionMode(component.dir) == ConnectionMode.DISABLED) {
tex = ConduitBundleRenderManager.instance.getConnectorIcon(component.data);
List<Vertex> corners = component.bound.getCornersWithUvForFace(component.dir, tex.getMinU(), tex.getMaxU(), tex.getMinV(), tex.getMaxV());
for (Vertex c : corners) {
vertices.add(c);
}
// back face
for (int i = corners.size() - 1; i >= 0; i--) {
Vertex c = corners.get(i);
vertices.add(c);
}
}
BakedQuadBuilder.addBakedQuads(quads, vertices, texture, null);
}
use of com.enderio.core.client.render.BoundingBox in project EnderIO by SleepyTrousers.
the class InsulatedRedstoneConduit method createCollidables.
@Override
@Nonnull
public Collection<CollidableComponent> createCollidables(@Nonnull CacheKey key) {
Collection<CollidableComponent> baseCollidables = super.createCollidables(key);
if (key.dir == null) {
return baseCollidables;
}
BoundingBox bb = ConduitGeometryUtil.instance.createBoundsForConnectionController(key.dir, key.offset);
CollidableComponent cc = new CollidableComponent(IRedstoneConduit.class, bb, key.dir, COLOR_CONTROLLER_ID);
List<CollidableComponent> result = new ArrayList<CollidableComponent>();
result.addAll(baseCollidables);
result.add(cc);
return result;
}
Aggregations