Search in sources :

Example 1 with EntityResizableCuboid

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

the class PipeTransportRendererFluids method getDisplayFluidList.

private static DisplayFluidList getDisplayFluidList(int fluidID) {
    if (INSTANCE.fluidLists.containsKey(fluidID)) {
        return INSTANCE.fluidLists.get(fluidID);
    }
    long start = System.nanoTime();
    Fluid fluid = FluidRegistry.getFluid(fluidID);
    if (fluid == null) {
        INSTANCE.fluidLists.put(fluidID, null);
        return null;
    }
    TextureAtlasSprite sprite = FluidRenderer.getFluidTexture(fluid, FluidType.STILL);
    int[] center = new int[DISPLAY_STAGES];
    for (int i = 0; i < DISPLAY_STAGES; i++) {
        center[i] = GLAllocation.generateDisplayLists(1);
        GL11.glNewList(center[i], GL11.GL_COMPILE);
        GL11.glPushMatrix();
        GL11.glTranslated(0.5, 0.5, 0.5);
        GL11.glScalef(0.99f, 0.99f, 0.99f);
        GL11.glTranslated(-0.25, -0.25, -0.25);
        EntityResizableCuboid cuboid = new EntityResizableCuboid(null);
        cuboid.xSize = 0.5;
        cuboid.ySize = 0.5 * ((i + 1) / (float) (DISPLAY_STAGES));
        cuboid.zSize = 0.5;
        cuboid.texture = sprite;
        RenderResizableCuboid.INSTANCE.renderCube(cuboid, true, false);
        GL11.glPopMatrix();
        GL11.glEndList();
    }
    int[] vertical = new int[DISPLAY_STAGES];
    for (int i = 0; i < DISPLAY_STAGES; i++) {
        vertical[i] = GLAllocation.generateDisplayLists(1);
        GL11.glNewList(vertical[i], GL11.GL_COMPILE);
        double width = ((i + 1) / (float) (DISPLAY_STAGES));
        GL11.glPushMatrix();
        GL11.glTranslated(0.5, 0.5, 0.5);
        GL11.glScalef(0.99f, 0.99f, 0.99f);
        GL11.glTranslated(-0.25 * width, -0.25, -0.25 * width);
        EntityResizableCuboid cuboid = new EntityResizableCuboid(null);
        cuboid.xSize = 0.5 * width;
        cuboid.ySize = 0.5;
        cuboid.zSize = 0.5 * width;
        cuboid.texture = sprite;
        RenderResizableCuboid.INSTANCE.renderCube(cuboid, true, false);
        GL11.glPopMatrix();
        GL11.glEndList();
    }
    int[][] connections = new int[DISPLAY_STAGES][];
    for (int i = 0; i < DISPLAY_STAGES; i++) {
        connections[i] = new int[6];
        for (EnumFacing connect : EnumFacing.values()) {
            int connectOrdinal = connect.ordinal();
            boolean vert = connect.getAxis() == Axis.Y;
            double diff = ((i + 1) / (float) (DISPLAY_STAGES)) * 0.5;
            double width = vert ? diff : 0.5;
            double height = vert ? 0.5 : diff;
            EnumFacing pos = connect.getAxisDirection() == AxisDirection.POSITIVE ? connect : connect.getOpposite();
            Vec3d size = new Vec3d(width, 0.5, width).subtract(Utils.convert(pos, 0.25));
            Vec3d position = new Vec3d(0.5, 0.5, 0.5).add(Utils.convert(connect, 0.375));
            position = position.subtract(Utils.multiply(size, 0.5));
            // The position is not correct!
            connections[i][connectOrdinal] = GLAllocation.generateDisplayLists(1);
            GL11.glNewList(connections[i][connectOrdinal], GL11.GL_COMPILE);
            GL11.glTranslated(position.xCoord, position.yCoord, position.zCoord);
            GL11.glTranslated(size.xCoord / 2d, size.yCoord / 2d, size.zCoord / 2d);
            GL11.glScalef(0.99f, 0.99f, 0.99f);
            GL11.glTranslated(-size.xCoord / 2d, -size.yCoord / 2d, -size.zCoord / 2d);
            EntityResizableCuboid cuboid = new EntityResizableCuboid(null);
            cuboid.xSize = size.xCoord;
            cuboid.ySize = height;
            cuboid.zSize = size.zCoord;
            cuboid.texture = sprite;
            RenderResizableCuboid.INSTANCE.renderCube(cuboid, true, false);
            GL11.glEndList();
        }
    }
    DisplayFluidList dfl = new DisplayFluidList(center, vertical, connections);
    INSTANCE.fluidLists.put(fluidID, dfl);
    long diff = System.nanoTime() - start;
    BCLog.logger.info("DisplayFluidList generation took " + (diff / 1000000) + "ms, " + (diff % 1000000) + "ns for " + new FluidStack(fluid, 1).getLocalizedName() + "#" + fluidID);
    return dfl;
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) FluidStack(net.minecraftforge.fluids.FluidStack) Fluid(net.minecraftforge.fluids.Fluid) EntityResizableCuboid(buildcraft.core.lib.EntityResizableCuboid) EnumFacing(net.minecraft.util.EnumFacing) Vec3d(net.minecraft.util.math.Vec3d)

Example 2 with EntityResizableCuboid

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

the class PipeTransportRendererFluids method renderConnection.

private static void renderConnection(TextureAtlasSprite sprite, float amount, double sideFlow, EnumFacing connect) {
    boolean vert = connect.getAxis() == Axis.Y;
    double diff = amount * 0.5;
    double width = vert ? diff : 0.5;
    double height = vert ? 0.5 : diff;
    EnumFacing positive = Utils.convertPositive(connect);
    Vec3d size = new Vec3d(width, 0.5, width).subtract(Utils.convert(positive, 0.25));
    Vec3d position = new Vec3d(0.5, 0.5, 0.5).add(Utils.convert(connect, 0.375));
    position = position.subtract(Utils.multiply(size, 0.5));
    // The position is not correct!
    GL11.glPushMatrix();
    GL11.glTranslated(position.xCoord, position.yCoord, position.zCoord);
    GL11.glTranslated(size.xCoord / 2d, size.yCoord / 2d, size.zCoord / 2d);
    GL11.glScalef(0.99f, 0.99f, 0.99f);
    GL11.glTranslated(-size.xCoord / 2d, -size.yCoord / 2d, -size.zCoord / 2d);
    EntityResizableCuboid cuboid = new EntityResizableCuboid(null);
    cuboid.xSize = size.xCoord;
    cuboid.ySize = height;
    cuboid.zSize = size.zCoord;
    cuboid.texture = sprite;
    double flow = sideFlow;
    cuboid.textureOffsetX = connect.getAxis() == Axis.X ? flow : 0;
    cuboid.textureOffsetY = connect.getAxis() == Axis.Y ? flow : 0;
    cuboid.textureOffsetZ = connect.getAxis() == Axis.Z ? flow : 0;
    RenderResizableCuboid.INSTANCE.renderCube(cuboid);
    GL11.glPopMatrix();
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) EntityResizableCuboid(buildcraft.core.lib.EntityResizableCuboid) Vec3d(net.minecraft.util.math.Vec3d)

Example 3 with EntityResizableCuboid

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

the class PipeTransportRendererPower method renderSidePower.

private static void renderSidePower(EnumFacing face, double stage, double flow, double centerStage) {
    if (stage <= 0) {
        return;
    }
    double width = 0.5 * stage / POWER_STAGES;
    double centerRadius = 0.25 * centerStage / POWER_STAGES;
    Vec3d center = Utils.VEC_HALF.add(Utils.convert(face, 0.25 + centerRadius / 2d));
    face = Utils.convertPositive(face);
    Vec3d size = Utils.VEC_ONE.subtract(Utils.convert(face));
    size = Utils.multiply(size, width);
    size = size.add(Utils.convert(face, 0.5 - centerRadius));
    EntityResizableCuboid cuboid = new EntityResizableCuboid(null);
    cuboid.setSize(size);
    cuboid.texture = PipeIconProvider.TYPE.Power_Normal.getIcon();
    cuboid.makeClient();
    // 8 - textureWidth / 2;
    double offsetNonFlow = 0;
    double offsetFlow = flow;
    Vec3d textureOffset = new Vec3d(offsetNonFlow, offsetNonFlow, offsetNonFlow);
    textureOffset = textureOffset.add(Utils.convert(face, -offsetNonFlow));
    textureOffset = textureOffset.add(Utils.convert(face, offsetFlow));
    cuboid.textureOffsetX = textureOffset.xCoord;
    cuboid.textureOffsetY = textureOffset.yCoord;
    cuboid.textureOffsetZ = textureOffset.zCoord;
    GL11.glPushMatrix();
    RenderUtils.translate(center);
    // Tessellator.getInstance().getWorldRenderer().setBrightness(0xFFFFFFFF);
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 0xF0, 0xF0);
    RenderResizableCuboid.INSTANCE.renderCubeFromCentre(cuboid);
    GL11.glPopMatrix();
}
Also used : EntityResizableCuboid(buildcraft.core.lib.EntityResizableCuboid) Vec3d(net.minecraft.util.math.Vec3d)

Example 4 with EntityResizableCuboid

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

the class PipeTransportRendererPower method renderCenterPower.

private static void renderCenterPower(double stage, Vec3d centerFlow) {
    if (stage <= 0) {
        return;
    }
    double width = 0.5 * stage / POWER_STAGES;
    Vec3d size = new Vec3d(width, width, width);
    Vec3d pos = Utils.VEC_HALF;
    EntityResizableCuboid erc = new EntityResizableCuboid(null);
    erc.setSize(size);
    erc.texture = PipeIconProvider.TYPE.Power_Normal.getIcon();
    erc.textureOffsetX = centerFlow.xCoord;
    erc.textureOffsetY = centerFlow.yCoord;
    erc.textureOffsetZ = centerFlow.zCoord;
    GL11.glPushMatrix();
    RenderUtils.translate(pos);
    // Tessellator.getInstance().getWorldRenderer().setBrightness(0xFFFFFFFF);
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 0xF0, 0xF0);
    RenderResizableCuboid.INSTANCE.renderCubeFromCentre(erc);
    GL11.glPopMatrix();
}
Also used : EntityResizableCuboid(buildcraft.core.lib.EntityResizableCuboid) Vec3d(net.minecraft.util.math.Vec3d)

Example 5 with EntityResizableCuboid

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

the class FactoryProxyClient method newPumpTube.

@Override
public EntityResizableCuboid newPumpTube(World w) {
    EntityResizableCuboid eb = super.newPumpTube(w);
    eb.texture = pumpTexture;
    return eb;
}
Also used : EntityResizableCuboid(buildcraft.core.lib.EntityResizableCuboid)

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