Example usage for org.lwjgl.opengl GL11 glPushAttrib

List of usage examples for org.lwjgl.opengl GL11 glPushAttrib

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glPushAttrib.

Prototype

public static native void glPushAttrib(@NativeType("GLbitfield") int mask);

Source Link

Document

Takes a bitwise OR of symbolic constants indicating which groups of state variables to push onto the server attribute stack.

Usage

From source file:buildcraft.energy.render.RenderEngine.java

License:Minecraft Mod Public

private void render(float progress, ForgeDirection orientation, ResourceLocation baseTexture,
        ResourceLocation chamberTexture, ResourceLocation trunkTexture, double x, double y, double z) {

    if (BuildCraftCore.render == RenderMode.NoDynamic) {
        return;/*from ww w.j  av a 2s  . co m*/
    }

    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glColor3f(1, 1, 1);

    GL11.glTranslatef((float) x, (float) y, (float) z);

    float step;

    if (progress > 0.5) {
        step = 7.99F - (progress - 0.5F) * 2F * 7.99F;
    } else {
        step = progress * 2F * 7.99F;
    }

    float translatefact = step / 16;

    float[] angle = { 0, 0, 0 };
    float[] translate = { orientation.offsetX, orientation.offsetY, orientation.offsetZ };

    switch (orientation) {
    case EAST:
    case WEST:
    case DOWN:
        angle[2] = angleMap[orientation.ordinal()];
        break;
    case SOUTH:
    case NORTH:
    default:
        angle[0] = angleMap[orientation.ordinal()];
        break;
    }

    box.rotateAngleX = angle[0];
    box.rotateAngleY = angle[1];
    box.rotateAngleZ = angle[2];

    trunk.rotateAngleX = angle[0];
    trunk.rotateAngleY = angle[1];
    trunk.rotateAngleZ = angle[2];

    movingBox.rotateAngleX = angle[0];
    movingBox.rotateAngleY = angle[1];
    movingBox.rotateAngleZ = angle[2];

    chamber.rotateAngleX = angle[0];
    chamber.rotateAngleY = angle[1];
    chamber.rotateAngleZ = angle[2];

    float factor = (float) (1.0 / 16.0);

    bindTexture(baseTexture);

    box.render(factor);

    GL11.glTranslatef(translate[0] * translatefact, translate[1] * translatefact, translate[2] * translatefact);
    movingBox.render(factor);
    GL11.glTranslatef(-translate[0] * translatefact, -translate[1] * translatefact,
            -translate[2] * translatefact);

    bindTexture(chamberTexture);

    float chamberf = 2F / 16F;

    for (int i = 0; i <= step + 2; i += 2) {
        chamber.render(factor);
        GL11.glTranslatef(translate[0] * chamberf, translate[1] * chamberf, translate[2] * chamberf);
    }

    for (int i = 0; i <= step + 2; i += 2) {
        GL11.glTranslatef(-translate[0] * chamberf, -translate[1] * chamberf, -translate[2] * chamberf);
    }

    bindTexture(trunkTexture);

    trunk.render(factor);

    GL11.glPopAttrib();
    GL11.glPopMatrix();
}

From source file:buildcraft.factory.render.RenderRefinery.java

License:Minecraft Mod Public

private void render(TileRefinery tile, double x, double y, double z) {
    FluidStack liquid1 = null, liquid2 = null, liquidResult = null;
    int color1 = 0xFFFFFF, color2 = 0xFFFFFF, colorResult = 0xFFFFFF;

    float anim = 0;
    int angle = 0;
    ModelRenderer theMagnet = magnet[0];
    if (tile != null) {
        if (tile.tank1.getFluid() != null) {
            liquid1 = tile.tank1.getFluid();
            color1 = tile.tank1.colorRenderCache;
        }/*from ww  w  .j a v  a  2s  .c om*/

        if (tile.tank2.getFluid() != null) {
            liquid2 = tile.tank2.getFluid();
            color2 = tile.tank2.colorRenderCache;
        }

        if (tile.result.getFluid() != null) {
            liquidResult = tile.result.getFluid();
            colorResult = tile.result.colorRenderCache;
        }

        anim = tile.getAnimationStage();

        angle = 0;
        switch (tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord)) {
        case 2:
            angle = 90;
            break;
        case 3:
            angle = 270;
            break;
        case 4:
            angle = 180;
            break;
        case 5:
            angle = 0;
            break;
        }

        if (tile.animationSpeed <= 1) {
            theMagnet = magnet[0];
        } else if (tile.animationSpeed <= 2.5) {
            theMagnet = magnet[1];
        } else if (tile.animationSpeed <= 4.5) {
            theMagnet = magnet[2];
        } else {
            theMagnet = magnet[3];
        }
    }

    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);
    GL11.glScalef(0.99F, 0.99F, 0.99F);

    GL11.glRotatef(angle, 0, 1, 0);

    bindTexture(TEXTURE);

    GL11.glPushMatrix();
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    GL11.glTranslatef(-4F * pixel, 0, -4F * pixel);
    tank.render(pixel);
    GL11.glTranslatef(4F * pixel, 0, 4F * pixel);

    GL11.glTranslatef(-4F * pixel, 0, 4F * pixel);
    tank.render(pixel);
    GL11.glTranslatef(4F * pixel, 0, -4F * pixel);

    GL11.glTranslatef(4F * pixel, 0, 0);
    tank.render(pixel);
    GL11.glTranslatef(-4F * pixel, 0, 0);
    GL11.glPopMatrix();

    float trans1, trans2;

    if (anim <= 100) {
        trans1 = 12F * pixel * anim / 100F;
        trans2 = 0;
    } else if (anim <= 200) {
        trans1 = 12F * pixel - (12F * pixel * (anim - 100F) / 100F);
        trans2 = 12F * pixel * (anim - 100F) / 100F;
    } else {
        trans1 = 12F * pixel * (anim - 200F) / 100F;
        trans2 = 12F * pixel - (12F * pixel * (anim - 200F) / 100F);
    }

    GL11.glPushMatrix();
    GL11.glScalef(0.99F, 0.99F, 0.99F);
    GL11.glTranslatef(-0.51F, trans1 - 0.5F, -0.5F);
    theMagnet.render(pixel);
    GL11.glPopMatrix();

    GL11.glPushMatrix();
    GL11.glScalef(0.99F, 0.99F, 0.99F);
    GL11.glTranslatef(-0.51F, trans2 - 0.5F, 12F * pixel - 0.5F);
    theMagnet.render(pixel);
    GL11.glPopMatrix();

    if (tile != null) {
        GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

        GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
        GL11.glScalef(0.5F, 1, 0.5F);

        if (liquid1 != null && liquid1.amount > 0) {
            int[] list1 = FluidRenderer.getFluidDisplayLists(liquid1, tile.getWorldObj(), false);

            if (list1 != null) {
                bindTexture(FluidRenderer.getFluidSheet(liquid1));
                RenderUtils.setGLColorFromInt(color1);
                GL11.glCallList(list1[getDisplayListIndex(tile.tank1)]);
            }
        }

        if (liquid2 != null && liquid2.amount > 0) {
            int[] list2 = FluidRenderer.getFluidDisplayLists(liquid2, tile.getWorldObj(), false);

            if (list2 != null) {
                GL11.glPushMatrix();
                GL11.glTranslatef(0, 0, 1);
                bindTexture(FluidRenderer.getFluidSheet(liquid2));
                RenderUtils.setGLColorFromInt(color2);
                GL11.glCallList(list2[getDisplayListIndex(tile.tank2)]);
                GL11.glPopMatrix();
            }
        }

        if (liquidResult != null && liquidResult.amount > 0) {
            int[] list3 = FluidRenderer.getFluidDisplayLists(liquidResult, tile.getWorldObj(), false);

            if (list3 != null) {
                GL11.glPushMatrix();
                GL11.glTranslatef(1, 0, 0.5F);
                bindTexture(FluidRenderer.getFluidSheet(liquidResult));
                RenderUtils.setGLColorFromInt(colorResult);
                GL11.glCallList(list3[getDisplayListIndex(tile.result)]);
                GL11.glPopMatrix();
            }
        }
        GL11.glPopAttrib();
    }

    GL11.glPopAttrib();
    GL11.glPopMatrix();
}

From source file:buildcraft.factory.render.RenderTank.java

License:Minecraft Mod Public

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {

    TileTank tank = (TileTank) tileentity;

    FluidStack liquid = tank.tank.getFluid();
    int color = tank.tank.colorRenderCache;
    if (liquid == null || liquid.amount <= 0) {
        return;//  w  w w . j av  a2 s  . c  o  m
    }

    int[] displayList = FluidRenderer.getFluidDisplayLists(liquid, tileentity.getWorldObj(), false);
    if (displayList == null) {
        return;
    }

    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    bindTexture(FluidRenderer.getFluidSheet(liquid));
    RenderUtils.setGLColorFromInt(color);

    GL11.glTranslatef((float) x + 0.125F, (float) y + 0.5F, (float) z + 0.125F);
    GL11.glScalef(0.75F, 0.999F, 0.75F);
    GL11.glTranslatef(0, -0.5F, 0);

    GL11.glCallList(displayList[(int) ((float) liquid.amount / (float) (tank.tank.getCapacity())
            * (FluidRenderer.DISPLAY_STAGES - 1))]);

    GL11.glPopAttrib();
    GL11.glPopMatrix();
}

From source file:buildcraft.robotics.gui.GuiZonePlan.java

License:Minecraft Mod Public

@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
    super.drawGuiContainerBackgroundLayer(f, x, y);

    if (getContainer().mapTexture.width <= WINDOWED_MAP_WIDTH) {
        mapXMin = guiLeft + 8 + ((WINDOWED_MAP_WIDTH - getContainer().mapTexture.width) / 2);
    } else {/*from  ww w .  j av a 2 s .  c  o  m*/
        mapXMin = (width - getContainer().mapTexture.width) / 2;
    }

    if (getContainer().mapTexture.height <= WINDOWED_MAP_HEIGHT) {
        mapYMin = guiTop + 9 + ((WINDOWED_MAP_HEIGHT - getContainer().mapTexture.height) / 2);
    } else {
        mapYMin = (height - getContainer().mapTexture.height) / 2;
    }

    getContainer().mapTexture.draw(mapXMin, mapYMin, zLevel);

    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_BLEND);

    currentSelection.draw(mapXMin, mapYMin, zLevel);

    GL11.glPopAttrib();
    GL11.glDisable(GL11.GL_BLEND);

    newSelection.updateTexture();

    if (inSelection && selX2 != 0) {
        GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
        GL11.glEnable(GL11.GL_BLEND);

        int x1 = selX1 < selX2 ? selX1 : selX2;
        int x2 = selX1 < selX2 ? selX2 : selX1;
        int y1 = selY1 < selY2 ? selY1 : selY2;
        int y2 = selY1 < selY2 ? selY2 : selY1;

        drawTexturedModalRect(x1, y1, 0, 0, x2 - x1 + 1, y2 - y1 + 1);
        GL11.glPopAttrib();
        GL11.glDisable(GL11.GL_BLEND);
    }

    if (!isFullscreen()) {
        drawBackgroundSlots(x, y);

        bindTexture(texture);

        GL11.glEnable(GL11.GL_ALPHA_TEST);
        drawTexturedModalRect(guiLeft + colorSelected.x, guiTop + colorSelected.y, 0, 228, 16, 16);
        drawTexturedModalRect(guiLeft + 236, guiTop + 27, 16, 228, 8,
                (int) ((zonePlan.progress / (float) TileZonePlan.CRAFT_TIME) * 27));
    }
}

From source file:buildcraft.robotics.render.RenderRobot.java

License:Minecraft Mod Public

private void doRenderWearable(EntityRobot entity, TextureManager textureManager, ItemStack wearable) {
    if (wearable.getItem() instanceof IRobotOverlayItem) {
        ((IRobotOverlayItem) wearable.getItem()).renderRobotOverlay(wearable, textureManager);
    } else if (wearable.getItem() instanceof ItemArmor) {
        GL11.glPushMatrix();//ww w.  j  av  a2  s  .c o  m
        GL11.glScalef(1.0125F, 1.0125F, 1.0125F);
        GL11.glTranslatef(0.0f, -0.25f, 0.0f);
        GL11.glRotatef(180F, 0, 0, 1);

        int color = wearable.getItem().getColorFromItemStack(wearable, 0);
        if (color != 16777215) {
            GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
            GL11.glColor3ub((byte) (color >> 16), (byte) ((color >> 8) & 255), (byte) (color & 255));
        }

        textureManager.bindTexture(RenderBiped.getArmorResource(entity, wearable, 0, null));
        ModelBiped armorModel = ForgeHooksClient.getArmorModel(entity, wearable, 0, null);
        if (armorModel != null) {
            armorModel.render(entity, 0, 0, 0, -90f, 0, 1 / 16F);

            if (color != 16777215) {
                GL11.glPopAttrib();
            }
        } else {
            GL11.glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);
            helmetBox.render(1 / 16F);

            if (color != 16777215) {
                this.bindTexture(RenderBiped.getArmorResource(entity, wearable, 0, "overlay"));
                helmetBox.render(1 / 16F);
                GL11.glPopAttrib();
            }
        }

        GL11.glPopMatrix();
    } else if (wearable.getItem() instanceof ItemSkull) {
        doRenderSkull(wearable);
    }
}

From source file:buildcraft.silicon.render.RenderLaserBlock.java

License:Minecraft Mod Public

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
    TileLaser laser = (TileLaser) tileentity;

    if (laser != null) {
        GL11.glPushMatrix();/*ww w  . ja  v  a2 s  . c  o  m*/
        GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

        GL11.glTranslated(x, y, z);
        GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord);

        GL11.glPushMatrix();
        RenderLaser.doRenderLaser(TileEntityRendererDispatcher.instance.field_147553_e, laser.laser,
                laser.getTexture());
        GL11.glPopMatrix();

        //GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glPopAttrib();
        GL11.glPopMatrix();
    }
}

From source file:buildcraft.transport.render.PipeItemRenderer.java

License:Minecraft Mod Public

private void renderPipeItem(RenderBlocks render, ItemStack item, float translateX, float translateY,
        float translateZ) {
    GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT); //don't break other mods' guis when holding a pipe
    //force transparency
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_BLEND);/*from w w  w.  j a v a  2  s  . co m*/

    // GL11.glBindTexture(GL11.GL_TEXTURE_2D, 10);
    Tessellator tessellator = Tessellator.instance;

    Block block = BuildCraftTransport.genericPipeBlock;
    IIcon icon = item.getItem().getIconFromDamage(0);

    if (icon == null) {
        icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager()
                .getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
    }

    block.setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS,
            CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS);
    block.setBlockBoundsForItemRender();
    render.setRenderBoundsFromBlock(block);

    GL11.glTranslatef(translateX, translateY, translateZ);
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, -1F, 0.0F);
    render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1F);
    render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(-1F, 0.0F, 0.0F);
    render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
    render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);

    GL11.glPopAttrib(); // nicely leave the rendering how it was
}

From source file:buildcraft.transport.render.PipeRendererTESR.java

License:Minecraft Mod Public

private void pipeWireRender(TileGenericPipe pipe, float cx, float cy, float cz, PipeWire color, double x,
        double y, double z) {

    PipeRenderState state = pipe.renderState;

    float minX = CoreConstants.PIPE_MIN_POS;
    float minY = CoreConstants.PIPE_MIN_POS;
    float minZ = CoreConstants.PIPE_MIN_POS;

    float maxX = CoreConstants.PIPE_MAX_POS;
    float maxY = CoreConstants.PIPE_MAX_POS;
    float maxZ = CoreConstants.PIPE_MAX_POS;

    boolean foundX = false, foundY = false, foundZ = false;

    if (state.wireMatrix.isWireConnected(color, ForgeDirection.WEST)) {
        minX = 0;/* ww  w.j  a  v  a2  s .co  m*/
        foundX = true;
    }

    if (state.wireMatrix.isWireConnected(color, ForgeDirection.EAST)) {
        maxX = 1;
        foundX = true;
    }

    if (state.wireMatrix.isWireConnected(color, ForgeDirection.DOWN)) {
        minY = 0;
        foundY = true;
    }

    if (state.wireMatrix.isWireConnected(color, ForgeDirection.UP)) {
        maxY = 1;
        foundY = true;
    }

    if (state.wireMatrix.isWireConnected(color, ForgeDirection.NORTH)) {
        minZ = 0;
        foundZ = true;
    }

    if (state.wireMatrix.isWireConnected(color, ForgeDirection.SOUTH)) {
        maxZ = 1;
        foundZ = true;
    }

    boolean center = false;

    if (minX == 0 && maxX != 1 && (foundY || foundZ)) {
        if (cx == CoreConstants.PIPE_MIN_POS) {
            maxX = CoreConstants.PIPE_MIN_POS;
        } else {
            center = true;
        }
    }

    if (minX != 0 && maxX == 1 && (foundY || foundZ)) {
        if (cx == CoreConstants.PIPE_MAX_POS) {
            minX = CoreConstants.PIPE_MAX_POS;
        } else {
            center = true;
        }
    }

    if (minY == 0 && maxY != 1 && (foundX || foundZ)) {
        if (cy == CoreConstants.PIPE_MIN_POS) {
            maxY = CoreConstants.PIPE_MIN_POS;
        } else {
            center = true;
        }
    }

    if (minY != 0 && maxY == 1 && (foundX || foundZ)) {
        if (cy == CoreConstants.PIPE_MAX_POS) {
            minY = CoreConstants.PIPE_MAX_POS;
        } else {
            center = true;
        }
    }

    if (minZ == 0 && maxZ != 1 && (foundX || foundY)) {
        if (cz == CoreConstants.PIPE_MIN_POS) {
            maxZ = CoreConstants.PIPE_MIN_POS;
        } else {
            center = true;
        }
    }

    if (minZ != 0 && maxZ == 1 && (foundX || foundY)) {
        if (cz == CoreConstants.PIPE_MAX_POS) {
            minZ = CoreConstants.PIPE_MAX_POS;
        } else {
            center = true;
        }
    }

    boolean found = foundX || foundY || foundZ;

    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_CULL_FACE);
    RenderHelper.disableStandardItemLighting();

    GL11.glColor3f(1, 1, 1);
    GL11.glTranslatef((float) x, (float) y, (float) z);

    float scale = 1.001f;
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    GL11.glScalef(scale, scale, scale);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);

    bindTexture(TextureMap.locationBlocksTexture);

    RenderInfo renderBox = new RenderInfo();
    renderBox.texture = BuildCraftTransport.instance.wireIconProvider
            .getIcon(state.wireMatrix.getWireIconIndex(color));

    // Z render

    if (minZ != CoreConstants.PIPE_MIN_POS || maxZ != CoreConstants.PIPE_MAX_POS || !found) {
        renderBox.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx,
                cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, minZ,
                cx == CoreConstants.PIPE_MIN_POS ? cx : cx + 0.05F,
                cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F, maxZ);
        RenderEntityBlock.INSTANCE.renderBlock(renderBox, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord,
                pipe.zCoord, true, true);
    }

    // X render

    if (minX != CoreConstants.PIPE_MIN_POS || maxX != CoreConstants.PIPE_MAX_POS || !found) {
        renderBox.setBounds(minX, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy,
                cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, maxX,
                cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F,
                cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F);
        RenderEntityBlock.INSTANCE.renderBlock(renderBox, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord,
                pipe.zCoord, true, true);
    }

    // Y render

    if (minY != CoreConstants.PIPE_MIN_POS || maxY != CoreConstants.PIPE_MAX_POS || !found) {
        renderBox.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, minY,
                cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz,
                cx == CoreConstants.PIPE_MIN_POS ? cx : cx + 0.05F, maxY,
                cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F);
        RenderEntityBlock.INSTANCE.renderBlock(renderBox, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord,
                pipe.zCoord, true, true);
    }

    if (center || !found) {
        renderBox.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx,
                cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy,
                cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz,
                cx == CoreConstants.PIPE_MIN_POS ? cx : cx + 0.05F,
                cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F,
                cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F);
        RenderEntityBlock.INSTANCE.renderBlock(renderBox, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord,
                pipe.zCoord, true, true);
    }

    RenderHelper.enableStandardItemLighting();

    GL11.glPopAttrib();
    GL11.glPopMatrix();
}

From source file:buildcraft.transport.render.PipeRendererTESR.java

License:Minecraft Mod Public

private void pipeGateRender(TileGenericPipe pipe, double x, double y, double z) {
    GL11.glPushMatrix();// ww  w. j a  v  a 2 s .c  om
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    //      GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_CULL_FACE);
    //      GL11.glDisable(GL11.GL_TEXTURE_2D);
    RenderHelper.disableStandardItemLighting();

    GL11.glColor3f(1, 1, 1);
    GL11.glTranslatef((float) x, (float) y, (float) z);

    bindTexture(TextureMap.locationBlocksTexture);

    IIcon iconLogic;
    if (pipe.renderState.isGateLit()) {
        iconLogic = pipe.pipe.gate.logic.getIconLit();
    } else {
        iconLogic = pipe.pipe.gate.logic.getIconDark();
    }

    float translateCenter = 0;

    // Render base gate
    renderGate(pipe, iconLogic, 0, 0.1F, 0, 0);

    float pulseStage = pipe.pipe.gate.getPulseStage() * 2F;

    if (pipe.renderState.isGatePulsing() || pulseStage != 0) {
        // Render pulsing gate
        float amplitude = 0.10F;
        float start = 0.01F;

        if (pulseStage < 1) {
            translateCenter = (pulseStage * amplitude) + start;
        } else {
            translateCenter = amplitude - ((pulseStage - 1F) * amplitude) + start;
        }

        renderGate(pipe, iconLogic, 0, 0.13F, translateCenter, translateCenter);
    }

    IIcon materialIcon = pipe.pipe.gate.material.getIconBlock();
    if (materialIcon != null) {
        renderGate(pipe, materialIcon, 1, 0.13F, translateCenter, translateCenter);
    }

    for (IGateExpansion expansion : pipe.pipe.gate.expansions.keySet()) {
        renderGate(pipe, expansion.getOverlayBlock(), 2, 0.13F, translateCenter, translateCenter);
    }

    RenderHelper.enableStandardItemLighting();

    GL11.glPopAttrib();
    GL11.glPopMatrix();
}

From source file:buildcraft.transport.render.PipeRendererTESR.java

License:Minecraft Mod Public

private void renderPower(Pipe<PipeTransportPower> pipe, double x, double y, double z) {
    initializeDisplayPowerList(pipe.container.getWorldObj());

    PipeTransportPower pow = pipe.transport;

    GL11.glPushMatrix();//from www  .  ja v  a  2  s .c o  m
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glDisable(GL11.GL_LIGHTING);
    //      GL11.glEnable(GL11.GL_BLEND);

    GL11.glTranslatef((float) x, (float) y, (float) z);

    bindTexture(TextureMap.locationBlocksTexture);

    int[] displayList = pow.overload > 0 ? displayPowerListOverload : displayPowerList;

    for (int side = 0; side < 6; ++side) {
        GL11.glPushMatrix();

        GL11.glTranslatef(0.5F, 0.5F, 0.5F);
        GL11.glRotatef(angleY[side], 0, 1, 0);
        GL11.glRotatef(angleZ[side], 0, 0, 1);
        float scale = 1.0F - side * 0.0001F;
        GL11.glScalef(scale, scale, scale);
        GL11.glTranslatef(-0.5F, -0.5F, -0.5F);

        short stage = pow.clientDisplayPower[side];
        if (stage >= 1) {
            if (stage < displayList.length) {
                GL11.glCallList(displayList[stage]);
            } else {
                GL11.glCallList(displayList[displayList.length - 1]);
            }
        }

        GL11.glPopMatrix();
    }

    /*bindTexture(STRIPES_TEXTURE);
            
    for (int side = 0; side < 6; side += 2) {
       if (pipe.container.isPipeConnected(ForgeDirection.values()[side])) {
    GL11.glPushMatrix();
            
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
            
    GL11.glRotatef(angleY[side], 0, 1, 0);
    GL11.glRotatef(angleZ[side], 0, 0, 1);
            
    float scale = 1.0F - side * 0.0001F;
    GL11.glScalef(scale, scale, scale);
            
    float movement = (0.50F) * pipe.transport.getPistonStage(side / 2);
    GL11.glTranslatef(-0.25F - 1F / 16F - movement, -0.5F, -0.5F);
            
    // float factor = (float) (1.0 / 256.0);
    float factor = (float) (1.0 / 16.0);
    box.render(factor);
    GL11.glPopMatrix();
       }
    }*/

    GL11.glPopAttrib();
    GL11.glPopMatrix();
}