Search in sources :

Example 16 with BoundingBox

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

the class TileKillerJoe method getHooverBounds.

@Nonnull
private AxisAlignedBB getHooverBounds() {
    if (hooverBounds == NULL_AABB) {
        double killerJoeHooverXpHeight = KillerJoeConfig.killerJoeHooverXpHeight.get();
        double killerJoeHooverXpLength = KillerJoeConfig.killerJoeHooverXpLength.get();
        double killerJoeHooverXpWidth = KillerJoeConfig.killerJoeHooverXpWidth.get();
        BoundingBox bb = new BoundingBox(getLocation());
        Vector3d min = bb.getMin();
        Vector3d max = bb.getMax();
        max.y += killerJoeHooverXpHeight;
        min.y -= killerJoeHooverXpHeight;
        EnumFacing facingDir = facing;
        if (ForgeDirectionOffsets.isPositiveOffset(facingDir)) {
            max.add(ForgeDirectionOffsets.offsetScaled(facingDir, killerJoeHooverXpLength));
            min.add(ForgeDirectionOffsets.forDir(facingDir));
        } else {
            min.add(ForgeDirectionOffsets.offsetScaled(facingDir, killerJoeHooverXpLength));
            max.add(ForgeDirectionOffsets.forDir(facingDir));
        }
        if (facingDir.getFrontOffsetX() == 0) {
            min.x -= killerJoeHooverXpWidth * 2;
            max.x += killerJoeHooverXpWidth * 2;
        } else {
            min.z -= killerJoeHooverXpWidth * 2;
            max.z += killerJoeHooverXpWidth * 2;
        }
        hooverBounds = new AxisAlignedBB(min.x, min.y, min.z, max.x, max.y, max.z);
    }
    return hooverBounds;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Vector3d(com.enderio.core.common.vecmath.Vector3d) BoundingBox(com.enderio.core.client.render.BoundingBox) EnumFacing(net.minecraft.util.EnumFacing) Nonnull(javax.annotation.Nonnull)

Example 17 with BoundingBox

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

the class ConduitGeometryUtil method createConduitBounds.

@Nonnull
private BoundingBox createConduitBounds(Class<? extends IConduit> type, EnumFacing dir, boolean isStub, @Nonnull Offset offset) {
    BoundingBox bb = CORE_BOUNDS;
    Vector3d min = bb.getMin();
    Vector3d max = bb.getMax();
    if (dir != null) {
        switch(dir) {
            case WEST:
                min.x = isStub ? Math.max(0, bb.minX - STUB_WIDTH) : 0;
                max.x = bb.minX;
                break;
            case EAST:
                min.x = bb.maxX;
                max.x = isStub ? Math.min(1, bb.maxX + STUB_WIDTH) : 1;
                break;
            case DOWN:
                min.y = isStub ? Math.max(0, bb.minY - STUB_HEIGHT) : 0;
                max.y = bb.minY;
                break;
            case UP:
                max.y = isStub ? Math.min(1, bb.maxY + STUB_HEIGHT) : 1;
                min.y = bb.maxY;
                break;
            case NORTH:
                min.z = isStub ? Math.max(0.0F, bb.minZ - STUB_WIDTH) : 0;
                max.z = bb.minZ;
                break;
            case SOUTH:
                max.z = isStub ? Math.min(1F, bb.maxZ + STUB_WIDTH) : 1;
                min.z = bb.maxZ;
                break;
            default:
                break;
        }
    }
    Vector3d trans = getTranslation(dir, offset);
    min.add(trans);
    max.add(trans);
    bb = new BoundingBox(VecmathUtil.clamp(min, 0, 1), VecmathUtil.clamp(max, 0, 1));
    return bb;
}
Also used : Vector3d(com.enderio.core.common.vecmath.Vector3d) BoundingBox(com.enderio.core.client.render.BoundingBox) Nonnull(javax.annotation.Nonnull)

Example 18 with BoundingBox

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

the class ConduitGeometryUtil method getBoundingBox.

@Nonnull
public BoundingBox getBoundingBox(Class<? extends IConduit> type, EnumFacing dir, boolean isStub, Offset offset) {
    GeometryKey key = new GeometryKey(dir, isStub, offset, type);
    BoundingBox result = boundsCache.get(key);
    if (result == null) {
        result = createConduitBounds(type, key);
        boundsCache.put(key, result);
    }
    return result;
}
Also used : BoundingBox(com.enderio.core.client.render.BoundingBox) Nonnull(javax.annotation.Nonnull)

Example 19 with BoundingBox

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

the class LiquidConduitRenderer method computeFluidOutlineToCache.

public static List<CachableRenderStatement> computeFluidOutlineToCache(CollidableComponent component, Fluid fluid, double scaleFactor, float outlineWidth) {
    Map<Fluid, List<CachableRenderStatement>> cache0 = cache.get(component);
    if (cache0 == null) {
        cache0 = new HashMap<Fluid, List<CachableRenderStatement>>();
        cache.put(component, cache0);
    }
    List<CachableRenderStatement> data = cache0.get(fluid);
    if (data != null) {
        return data;
    }
    data = new ArrayList<CachableRenderStatement>();
    cache0.put(fluid, data);
    TextureAtlasSprite texture = RenderUtil.getStillTexture(fluid);
    if (texture == null) {
        return data;
    }
    int color = fluid.getColor();
    Vector4f colorv = new Vector4f((color >> 16 & 0xFF) / 255d, (color >> 8 & 0xFF) / 255d, (color & 0xFF) / 255d, 1);
    BoundingBox bbb;
    double width = outlineWidth;
    scaleFactor = scaleFactor - 0.05;
    double xScale = Math.abs(component.dir.getFrontOffsetX()) == 1 ? width : scaleFactor;
    double yScale = Math.abs(component.dir.getFrontOffsetY()) == 1 ? width : scaleFactor;
    double zScale = Math.abs(component.dir.getFrontOffsetZ()) == 1 ? width : scaleFactor;
    double offSize = (0.5 - width) / 2 - width / 2;
    double xOff = component.dir.getFrontOffsetX() * offSize;
    double yOff = component.dir.getFrontOffsetY() * offSize;
    double zOff = component.dir.getFrontOffsetZ() * offSize;
    bbb = component.bound.scale(xScale, yScale, zScale);
    bbb = bbb.translate(new Vector3d(xOff, yOff, zOff));
    for (EnumFacing face : EnumFacing.VALUES) {
        if (face != component.dir && face != component.dir.getOpposite()) {
            List<Vertex> corners = bbb.getCornersWithUvForFace(face, texture.getMinU(), texture.getMaxU(), texture.getMinV(), texture.getMaxV());
            for (Vertex corner : corners) {
                data.add(new CachableRenderStatement.AddVertexWithUV(corner.x(), corner.y(), corner.z(), corner.uv.x, corner.uv.y, colorv));
            }
        }
    }
    return data;
}
Also used : Vertex(com.enderio.core.common.vecmath.Vertex) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Fluid(net.minecraftforge.fluids.Fluid) EnumFacing(net.minecraft.util.EnumFacing) Vector4f(com.enderio.core.common.vecmath.Vector4f) Vector3d(com.enderio.core.common.vecmath.Vector3d) BoundingBox(com.enderio.core.client.render.BoundingBox) ArrayList(java.util.ArrayList) List(java.util.List)

Example 20 with BoundingBox

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

the class PowerConduit 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(IPowerConduit.class, bb, key.dir, COLOR_CONTROLLER_ID);
    List<CollidableComponent> result = new ArrayList<CollidableComponent>();
    result.addAll(baseCollidables);
    result.add(cc);
    return result;
}
Also used : CollidableComponent(crazypants.enderio.base.conduit.geom.CollidableComponent) BoundingBox(com.enderio.core.client.render.BoundingBox) ArrayList(java.util.ArrayList) Nonnull(javax.annotation.Nonnull)

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