List of usage examples for org.lwjgl.opengl GL11 glTranslatef
public static native void glTranslatef(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y, @NativeType("GLfloat") float z);
From source file:de.sanandrew.core.manpack.mod.client.render.RenderSanPlayer.java
License:Creative Commons License
@Override protected void renderEquippedItems(AbstractClientPlayer player, float partTicks) { super.renderEquippedItems(player, partTicks); GL11.glPushMatrix();/*from w w w. ja v a 2s . c o m*/ this.myModel.body.postRender(0.0625F); ItemStack slot = player.inventory.getStackInSlot(0); if (slot != null && slot != player.getCurrentEquippedItem()) { GL11.glPushMatrix(); GL11.glRotatef(-80.0F, 0.0F, 0.0F, 1.0F); GL11.glScalef(0.6F, 0.6F, 0.6F); GL11.glTranslatef(-1.0F, -0.4F, 0.3F); ItemRenderHelper.renderItemIn3D(slot); GL11.glPopMatrix(); GL11.glTranslatef(0.0F, 0.0F, 0.05F); } slot = player.inventory.getStackInSlot(1); if (slot != null && slot != player.getCurrentEquippedItem()) { GL11.glPushMatrix(); GL11.glRotatef(-10.0F, 0.0F, 0.0F, 1.0F); GL11.glScalef(0.6F, 0.6F, 0.6F); GL11.glTranslatef(-0.6F, -0.0F, 0.3F); ItemRenderHelper.renderItemIn3D(slot); GL11.glPopMatrix(); } GL11.glPopMatrix(); }
From source file:de.sanandrew.core.manpack.mod.client.render.RenderSanPlayer.java
License:Creative Commons License
@Override public void renderFirstPersonArm(EntityPlayer player) { GL11.glColor3f(1.0F, 1.0F, 1.0F);// w w w .j ava 2s . c om this.modelBipedMain.onGround = 0.0F; boolean isRidingPrev = this.modelBipedMain.isRiding; this.modelBipedMain.isRiding = false; this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, player); this.modelBipedMain.isRiding = isRidingPrev; if (this.renderManager.renderEngine != null) { if (player.getCurrentArmor(2) != null) { this.bindTexture(this.getEntityTexture(player)); this.myModel.bipedLeftArm.render(0.0625F); String armoredChest = player.getCurrentArmor(2).getUnlocalizedName().replace(':', '_'); boolean prevArmR2Visible = this.myModel.armRight2.showModel; Minecraft.getMinecraft().getTextureManager().bindTexture( tryLoadArmorPiece("Chest", armoredChest, player, player.getCurrentArmor(2), 1)); this.myModel.bipedRightArm.render(0.0625F); GL11.glPushMatrix(); GL11.glScalef(1.05F, 1.05F, 1.05F); GL11.glTranslatef(0.015F, 0.00F, 0.0F); int armorColor = ((ItemArmor) player.getCurrentArmor(2).getItem()) .getColor(player.getCurrentArmor(2)); if (armorColor != -1) { float red = (armorColor >> 16 & 255) / 255.0F; float green = (armorColor >> 8 & 255) / 255.0F; float blue = (armorColor & 255) / 255.0F; GL11.glColor3f(red, green, blue); } else if (this.unknownTextureColorMap.containsKey(armoredChest)) { RGBAValues rgba = this.unknownTextureColorMap.get(armoredChest); GL11.glColor3f(rgba.getRed() / 255.0F, rgba.getGreen() / 255.0F, rgba.getBlue() / 255.0F); } this.myModel.armRight2.showModel = true; this.myModel.armRight2.render(0.0625F); this.myModel.armRight2.showModel = prevArmR2Visible; GL11.glColor3f(1.0F, 1.0F, 1.0F); GL11.glPopMatrix(); } else { boolean prevArmR2Visible = this.myModel.armRight2.showModel; this.bindTexture(this.getEntityTexture(player)); this.myModel.bipedRightArm.render(0.0625F); GL11.glPushMatrix(); GL11.glScalef(1.05F, 1.05F, 1.05F); GL11.glTranslatef(0.015F, 0.00F, 0.0F); this.myModel.armRight2.showModel = true; this.myModel.armRight2.render(0.0625F); this.myModel.armRight2.showModel = prevArmR2Visible; GL11.glPopMatrix(); } } }
From source file:de.sanandrew.core.manpack.util.client.helpers.GuiUtils.java
License:Creative Commons License
public static void drawOutlinedString(FontRenderer renderer, String s, int x, int y, int foreColor, int frameColor) { if (renderer.getUnicodeFlag()) { GL11.glTranslatef(0.0F, 0.5F, 0.0F); renderer.drawString(s, x, y, frameColor); GL11.glTranslatef(0.0F, -1.0F, 0.0F); renderer.drawString(s, x, y, frameColor); GL11.glTranslatef(0.5F, 0.5F, 0.0F); renderer.drawString(s, x, y, frameColor); GL11.glTranslatef(-1.0F, 0.0F, 0.0F); renderer.drawString(s, x, y, frameColor); GL11.glTranslatef(0.5F, 0.0F, 0.0F); } else {/* ww w .j a v a 2 s . co m*/ renderer.drawString(s, x - 1, y, frameColor); renderer.drawString(s, x + 1, y, frameColor); renderer.drawString(s, x, y - 1, frameColor); renderer.drawString(s, x, y + 1, frameColor); } renderer.drawString(s, x, y, foreColor); }
From source file:de.sanandrew.core.manpack.util.client.helpers.GuiUtils.java
License:Creative Commons License
public static void drawGuiIcon(IIcon icon, int posX, int posY) { GL11.glPushMatrix();// ww w.j a v a 2 s . c o m GL11.glTranslatef(0.0F, 0.0F, 32.0F); itemRenderer.zLevel = 200.0F; GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); GL11.glEnable(GL11.GL_ALPHA_TEST); ResourceLocation resourcelocation = Minecraft.getMinecraft().getTextureManager().getResourceLocation(1); Minecraft.getMinecraft().getTextureManager().bindTexture(resourcelocation); if (icon == null) { icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(resourcelocation)) .getAtlasSprite("missingno"); } itemRenderer.renderIcon(posX, posY, icon, 16, 16); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_BLEND); itemRenderer.zLevel = 0.0F; GL11.glPopMatrix(); }
From source file:de.sanandrew.core.manpack.util.client.helpers.ItemRenderHelper.java
License:Creative Commons License
/** * Renders an ItemStack in a GUI.//from w ww .j ava 2 s . c o m * * @param mc the Minecraft instance * @param stack the ItemStack to be rendered * @param x x-position in the GUI * @param y y-position in the GUI */ public static void renderItemInGui(Minecraft mc, ItemStack stack, int x, int y) { if (stack != null) { GL11.glTranslatef(0.0F, 0.0F, 32.0F); itemRender.zLevel = 200.0F; itemRender.renderItemIntoGUI(null, mc.getTextureManager(), stack, x, y); itemRender.zLevel = 0.0F; } }
From source file:de.sanandrew.core.manpack.util.client.helpers.ItemRenderHelper.java
License:Creative Commons License
/** * Renders an IIcon instance in 3D./* w ww.jav a2 s. c om*/ * * @param icon the icon to be rendered * @param isBlock if it should be rendered as a block or not * @param hasAlpha if it has a transparent texture * @param color the tint it should be rendered in */ public static void renderIconIn3D(IIcon icon, boolean isBlock, boolean hasAlpha, int color) { GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); if (isBlock) { Minecraft.getMinecraft().renderEngine .bindTexture(Minecraft.getMinecraft().renderEngine.getResourceLocation(0)); if (hasAlpha) { GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); } GL11.glTranslatef(0.5F, 0.5F, 0.0F); GL11.glScalef(0.5F, 0.5F, 0.5F); GL11.glPushMatrix(); Tessellator tessellator = Tessellator.instance; float red = (color >> 16 & 255) / 255.0F; float green = (color >> 8 & 255) / 255.0F; float blue = (color & 255) / 255.0F; GL11.glColor4f(red, green, blue, 1.0F); Blocks.stone.setBlockBoundsForItemRender(); renderBlocksRi.setRenderBoundsFromBlock(Blocks.stone); GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, -1.0F, 0.0F); renderBlocksRi.renderFaceYNeg(Blocks.stone, 0.0D, 0.0D, 0.0D, icon); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); renderBlocksRi.renderFaceYPos(Blocks.stone, 0.0D, 0.0D, 0.0D, icon); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, -1.0F); renderBlocksRi.renderFaceZNeg(Blocks.stone, 0.0D, 0.0D, 0.0D, icon); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, 1.0F); renderBlocksRi.renderFaceZPos(Blocks.stone, 0.0D, 0.0D, 0.0D, icon); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(-1.0F, 0.0F, 0.0F); renderBlocksRi.renderFaceXNeg(Blocks.stone, 0.0D, 0.0D, 0.0D, icon); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(1.0F, 0.0F, 0.0F); renderBlocksRi.renderFaceXPos(Blocks.stone, 0.0D, 0.0D, 0.0D, icon); tessellator.draw(); GL11.glPopMatrix(); if (hasAlpha) { GL11.glDisable(GL11.GL_BLEND); } } else { if (hasAlpha) { GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); } float red = (color >> 16 & 255) / 255.0F; float green = (color >> 8 & 255) / 255.0F; float blue = (color & 255) / 255.0F; GL11.glColor4f(red, green, blue, 1.0F); renderItemIn3D(icon, false, 1); if (hasAlpha) { GL11.glDisable(GL11.GL_BLEND); } } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); TextureUtil.func_147945_b(); }
From source file:de.sanandrew.core.manpack.util.client.helpers.ItemRenderHelper.java
License:Creative Commons License
/** * Renders an ItemStack in 3D./*w w w . j av a 2s . c o m*/ * * @param stack the ItemStack to be rendered */ public static void renderItemIn3D(ItemStack stack) { if (stack.getItem() != null) { GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(stack, ItemRenderType.EQUIPPED); if (customRenderer != null) { Minecraft.getMinecraft().renderEngine.bindTexture( Minecraft.getMinecraft().renderEngine.getResourceLocation(stack.getItemSpriteNumber())); GL11.glPushMatrix(); GL11.glTranslatef(0.5F, 0.5F, 0.0F); float blockScale = 0.5F; GL11.glScalef(blockScale, blockScale, blockScale); ForgeHooksClient.renderEquippedItem(ItemRenderType.EQUIPPED, customRenderer, renderBlocksRi, Minecraft.getMinecraft().player, stack); GL11.glPopMatrix(); } else if (stack.getItemSpriteNumber() == 0 && stack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType())) { Minecraft.getMinecraft().renderEngine.bindTexture( Minecraft.getMinecraft().renderEngine.getResourceLocation(stack.getItemSpriteNumber())); Block block = Block.getBlockFromItem(stack.getItem()); float blockScale = 0.5F; int renderType = block.getRenderType(); if (renderType == 1 || renderType == 19 || renderType == 12 || renderType == 2) { blockScale = 1.0F; } if (block.getRenderBlockPass() > 0) { GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); } GL11.glTranslatef(0.5F, 0.5F, 0.0F); GL11.glScalef(blockScale, blockScale, blockScale); GL11.glPushMatrix(); renderBlocksRi.renderBlockAsItem(block, stack.getItemDamage(), 1.0F); GL11.glPopMatrix(); if (block.getRenderBlockPass() > 0) { GL11.glDisable(GL11.GL_BLEND); } } else { if (stack.getItem().requiresMultipleRenderPasses()) { for (int j = 0; j < stack.getItem().getRenderPasses(stack.getItemDamage()); j++) { IIcon icon = stack.getItem().getIcon(stack, j); int color = stack.getItem().getColorFromItemStack(stack, j); float red = (color >> 16 & 255) / 255.0F; float green = (color >> 8 & 255) / 255.0F; float blue = (color & 255) / 255.0F; GL11.glColor4f(red, green, blue, 1.0F); renderItemIn3D(icon, stack.hasEffect(j), 1); } } else { IIcon icon = stack.getItem().getIcon(stack, 0); if (stack.getItem() instanceof ItemCloth) { GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); } int color = stack.getItem().getColorFromItemStack(stack, 0); float red = (color >> 16 & 255) / 255.0F; float green = (color >> 8 & 255) / 255.0F; float blue = (color & 255) / 255.0F; GL11.glColor4f(red, green, blue, 1.0F); renderItemIn3D(icon, stack.hasEffect(0), 1); if (stack.getItem() instanceof ItemCloth) { GL11.glDisable(GL11.GL_BLEND); } } } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); TextureUtil.func_147945_b(); } }
From source file:de.sanandrew.core.manpack.util.client.helpers.ItemRenderHelper.java
License:Creative Commons License
private static void renderItemIn3D(IIcon icon, boolean withEffect, int spriteIndex) { GL11.glPushMatrix();/*from w w w . j av a2s . c om*/ if (icon == null) { GL11.glPopMatrix(); return; } float minU = icon.getMinU(); float maxU = icon.getMaxU(); float minV = icon.getMinV(); float maxV = icon.getMaxV(); Tessellator tessellator = Tessellator.instance; Minecraft.getMinecraft().renderEngine .bindTexture(Minecraft.getMinecraft().renderEngine.getResourceLocation(spriteIndex)); GL11.glEnable(GL12.GL_RESCALE_NORMAL); renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(), icon.getIconHeight(), 0.0625F, false); if (withEffect) { float baseClr = 0.76F; float glintScale = 0.125F; float glintTransX = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F; GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); Minecraft.getMinecraft().renderEngine.bindTexture(GLINT_PNG); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); GL11.glColor4f(0.5F * baseClr, 0.25F * baseClr, 0.8F * baseClr, 1.0F); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glPushMatrix(); GL11.glScalef(glintScale, glintScale, glintScale); GL11.glTranslatef(glintTransX, 0.0F, 0.0F); GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F, false); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(glintScale, glintScale, glintScale); glintTransX = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F; GL11.glTranslatef(-glintTransX, 0.0F, 0.0F); GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F, false); GL11.glPopMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_LEQUAL); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
From source file:de.sanandrew.core.manpack.util.client.helpers.ItemRenderHelper.java
License:Creative Commons License
/** * Renders an IIcon in 2D.//from ww w .ja v a 2s. com * * @param icon the icon to be rendered * @param spriteIndex the index of the texture to be used (0 = blocks, 1 = items) * @param hasEffect if it has an enchantment effect * @param isGlowing if it should glow in the dark */ public static void renderIcon(IIcon icon, int spriteIndex, boolean hasEffect, boolean isGlowing) { GL11.glPushMatrix(); if (icon == null) { GL11.glPopMatrix(); return; } float minU = icon.getMinU(); float maxU = icon.getMaxU(); float minV = icon.getMinV(); float maxV = icon.getMaxV(); float transX = 0.0F; float transY = 0.3F; float scale = 1.5F; Tessellator tessellator = Tessellator.instance; Minecraft.getMinecraft().renderEngine .bindTexture(Minecraft.getMinecraft().renderEngine.getResourceLocation(spriteIndex)); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glTranslatef(-transX, -transY, 0.0F); GL11.glScalef(scale, scale, scale); 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); renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(), icon.getIconHeight(), 0.0625F, isGlowing); if (hasEffect) { float baseClr = 0.76F; float glintScale = 0.125F; float glintTransX = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F; GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); Minecraft.getMinecraft().renderEngine.bindTexture(GLINT_PNG); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); GL11.glColor4f(0.5F * baseClr, 0.25F * baseClr, 0.8F * baseClr, 1.0F); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glPushMatrix(); GL11.glScalef(glintScale, glintScale, glintScale); GL11.glTranslatef(glintTransX, 0.0F, 0.0F); GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F, false); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(glintScale, glintScale, glintScale); glintTransX = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F; GL11.glTranslatef(-glintTransX, 0.0F, 0.0F); GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F, false); GL11.glPopMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_LEQUAL); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
From source file:de.sanandrew.mods.betterboat.client.RenderBetterBoat.java
License:Creative Commons License
public void doRender(EntityBetterBoat boat, double x, double y, double z, float yaw, float partTicks) { GL11.glPushMatrix();/*from w w w.j a v a 2s . com*/ GL11.glTranslatef((float) x, (float) y, (float) z); GL11.glRotatef(180.0F - yaw, 0.0F, 1.0F, 0.0F); float timeSinceHit = (float) boat.getTimeSinceHit() - partTicks; float damageTaken = boat.getDamageTaken() - partTicks; if (damageTaken < 0.0F) { damageTaken = 0.0F; } if (timeSinceHit > 0.0F) { GL11.glRotatef(MathHelper.sin(timeSinceHit) * timeSinceHit * damageTaken / 10.0F * (float) boat.getForwardDirection(), 1.0F, 0.0F, 0.0F); } float scale = 0.75F; GL11.glScalef(scale, scale, scale); GL11.glScalef(1.0F / scale, 1.0F / scale, 1.0F / scale); this.bindEntityTexture(boat); GL11.glScalef(-1.0F, -1.0F, 1.0F); this.modelBoat.render(boat, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); }