Search in sources :

Example 6 with BoundingBox

use of com.enderio.core.client.render.BoundingBox in project EnderIO by SleepyTrousers.

the class TileDialingDevice method getBounds.

@Override
@Nonnull
public BoundingBox getBounds() {
    EnumFacing forward = getDialerFacing().getInputSide();
    EnumFacing up;
    EnumFacing side;
    if (forward.getFrontOffsetY() == 0) {
        up = EnumFacing.UP;
        side = forward.rotateY();
    } else {
        // look along y
        up = EnumFacing.NORTH;
        side = EnumFacing.EAST;
    }
    int range = 4;
    BlockPos checkMin = pos.offset(forward, 0 + 1).offset(side, 0 - range).offset(up, 0 - range);
    BlockPos checkMax = pos.offset(forward, (range * 2 - 1) + 1).offset(side, (range * 2 - 1) - range).offset(up, (range * 2 - 1) - range);
    return new BoundingBox(checkMin, checkMax);
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) BoundingBox(com.enderio.core.client.render.BoundingBox) BlockPos(net.minecraft.util.math.BlockPos) Nonnull(javax.annotation.Nonnull)

Example 7 with BoundingBox

use of com.enderio.core.client.render.BoundingBox in project EnderIO by SleepyTrousers.

the class ConduitGeometryUtil method preInit.

@SubscribeEvent
public static void preInit(EnderIOLifecycleEvent.Config.Post event) {
    float size = (float) (0.075f + (0.175f * Config.conduitScale));
    WIDTH = size;
    HEIGHT = size;
    HWIDTH = WIDTH / 2;
    HHEIGHT = HEIGHT / 2;
    final Vector3d core_min = new Vector3d(0.5f - HWIDTH, 0.5 - HHEIGHT, 0.5 - HWIDTH);
    CORE_MIN = core_min;
    final Vector3d core_max = new Vector3d(CORE_MIN.x + WIDTH, CORE_MIN.y + HEIGHT, CORE_MIN.z + WIDTH);
    CORE_MAX = core_max;
    CORE_BOUNDS = new BoundingBox(core_min, core_max);
    float connectorWidth = (float) (0.25f + (Config.conduitScale * 0.5f));
    for (EnumFacing dir : EnumFacing.VALUES) {
        EXTERNAL_CONNECTOR_BOUNDS.put(dir, createExternalConnector(dir, CONNECTOR_DEPTH, connectorWidth));
    }
}
Also used : Vector3d(com.enderio.core.common.vecmath.Vector3d) BoundingBox(com.enderio.core.client.render.BoundingBox) EnumFacing(net.minecraft.util.EnumFacing) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 8 with BoundingBox

use of com.enderio.core.client.render.BoundingBox in project EnderIO by SleepyTrousers.

the class ConduitGeometryUtil method createConnectorComponent.

@Nonnull
private static BoundingBox createConnectorComponent(@Nonnull EnumFacing dir, float cornerMin, float cornerMax, float depthMin, float depthMax) {
    float minX = (1 - Math.abs(dir.getFrontOffsetX())) * cornerMin + dir.getFrontOffsetX() * depthMin;
    float minY = (1 - Math.abs(dir.getFrontOffsetY())) * cornerMin + dir.getFrontOffsetY() * depthMin;
    float minZ = (1 - Math.abs(dir.getFrontOffsetZ())) * cornerMin + dir.getFrontOffsetZ() * depthMin;
    float maxX = (1 - Math.abs(dir.getFrontOffsetX())) * cornerMax + (dir.getFrontOffsetX() * depthMax);
    float maxY = (1 - Math.abs(dir.getFrontOffsetY())) * cornerMax + (dir.getFrontOffsetY() * depthMax);
    float maxZ = (1 - Math.abs(dir.getFrontOffsetZ())) * cornerMax + (dir.getFrontOffsetZ() * depthMax);
    minX = fix(minX);
    minY = fix(minY);
    minZ = fix(minZ);
    maxX = fix(maxX);
    maxY = fix(maxY);
    maxZ = fix(maxZ);
    BoundingBox bb = new BoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
    bb = bb.fixMinMax();
    return bb;
}
Also used : BoundingBox(com.enderio.core.client.render.BoundingBox) Nonnull(javax.annotation.Nonnull)

Example 9 with BoundingBox

use of com.enderio.core.client.render.BoundingBox in project EnderIO by SleepyTrousers.

the class ConduitGeometryUtil method createBoundsForConnectionController.

@Nonnull
public BoundingBox createBoundsForConnectionController(@Nonnull EnumFacing dir, @Nonnull Offset offset) {
    Vector3d nonUniformScale = ForgeDirectionOffsets.forDirCopy(dir);
    nonUniformScale.scale(0.5);
    nonUniformScale.x = 0.8 * (1 - Math.abs(nonUniformScale.x));
    nonUniformScale.y = 0.8 * (1 - Math.abs(nonUniformScale.y));
    nonUniformScale.z = 0.8 * (1 - Math.abs(nonUniformScale.z));
    BoundingBox bb = CORE_BOUNDS;
    bb = bb.scale(nonUniformScale.x, nonUniformScale.y, nonUniformScale.z);
    double offsetFromEnd = Math.min(bb.sizeX(), bb.sizeY());
    offsetFromEnd = Math.min(offsetFromEnd, bb.sizeZ());
    offsetFromEnd = Math.max(offsetFromEnd, 0.075);
    double transMag = 0.5 - (offsetFromEnd * 1.2);
    Vector3d trans = ForgeDirectionOffsets.forDirCopy(dir);
    trans.scale(transMag);
    bb = bb.translate(trans);
    bb = bb.translate(getTranslation(dir, offset));
    return bb;
}
Also used : Vector3d(com.enderio.core.common.vecmath.Vector3d) BoundingBox(com.enderio.core.client.render.BoundingBox) Nonnull(javax.annotation.Nonnull)

Example 10 with BoundingBox

use of com.enderio.core.client.render.BoundingBox in project EnderIO by SleepyTrousers.

the class ReservoirRenderer method renderTankFluid.

private void renderTankFluid(SmartTank tank, Set<EnumFacing> mergers, World world, BlockPos pos) {
    final FluidStack fluid = tank.getFluid();
    if (fluid != null) {
        TextureAtlasSprite icon = RenderUtil.getStillTexture(fluid);
        int color = fluid.getFluid().getColor(fluid);
        float fullness = tank.getFilledRatio();
        boolean[][][] merge = getMergers9(world, pos);
        BufferBuilder tes = Tessellator.getInstance().getBuffer();
        float minU = icon.getMinU(), maxU = icon.getMaxU(), minV = icon.getMinV(), maxV = icon.getMaxV();
        for (int i = 0; i <= 1; i++) {
            if (i == 0) {
                GlStateManager.cullFace(CullFace.FRONT);
            } else {
                GlStateManager.cullFace(CullFace.BACK);
            }
            for (NNIterator<EnumFacing> facings = NNList.FACING.fastIterator(); facings.hasNext(); ) {
                EnumFacing dir = facings.next();
                float fullness2 = 0;
                if (mergers.contains(dir)) {
                    BlockPos pos2 = pos.offset(dir);
                    TileEntity tileEntity = world.getTileEntity(pos2);
                    if (tileEntity instanceof TileReservoir) {
                        TileReservoir res2 = (TileReservoir) tileEntity;
                        fullness2 = res2.tank.getFilledRatio();
                    }
                }
                BoundingBox bb = mkFace(merge, dir, fullness, fullness2);
                if (bb != null) {
                    float minVx = minV, maxVx = maxV;
                    if (dir.getAxis() != EnumFacing.Axis.Y) {
                        minVx = icon.getInterpolatedV((1 - fullness) * 16);
                        maxVx = icon.getInterpolatedV((1 - fullness2) * 16);
                    }
                    renderFace(tes, bb, dir, minU, maxU, minVx, maxVx, color);
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidStack(net.minecraftforge.fluids.FluidStack) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) EnumFacing(net.minecraft.util.EnumFacing) BoundingBox(com.enderio.core.client.render.BoundingBox) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

BoundingBox (com.enderio.core.client.render.BoundingBox)30 Nonnull (javax.annotation.Nonnull)11 EnumFacing (net.minecraft.util.EnumFacing)11 Vector3d (com.enderio.core.common.vecmath.Vector3d)9 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)9 ArrayList (java.util.ArrayList)7 CollidableComponent (crazypants.enderio.base.conduit.geom.CollidableComponent)5 Vector4f (com.enderio.core.common.vecmath.Vector4f)4 Vertex (com.enderio.core.common.vecmath.Vertex)4 HalfBakedList (crazypants.enderio.base.render.util.HalfBakedQuad.HalfBakedList)3 FluidStack (net.minecraftforge.fluids.FluidStack)3 VertexRotationFacing (com.enderio.core.client.render.VertexRotationFacing)2 Offset (crazypants.enderio.base.conduit.geom.Offset)2 HashSet (java.util.HashSet)2 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)2 TileEntity (net.minecraft.tileentity.TileEntity)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 BlockPos (net.minecraft.util.math.BlockPos)2 VertexTransform (com.enderio.core.api.client.render.VertexTransform)1 VertexRotation (com.enderio.core.client.render.VertexRotation)1