Search in sources :

Example 6 with EntityResizableCuboid

use of buildcraft.core.lib.EntityResizableCuboid 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)

Example 7 with EntityResizableCuboid

use of buildcraft.core.lib.EntityResizableCuboid in project BuildCraft by BuildCraft.

the class BuilderProxyClient method newDrillHead.

@Override
public EntityResizableCuboid newDrillHead(World w, double i, double j, double k, double l, double d, double e) {
    EntityResizableCuboid cuboid = super.newDrillHead(w, i, j, k, l, d, e);
    cuboid.texture = drillHeadTexture;
    cuboid.makeClient();
    cuboid.textureFlips[2] = 2;
    cuboid.textureFlips[3] = 2;
    cuboid.textureFlips[4] = 2;
    cuboid.textureFlips[5] = 2;
    return cuboid;
}
Also used : EntityResizableCuboid(buildcraft.core.lib.EntityResizableCuboid)

Example 8 with EntityResizableCuboid

use of buildcraft.core.lib.EntityResizableCuboid in project BuildCraft by BuildCraft.

the class BuilderProxyClient method newDrill.

@Override
public EntityResizableCuboid newDrill(World w, double i, double j, double k, double l, double d, double e) {
    EntityResizableCuboid cuboid = super.newDrill(w, i, j, k, l, d, e);
    cuboid.texture = drillTexture;
    cuboid.makeClient();
    // Special casing for the arms
    if (l == 1) {
        // X-arm (East - West)
        cuboid.textureOffsetX = 8;
        // Don't render the caps
        cuboid.textures[EnumFacing.WEST.ordinal()] = null;
        cuboid.textures[EnumFacing.EAST.ordinal()] = null;
    } else if (e == 1) {
        // Z-arm (North - South)
        cuboid.textureOffsetZ = 8;
        // Don't render the caps
        cuboid.textures[EnumFacing.NORTH.ordinal()] = null;
        cuboid.textures[EnumFacing.SOUTH.ordinal()] = null;
    }
    return cuboid;
}
Also used : EntityResizableCuboid(buildcraft.core.lib.EntityResizableCuboid)

Example 9 with EntityResizableCuboid

use of buildcraft.core.lib.EntityResizableCuboid in project BuildCraft by BuildCraft.

the class RenderLaser method initScaledBoxes.

private static void initScaledBoxes(World world) {
    if (scaledBoxes == null) {
        scaledBoxes = new int[100][20];
        for (int size = 0; size < 100; ++size) {
            for (int i = 0; i < 20; ++i) {
                scaledBoxes[size][i] = GLAllocation.generateDisplayLists(1);
                GL11.glNewList(scaledBoxes[size][i], GL11.GL_COMPILE);
                EntityResizableCuboid cuboid = new EntityResizableCuboid(null);
                float minSize = 0.2F * size / 100F;
                float maxSize = 0.4F * size / 100F;
                // float minSize = 0.1F;
                // float maxSize = 0.2F;
                float range = maxSize - minSize;
                float diff = (float) (Math.cos(i / 20F * 2 * Math.PI) * range / 2F);
                cuboid.setPosition(new Vec3d(0, -maxSize / 2f - diff, -maxSize / 2f - diff));
                cuboid.setSize(new Vec3d(STEP, maxSize / 2f - diff, maxSize / 2f - diff));
                RenderResizableCuboid.INSTANCE.renderCube(cuboid);
                GL11.glEndList();
            }
        }
    }
}
Also used : EntityResizableCuboid(buildcraft.core.lib.EntityResizableCuboid) Vec3d(net.minecraft.util.math.Vec3d)

Example 10 with EntityResizableCuboid

use of buildcraft.core.lib.EntityResizableCuboid in project BuildCraft by BuildCraft.

the class FluidRenderer method getFluidDisplayLists.

public static int[] getFluidDisplayLists(FluidStack fluidStack, FluidType type, Vec3d size) {
    if (fluidStack == null) {
        return null;
    }
    Fluid fluid = fluidStack.getFluid();
    if (fluid == null) {
        return null;
    }
    Map<Fluid, Map<Vec3d, int[]>> cache = type == FluidType.FLOWING ? INSTANCE.flowingRenderCache : (type == FluidType.STILL ? INSTANCE.stillRenderCache : INSTANCE.frozenRenderCache);
    Map<Vec3d, int[]> displayLists = cache.get(fluid);
    int[] displayList;
    if (displayLists != null) {
        displayList = displayLists.get(size);
        if (displayList != null) {
            return displayList;
        }
    } else {
        displayLists = Maps.newHashMap();
        cache.put(fluid, displayLists);
    }
    displayList = new int[DISPLAY_STAGES];
    cache.put(fluid, displayLists);
    for (int s = 0; s < DISPLAY_STAGES; ++s) {
        displayList[s] = GLAllocation.generateDisplayLists(1);
        GL11.glNewList(displayList[s], GL11.GL_COMPILE);
        EntityResizableCuboid ent = new EntityResizableCuboid(null);
        ent.xSize = size.xCoord;
        ent.ySize = (Math.max(s, 1) / (float) DISPLAY_STAGES) * size.yCoord;
        ent.zSize = size.zCoord;
        ent.texture = getFluidTexture(fluidStack, type);
        RenderResizableCuboid.INSTANCE.renderCube(ent, true, false);
        GL11.glEndList();
    }
    displayLists.put(size, displayList);
    return displayList;
}
Also used : Fluid(net.minecraftforge.fluids.Fluid) EntityResizableCuboid(buildcraft.core.lib.EntityResizableCuboid) TextureMap(net.minecraft.client.renderer.texture.TextureMap) HashMap(java.util.HashMap) Map(java.util.Map) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

EntityResizableCuboid (buildcraft.core.lib.EntityResizableCuboid)13 Vec3d (net.minecraft.util.math.Vec3d)8 EnumFacing (net.minecraft.util.EnumFacing)3 Fluid (net.minecraftforge.fluids.Fluid)3 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 IItemCustomPipeRender (buildcraft.api.items.IItemCustomPipeRender)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 MutableQuad (buildcraft.lib.client.model.MutableQuad)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)1 TextureMap (net.minecraft.client.renderer.texture.TextureMap)1 EnumDyeColor (net.minecraft.item.EnumDyeColor)1 ItemStack (net.minecraft.item.ItemStack)1 FluidStack (net.minecraftforge.fluids.FluidStack)1