Search in sources :

Example 21 with BoundingBox

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

the class PowerConduitRenderer 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) {
    if (IPowerConduit.COLOR_CONTROLLER_ID.equals(component.data)) {
        IPowerConduit pc = (IPowerConduit) conduit;
        ConnectionMode conMode = pc.getConnectionMode(component.dir);
        if (conduit.containsExternalConnection(component.dir) && pc.getExtractionRedstoneMode(component.dir) != RedstoneControlMode.IGNORE && conMode != ConnectionMode.DISABLED) {
            int cInt = ((IPowerConduit) conduit).getExtractionSignalColor(component.dir).getColor();
            Vector4f col = ColorUtil.toFloat4(cInt);
            BoundingBox bound = component.bound;
            if (conMode != ConnectionMode.IN_OUT && conMode != ConnectionMode.NOT_SET) {
                Vector3d trans = ForgeDirectionOffsets.offsetScaled(component.dir, -0.12);
                bound = bound.translate(trans);
            }
            addQuadsForSection(bound, tex, component.dir, quads, col);
        }
        return;
    }
    super.addConduitQuads(bundle, conduit, tex, component, selfIllum, layer, quads);
    if (component.dir == null) {
        return;
    }
    IPowerConduit pc = (IPowerConduit) conduit;
    ConnectionMode mode = pc.getConnectionMode(component.dir);
    if (mode != ConnectionMode.INPUT && mode != ConnectionMode.OUTPUT) {
        return;
    }
    if (mode == ConnectionMode.INPUT) {
        tex = pc.getTextureForInputMode();
    } else {
        tex = pc.getTextureForOutputMode();
    }
    Offset offset = bundle.getOffset(IPowerConduit.class, component.dir);
    ConnectionModeGeometry.addModeConnectorQuads(component.dir, offset, tex, null, quads);
}
Also used : Vector4f(com.enderio.core.common.vecmath.Vector4f) Vector3d(com.enderio.core.common.vecmath.Vector3d) BoundingBox(com.enderio.core.client.render.BoundingBox) ConnectionMode(crazypants.enderio.base.conduit.ConnectionMode) Offset(crazypants.enderio.base.conduit.geom.Offset)

Example 22 with BoundingBox

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

the class ConduitBundleRenderer method addConduitQuads.

private void addConduitQuads(@Nonnull IBlockStateWrapper state, @Nonnull IConduitBundle bundle, float brightness, @Nonnull BlockRenderLayer layer, @Nonnull List<BakedQuad> quads) {
    // Conduits
    Set<EnumFacing> externals = new HashSet<EnumFacing>();
    List<BoundingBox> wireBounds = new ArrayList<BoundingBox>();
    if (bundle.hasFacade() && state.getYetaDisplayMode().isHideFacades()) {
        wireBounds.add(BoundingBox.UNIT_CUBE);
    }
    for (IClientConduit c : bundle.getClientConduits()) {
        // TODO Temporary Workaround
        IClientConduit.WithDefaultRendering con = (IClientConduit.WithDefaultRendering) c;
        if (state.getYetaDisplayMode().renderConduit(con)) {
            IConduitRenderer renderer = getRendererForConduit(con);
            renderer.addBakedQuads(this, bundle, con, brightness, layer, quads);
            Set<EnumFacing> extCons = con.getExternalConnections();
            for (EnumFacing dir : extCons) {
                if (con.getConnectionMode(dir) != ConnectionMode.DISABLED && con.getConnectionMode(dir) != ConnectionMode.NOT_SET) {
                    externals.add(dir);
                }
            }
        } else if (con != null) {
            Collection<CollidableComponent> components = con.getCollidableComponents();
            for (CollidableComponent component : components) {
                addWireBounds(wireBounds, component);
            }
        }
    }
    // Internal connectors between conduits
    List<CollidableComponent> connectors = bundle.getConnectors();
    for (CollidableComponent component : connectors) {
        if (component != null) {
            if (component.conduitType != null) {
                // TODO Make an actual check before assuming a default render
                IClientConduit.WithDefaultRendering conduit = (IClientConduit.WithDefaultRendering) bundle.getConduit(component.conduitType);
                if (conduit != null) {
                    if (state.getYetaDisplayMode().renderConduit(component.conduitType)) {
                        TextureAtlasSprite tex = conduit.getTextureForState(component);
                        if (tex == null) {
                            tex = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
                        }
                        BakedQuadBuilder.addBakedQuads(quads, component.bound, tex);
                    } else {
                        addWireBounds(wireBounds, component);
                    }
                }
            } else if (state.getYetaDisplayMode().getDisplayMode().isAll()) {
                TextureAtlasSprite tex = ConduitBundleRenderManager.instance.getConnectorIcon(component.data);
                BakedQuadBuilder.addBakedQuads(quads, component.bound, tex);
            }
        }
    }
    // render these after the 'normal' conduits so help with proper blending
    for (BoundingBox wireBound : wireBounds) {
        BakedQuadBuilder.addBakedQuads(quads, wireBound, ConduitBundleRenderManager.instance.getWireFrameIcon());
    }
    // External connection terminations
    for (EnumFacing dir : externals) {
        addQuadsForExternalConnection(dir, quads);
    }
    if (quads.isEmpty() && !bundle.hasFacade()) {
        BakedQuadBuilder.addBakedQuads(quads, BoundingBox.UNIT_CUBE.scale(.10), ConduitBundleRenderManager.instance.getWireFrameIcon());
        BakedQuadBuilder.addBakedQuads(quads, BoundingBox.UNIT_CUBE.scale(.15), ConduitBundleRenderManager.instance.getWireFrameIcon());
        BakedQuadBuilder.addBakedQuads(quads, BoundingBox.UNIT_CUBE.scale(.20), ConduitBundleRenderManager.instance.getWireFrameIcon());
        BakedQuadBuilder.addBakedQuads(quads, BoundingBox.UNIT_CUBE.scale(.25), ConduitBundleRenderManager.instance.getWireFrameIcon());
    }
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) IClientConduit(crazypants.enderio.base.conduit.IClientConduit) CollidableComponent(crazypants.enderio.base.conduit.geom.CollidableComponent) BoundingBox(com.enderio.core.client.render.BoundingBox) Collection(java.util.Collection) IConduitRenderer(crazypants.enderio.base.conduit.IConduitRenderer) HashSet(java.util.HashSet)

Example 23 with BoundingBox

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

the class ConduitBundleRenderer method addQuadsForExternalConnection.

private void addQuadsForExternalConnection(@Nonnull EnumFacing dir, @Nonnull List<BakedQuad> quads) {
    TextureAtlasSprite tex = ConduitBundleRenderManager.instance.getConnectorIcon(ConduitConnectorType.EXTERNAL);
    BoundingBox[] bbs = ConduitGeometryUtil.instance.getExternalConnectorBoundingBoxes(dir);
    for (BoundingBox bb : bbs) {
        BakedQuadBuilder.addBakedQuads(quads, bb, tex);
    }
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) BoundingBox(com.enderio.core.client.render.BoundingBox)

Example 24 with BoundingBox

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

the class DefaultConduitRenderer method addConduitQuads.

protected void addConduitQuads(@Nonnull IConduitBundle bundle, @Nonnull IConduit conduit, @Nonnull TextureAtlasSprite tex, @Nonnull CollidableComponent component, float selfIllum, BlockRenderLayer layer, @Nonnull List<BakedQuad> quads) {
    if (isNSEWUD(component.dir)) {
        if (layer == null) {
            // TODO? null is the blockbreaking animation
            return;
        }
        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);
        addQuadsForSection(bb, tex, component.dir, quads);
        if (conduit.getConnectionMode(component.dir) == ConnectionMode.DISABLED) {
            tex = ConduitBundleRenderManager.instance.getConnectorIcon(component.data);
            BakedQuadBuilder.addBakedQuadForFace(quads, bb, tex, component.dir);
        }
    } else {
        BakedQuadBuilder.addBakedQuads(quads, component.bound, tex);
    }
}
Also used : BoundingBox(com.enderio.core.client.render.BoundingBox)

Example 25 with BoundingBox

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

the class DefaultConduitRenderer method addTransmissionQuads.

protected void addTransmissionQuads(TextureAtlasSprite tex, Vector4f color, IConduit conduit, CollidableComponent component, float selfIllum, List<BakedQuad> quads) {
    float scaleFactor = 0.6f;
    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);
    addQuadsForSection(bb, tex, component.dir, quads, color);
}
Also used : BoundingBox(com.enderio.core.client.render.BoundingBox)

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