Example usage for org.lwjgl.opengl GL11 glTranslatef

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

Introduction

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

Prototype

public static native void glTranslatef(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y,
        @NativeType("GLfloat") float z);

Source Link

Document

Manipulates the current matrix with a translation matrix along the x-, y- and z- axes.

Usage

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

License:Minecraft Mod Public

private void doRender(EntityRobot robot, double x, double y, double z) {
    GL11.glPushMatrix();//ww  w .j a  v a  2s .  c  o  m
    GL11.glTranslated(x, y, z);

    if (robot.getStackInSlot(0) != null) {
        GL11.glPushMatrix();
        GL11.glTranslatef(-0.125F, 0, -0.125F);
        doRenderItem(robot.getStackInSlot(0));
        GL11.glPopMatrix();
    }

    if (robot.getStackInSlot(1) != null) {
        GL11.glPushMatrix();
        GL11.glTranslatef(+0.125F, 0, -0.125F);
        doRenderItem(robot.getStackInSlot(1));
        GL11.glPopMatrix();
    }

    if (robot.getStackInSlot(2) != null) {
        GL11.glPushMatrix();
        GL11.glTranslatef(+0.125F, 0, +0.125F);
        doRenderItem(robot.getStackInSlot(2));
        GL11.glPopMatrix();
    }

    if (robot.getStackInSlot(3) != null) {
        GL11.glPushMatrix();
        GL11.glTranslatef(-0.125F, 0, +0.125F);
        doRenderItem(robot.getStackInSlot(3));
        GL11.glPopMatrix();
    }

    if (robot.itemInUse != null) {
        GL11.glPushMatrix();

        GL11.glRotatef((float) (-robot.itemAngle1 / (2 * Math.PI) * 360) + 180, 0, 1, 0);
        GL11.glRotatef((float) (robot.itemAngle2 / (2 * Math.PI) * 360), 0, 0, 1);

        if (robot.itemActive) {
            long newDate = new Date().getTime();
            robot.itemActiveStage = (robot.itemActiveStage + (newDate - robot.lastUpdateTime) / 10) % 45;
            GL11.glRotatef(robot.itemActiveStage, 0, 0, 1);
            robot.lastUpdateTime = newDate;
        }

        GL11.glTranslatef(-0.4F, 0, 0);
        GL11.glRotatef(-45F + 180F, 0, 1, 0);
        GL11.glScalef(0.8F, 0.8F, 0.8F);

        ItemStack itemstack1 = robot.itemInUse;

        if (itemstack1.getItem().requiresMultipleRenderPasses()) {
            for (int k = 0; k < itemstack1.getItem().getRenderPasses(itemstack1.getItemDamage()); ++k) {
                RenderUtils.setGLColorFromInt(itemstack1.getItem().getColorFromItemStack(itemstack1, k));
                this.renderManager.itemRenderer.renderItem(robot, itemstack1, k);
            }
        } else {
            RenderUtils.setGLColorFromInt(itemstack1.getItem().getColorFromItemStack(itemstack1, 0));
            this.renderManager.itemRenderer.renderItem(robot, itemstack1, 0);
        }

        GL11.glColor3f(1, 1, 1);
        GL11.glPopMatrix();
    }

    if (robot.laser.isVisible) {
        robot.laser.head.x = robot.posX;
        robot.laser.head.y = robot.posY;
        robot.laser.head.z = robot.posZ;

        RenderLaser.doRenderLaser(renderManager.renderEngine, robot.laser, EntityLaser.LASER_TEXTURES[1]);
    }

    if (robot.getTexture() != null) {
        renderManager.renderEngine.bindTexture(robot.getTexture());
        doRenderRobot(1F / 16F, renderManager.renderEngine);
    }

    GL11.glPopMatrix();
}

From source file:buildcraft.silicon.SiliconRenderBlock.java

License:Minecraft Mod Public

@Override
public void renderInventoryBlock(Block block, int i, int j, RenderBlocks renderblocks) {
    block.setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS,
            CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);

    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1, 4F / 16F, 1);
    renderblocks.setRenderBoundsFromBlock(block);
    renderBlockInInv(renderblocks, block, 0);

    block.setBlockBounds(5F / 16F, 4F / 16F, 5F / 16F, 11F / 16F, 13F / 16F, 11F / 16F);
    renderblocks.setRenderBoundsFromBlock(block);
    renderBlockInInv(renderblocks, block, 1);

    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}

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

License:Minecraft Mod Public

private void renderFacadeItem(RenderBlocks render, ItemStack item, float translateX, float translateY,
        float translateZ) {
    if (lastTime < System.currentTimeMillis()) {
        renderState = !renderState;/* ww  w.  j a  v a 2  s .c  om*/
        lastTime = System.currentTimeMillis() + 1000L;
    }

    Block block = null;
    int decodedMeta = 0;

    int type = ItemFacade.getType(item);
    Block[] blocks = ItemFacade.getBlocks(item);
    int[] metas = ItemFacade.getMetaValues(item);
    if (blocks == null || blocks.length == 0 || metas == null || metas.length != blocks.length) {
        return;
    }

    if (type == ItemFacade.TYPE_BASIC || (type == ItemFacade.TYPE_PHASED && renderState)) {
        block = blocks[0];
        decodedMeta = metas[0];
    } else if (type == ItemFacade.TYPE_PHASED && blocks.length >= 2) {
        block = blocks[1];
        decodedMeta = metas[1];
    }

    try {
        int color = item.getItem().getColorFromItemStack(new ItemStack(block, 1, decodedMeta), 0);
        RenderUtils.setGLColorFromInt(color);
    } catch (Throwable error) {
    }

    Tessellator tessellator = Tessellator.instance;

    if (block == null) {
        return;
    }

    if (tryGetBlockIcon(block, 0, decodedMeta) == null) {
        return;
    }

    // Render Facade
    GL11.glPushMatrix();

    // Enable glBlending for transparency
    if (block.getRenderBlockPass() > 0) {
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        GL11.glEnable(GL11.GL_BLEND);
        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    }

    block.setBlockBounds(0F, 0F, 1F - 1F / 16F, 1F, 1F, 1F);
    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, tryGetBlockIcon(block, 0, decodedMeta));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 1, decodedMeta));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1F);
    render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 2, decodedMeta));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 3, decodedMeta));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(-1F, 0.0F, 0.0F);
    render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 4, decodedMeta));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
    render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 5, decodedMeta));
    tessellator.draw();
    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);

    // Disable blending
    if (block.getRenderBlockPass() > 0) {
        GL11.glDisable(GL11.GL_BLEND);
    }

    GL11.glPopMatrix();

    // Render StructurePipe
    block = BuildCraftTransport.genericPipeBlock;
    IIcon textureID = BuildCraftTransport.instance.pipeIconProvider
            .getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure pipe

    block.setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS,
            CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS - 1F / 16F);
    block.setBlockBoundsForItemRender();
    render.setRenderBoundsFromBlock(block);
    GL11.glTranslatef(translateX, translateY, translateZ + 0.25F);

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, -0F, 0.0F);
    render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, textureID);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, textureID);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1F);
    render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, textureID);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, textureID);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(-1F, 0.0F, 0.0F);
    render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, textureID);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
    render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, textureID);
    tessellator.draw();
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}

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

License:Minecraft Mod Public

private void renderAsEntity(ItemStack stack, EntityItem entity) {
    GL11.glPushMatrix();/*from   w w  w.j a  v  a  2s .c om*/
    byte iterations = 1;
    if (stack.stackSize > 1) {
        iterations = 2;
    }
    if (stack.stackSize > 15) {
        iterations = 3;
    }
    if (stack.stackSize > 31) {
        iterations = 4;
    }

    Random rand = new Random(187L);

    float offsetZ = 0.0625F + 0.021875F;

    GL11.glRotatef(((entity.age + 1.0F) / 20.0F + entity.hoverStart) * (180F / (float) Math.PI), 0.0F, 1.0F,
            0.0F);
    GL11.glTranslatef(-0.5F, -0.25F, -(offsetZ * iterations / 2.0F));

    for (int count = 0; count < iterations; ++count) {
        if (count > 0) {
            float offsetX = (rand.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
            float offsetY = (rand.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
            float z = (rand.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
            GL11.glTranslatef(offsetX, offsetY, offsetZ);
        } else {
            GL11.glTranslatef(0f, 0f, offsetZ);
        }

        renderIn3D(stack);
    }
    GL11.glPopMatrix();
}

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

License:Minecraft Mod Public

private void renderAsEntityFlat(ItemStack stack) {
    GL11.glPushMatrix();/* w  ww  .  j av a2  s.c  o m*/
    byte iterations = 1;
    if (stack.stackSize > 1) {
        iterations = 2;
    }
    if (stack.stackSize > 15) {
        iterations = 3;
    }
    if (stack.stackSize > 31) {
        iterations = 4;
    }

    Random rand = new Random(187L);

    for (int ii = 0; ii < iterations; ++ii) {
        GL11.glPushMatrix();
        GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(180 - RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F);

        if (ii > 0) {
            float var12 = (rand.nextFloat() * 2.0F - 1.0F) * 0.3F;
            float var13 = (rand.nextFloat() * 2.0F - 1.0F) * 0.3F;
            float var14 = (rand.nextFloat() * 2.0F - 1.0F) * 0.3F;
            GL11.glTranslatef(var12, var13, var14);
        }

        GL11.glTranslatef(0.5f, 0.8f, 0);
        GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
        GL11.glScalef(1f / 16f, 1f / 16f, 1);

        render(ItemRenderType.ENTITY, stack);
        GL11.glPopMatrix();
    }
    GL11.glPopMatrix();
}

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

License:Minecraft Mod Public

private void render(ItemRenderType type, ItemStack stack) {
    GL11.glPushMatrix();/*from ww  w  . j  a  v a 2  s  . c o  m*/
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_ALPHA_TEST); // In certain cases gets disabled by this point
    IIcon icon = ItemGate.getLogic(stack).getIconItem();
    renderItem.renderIcon(0, 0, icon, 16, 16);

    if (type == ItemRenderType.ENTITY) {
        GL11.glTranslatef(0, 0, -0.01f);
    }

    icon = ItemGate.getMaterial(stack).getIconItem();
    if (icon != null) {
        renderItem.renderIcon(0, 0, icon, 16, 16);
    }

    for (IGateExpansion expansion : ItemGate.getInstalledExpansions(stack)) {
        icon = expansion.getOverlayItem();
        if (icon != null) {
            renderItem.renderIcon(0, 0, icon, 16, 16);
        }
    }
    GL11.glEnable(GL11.GL_LIGHTING);
    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);/* w w  w .  ja va2  s.  c om*/

    // 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  ava2s  .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();/*from w w  w. j a  va2  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 renderGate(TileGenericPipe tile, IIcon icon, int layer, float trim, float translateCenter,
        float extraDepth) {
    PipeRenderState state = tile.renderState;

    RenderInfo renderBox = new RenderInfo();
    renderBox.texture = icon;/*from www.j  a  v a  2  s.c o m*/

    float[][] zeroState = new float[3][2];
    float min = CoreConstants.PIPE_MIN_POS + trim / 2F;
    float max = CoreConstants.PIPE_MAX_POS - trim / 2F;

    // X START - END
    zeroState[0][0] = min;
    zeroState[0][1] = max;
    // Y START - END
    zeroState[1][0] = CoreConstants.PIPE_MIN_POS - 0.10F - 0.001F * layer;
    zeroState[1][1] = CoreConstants.PIPE_MIN_POS + 0.001F + 0.01F * layer + extraDepth;
    // Z START - END
    zeroState[2][0] = min;
    zeroState[2][1] = max;

    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
        if (shouldRenderNormalPipeSide(state, direction)) {
            GL11.glPushMatrix();

            float xt = direction.offsetX * translateCenter, yt = direction.offsetY * translateCenter,
                    zt = direction.offsetZ * translateCenter;

            GL11.glTranslatef(xt, yt, zt);

            float[][] rotated = MatrixTranformations.deepClone(zeroState);
            MatrixTranformations.transform(rotated, direction);

            if (layer != 0) {
                renderBox.setRenderSingleSide(direction.ordinal());
            }
            renderBox.setBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1],
                    rotated[2][1]);
            RenderEntityBlock.INSTANCE.renderBlock(renderBox, tile.getWorldObj(), 0, 0, 0, tile.xCoord,
                    tile.yCoord, tile.zCoord, true, true);
            GL11.glPopMatrix();
        }
    }
}