List of usage examples for org.lwjgl.opengl GL11 glScalef
public static native void glScalef(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y, @NativeType("GLfloat") float z);
From source file:mods.railcraft.client.render.RenderChest.java
License:Open Source License
/** * Helps to render Ender Chest.//ww w . jav a 2 s.c o m */ public void renderChest(TileChestRailcraft tile, double x, double y, double z, float time) { int facing = tile.getFacing().ordinal(); bindTexture(texture); GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F); GL11.glScalef(1.0F, -1.0F, -1.0F); GL11.glTranslatef(0.5F, 0.5F, 0.5F); short rotation = 0; switch (facing) { case 2: rotation = 180; break; case 3: rotation = 0; break; case 4: rotation = 90; break; case 5: rotation = -90; break; } GL11.glRotatef((float) rotation, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); float lidAngle = tile.prevLidAngle + (tile.lidAngle - tile.prevLidAngle) * time; lidAngle = 1.0F - lidAngle; lidAngle = 1.0F - lidAngle * lidAngle * lidAngle; this.chestModel.chestLid.rotateAngleX = -(lidAngle * (float) Math.PI / 2.0F); this.chestModel.renderAll(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopAttrib(); GL11.glPopMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); }
From source file:mods.railcraft.client.render.RenderFluidLoader.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f) { TileLoaderFluidBase base = (TileLoaderFluidBase) tile; GL11.glPushMatrix();/*from w w w .ja va 2 s . c o m*/ GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); // GL11.glEnable(GL11.GL_CULL_FACE); backDrop.texture[0] = base.getMachineType().getTexture(7); bindTexture(TextureMap.locationBlocksTexture); RenderFakeBlock.renderBlock(backDrop, base.getWorld(), x, y, z, false, true); GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F); GL11.glScalef(1f, 0.6f, 1f); StandardTank tank = base.getTankManager().get(0); if (tank.renderData.fluid != null && tank.renderData.amount > 0) { int[] displayLists = FluidRenderer.getLiquidDisplayLists(tank.renderData.fluid); if (displayLists != null) { GL11.glPushMatrix(); if (FluidRenderer.getFluidTexture(tank.renderData.fluid, false) != null) { float cap = tank.getCapacity(); float level = (float) Math.min(tank.renderData.amount, cap) / cap; bindTexture(FluidRenderer.getFluidSheet(tank.renderData.fluid)); FluidRenderer.setColorForTank(tank); GL11.glCallList(displayLists[(int) (level * (float) (FluidRenderer.DISPLAY_STAGES - 1))]); } GL11.glPopMatrix(); } } // GL11.glScalef(0.994f, 1.05f, 0.994f); GL11.glPopAttrib(); GL11.glPopMatrix(); if (tile.getClass() == TileFluidLoader.class) { TileFluidLoader loader = (TileFluidLoader) tile; pipe.minY = RenderTools.PIXEL - loader.getPipeLenght(); RenderFakeBlock.renderBlock(pipe, loader.getWorld(), x, y, z, false, true); } }
From source file:mods.railcraft.client.render.RenderIronTank.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f) { if (!((TileMultiBlock) tile).isStructureValid()) return;/*from ww w . ja v a 2 s . com*/ if (tile instanceof TileTankIronValve) { TileTankIronValve valve = (TileTankIronValve) tile; StandardTank fillTank = valve.getFillTank(); if (fillTank.renderData.fluid != null && fillTank.renderData.amount > 0) { GL11.glPushMatrix(); if (valve.getPattern().getPatternMarkerChecked(valve.getPatternPositionX(), valve.getPatternPositionY() - 1, valve.getPatternPositionZ()) == 'A') { prepFillTexture(fillTank); int height = getTankHeight(valve); float yOffset = height / 2f; float vScale = height - 2f; GL11.glTranslatef((float) x + 0.5F, (float) y + yOffset - height + 1, (float) z + 0.5F); GL11.glScalef(1f, vScale, 1f); draw(fillTank); } else if (valve.getPattern().getPatternMarkerChecked(valve.getPatternPositionX() - 1, valve.getPatternPositionY(), valve.getPatternPositionZ()) == 'A') { prepFillTexture(fillTank); float vScale = getVerticalScaleSide(valve); float yOffset = 0.5f - vScale / 2f + RenderTools.PIXEL * 3; GL11.glTranslatef((float) x - 0.5F + RenderTools.PIXEL * 5, (float) y + yOffset, (float) z + 0.5F); GL11.glScalef(1f, vScale, 1f); draw(fillTank); } else if (valve.getPattern().getPatternMarkerChecked(valve.getPatternPositionX() + 1, valve.getPatternPositionY(), valve.getPatternPositionZ()) == 'A') { prepFillTexture(fillTank); float vScale = getVerticalScaleSide(valve); float yOffset = 0.5f - vScale / 2f + RenderTools.PIXEL * 3; GL11.glTranslatef((float) x + 1.5F - RenderTools.PIXEL * 5, (float) y + yOffset, (float) z + 0.5F); GL11.glScalef(1f, vScale, 1f); draw(fillTank); } else if (valve.getPattern().getPatternMarkerChecked(valve.getPatternPositionX(), valve.getPatternPositionY(), valve.getPatternPositionZ() - 1) == 'A') { prepFillTexture(fillTank); float vScale = getVerticalScaleSide(valve); float yOffset = 0.5f - vScale / 2f + RenderTools.PIXEL * 3; GL11.glTranslatef((float) x + 0.5F, (float) y + yOffset, (float) z - 0.5F + RenderTools.PIXEL * 5); GL11.glScalef(1f, vScale, 1f); draw(fillTank); } else if (valve.getPattern().getPatternMarkerChecked(valve.getPatternPositionX(), valve.getPatternPositionY(), valve.getPatternPositionZ() + 1) == 'A') { prepFillTexture(fillTank); float vScale = getVerticalScaleSide(valve); float yOffset = 0.5f - vScale / 2f + RenderTools.PIXEL * 3; GL11.glTranslatef((float) x + 0.5F, (float) y + yOffset, (float) z + 1.5F - RenderTools.PIXEL * 5); GL11.glScalef(1f, vScale, 1f); draw(fillTank); } GL11.glPopMatrix(); } } TileTankBase ironTank = (TileTankBase) tile; if (!ironTank.isMaster() || ironTank.isInvalid()) return; int height = getTankHeight(ironTank); float yOffset = height / 2f; float vScale = height - 2; float hScale = ironTank.getPattern().getPatternWidthX() - 2; TankManager tankManager = ironTank.getTankManager(); if (tankManager == null) return; StandardTank tank = tankManager.get(0); if (tank == null) return; if (tank.renderData.fluid != null && tank.renderData.amount > 0) { preGL(); GL11.glTranslatef((float) x + 0.5F, (float) y + yOffset + 0.01f, (float) z + 0.5F); GL11.glScalef(hScale, vScale, hScale); // GL11.glScalef(0.999f, 1, 0.999f); int[] displayLists = FluidRenderer.getLiquidDisplayLists(tank.renderData.fluid); if (displayLists != null) { GL11.glPushMatrix(); float cap = tank.getCapacity(); float level = (float) Math.min(tank.renderData.amount, cap) / cap; bindTexture(FluidRenderer.getFluidSheet(tank.renderData.fluid)); FluidRenderer.setColorForTank(tank); GL11.glCallList(displayLists[(int) (level * (float) (FluidRenderer.DISPLAY_STAGES - 1))]); GL11.glPopMatrix(); } postGL(); } }
From source file:mods.railcraft.client.render.RenderLiquidLoader.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f) { TileLoaderLiquidBase base = (TileLoaderLiquidBase) tile; GL11.glPushMatrix();//w w w.j av a 2s.c o m GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); // GL11.glEnable(GL11.GL_CULL_FACE); backDrop.texture[0] = base.getMachineType().getTexture(7); bindTexture(TextureMap.locationBlocksTexture); RenderFakeBlock.renderBlock(backDrop, base.getWorld(), x, y, z, false, true); GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F); GL11.glScalef(1f, 0.6f, 1f); IFluidTank tank = base.getTankManager().get(0); FluidStack fluidStack = tank.getFluid(); if (fluidStack != null && fluidStack.amount > 0) { int[] displayLists = FluidRenderer.getLiquidDisplayLists(fluidStack); if (displayLists != null) { GL11.glPushMatrix(); if (FluidRenderer.getFluidTexture(fluidStack, false) != null) { float cap = tank.getCapacity(); float level = (float) Math.min(fluidStack.amount, cap) / cap; bindTexture(FluidRenderer.getFluidSheet(fluidStack)); FluidRenderer.setColorForFluidStack(fluidStack); GL11.glCallList(displayLists[(int) (level * (float) (FluidRenderer.DISPLAY_STAGES - 1))]); } GL11.glPopMatrix(); } } // GL11.glScalef(0.994f, 1.05f, 0.994f); GL11.glPopAttrib(); GL11.glPopMatrix(); if (tile.getClass() == TileLiquidLoader.class) { TileLiquidLoader loader = (TileLiquidLoader) tile; pipe.minY = RenderTools.PIXEL - loader.getPipeLenght(); RenderFakeBlock.renderBlock(pipe, loader.getWorld(), x, y, z, false, true); } }
From source file:mods.railcraft.client.render.RenderSwitch.java
License:Open Source License
@Override public void renderItem(RenderBlocks renderblocks, ItemStack item, ItemRenderType renderType) { switch (renderType) { case EQUIPPED: case EQUIPPED_FIRST_PERSON: case ENTITY://from w w w. java 2 s . c o m float scale = 1.5f; GL11.glScalef(scale, scale, scale); } // Core setTextureCore(); float min = 4.0F * PIX; float max = 12.0F * PIX; info.setBlockBounds(min, 0.0F, min, max, 5.0F * PIX, max); RenderFakeBlock.renderBlockOnInventory(renderblocks, info, 1); // Post min = 7.0F * PIX; max = 9.0F * PIX; info.setBlockBounds(min, 0.0F, min, max, 8.0F * PIX, max); RenderFakeBlock.renderBlockOnInventory(renderblocks, info, 1); info.setBlockBounds(min, 11.0F * PIX, min, max, 12.0F * PIX, max); RenderFakeBlock.renderBlockOnInventory(renderblocks, info, 1); // Extensions setTextureExtension(); info.setBlockBounds(6.0F * PIX, 0.0F, 0.0F, 10.0F * PIX, 3.0F * PIX, 1.0F); RenderFakeBlock.renderBlockOnInventory(renderblocks, info, 1); // Red target setTextureRed(); info.setBlockBounds(4.0F * PIX, 8.0F * PIX, 7.0F * PIX, 8.0F * PIX, 11.0F * PIX, 8.0F * PIX); RenderFakeBlock.renderBlockOnInventory(renderblocks, info, 1); info.setBlockBounds(8.0F * PIX, 8.0F * PIX, 8.0F * PIX, 12.0F * PIX, 11.0F * PIX, 9.0F * PIX); RenderFakeBlock.renderBlockOnInventory(renderblocks, info, 1); info.setBlockBounds(12.0F * PIX, 9.0F * PIX, 8.0F * PIX, 13.0F * PIX, 10.0F * PIX, 9.0F * PIX); RenderFakeBlock.renderBlockOnInventory(renderblocks, info, 1); info.setBlockBounds(3.0F * PIX, 8.0F * PIX, 7.0F * PIX, 4.0F * PIX, 9.0F * PIX, 8.0F * PIX); RenderFakeBlock.renderBlockOnInventory(renderblocks, info, 1); info.setBlockBounds(3.0F * PIX, 10.0F * PIX, 7.0F * PIX, 4.0F * PIX, 11.0F * PIX, 8.0F * PIX); RenderFakeBlock.renderBlockOnInventory(renderblocks, info, 1); // White target setTextureWhite(); info.setBlockBounds(8.0F * PIX, 8.0F * PIX, 4.0F * PIX, 9.0F * PIX, 11.0F * PIX, 8.0F * PIX); RenderFakeBlock.renderBlockOnInventory(renderblocks, info, 1); info.setBlockBounds(7.0F * PIX, 8.0F * PIX, 8.0F * PIX, 8.0F * PIX, 11.0F * PIX, 12.0F * PIX); RenderFakeBlock.renderBlockOnInventory(renderblocks, info, 1); // Lever if (type == EnumSignal.SWITCH_LEVER) { Tessellator tess = Tessellator.instance; tess.startDrawingQuads(); renderLever(-0.5, -0.5, -0.5, 3, false); tess.draw(); } }
From source file:mods.railcraft.client.render.RenderTankCartItem.java
License:Open Source License
@Override public void renderItem(ItemRenderType type, ItemStack stack, Object... data) { if (type == ItemRenderType.INVENTORY) render(ItemRenderType.INVENTORY, stack); else if (type == ItemRenderType.ENTITY) if (RenderManager.instance.options.fancyGraphics) renderAsEntity(stack, (EntityItem) data[1]); else// w ww . j a va2s . c om renderAsEntityFlat(stack); else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glPushMatrix(); renderEquiped(stack, (EntityLivingBase) data[1]); ItemStack filter = EntityCartTank.getFilterFromCartItem(stack); if (filter != null) { float scale = 0.6f; GL11.glScalef(scale, scale, 1.1f); GL11.glTranslatef(0.7f, 0, 0.001f); renderEquiped(filter, (EntityLivingBase) data[1]); } GL11.glPopMatrix(); } }
From source file:mods.railcraft.client.render.RenderTankCartItem.java
License:Open Source License
private void renderAsEntity(ItemStack stack, EntityItem entity) { GL11.glPushMatrix();/*from ww w. ja v a 2 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); float offsetZ = 0.0625F + 0.021875F; GL11.glRotatef((((float) 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 * (float) 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); ItemStack filter = EntityCartTank.getFilterFromCartItem(stack); if (filter != null) { GL11.glPushMatrix(); float scale = 0.6f; GL11.glScalef(scale, scale, 1.1F); GL11.glTranslatef(0.0F, -0.05F, 0.003F); renderIn3D(filter); GL11.glPopMatrix(); } } GL11.glPopMatrix(); }
From source file:mods.railcraft.client.render.RenderTankCartItem.java
License:Open Source License
private void renderIn3D(ItemStack stack) { GL11.glPushMatrix();//from w w w.j a va 2 s. c o m Tessellator tessellator = Tessellator.instance; int meta = stack.getItemDamage(); for (int pass = 0; pass < stack.getItem().getRenderPasses(meta); ++pass) { IIcon icon = stack.getItem().getIconFromDamageForRenderPass(meta, pass); if (icon == null) continue; int color = stack.getItem().getColorFromItemStack(stack, pass); float c1 = (float) (color >> 16 & 255) / 255.0F; float c2 = (float) (color >> 8 & 255) / 255.0F; float c3 = (float) (color & 255) / 255.0F; if (renderItem.renderWithColor) GL11.glColor4f(c1, c2, c3, 1.0F); float minU = icon.getMinU(); float maxU = icon.getMaxU(); float minV = icon.getMinV(); float maxV = icon.getMaxV(); if (stack.getItemSpriteNumber() == 0) RenderManager.instance.renderEngine.bindTexture(BLOCK_TEXTURE); else RenderManager.instance.renderEngine.bindTexture(ITEM_TEXTURE); ItemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(), icon.getIconHeight(), RenderTools.PIXEL); if (stack.hasEffect(pass)) { GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); RenderManager.instance.renderEngine.bindTexture(GLINT_TEXTURE); 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, RenderTools.PIXEL); 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, RenderTools.PIXEL); 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:mods.railcraft.client.render.RenderTankCartItem.java
License:Open Source License
private void renderAsEntityFlat(ItemStack stack) { GL11.glPushMatrix();//w w w.j av a2 s . co 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:mods.railcraft.client.render.RenderTankCartItem.java
License:Open Source License
private void render(ItemRenderType type, ItemStack stack) { GL11.glPushMatrix();//w w w.j a v a 2s . c o m GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); IIcon cartTexture = stack.getIconIndex(); renderItem.renderIcon(0, 0, cartTexture, 16, 16); ItemStack filter = EntityCartTank.getFilterFromCartItem(stack); if (filter != null) { int meta = filter.getItemDamage(); float scale = 0.6f; GL11.glScalef(scale, scale, 1); GL11.glTranslatef(0, 11f, 0); if (type == ItemRenderType.ENTITY) GL11.glTranslatef(0, 0, -0.01f); for (int pass = 0; pass < filter.getItem().getRenderPasses(meta); ++pass) { IIcon bucketTexture = filter.getItem().getIconFromDamageForRenderPass(meta, pass); if (bucketTexture == null) continue; int color = filter.getItem().getColorFromItemStack(filter, pass); float c1 = (float) (color >> 16 & 255) / 255.0F; float c2 = (float) (color >> 8 & 255) / 255.0F; float c3 = (float) (color & 255) / 255.0F; if (renderItem.renderWithColor) GL11.glColor4f(c1, c2, c3, 1.0F); renderItem.renderIcon(0, 0, bucketTexture, 16, 16); } } GL11.glPopAttrib(); GL11.glPopMatrix(); }