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:de.mineformers.robots.client.renderer.entity.RenderRobot.java

License:LGPL

@Override
protected void renderModel(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4,
        float par5, float par6, float par7) {
    super.renderModel(par1EntityLivingBase, par2, par3, par4, par5, par6, par7);
    EntityRobot robot = ((EntityRobot) par1EntityLivingBase);
    RenderHelper.bindTexture(robot.getChipset().getHeadTexture());
    ((ModelRobot) mainModel).renderEye(false);
    Tessellator tessellator = Tessellator.instance;
    GL11.glPushMatrix();/*from  w  w  w . j  a  v a  2s .  c o  m*/

    GL11.glTranslatef(0, 0.35F, -0.1F);
    GL11.glRotatef(180, 1, 0, 0);
    GL11.glScalef(0.5F, 0.5F, 1F);
    ItemStack itemstack = PrivateRobotHelper.createModuleStack(robot.getModule());
    Icon icon = ModItems.module.getIcon(itemstack, 0);
    float f4 = icon.getMinU();
    float f5 = icon.getMaxU();
    float f6 = icon.getMinV();
    float f7 = icon.getMaxV();
    float f9 = 0.5F;
    float f10 = 0.25F;
    float f12 = 0.0625F;
    float f11 = 0.021875F;

    int j = itemstack.stackSize;
    byte b0 = customRenderItem.getMiniItemCount(itemstack);

    GL11.glTranslatef(-f9, -f10, -((f12 + f11) * (float) b0 / 2.0F));

    for (int k = 0; k < b0; ++k) {
        // Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug...
        GL11.glTranslatef(0f, 0f, f12 + f11);

        if (itemstack.getItemSpriteNumber() == 0) {
            RenderHelper.bindTexture(TextureMap.locationBlocksTexture);
        } else {
            RenderHelper.bindTexture(TextureMap.locationItemsTexture);
        }

        GL11.glColor4f(1, 1, 1, 1.0F);
        GL11.glRotatef(180, 0, 1, 0);
        GL11.glTranslatef(-1, 0, 0.05F);
        ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, icon.getIconWidth(), icon.getIconHeight(),
                f12);

        if (itemstack.hasEffect(0)) {
            GL11.glDepthFunc(GL11.GL_EQUAL);
            GL11.glDisable(GL11.GL_LIGHTING);
            RenderManager.instance.renderEngine.bindTexture(RES_ITEM_GLINT);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
            float f13 = 0.76F;
            GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F);
            GL11.glMatrixMode(GL11.GL_TEXTURE);
            GL11.glPushMatrix();
            float f14 = 0.125F;
            GL11.glScalef(f14, f14, f14);
            float f15 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
            GL11.glTranslatef(f15, 0.0F, 0.0F);
            GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
            ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12);
            GL11.glPopMatrix();
            GL11.glPushMatrix();
            GL11.glScalef(f14, f14, f14);
            f15 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
            GL11.glTranslatef(-f15, 0.0F, 0.0F);
            GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
            ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12);
            GL11.glPopMatrix();
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glDepthFunc(GL11.GL_LEQUAL);
        }
    }

    GL11.glPopMatrix();
}

From source file:de.mineformers.robots.client.renderer.tileentity.TileFactoryControllerRenderer.java

License:LGPL

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTicks) {
    if (((TileFactoryController) tileentity).isValidMultiblock()) {
        GL11.glPushMatrix();//from   www .  ja  va 2  s.  c  om
        int i = 15728880;

        int j = i % 65536;
        int k = i / 65536;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j / 1.0F, (float) k / 1.0F);
        GL11.glTranslated(x + 0.5F, y + 0.65F, z + 0.5f);
        switch (((TileFactoryController) tileentity).getOrientation()) {
        case WEST:
            GL11.glRotatef(90, 0, 1, 0);
            break;
        case EAST:
            GL11.glRotatef(-90, 0, 1, 0);
            break;
        case SOUTH:
            GL11.glRotatef(180, 0, 1, 0);
            break;
        }
        GL11.glTranslatef(0, 0, -0.47F);
        GL11.glScalef(0.3F, 0.3F, 0.3F);
        GL11.glRotatef(180, 1, 0, 0);
        GL11.glRotatef(180, 0, 1, 0);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glColor4f(255F, 255F, 255F, 255F);
        this.bindTexture(robotTexture);
        robot.justRender();
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glPopMatrix();
    }
}

From source file:de.paleocrafter.netcraft.client.renderer.item.ItemArcPadRenderer.java

License:LGPL

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    GL11.glPushMatrix();/*from w  ww. ja  v a  2s  .  c o m*/
    FMLClientHandler.instance().getClient().renderEngine.bindTexture("/gui/items.png");
    Icon icon = item.getItem().getIcon(item, 0);

    Tessellator tessellator = Tessellator.instance;
    float f = icon.getMinU();
    float f1 = icon.getMaxU();
    float f2 = icon.getMinV();
    float f3 = icon.getMaxV();
    float f4 = 0.0F;
    float f5 = 0.3F;
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glTranslatef(-f4, -f5, 0.0F);
    float f6 = 1.5F;
    GL11.glScalef(f6, f6, f6);
    GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F);
    GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F);
    ItemRenderer.renderItemIn2D(tessellator, f1, f2, f, f3, icon.getSheetWidth(), icon.getSheetHeight(),
            0.0625F);
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
}

From source file:de.paleocrafter.pcraft.client.renderer.item.ItemDinoEggRenderer.java

License:LGPL

private void renderEgg(float x, float y, float z) {

    FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_EGG);
    GL11.glPushMatrix(); // start
    GL11.glTranslatef(x, y, z); // size
    GL11.glRotatef(180, 1, 0, 0);/*from  w ww  .  j ava2  s.c  om*/
    GL11.glRotatef(90, 0, 1, 0);
    modelDinoEgg.renderAll();
    GL11.glPopMatrix(); // end
}

From source file:de.paleocrafter.pcraft.client.renderer.item.ItemMachineRenderer.java

License:LGPL

private void renderAnalyzer(float x, float y, float z) {

    FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_ANALYZER);
    GL11.glPushMatrix(); // start
    GL11.glTranslatef(x, y, z); // size
    GL11.glRotatef(180, 1, 0, 0);/*from   w  w w  . ja va 2s  .  co  m*/
    GL11.glRotatef(90, 0, 1, 0);
    modelAnalyzer.renderAll(0);
    GL11.glPopMatrix(); // end
}

From source file:de.paleocrafter.pcraft.client.renderer.item.ItemMachineRenderer.java

License:LGPL

private void renderMicroscope(float x, float y, float z) {

    FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_MICROSCOPE);
    GL11.glPushMatrix(); // start
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glTranslatef(x, y, z); // size
    GL11.glScalef(0.5F, 0.5F, 0.5F);// w  w  w  .  j  ava2s  .co  m
    GL11.glRotatef(180, 1, 0, 0);
    modelMicroscope.renderAll();
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix(); // end
}

From source file:de.paleocrafter.pcraft.client.renderer.tileentity.TileEntityMachineRenderer.java

License:LGPL

private void renderAnalyzer(TileAnalyzer te, double x, double y, double z) {
    GL11.glPushMatrix();//from   w  w  w  . j a  v  a2 s . c o  m
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glTranslatef((float) x, (float) y + 2.0F, (float) z + 1.0F);
    GL11.glScalef(1.0F, -1.0F, -1.0F);
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);

    ForgeDirection direction = te.getOrientation();
    short angle = 0;

    if (direction != null) {
        if (direction == ForgeDirection.NORTH) {
            angle = 0;
        } else if (direction == ForgeDirection.SOUTH) {
            angle = 180;
        } else if (direction == ForgeDirection.WEST) {
            angle = -90;
        } else if (direction == ForgeDirection.EAST) {
            angle = 90;
        }
    }

    GL11.glRotatef(angle, 0.0F, 1.0F, 0.0F);

    FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_ANALYZER);
    modelAnalyzer.renderAll((int) Math.ceil(te.getProgress() / 10));
    if (te.getState() == 1) {
        FMLClientHandler.instance().getClient().renderEngine
                .bindTexture(Textures.MODEL_LASER + ((int) Math.ceil(te.getProgress() / 10)) + ".png");
        ModelRenderer laser = new ModelRenderer(modelAnalyzer, 0, 0);
        laser.addBox(-0.5F, 12.5F, -0.5F, 1, 10, 1);
        laser.setRotationPoint(0F, 0F, 0F);
        if (delta >= 0.9F) {
            Random rand = new Random();
            float val = 1F;
            float rotX = 0;
            float rotZ = 0;
            while (val > 0.07F) {
                val = rand.nextFloat();
            }
            rotX = val;
            val = 1F;
            while (val > 0.09F) {
                val = rand.nextFloat();
            }
            rotZ = val;
            switch (rand.nextInt(4)) {
            case 0:
                rotZ *= -1;
                break;
            case 1:
                rotX *= -1;
                break;
            case 3:
            case 4:
                rotX *= -1;
                rotZ *= -1;
                break;
            }
            te.setLaserRotX(rotX);
            te.setLaserRotZ(rotZ);
        }
        setRotation(laser, te.getLaserRotX(), 0F, te.getLaserRotZ());
        laser.setTextureSize(64, 32);
        laser.mirror = true;
        if (te.getFuelLevel() >= 2) {
            laser.render(0.0625F);
        }
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_FOSSIL);
        GL11.glTranslatef(-0.475F, 1.42F, 0.165F);
        GL11.glScalef(0.08F, 0.08F, 0.08F);
        GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
        new ModelFossil().render();
    }

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}

From source file:de.paleocrafter.pcraft.client.renderer.tileentity.TileEntityMachineRenderer.java

License:LGPL

private void renderMicroscope(TileMicroscope te, double x, double y, double z) {
    GL11.glPushMatrix();//from   w  ww .j av  a2s  .co m
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glTranslatef((float) x, (float) y + 2.0F, (float) z + 1.0F);
    GL11.glScalef(0.5F, -0.5F, -0.5F);
    GL11.glTranslatef(1F, 1F, 1F);

    ForgeDirection direction = te.getOrientation();
    short angle = 0;

    if (direction != null) {
        if (direction == ForgeDirection.NORTH) {
            angle = -90;
        } else if (direction == ForgeDirection.SOUTH) {
            angle = 90;
        } else if (direction == ForgeDirection.WEST) {
            angle = 180;
        } else if (direction == ForgeDirection.EAST) {
            angle = 0;
        }
    }

    GL11.glRotatef(angle, 0.0F, 1.0F, 0.0F);

    FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_MICROSCOPE);
    modelMicroscope.renderAll();

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}

From source file:de.sanandrew.core.manpack.mod.client.gui.GuiUpdateDetails.java

License:Creative Commons License

@Override
public void drawScreen(int mouseX, int mouseY, float partTicks) {
    int xPos = (this.width - 276) / 2;
    int yPos = (this.height - 240) / 2;
    int listX = 16;
    int listY = 60;
    int listWidth = 244;
    int listHeight = 150;
    int listTextY = 5;
    String s;/*from  ww  w  .  jav  a 2 s . c  om*/
    boolean isLeftMBDown = Mouse.isButtonDown(0);

    int scrollX = xPos + listX + listWidth - 4;
    int scrollY = yPos + listY;
    if (!this.isScrolling && isLeftMBDown && mouseX >= scrollX && mouseY >= scrollY && mouseX < scrollX + 4
            && mouseY < scrollY + listHeight) {
        this.isScrolling = this.scrollMax > 0.0F;
    }

    if (!isLeftMBDown) {
        this.isScrolling = false;
    }

    if (this.isScrolling) {
        this.scrollAmount = Math.min(this.scrollMax,
                Math.max(0.0F, (mouseY - scrollY - 5) / (listHeight - 10.0F)) * scrollMax);
    }

    this.drawDefaultBackground();

    GL11.glEnable(GL11.GL_BLEND);
    OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
    Gui.drawRect(xPos, 0, xPos + 276, this.height, 0x80000000);
    GuiUtils.drawGradientRect(xPos, 0, xPos + 5, this.height, 0xFF000000, 0x00000000, this.zLevel);
    GuiUtils.drawGradientRect(xPos + 271, 0, xPos + 276, this.height, 0x00000000, 0xFF000000, this.zLevel);

    GL11.glPushMatrix();
    GL11.glTranslatef(16.0F, 4.0F, 0.0F);
    GL11.glScalef(1.5F, 1.5F, 1.0F);
    GL11.glTranslatef(xPos / 1.5F - xPos, yPos / 1.5F - yPos, 0.0F);
    this.fontRendererObj.drawString(this.manager.getModName(), xPos, yPos, 0xFFFFFFFF);
    GL11.glPopMatrix();

    s = "Currently installed version";
    this.fontRendererObj.drawString(s, xPos + 16, yPos + 22, 0xFFA0A0A0);
    Gui.drawRect(xPos + this.fontRendererObj.getStringWidth(s) + 18, yPos + 26, xPos + 160, yPos + 27,
            0xFF606060);
    s = "Updated version";
    this.fontRendererObj.drawString(s, xPos + 16, yPos + 32, 0xFFA0A0A0);
    Gui.drawRect(xPos + this.fontRendererObj.getStringWidth(s) + 18, yPos + 36, xPos + 160, yPos + 37,
            0xFF606060);

    this.fontRendererObj.drawString(this.manager.getVersion().toString(), xPos + 162, yPos + 22, 0xFFFFFFFF);
    this.fontRendererObj.drawString(this.manager.getUpdateInfo().version, xPos + 162, yPos + 32, 0xFFFFFFFF);

    this.fontRendererObj.drawString("Details and Changelog:", xPos + 16, yPos + 48, 0xFFA0A0A0);

    this.mc.renderEngine.bindTexture(TEXTURE);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    this.drawTexturedModalRect(xPos + listX - 1, yPos + listY - 1, 0, 0, listWidth + 2, listHeight + 2);

    GuiUtils.doGlScissor(xPos + listX, yPos + listY, listWidth, listHeight);
    GL11.glEnable(GL11.GL_SCISSOR_TEST);

    GL11.glPushMatrix();
    GL11.glTranslatef(0.0F, -this.scrollAmount, 0.0F);

    s = this.manager.getUpdateInfo().description;
    this.fontRendererObj.drawSplitString(s, xPos + listX + 4, yPos + listY + listTextY + 2, listWidth - 12,
            0xFFA00060);
    listTextY += this.fontRendererObj.splitStringWidth(s, listWidth - 12) + 4;

    if (this.manager.getUpdateInfo().changelog != null) {
        for (int i = 0; i < this.manager.getUpdateInfo().changelog.length; i++) {
            s = this.manager.getUpdateInfo().changelog[i];
            Gui.drawRect(xPos + listX + 4, yPos + listY + listTextY + 4, xPos + listX + 8,
                    yPos + listY + listTextY + 8, i % 2 == 0 ? 0xFF000000 : 0xFF606060);
            this.fontRendererObj.drawSplitString(s, xPos + listX + 14, yPos + listY + listTextY + 2,
                    listWidth - 22, i % 2 == 0 ? 0xFF000000 : 0xFF606060);
            listTextY += this.fontRendererObj.splitStringWidth(s, listWidth - 22) + 2;
        }
    }

    this.scrollMax = listTextY - listHeight + 4;

    GL11.glPopMatrix();

    GL11.glDisable(GL11.GL_SCISSOR_TEST);

    this.mc.renderEngine.bindTexture(TEXTURE);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    int scrollPos = (int) (this.scrollAmount / this.scrollMax * (listHeight - 10.0F));
    this.drawTexturedModalRect(xPos + listX + listWidth - 4, yPos + listY + scrollPos, listWidth + 2, 0, 4, 10);

    GL11.glDisable(GL11.GL_BLEND);
    super.drawScreen(mouseX, mouseY, partTicks);
}

From source file:de.sanandrew.core.manpack.mod.client.model.ModelSanPlayer.java

License:Creative Commons License

@Override
public void render(Entity entity, float limbSwing, float limbSwingAmount, float rotFloat, float rotYaw,
        float rotPitch, float partTicks) {
    this.setRotationAngles(limbSwing, limbSwingAmount, rotFloat, rotYaw, rotPitch, partTicks, entity);

    this.quadTail1.isHidden = this.hideTails;
    this.quadTail2.isHidden = this.hideTails;
    this.quadTail3.isHidden = this.hideTails;
    this.quadTail4.isHidden = this.hideTails;

    if (!this.isArmor) {
        GL11.glPushMatrix();//from   w ww .j ava 2 s.  c om
        GL11.glTranslatef(this.head.offsetX, this.head.offsetY, this.head.offsetZ);
        GL11.glTranslatef(this.head.rotationPointX * partTicks, this.head.rotationPointY * partTicks,
                this.head.rotationPointZ * partTicks);
        GL11.glScaled(1.1D, 1.1D, 1.1D);
        GL11.glTranslatef(-this.head.offsetX, -this.head.offsetY, -this.head.offsetZ);
        GL11.glTranslatef(-this.head.rotationPointX * partTicks, -this.head.rotationPointY * partTicks,
                -this.head.rotationPointZ * partTicks);
        this.head.render(partTicks);
        GL11.glPopMatrix();

        this.hair.render(partTicks);
    } else if (this.hatBase != null) {
        this.hatBase.render(partTicks);
    }

    this.bipedLeftArm.render(partTicks);
    this.bipedRightArm.render(partTicks);
    this.legLeft.render(partTicks);
    this.legRight.render(partTicks);
    this.body.render(partTicks);
    this.skirt1.render(partTicks);
    this.skirt2.render(partTicks);

    GL11.glPushMatrix();
    GL11.glTranslatef(this.armLeft2.offsetX, this.armLeft2.offsetY, this.armLeft2.offsetZ);
    GL11.glTranslatef(this.armLeft2.rotationPointX * partTicks + 0.025F,
            this.armLeft2.rotationPointY * partTicks, this.armLeft2.rotationPointZ * partTicks);
    GL11.glScaled(1.05D, 1.05D, 1.05D);
    GL11.glTranslatef(-this.armLeft2.offsetX, -this.armLeft2.offsetY, -this.armLeft2.offsetZ);
    GL11.glTranslatef(-this.armLeft2.rotationPointX * partTicks - 0.025F,
            -this.armLeft2.rotationPointY * partTicks, -this.armLeft2.rotationPointZ * partTicks);
    this.armLeft2.render(partTicks);
    GL11.glPopMatrix();
    GL11.glPushMatrix();
    GL11.glTranslatef(this.armRight2.offsetX, this.armRight2.offsetY, this.armRight2.offsetZ);
    GL11.glTranslatef(this.armRight2.rotationPointX * partTicks - 0.025F,
            this.armRight2.rotationPointY * partTicks, this.armRight2.rotationPointZ * partTicks);
    GL11.glScaled(1.05D, 1.05D, 1.05D);
    GL11.glTranslatef(-this.armRight2.offsetX, -this.armRight2.offsetY, -this.armRight2.offsetZ);
    GL11.glTranslatef(-this.armRight2.rotationPointX * partTicks + 0.025F,
            -this.armRight2.rotationPointY * partTicks, -this.armRight2.rotationPointZ * partTicks);
    this.armRight2.render(partTicks);
    GL11.glPopMatrix();
}