Example usage for org.lwjgl.opengl GL11 glTranslated

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

Introduction

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

Prototype

public static native void glTranslated(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y,
        @NativeType("GLdouble") double z);

Source Link

Document

Double version of #glTranslatef Translatef .

Usage

From source file:com.bluepowermod.client.render.RenderLamp.java

License:Open Source License

/******* TESR ***********/
@Override/*ww w.  j a va  2 s .c om*/
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) {

    if (pass != 0) {
        BlockLamp bLamp = (BlockLamp) te.getBlockType();
        int power = ((TileLamp) te).getPower();

        int color = bLamp.getColor(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord);

        int redMask = 0xFF0000, greenMask = 0xFF00, blueMask = 0xFF;
        int r = (color & redMask) >> 16;
        int g = (color & greenMask) >> 8;
        int b = (color & blueMask);

        if (bLamp.isInverted()) {
            power = 15 - power;
        }
        // power = 15;
        Vec3i vector = new Vec3i(te);
        Vec3dCube box = new Vec3dCube(-0.5, -0.5, -0.5, 0.5, 0.5, 0.5).expand(0.8 / 16D);

        boolean[] renderFaces = new boolean[] { true, true, true, true, true, true };

        for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
            Vec3i v = vector.getRelative(d);
            Block bl = v.getBlock();
            if (bl instanceof BlockLamp
                    && ((BlockLamp) bl).getPower(v.getWorld(), v.getX(), v.getY(), v.getZ()) > 0) {
                if (d.offsetX < 0) {
                    box.getMin().setX(-0.5);
                    renderFaces[2] = false;
                } else if (d.offsetY < 0) {
                    box.getMin().setY(-0.5);
                    renderFaces[1] = false;
                } else if (d.offsetZ < 0) {
                    box.getMin().setZ(-0.5);
                    renderFaces[4] = false;
                } else if (d.offsetX > 0) {
                    box.getMax().setX(0.5);
                    renderFaces[3] = false;
                } else if (d.offsetY > 0) {
                    box.getMax().setY(0.5);
                    renderFaces[0] = false;
                } else if (d.offsetZ > 0) {
                    box.getMax().setZ(0.5);
                    renderFaces[5] = false;
                }
            }
        }

        box.getMin().add(0.5, 0.5, 0.5);
        box.getMax().add(0.5, 0.5, 0.5);

        GL11.glTranslated(x, y, z);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        // GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glBegin(GL11.GL_QUADS);
        double powerDivision = power / 18D;
        com.bluepowermod.client.render.RenderHelper.drawColoredCube(box, r / 256D, g / 256D, b / 256D,
                powerDivision * 0.625D, renderFaces);
        GL11.glEnd();
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        // GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        GL11.glDisable(GL11.GL_BLEND);

        GL11.glTranslated(-x, -y, -z);
    }
}

From source file:com.bluepowermod.client.render.RenderLamp.java

License:Open Source License

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

    GL11.glPushMatrix();/*from   w w w.  jav a 2  s .  c o m*/
    {
        switch (type) {
        case ENTITY:
            GL11.glTranslated(-0.5, -0.5, -0.5);
            break;
        case EQUIPPED:
            break;
        case EQUIPPED_FIRST_PERSON:
            GL11.glTranslated(0, -0.1, 0);
            break;
        case INVENTORY:
            GL11.glTranslated(0, -0.1, 0);
            break;
        default:
            break;
        }

        BlockLamp block = (BlockLamp) Block.getBlockFromItem(item.getItem());
        int redMask = 0xFF0000, greenMask = 0xFF00, blueMask = 0xFF;
        int r = (block.getColor() & redMask) >> 16;
        int g = (block.getColor() & greenMask) >> 8;
        int b = (block.getColor() & blueMask);

        Vec3dCube cube = new Vec3dCube(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);

        Tessellator t = Tessellator.instance;
        t.startDrawingQuads();
        t.setColorOpaque(r, g, b);

        RenderHelper h = RenderHelper.instance;
        h.reset();
        h.setColor(block.getColor());
        h.renderBox(cube, block.isInverted() ? BlockLamp.on : BlockLamp.off);
        h.reset();

        t.draw();
        if (block.isInverted()) {
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
            // GL11.glAlphaFunc(GL11.GL_EQUAL, (power / 15F) * 1F);
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            GL11.glDisable(GL11.GL_LIGHTING);
            // GL11.glDisable(GL11.GL_CULL_FACE);
            GL11.glDepthMask(false);
            GL11.glBegin(GL11.GL_QUADS);
            com.bluepowermod.client.render.RenderHelper.drawColoredCube(cube.clone().expand(0.8 / 16D),
                    r / 256D, g / 256D, b / 256D, 0.625D);
            GL11.glEnd();
            GL11.glDepthMask(true);
            GL11.glEnable(GL11.GL_CULL_FACE);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            // GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
            GL11.glDisable(GL11.GL_BLEND);
        }
    }
    GL11.glPopMatrix();
}

From source file:com.bluepowermod.client.render.RenderWindmill.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float var8) {
    TileWindmill mill = (TileWindmill) tile.getWorldObj().getTileEntity(tile.xCoord, tile.yCoord, tile.zCoord);

    GL11.glPushMatrix();//  w ww. j ava  2 s  .  c  om
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glTranslated(x + .5, y, z + .5);
    GL11.glScaled(.15, .15, .15);
    this.bindTexture(textureLocation);

    GL11.glRotated(mill.turbineTick, 0, 1, 0);
    model.renderAll();
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}

From source file:com.bluepowermod.part.gate.GateCounter.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)//ww  w .  j  a  v a2s .  c om
public void renderTop(float frame) {

    renderTop("left", left().getInput() > 0);
    renderTop("right", right().getInput() > 0);
    renderTop("centerleft", left().getInput() > 0);

    RenderHelper.renderDigitalRedstoneTorch(-2 / 16D, 2D / 8D, 0, 13D / 16D, true);
    RenderHelper.renderDigitalRedstoneTorch(0, 2D / 8D, -5D / 16D, 8D / 16D, count == 0);
    RenderHelper.renderDigitalRedstoneTorch(0, 2D / 8D, 5D / 16D, 8D / 16D, count == max);
    GL11.glPushMatrix();
    {
        GL11.glTranslated(2 / 16D, 0, 0);
        double min = 0.555;
        double max = 0.385;

        double angle = min + max * (count / (double) this.max);

        RenderHelper.renderPointer(-4 / 16D, 7 / 16D, 0, -angle + 0.5);
    }
    GL11.glPopMatrix();
}

From source file:com.bluepowermod.part.gate.GateRSLatch.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)// w ww  .j a va  2  s  .c o m
public void renderTop(float frame) {

    if (mode % 2 == 1) {
        GL11.glPushMatrix();
        GL11.glTranslated(0.5, 0, 0.5);
        GL11.glScaled(-1, 1, 1);
        GL11.glTranslated(-0.5, 0, -0.5);

        GL11.glDisable(GL11.GL_CULL_FACE);
    }

    Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(
            Refs.MODID + ":textures/blocks/gates/" + getTextureName() + (mode > 1 ? "2" : "") + "/base.png"));
    this.renderTop();

    Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(Refs.MODID
            + ":textures/blocks/gates/" + getTextureName() + (mode > 1 ? "2" : "") + "/left_"
            + ((mode % 2 == 0 ? left().getInput() > 0 : right().getInput() > 0) ? "on" : "off") + ".png"));
    renderTop();
    Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(Refs.MODID
            + ":textures/blocks/gates/" + getTextureName() + (mode > 1 ? "2" : "") + "/right_"
            + ((mode % 2 == 0 ? right().getInput() > 0 : left().getInput() > 0) ? "on" : "off") + ".png"));
    renderTop();
    if (mode > 1) {
        Minecraft.getMinecraft().renderEngine
                .bindTexture(new ResourceLocation(Refs.MODID + ":textures/blocks/gates/" + getTextureName()
                        + "2/front" + "_" + (front().getInput() > 0 ? "on" : "off") + ".png"));
        renderTop();
        Minecraft.getMinecraft().renderEngine
                .bindTexture(new ResourceLocation(Refs.MODID + ":textures/blocks/gates/" + getTextureName()
                        + "2/back" + "_" + (back().getInput() > 0 ? "on" : "off") + ".png"));
        renderTop();
    }

    RenderHelper.renderDigitalRedstoneTorch(1D / 8D, 3D / 16D, -2D / 8D, 9D / 16D, front().getInput() == 0);
    RenderHelper.renderDigitalRedstoneTorch(-1D / 8D, 3D / 16D, 2D / 8D, 9D / 16D, back().getInput() == 0);

    if (mode % 2 == 1) {
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glPopMatrix();
    }
}

From source file:com.bluepowermod.part.gate.GateTransparentLatch.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)//from w  ww.ja va  2s  .  c  o  m
public void renderTop(float frame) {

    if (mirrored) {
        GL11.glPushMatrix();
        GL11.glTranslated(0.5, 0, 0.5);
        GL11.glScaled(-1, 1, 1);
        GL11.glTranslated(-0.5, 0, -0.5);

        GL11.glDisable(GL11.GL_CULL_FACE);
    }

    renderTop("front", front());
    renderTop("left", mirrored ? right() : left());
    renderTop("back", back());
    renderTop("leftcenter", back().getInput() == 0);
    RenderHelper.renderDigitalRedstoneTorch(4 / 16D, 3D / 16D, -4 / 16D, 8D / 16D, back().getInput() == 0);
    RenderHelper.renderDigitalRedstoneTorch(4 / 16D, 3D / 16D, 1 / 16D, 8D / 16D,
            back().getInput() > 0 && front().getInput() == 0);
    RenderHelper.renderDigitalRedstoneTorch(1 / 16D, 3D / 16D, 1 / 16D, 8D / 16D,
            back().getInput() == 0 && front().getInput() == 0);
    RenderHelper.renderDigitalRedstoneTorch(-4 / 16D, 2D / 16D, 1 / 16D, 10D / 16D, front().getInput() > 0);
    RenderHelper.renderDigitalRedstoneTorch(2 / 16D, 2D / 16D, 6 / 16D, 10D / 16D, front().getInput() > 0);
    renderTop("right", mirrored ? left() : right());

    if (mirrored) {
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glPopMatrix();
    }
}

From source file:com.bluepowermod.part.gate.ic.IntegratedCircuit.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)/*www  . j  a va  2s. c o m*/
protected void renderTop(float frame) {

    renderTop("front", front());
    renderTop("left", left());
    renderTop("back", back());
    renderTop("right", right());
    Vec3d loc = new Vec3d(0, 0, 0);

    RenderHelper rh = RenderHelper.instance;
    rh.reset();
    RenderBlocks rb = RenderBlocks.getInstance();

    GL11.glPushMatrix();
    {
        GL11.glTranslated(0, 2 / 16D - 1 / 16D * (1.0 / getCircuitWidth()), 0);
        GL11.glNormal3d(0, 1, 0);
        int size = getCircuitWidth();
        double textureMaxUV = 0.5 * size;

        Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(
                Refs.MODID + ":textures/blocks/gates/" + getTextureName() + "/checkerboard.png"));
        GL11.glBegin(GL11.GL_QUADS);
        {
            com.bluepowermod.client.render.RenderHelper.addVertexWithTexture(BORDER_WIDTH, 0, BORDER_WIDTH, 0,
                    0);
            com.bluepowermod.client.render.RenderHelper.addVertexWithTexture(BORDER_WIDTH, 0, 1 - BORDER_WIDTH,
                    0, textureMaxUV);
            com.bluepowermod.client.render.RenderHelper.addVertexWithTexture(1 - BORDER_WIDTH, 0,
                    1 - BORDER_WIDTH, textureMaxUV, textureMaxUV);
            com.bluepowermod.client.render.RenderHelper.addVertexWithTexture(1 - BORDER_WIDTH, 0, BORDER_WIDTH,
                    textureMaxUV, 0);
        }
        GL11.glEnd();
    }
    GL11.glPopMatrix();

    GL11.glPushMatrix();
    {
        GL11.glTranslated(BORDER_WIDTH, 2 / 16D + 0.001D, BORDER_WIDTH);
        GL11.glScaled((1 - 2 * BORDER_WIDTH) / 1, 1, (1 - 2 * BORDER_WIDTH) / 1);

        GL11.glScaled(1.0 / getCircuitWidth(), 1.0 / getCircuitWidth(), 1.0 / getCircuitWidth());
        GL11.glTranslated(0, -2 / 16D, 0);
        for (GateBase[] gateArray : gates) {
            GL11.glPushMatrix();
            for (GateBase gate : gateArray) {
                if (gate != null) {
                    GL11.glPushMatrix();
                    gate.renderDynamic(loc, frame, 0);
                    GL11.glPopMatrix();

                    if (!isRenderingItem) {
                        // Static renderer
                        GL11.glPushMatrix();
                        {
                            Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
                            Tessellator.instance.startDrawingQuads();
                            gate.renderStatic(new Vec3i(gate), rh, rb, 0);
                            Tessellator.instance.draw();
                        }
                        GL11.glPopMatrix();
                    }

                    rh.reset();
                }
                GL11.glTranslated(0, 0, 1);
            }
            GL11.glPopMatrix();
            GL11.glTranslated(1, 0, 0);
        }
    }
    GL11.glPopMatrix();
}

From source file:com.bluepowermod.part.tube.Accelerator.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)//from  ww w.j  a  va2  s  .com
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

    GL11.glPushMatrix();
    {
        GL11.glTranslated(0, -0.125, 0);

        Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
        rotation = ForgeDirection.UP;
        renderDynamic(new Vec3d(0, 0, 0), 0, 0);
    }
    GL11.glPopMatrix();
}

From source file:com.bluepowermod.part.tube.PneumaticTube.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)/*from   ww w.j  av  a2 s  .c  o m*/
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

    GL11.glPushMatrix();
    GL11.glTranslated(0, -0.125D, 0);

    Tessellator t = Tessellator.instance;
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
    t.startDrawingQuads();

    connections[ForgeDirection.DOWN.ordinal()] = true;
    connections[ForgeDirection.UP.ordinal()] = true;

    RenderHelper renderer = RenderHelper.instance;
    renderer.fullReset();
    RenderBlocks rb = new RenderBlocks();

    renderStatic(new Vec3i(0, 0, 0), renderer, rb, 0);

    t.draw();
    renderSide();
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);

    GL11.glPopMatrix();
}

From source file:com.bluepowermod.part.tube.TubeLogic.java

License:Open Source License

@SideOnly(Side.CLIENT)
public void renderDynamic(Vec3d pos, float partialTick) {

    GL11.glPushMatrix();//  w  w w .j  a v  a2 s  . c  om
    GL11.glTranslated(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
    for (TubeStack stack : tubeStacks) {
        stack.render(partialTick);
    }
    GL11.glPopMatrix();
}