Search in sources :

Example 1 with IBlockLocation

use of buildcraft.core.lib.client.render.RenderResizableCuboid.IBlockLocation in project BuildCraft by BuildCraft.

the class RenderEngine method fireRenderer.

private void fireRenderer(EnumEngineType type, final EnumFacing face, float progress, BlockPos pos) {
    if (progress > 0.5) {
        progress = 1 - progress;
    }
    progress *= 2;
    final Vec3d coord = Utils.convert(pos);
    IBlockLocation locationFormula = new IBlockLocation() {

        @Override
        public Vec3d transformToWorld(Vec3d vec) {
            return coord;
        }
    };
    IFacingLocation faceFormula = new RotatedFacingLocation(EnumFacing.UP, face);
    GL11.glPushMatrix();
    RenderUtils.translate(Utils.VEC_HALF);
    if (face == EnumFacing.DOWN) {
        GL11.glRotated(180, 1, 0, 0);
    } else if (face == EnumFacing.UP) {
    // Up is already correct
    } else {
        GL11.glRotated(90, 1, 0, 0);
        int angle = 0;
        EnumFacing tempFace = face;
        while (tempFace != EnumFacing.SOUTH) {
            angle += 90;
            tempFace = tempFace.rotateYCCW();
        }
        // rotate Z because we rotated the whole axis model to swap Y and Z (so we really rotate the Y axis)
        GL11.glRotated(angle, 0, 0, 1);
        // Rotate the X axis back (because we messed it up above). Which is now the Y axis because we just
        // swapped X and Z with Y I think... or something... IT WORKS OK SHUT UP.
        GL11.glRotated(-angle, 0, 1, 0);
    }
    RenderUtils.translate(Utils.vec3(-0.5));
    EntityResizableCuboid chamberCuboid = new EntityResizableCuboid(getWorld());
    chamberCuboid.texture = spriteChamber;
    chamberCuboid.setTextureOffset(new Vec3d(3, 0, 3));
    Vec3d chamberSize = Utils.divide(new Vec3d(10, progress * 8, 10), 16);
    chamberCuboid.setSize(chamberSize);
    Vec3d chamberOffset = Utils.divide(new Vec3d(3, 4, 3), 16);
    RenderUtils.translate(chamberOffset);
    RenderResizableCuboid.INSTANCE.renderCube(chamberCuboid, EnumShadeArgument.FACE_LIGHT, locationFormula, faceFormula);
    RenderUtils.translate(Utils.multiply(chamberOffset, -1));
    EntityResizableCuboid boxCuboid = new EntityResizableCuboid(getWorld());
    boxCuboid.texture = spriteBoxSide.get(type);
    boxCuboid.makeClient();
    boxCuboid.textures[EnumFacing.UP.ordinal()] = spriteBoxTop.get(type);
    boxCuboid.textures[EnumFacing.DOWN.ordinal()] = spriteBoxTop.get(type);
    Vec3d boxSize = Utils.divide(new Vec3d(16, 4, 16), 16);
    boxCuboid.setSize(boxSize);
    Vec3d boxOffset = new Vec3d(0, 4 / 16d + progress / 2, 0);
    RenderUtils.translate(boxOffset);
    RenderResizableCuboid.INSTANCE.renderCube(boxCuboid, EnumShadeArgument.FACE_LIGHT, locationFormula, faceFormula);
    RenderUtils.translate(Utils.multiply(boxOffset, -1));
    GlStateManager.enableAlpha();
    GL11.glPopMatrix();
}
Also used : RotatedFacingLocation(buildcraft.core.lib.client.render.RenderResizableCuboid.RotatedFacingLocation) IBlockLocation(buildcraft.core.lib.client.render.RenderResizableCuboid.IBlockLocation) IFacingLocation(buildcraft.core.lib.client.render.RenderResizableCuboid.IFacingLocation) EnumFacing(net.minecraft.util.EnumFacing) EntityResizableCuboid(buildcraft.core.lib.EntityResizableCuboid) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

EntityResizableCuboid (buildcraft.core.lib.EntityResizableCuboid)1 IBlockLocation (buildcraft.core.lib.client.render.RenderResizableCuboid.IBlockLocation)1 IFacingLocation (buildcraft.core.lib.client.render.RenderResizableCuboid.IFacingLocation)1 RotatedFacingLocation (buildcraft.core.lib.client.render.RenderResizableCuboid.RotatedFacingLocation)1 EnumFacing (net.minecraft.util.EnumFacing)1 Vec3d (net.minecraft.util.math.Vec3d)1