Search in sources :

Example 1 with Vertex

use of com.enderio.core.common.vecmath.Vertex 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);
}
Also used : Vertex(com.enderio.core.common.vecmath.Vertex) Nonnull(javax.annotation.Nonnull) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) FluidStack(net.minecraftforge.fluids.FluidStack) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) Offset(crazypants.enderio.base.conduit.geom.Offset) Vector4f(com.enderio.core.common.vecmath.Vector4f) BoundingBox(com.enderio.core.client.render.BoundingBox)

Example 2 with Vertex

use of com.enderio.core.common.vecmath.Vertex in project EnderIO by SleepyTrousers.

the class ConnectionModeGeometry method createVerticesForDir.

private static List<Vertex> createVerticesForDir(BoundingBox refBB, VertexTransform xform) {
    List<Vertex> result = new ArrayList<Vertex>(24);
    for (EnumFacing face : EnumFacing.VALUES) {
        result.addAll(refBB.getCornersWithUvForFace(face));
    }
    for (Vertex v : result) {
        xform.apply(v.xyz);
        xform.applyToNormal(v.normal);
    }
    return result;
}
Also used : Vertex(com.enderio.core.common.vecmath.Vertex) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList)

Example 3 with Vertex

use of com.enderio.core.common.vecmath.Vertex in project EnderIO by SleepyTrousers.

the class ConnectionModeGeometry method addModeConnectorQuads.

public static void addModeConnectorQuads(EnumFacing dir, Offset offset, TextureAtlasSprite tex, Vector4f color, List<BakedQuad> quads) {
    List<Vertex> verts = VERTS.get(dir);
    if (verts == null) {
        return;
    }
    Vector3d trans = ConduitGeometryUtil.instance.getTranslation(dir, offset);
    List<Vertex> xFormed = new ArrayList<Vertex>(verts.size());
    for (Vertex v : verts) {
        Vertex xf = new Vertex(v);
        xf.xyz.add(trans);
        xFormed.add(xf);
    }
    BakedQuadBuilder.addBakedQuads(quads, xFormed, tex, color);
}
Also used : Vertex(com.enderio.core.common.vecmath.Vertex) Vector3d(com.enderio.core.common.vecmath.Vector3d) ArrayList(java.util.ArrayList)

Example 4 with Vertex

use of com.enderio.core.common.vecmath.Vertex in project EnderIO by SleepyTrousers.

the class IoConfigRenderer method renderSelection.

private void renderSelection() {
    if (selection == null) {
        return;
    }
    BoundingBox bb = new BoundingBox(selection.config.getLocation());
    TextureAtlasSprite icon = selectedFaceIcon.get(TextureAtlasSprite.class);
    List<Vertex> corners = bb.getCornersWithUvForFace(selection.face, icon.getMinU(), icon.getMaxU(), icon.getMinV(), icon.getMaxV());
    GlStateManager.disableDepth();
    GlStateManager.disableLighting();
    RenderUtil.bindBlockTexture();
    BufferBuilder tes = Tessellator.getInstance().getBuffer();
    GlStateManager.color(1, 1, 1);
    Vector3d trans = new Vector3d((-origin.x) + eye.x, (-origin.y) + eye.y, (-origin.z) + eye.z);
    tes.setTranslation(trans.x, trans.y, trans.z);
    RenderUtil.addVerticesToTessellator(corners, DefaultVertexFormats.POSITION_TEX, true);
    Tessellator.getInstance().draw();
    tes.setTranslation(0, 0, 0);
}
Also used : Vertex(com.enderio.core.common.vecmath.Vertex) Vector3d(com.enderio.core.common.vecmath.Vector3d) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) BoundingBox(com.enderio.core.client.render.BoundingBox) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 5 with Vertex

use of com.enderio.core.common.vecmath.Vertex in project EnderIO by SleepyTrousers.

the class HalfBakedQuad method recomputeNormals.

public void recomputeNormals() {
    Vector3d T1 = new Vector3d();
    Vector3d T2 = new Vector3d();
    Vector3d T3 = new Vector3d();
    T1.set(corners.get(1).xyz);
    T1.sub(corners.get(0).xyz);
    T2.set(corners.get(2).xyz);
    T2.sub(corners.get(0).xyz);
    T3.cross(T1, T2);
    T3.normalize();
    for (Vertex vertex : corners) {
        vertex.setNormal(T3.x, T3.y, T3.z);
    }
}
Also used : Vertex(com.enderio.core.common.vecmath.Vertex) Vector3d(com.enderio.core.common.vecmath.Vector3d)

Aggregations

Vertex (com.enderio.core.common.vecmath.Vertex)10 ArrayList (java.util.ArrayList)5 BoundingBox (com.enderio.core.client.render.BoundingBox)4 Vector3d (com.enderio.core.common.vecmath.Vector3d)4 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)4 EnumFacing (net.minecraft.util.EnumFacing)4 Vector4f (com.enderio.core.common.vecmath.Vector4f)2 Offset (crazypants.enderio.base.conduit.geom.Offset)1 CapBankClientNetwork (crazypants.enderio.powertools.machine.capbank.network.CapBankClientNetwork)1 List (java.util.List)1 Nonnull (javax.annotation.Nonnull)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 Fluid (net.minecraftforge.fluids.Fluid)1 FluidStack (net.minecraftforge.fluids.FluidStack)1