Search in sources :

Example 6 with Rotation

use of uk.co.qmunity.lib.transform.Rotation in project BluePower by Qmunity.

the class PartLamp method renderDynamic.

/**
     * @author Koen Beckers (K4Unl), Amadornes
     */
@Override
@SideOnly(Side.CLIENT)
public void renderDynamic(Vec3d translation, double delta, int pass) {
    RenderHelper renderer = RenderHelper.instance;
    renderer.reset();
    switch(getFace().ordinal()) {
        case 0:
            break;
        case 1:
            renderer.addTransformation(new Rotation(180, 0, 0, Vec3d.center));
            break;
        case 2:
            renderer.addTransformation(new Rotation(90, 0, 0, Vec3d.center));
            break;
        case 3:
            renderer.addTransformation(new Rotation(-90, 0, 0, Vec3d.center));
            break;
        case 4:
            renderer.addTransformation(new Rotation(0, 0, -90, Vec3d.center));
            break;
        case 5:
            renderer.addTransformation(new Rotation(0, 0, 90, Vec3d.center));
            break;
    }
    renderGlow(pass);
    renderer.resetTransformations();
}
Also used : RenderHelper(uk.co.qmunity.lib.client.render.RenderHelper) Rotation(uk.co.qmunity.lib.transform.Rotation) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 7 with Rotation

use of uk.co.qmunity.lib.transform.Rotation in project BluePower by Qmunity.

the class GateTransceiver method renderStatic.

@Override
@SideOnly(Side.CLIENT)
public boolean renderStatic(Vec3i translation, RenderHelper renderer, RenderBlocks renderBlocks, int pass) {
    super.renderStatic(translation, renderer, renderBlocks, pass);
    if (getParent() != null)
        renderer.addTransformation(new Rotation(0, 180, 0));
    IIcon obsidian = Blocks.obsidian.getIcon(0, 0);
    IIcon quartz = Blocks.quartz_block.getIcon(0, 0);
    IIcon iron = Blocks.iron_block.getIcon(0, 0);
    IIcon gold = Blocks.gold_block.getIcon(0, 0);
    // Base
    renderer.renderBox(new Vec3dCube(7 / 16D, 2 / 16D, 7 / 16D, 9 / 16D, 8 / 16D, 9 / 16D), obsidian);
    if (getParent() == null || getWorld() == null)
        renderer.addTransformation(new Rotation(0, -(System.currentTimeMillis() / 100D) % 360, 0));
    renderer.addTransformation(new Rotation(45, 0, 0));
    // Post
    renderer.renderBox(new Vec3dCube(15 / 32D, 9 / 16D, 15 / 32D, 17 / 32D, 10 / 16D, 17 / 32D), iron);
    // Ball thingy
    renderer.renderBox(new Vec3dCube(7 / 16D, 10 / 16D, 7 / 16D, 9 / 16D, 12 / 16D, 9 / 16D), gold);
    renderer.renderBox(new Vec3dCube(6 / 16D, 8 / 16D, 5 / 16D, 10 / 16D, 9 / 16D, 11 / 16D), quartz);
    renderer.renderBox(new Vec3dCube(5 / 16D, 8 / 16D, 6 / 16D, 11 / 16D, 9 / 16D, 10 / 16D), quartz);
    for (int i = 0; i < 4; i++) {
        renderer.renderBox(new Vec3dCube(5 / 16D, 9 / 16D, 10 / 16D, 6 / 16D, 10 / 16D, 11 / 16D).rotate(0, i * 90, 0, Vec3d.center), quartz);
        renderer.renderBox(new Vec3dCube(4 / 16D, 9 / 16D, 6 / 16D, 5 / 16D, 10 / 16D, 10 / 16D).rotate(0, i * 90, 0, Vec3d.center), quartz);
        renderer.renderBox(new Vec3dCube(4 / 16D, 10 / 16D, 5 / 16D, 5 / 16D, 11 / 16D, 11 / 16D).rotate(0, i * 90, 0, Vec3d.center), quartz);
        renderer.renderBox(new Vec3dCube(4 / 16D, 11 / 16D, 11 / 16D, 5 / 16D, 12 / 16D, 12 / 16D).rotate(0, i * 90, 0, Vec3d.center), quartz);
        renderer.renderBox(new Vec3dCube(3 / 16D, 11 / 16D, 4 / 16D, 4 / 16D, 12 / 16D, 12 / 16D).rotate(0, i * 90, 0, Vec3d.center), quartz);
    }
    renderer.resetTransformations();
    return true;
}
Also used : IIcon(net.minecraft.util.IIcon) Rotation(uk.co.qmunity.lib.transform.Rotation) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 8 with Rotation

use of uk.co.qmunity.lib.transform.Rotation in project BluePower by Qmunity.

the class PneumaticTube method renderStatic.

@Override
@SideOnly(Side.CLIENT)
public boolean renderStatic(Vec3i loc, RenderHelper renderer, RenderBlocks renderBlocks, int pass) {
    boolean down = shouldRenderConnection(ForgeDirection.DOWN);
    boolean up = shouldRenderConnection(ForgeDirection.UP);
    boolean north = shouldRenderConnection(ForgeDirection.NORTH);
    boolean south = shouldRenderConnection(ForgeDirection.SOUTH);
    boolean west = shouldRenderConnection(ForgeDirection.WEST);
    boolean east = shouldRenderConnection(ForgeDirection.EAST);
    boolean renderFully = shouldRenderFully();
    if (this instanceof RestrictionTube) {
        IIcon icon = IconSupplier.restrictionTubeSide;
        renderer.renderBox(new Vec3dCube(0.25, 0.25, 0.25, 0.75, 0.75, 0.75), icon);
    }
    double addedThickness = getAddedThickness();
    double wireSize = getSize() / 16D;
    double frameSeparation = 6 / 16D - addedThickness - addedThickness - 0.001;
    double frameThickness = 1 / 16D + addedThickness;
    if (pass == 0) {
        if (this instanceof RestrictionTube) {
            IIcon icon = IconSupplier.restrictionTubeSide;
            renderer.renderBox(new Vec3dCube(0.25, 0.25, 0.25, 0.75, 0.75, 0.75), icon);
        }
        if (renderFully) {
            renderer.setColor(getColorMultiplier());
            renderFrame(renderer, wireSize, frameSeparation, frameThickness, true, true, true, true, true, true, down, up, west, east, north, south, true, getFrameIcon(), getFrameColorMultiplier());
            renderer.setColor(0xFFFFFF);
        } else {
            boolean isInWorld = getParent() != null;
            renderer.setColor(getFrameColorMultiplier());
            // Frame
            renderFrame(renderer, wireSize, frameSeparation, frameThickness, down, up, west, east, north, south, isInWorld, getFrameIcon(), getFrameColorMultiplier());
        }
        // Tube coloring
        {
            Vec3dCube side = new Vec3dCube(0.25 + 5 / 128D, 0, 0.25 - addedThickness, 0.25 + 9 / 128D + addedThickness, 0.25, 0.25 + 2 / 128D);
            Vec3dCube side2 = new Vec3dCube(0.25 - addedThickness, 0, 0.25 + 5 / 128D, 0.25 + 2 / 128D, 0.25, 0.25 + 9 / 128D + addedThickness);
            Vec3dCube side3 = new Vec3dCube(0.25 - addedThickness, 0.25 - addedThickness, 0.25 + 5 / 128D, 0.25 + 2 / 128D, 0.25 + 4 / 128D, 0.25 + 59 / 128D);
            Vec3dCube side4 = new Vec3dCube(0.25 + 5 / 128D, 0.25 - addedThickness, 0.25 + 5 / 128D, 0.25 + 9 / 128D + addedThickness, 0.25 + 2 / 128D, 0.25 + 56 / 128D);
            Vec3dCube side5 = new Vec3dCube(0.25 + 5 / 128D, 0.25 - addedThickness, 0.25 - 1 / 128D, 0.25 + 9 / 128D + addedThickness, 0.25 + 2 / 128D, 0.25 + 65 / 128D);
            for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                TubeColor c = color[d.ordinal()];
                if (c != TubeColor.NONE) {
                    try {
                        renderer.setColor(MinecraftColor.values()[15 - c.ordinal()].getHex());
                        if (connections[d.ordinal()]) {
                            for (int i = 0; i < 4; i++) {
                                renderer.renderBox(side.clone().rotate(0, i * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                                renderer.renderBox(side2.clone().rotate(0, i * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                                if (renderFully)
                                    renderer.renderBox(side3.clone().rotate(0, i * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                            }
                        } else if (renderFully) {
                            for (int i = 0; i < 4; i++) renderer.renderBox(side4.clone().rotate(0, i * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                        } else {
                            for (int i = 1; i < 4; i += 2) renderer.renderBox(side5.clone().rotate(0, (i + ((shouldRenderConnection(ForgeDirection.NORTH) || (shouldRenderConnection(ForgeDirection.UP) && (d == ForgeDirection.NORTH || d == ForgeDirection.SOUTH))) ? 1 : 0)) * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                        }
                        renderer.setColor(0xFFFFFF);
                    } catch (Exception ex) {
                        System.out.println("Err on side " + d + ". Color: " + c);
                    }
                }
            }
        }
        if (redwireType != null) {
            frameThickness /= 1.5;
            frameSeparation -= 1 / 32D;
            renderFrame(renderer, wireSize, frameSeparation, frameThickness, renderFully || shouldRenderConnection(ForgeDirection.DOWN), renderFully || shouldRenderConnection(ForgeDirection.UP), renderFully || shouldRenderConnection(ForgeDirection.WEST), renderFully || shouldRenderConnection(ForgeDirection.EAST), renderFully || shouldRenderConnection(ForgeDirection.NORTH), renderFully || shouldRenderConnection(ForgeDirection.SOUTH), redstoneConnections[ForgeDirection.DOWN.ordinal()], redstoneConnections[ForgeDirection.UP.ordinal()], redstoneConnections[ForgeDirection.WEST.ordinal()], redstoneConnections[ForgeDirection.EAST.ordinal()], redstoneConnections[ForgeDirection.NORTH.ordinal()], redstoneConnections[ForgeDirection.SOUTH.ordinal()], getParent() != null && getWorld() != null, IconSupplier.wire, WireHelper.getColorForPowerLevel(redwireType, getPower()));
            Vec3dCube c = new Vec3dCube(0.5 - 1 / 56D, 0, 0.2, 0.5 + 1 / 56D, 1 / 32D, 0.8);
            renderer.setColor(WireHelper.getColorForPowerLevel(redwireType, getPower()));
            for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                if (redstoneConnections[d.ordinal()] && !connections[d.ordinal()]) {
                    renderer.addTransformation(new Rotation(d));
                    for (int i = 0; i < 2; i++) {
                        renderer.addTransformation(new Rotation(0, 45 + 90 * i, 0));
                        renderer.renderBox(c.clone(), IconSupplier.wire);
                        renderer.removeTransformation();
                    }
                    renderer.removeTransformation();
                }
            }
            renderer.setColor(0xFFFFFF);
        }
    } else {
        IIcon glass = this instanceof MagTube ? IconSupplier.magTubeGlass : IconSupplier.pneumaticTubeGlass;
        IIcon glass2 = this instanceof MagTube ? IconSupplier.magTubeGlass2 : IconSupplier.pneumaticTubeGlass2;
        if (!(this instanceof RestrictionTube)) {
            renderer.setRenderSides(!down, !up, !west, !east, !north, !south);
            if (renderFully) {
                renderer.renderBox(new Vec3dCube(4.5 / 16D, 4.5 / 16D, 4.5 / 16D, 11.5 / 16D, 11.5 / 16D, 11.5 / 16D), glass);
            } else {
                boolean ud = west || east;
                boolean we = north || south;
                boolean ns = west || east;
                renderer.setTextureRotations(ud ? 1 : 0, ud ? 1 : 0, we ? 1 : 0, we ? 1 : 0, ns ? 1 : 0, ns ? 1 : 0);
                renderer.renderBox(new Vec3dCube(4.5 / 16D, 4.5 / 16D, 4.5 / 16D, 11.5 / 16D, 11.5 / 16D, 11.5 / 16D), glass2);
            }
            renderer.resetRenderedSides();
            renderer.resetTextureRotations();
        }
        Vec3dCube c = new Vec3dCube(4.5 / 16D, 0, 4.5 / 16D, 11.5 / 16D, 4.5 / 16D, 11.5 / 16D);
        if (renderFully) {
            boolean ud = west || east;
            boolean we = north || south;
            boolean ns = west || east;
            renderer.setTextureRotations(ud ? 1 : 0, ud ? 1 : 0, we ? 1 : 0, we ? 1 : 0, ns ? 1 : 0, ns ? 1 : 0);
            for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                if (shouldRenderConnection(d)) {
                    renderer.setRenderSide(d, false);
                    renderer.setRenderSide(d.getOpposite(), false);
                    renderer.renderBox(c.clone().rotate(d, Vec3d.center), glass);
                    renderer.resetRenderedSides();
                }
            }
        } else {
            boolean ud = west || east;
            boolean we = north || south;
            boolean ns = west || east;
            renderer.setTextureRotations(ud ? 1 : 0, ud ? 1 : 0, we ? 1 : 0, we ? 1 : 0, ns ? 1 : 0, ns ? 1 : 0);
            for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                if (shouldRenderConnection(d)) {
                    renderer.setRenderSide(d, false);
                    renderer.setRenderSide(d.getOpposite(), false);
                    renderer.renderBox(c.clone().rotate(d, Vec3d.center), glass2);
                    renderer.resetRenderedSides();
                }
            }
        }
    }
    return true;
}
Also used : TubeColor(com.bluepowermod.api.tube.IPneumaticTube.TubeColor) IIcon(net.minecraft.util.IIcon) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Rotation(uk.co.qmunity.lib.transform.Rotation) IOException(java.io.IOException) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 9 with Rotation

use of uk.co.qmunity.lib.transform.Rotation in project BluePower by Qmunity.

the class PneumaticTubeOpaque method renderStatic.

@Override
@SideOnly(Side.CLIENT)
public boolean renderStatic(Vec3i loc, RenderHelper renderer, RenderBlocks renderBlocks, int pass) {
    if (pass == 0) {
        boolean renderFully = false;
        int count = 0;
        for (int i = 0; i < 6; i++) {
            if (connections[i] || redstoneConnections[i])
                count++;
            if (i % 2 == 0 && connections[i] != connections[i + 1])
                renderFully = true;
        }
        renderFully |= count > 2 || count == 0;
        IIcon icon = this instanceof RestrictionTubeOpaque ? (renderFully ? IconSupplier.restrictionTubeNodeOpaque : IconSupplier.restrictionTubeSideOpaque) : renderFully ? IconSupplier.pneumaticTubeOpaqueNode : IconSupplier.pneumaticTubeOpaqueSide;
        if (shouldRenderConnection(ForgeDirection.EAST) || shouldRenderConnection(ForgeDirection.WEST))
            renderer.setTextureRotations(1, 1, 0, 0, 1, 1);
        if (shouldRenderConnection(ForgeDirection.NORTH) || shouldRenderConnection(ForgeDirection.SOUTH))
            renderer.setTextureRotations(0, 0, 1, 1, 0, 0);
        renderer.renderBox(new Vec3dCube(0.25, 0.25, 0.25, 0.75, 0.75, 0.75), icon);
        renderer.resetTextureRotations();
        for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
            if (shouldRenderConnection(d)) {
                renderer.addTransformation(new Rotation(d));
                renderer.renderBox(new Vec3dCube(0.25, 0, 0.25, 0.75, 0.25, 0.75), IconSupplier.pneumaticTubeOpaqueNode, null, icon, icon, icon, icon);
                renderer.removeTransformation();
            }
        }
        if (getRedwireType() != null) {
            double wireSize = getSize() / 16D;
            double frameSeparation = 6 / 16D - (wireSize - 2 / 16D);
            double frameThickness = 1 / 16D;
            frameThickness /= 1.5;
            frameSeparation -= 1 / 32D;
            renderFrame(renderer, wireSize, frameSeparation, frameThickness, renderFully || shouldRenderConnection(ForgeDirection.DOWN), renderFully || shouldRenderConnection(ForgeDirection.UP), renderFully || shouldRenderConnection(ForgeDirection.WEST), renderFully || shouldRenderConnection(ForgeDirection.EAST), renderFully || shouldRenderConnection(ForgeDirection.NORTH), renderFully || shouldRenderConnection(ForgeDirection.SOUTH), redstoneConnections[ForgeDirection.DOWN.ordinal()], redstoneConnections[ForgeDirection.UP.ordinal()], redstoneConnections[ForgeDirection.WEST.ordinal()], redstoneConnections[ForgeDirection.EAST.ordinal()], redstoneConnections[ForgeDirection.NORTH.ordinal()], redstoneConnections[ForgeDirection.SOUTH.ordinal()], getParent() != null && getWorld() != null, IconSupplier.wire, WireHelper.getColorForPowerLevel(getRedwireType(), getPower()));
        }
        // Tube coloring
        {
            Vec3dCube side = new Vec3dCube(0.25 + 5 / 128D, 0, 0.25 - 1 / 128D, 0.25 + 9 / 128D, 0.25, 0.25 + 2 / 128D);
            Vec3dCube side2 = new Vec3dCube(0.25 - 1 / 128D, 0, 0.25 + 5 / 128D, 0.25 + 2 / 128D, 0.25, 0.25 + 9 / 128D);
            Vec3dCube side3 = new Vec3dCube(0.25 - 1 / 128D, 0.25 - 1 / 128D, 0.25 + 5 / 128D, 0.25 + 2 / 128D, 0.25 + 2 / 128D, 0.25 + 59 / 128D);
            Vec3dCube side4 = new Vec3dCube(0.25 + 5 / 128D, 0.25 - 1 / 128D, 0.25 + 5 / 128D, 0.25 + 9 / 128D, 0.25 + 2 / 128D, 0.25 + 56 / 128D);
            Vec3dCube side5 = new Vec3dCube(0.25 + 5 / 128D, 0.25 - 1 / 128D, 0.25 - 1 / 128D, 0.25 + 9 / 128D, 0.25 + 2 / 128D, 0.25 + 65 / 128D);
            for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                TubeColor c = color[d.ordinal()];
                if (c != TubeColor.NONE) {
                    try {
                        renderer.setColor(MinecraftColor.values()[15 - c.ordinal()].getHex());
                        if (connections[d.ordinal()]) {
                            for (int i = 0; i < 4; i++) {
                                renderer.renderBox(side.clone().rotate(0, i * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                                renderer.renderBox(side2.clone().rotate(0, i * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                                if (renderFully)
                                    renderer.renderBox(side3.clone().rotate(0, i * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                            }
                        } else if (renderFully) {
                            for (int i = 0; i < 4; i++) renderer.renderBox(side4.clone().rotate(0, i * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                        } else {
                            for (int i = 1; i < 4; i += 2) renderer.renderBox(side5.clone().rotate(0, (i + ((shouldRenderConnection(ForgeDirection.NORTH) || (shouldRenderConnection(ForgeDirection.UP) && (d == ForgeDirection.NORTH || d == ForgeDirection.SOUTH))) ? 1 : 0)) * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                        }
                        renderer.setColor(0xFFFFFF);
                    } catch (Exception ex) {
                        System.out.println("Err on side " + d + ". Color: " + c);
                    }
                }
            }
        }
    }
    return true;
}
Also used : TubeColor(com.bluepowermod.api.tube.IPneumaticTube.TubeColor) IIcon(net.minecraft.util.IIcon) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Rotation(uk.co.qmunity.lib.transform.Rotation) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Aggregations

Rotation (uk.co.qmunity.lib.transform.Rotation)9 SideOnly (cpw.mods.fml.relauncher.SideOnly)8 Vec3dCube (uk.co.qmunity.lib.vec.Vec3dCube)6 IIcon (net.minecraft.util.IIcon)5 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4 IGateComponent (com.bluepowermod.api.gate.IGateComponent)2 TubeColor (com.bluepowermod.api.tube.IPneumaticTube.TubeColor)2 RenderHelper (uk.co.qmunity.lib.client.render.RenderHelper)2 IIntegratedCircuitPart (com.bluepowermod.api.gate.IIntegratedCircuitPart)1 IScrewdriver (com.bluepowermod.api.misc.IScrewdriver)1 ItemPart (com.bluepowermod.item.ItemPart)1 PartRedwireFace (com.bluepowermod.part.wire.redstone.PartRedwireFace)1 PartRedwireFaceUninsulated (com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated)1 IOException (java.io.IOException)1 ItemStack (net.minecraft.item.ItemStack)1 Vec3 (net.minecraft.util.Vec3)1 IPart (uk.co.qmunity.lib.part.IPart)1 Scale (uk.co.qmunity.lib.transform.Scale)1 Transformation (uk.co.qmunity.lib.transform.Transformation)1 Translation (uk.co.qmunity.lib.transform.Translation)1