List of usage examples for org.lwjgl.opengl GL11 glPushMatrix
public static native void glPushMatrix();
From source file:com.builtbroken.assemblyline.client.FakeItemRender.java
/** * Renders an item at the position//from w ww . j a v a 2 s . com * <p> * Make sure to call {@link #setWorldPosition(World, double, double, double)} first * * @param xx - render position offset from center * @param yy - render position offset from center * @param zz - render position offset from center * @param item - item to render */ public static void renderItemAtPosition(double xx, double yy, double zz, ItemStack item) { if (item != null) { //Start GL11.glPushMatrix(); //Translate GL11.glTranslated(xx, yy, zz); final float scale = 1f; GL11.glScalef(scale, scale, scale); try { //Fix missing render manager renderItem.setRenderManager(RenderManager.instance); entityItem.setEntityItemStack(item); entityItem.hoverStart = 0.0F; //Render item using RenderItem class to save time renderItem.doRender(entityItem, 0, 0, 0, 0, 0); } catch (Exception e) { e.printStackTrace(); } //End GL11.glPopMatrix(); } }
From source file:com.builtbroken.assemblyline.content.belt.pipe.listener.TilePipeRenderListener.java
@Override public void renderDynamic(TileEntity tile, double xx, double yy, double zz, float f) { final double spaceFromEdge = 5.4 / 32f; final double n = spaceFromEdge; final double n2 = 1 - spaceFromEdge; //Update fake item for rendering FakeItemRender.setWorldPosition(tile.getWorldObj(), tile.xCoord + 0.5, tile.yCoord + 0.5, tile.zCoord + 0.5);/*from w ww . j av a2s . c om*/ //Get node ITileNode node = tile instanceof ITileNodeHost ? ((ITileNodeHost) tile).getTileNode() : null; //Only render if pipe if (node instanceof TilePipeBelt) { TilePipeBelt belt = (TilePipeBelt) node; if (belt.renderInventory != null) { GL11.glPushMatrix(); GL11.glTranslated(xx, yy, zz); //Always render center as slot 2 unless center is a buffer chest FakeItemRender.renderItemAtPosition(0.5, 0.5, 0.5, belt.renderInventory.getStackInSlot(belt.getCenterSlots()[0])); //TODO optimize to use an object set to detail slots to render positions if (belt.type == BeltType.NORMAL) { if (belt.getDirection() == ForgeDirection.WEST) { FakeItemRender.renderItemAtPosition(n, 0.5, 0.5, belt.renderInventory.getStackInSlot(0)); FakeItemRender.renderItemAtPosition(n2, 0.5, 0.5, belt.renderInventory.getStackInSlot(1)); } else if (belt.getDirection() == ForgeDirection.EAST) { FakeItemRender.renderItemAtPosition(n, 0.5, 0.5, belt.renderInventory.getStackInSlot(1)); FakeItemRender.renderItemAtPosition(n2, 0.5, 0.5, belt.renderInventory.getStackInSlot(0)); } else if (belt.getDirection() == ForgeDirection.NORTH) { FakeItemRender.renderItemAtPosition(0.5, 0.5, n, belt.renderInventory.getStackInSlot(0)); FakeItemRender.renderItemAtPosition(0.5, 0.5, n2, belt.renderInventory.getStackInSlot(1)); } else if (belt.getDirection() == ForgeDirection.SOUTH) { FakeItemRender.renderItemAtPosition(0.5, 0.5, n, belt.renderInventory.getStackInSlot(1)); FakeItemRender.renderItemAtPosition(0.5, 0.5, n2, belt.renderInventory.getStackInSlot(0)); } } else if (belt.type == BeltType.END_CAP) { if (belt.getDirection() == ForgeDirection.WEST) { FakeItemRender.renderItemAtPosition(n2, 0.5, 0.5, belt.renderInventory.getStackInSlot(0)); } else if (belt.getDirection() == ForgeDirection.EAST) { FakeItemRender.renderItemAtPosition(n, 0.5, 0.5, belt.renderInventory.getStackInSlot(0)); } else if (belt.getDirection() == ForgeDirection.NORTH) { FakeItemRender.renderItemAtPosition(0.5, 0.5, n2, belt.renderInventory.getStackInSlot(0)); } else if (belt.getDirection() == ForgeDirection.SOUTH) { FakeItemRender.renderItemAtPosition(0.5, 0.5, n, belt.renderInventory.getStackInSlot(0)); } } else if (belt.type == BeltType.LEFT_ELBOW) { if (belt.getDirection() == ForgeDirection.WEST) { FakeItemRender.renderItemAtPosition(0.5, 0.5, n, belt.renderInventory.getStackInSlot(1)); FakeItemRender.renderItemAtPosition(n2, 0.5, 0.5, belt.renderInventory.getStackInSlot(0)); } else if (belt.getDirection() == ForgeDirection.EAST) { FakeItemRender.renderItemAtPosition(n, 0.5, 0.5, belt.renderInventory.getStackInSlot(0)); FakeItemRender.renderItemAtPosition(0.5, 0.5, n2, belt.renderInventory.getStackInSlot(1)); } else if (belt.getDirection() == ForgeDirection.NORTH) { FakeItemRender.renderItemAtPosition(n2, 0.5, 0.5, belt.renderInventory.getStackInSlot(1)); FakeItemRender.renderItemAtPosition(0.5, 0.5, n2, belt.renderInventory.getStackInSlot(0)); } else if (belt.getDirection() == ForgeDirection.SOUTH) { FakeItemRender.renderItemAtPosition(0.5, 0.5, n, belt.renderInventory.getStackInSlot(0)); FakeItemRender.renderItemAtPosition(n, 0.5, 0.5, belt.renderInventory.getStackInSlot(1)); } } else if (belt.type == BeltType.RIGHT_ELBOW) { if (belt.getDirection() == ForgeDirection.WEST) { FakeItemRender.renderItemAtPosition(0.5, 0.5, n2, belt.renderInventory.getStackInSlot(1)); FakeItemRender.renderItemAtPosition(n2, 0.5, 0.5, belt.renderInventory.getStackInSlot(0)); } else if (belt.getDirection() == ForgeDirection.EAST) { FakeItemRender.renderItemAtPosition(n, 0.5, 0.5, belt.renderInventory.getStackInSlot(0)); FakeItemRender.renderItemAtPosition(0.5, 0.5, n, belt.renderInventory.getStackInSlot(1)); } else if (belt.getDirection() == ForgeDirection.NORTH) { FakeItemRender.renderItemAtPosition(n, 0.5, 0.5, belt.renderInventory.getStackInSlot(1)); FakeItemRender.renderItemAtPosition(0.5, 0.5, n2, belt.renderInventory.getStackInSlot(0)); } else if (belt.getDirection() == ForgeDirection.SOUTH) { FakeItemRender.renderItemAtPosition(0.5, 0.5, n, belt.renderInventory.getStackInSlot(0)); FakeItemRender.renderItemAtPosition(n2, 0.5, 0.5, belt.renderInventory.getStackInSlot(1)); } } else if (belt.type == BeltType.JUNCTION || belt.type == BeltType.INTERSECTION) { if (belt.getDirection() == ForgeDirection.WEST) { FakeItemRender.renderItemAtPosition(0.5, 0.5, n2, belt.renderInventory.getStackInSlot(3)); //left FakeItemRender.renderItemAtPosition(n2, 0.5, 0.5, belt.renderInventory.getStackInSlot(0)); //output FakeItemRender.renderItemAtPosition(0.5, 0.5, n, belt.renderInventory.getStackInSlot(1)); //right if (belt.type == BeltType.INTERSECTION) { FakeItemRender.renderItemAtPosition(n, 0.5, 0.5, belt.renderInventory.getStackInSlot(4)); //input } } else if (belt.getDirection() == ForgeDirection.EAST) { FakeItemRender.renderItemAtPosition(0.5, 0.5, n2, belt.renderInventory.getStackInSlot(1)); //right FakeItemRender.renderItemAtPosition(n, 0.5, 0.5, belt.renderInventory.getStackInSlot(0)); //output FakeItemRender.renderItemAtPosition(0.5, 0.5, n, belt.renderInventory.getStackInSlot(3)); //left if (belt.type == BeltType.INTERSECTION) { FakeItemRender.renderItemAtPosition(n2, 0.5, 0.5, belt.renderInventory.getStackInSlot(4)); //input } } else if (belt.getDirection() == ForgeDirection.NORTH) { FakeItemRender.renderItemAtPosition(n, 0.5, 0.5, belt.renderInventory.getStackInSlot(3)); //left FakeItemRender.renderItemAtPosition(0.5, 0.5, n2, belt.renderInventory.getStackInSlot(0)); //output FakeItemRender.renderItemAtPosition(n2, 0.5, 0.5, belt.renderInventory.getStackInSlot(1)); //right if (belt.type == BeltType.INTERSECTION) { FakeItemRender.renderItemAtPosition(0.5, 0.5, n, belt.renderInventory.getStackInSlot(4)); //input } } else if (belt.getDirection() == ForgeDirection.SOUTH) { FakeItemRender.renderItemAtPosition(n, 0.5, 0.5, belt.renderInventory.getStackInSlot(1)); //right FakeItemRender.renderItemAtPosition(0.5, 0.5, n, belt.renderInventory.getStackInSlot(0)); //output FakeItemRender.renderItemAtPosition(n2, 0.5, 0.5, belt.renderInventory.getStackInSlot(3)); //left if (belt.type == BeltType.INTERSECTION) { FakeItemRender.renderItemAtPosition(0.5, 0.5, n2, belt.renderInventory.getStackInSlot(4)); //input } } } GL11.glPopMatrix(); } } }
From source file:com.builtbroken.assemblyline.content.inserter.TileInsertArmClient.java
@Override @SideOnly(Side.CLIENT)/*w ww. j a v a 2 s . c o m*/ public void renderDynamic(Pos pos, float deltaFrame, int pass) { if (ticks < 2) { renderAngle.set(rotation); } else { renderAngle.lerp(rotation, deltaFrame).clampTo360(); } float yaw = (float) renderAngle.yaw(); //Render inserter GL11.glPushMatrix(); GL11.glTranslatef(pos.xf() + 0.5f, pos.yf() + 0.4f, pos.zf() + 0.5f); GL11.glRotated(yaw, 0, 1, 0); FMLClientHandler.instance().getClient().renderEngine.bindTexture(texture); model.renderAllExcept("Base", "BaseTop"); GL11.glPopMatrix(); //----------------------------- //Render item in hand GL11.glPushMatrix(); GL11.glTranslated(pos.xf() + 0.5f, pos.yf() + 0.2f, pos.zf() + 0.5f); //Setup world position double x = renderAngle.x() * 1.15; double z = renderAngle.z() * 1.15; FakeItemRender.setWorldPosition(worldObj, xi() + 0.5 + x, yi() + 0.5, zi() + 0.5 + z); //Render actual item with rotation yaw += 90f; GL11.glRotatef(yaw, 0.0F, 1.0F, 0.0F); FakeItemRender.renderItemAtPosition(1, 0, 0, renderStack); GL11.glPopMatrix(); }
From source file:com.builtbroken.assemblyline.content.rail.carts.RenderCart.java
@Override public void doRender(final Entity entity, final double xx, final double yy, final double zz, final float p_76986_8_, final float delta) { final EntityCart cart = (EntityCart) entity; float f5 = cart.prevRotationPitch + (cart.rotationPitch - cart.prevRotationPitch) * delta; double x2 = MathHelper.lerp(cart.lastRenderX, xx, delta); double y2 = MathHelper.lerp(cart.lastRenderY, yy, delta); double z2 = MathHelper.lerp(cart.lastRenderZ, zz, delta); //Start all/*w w w . j a v a2 s.co m*/ GL11.glPushMatrix(); GL11.glTranslated(x2, y2, z2); GL11.glRotatef(180.0F - delta, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-f5, 0.0F, 0.0F, 1.0F); //store last position cart.lastRenderX = x2; cart.lastRenderY = y2; cart.lastRenderZ = z2; float halfWidth = cart.width / 2.0F; float halfLength = cart.length / 2.0F; float yaw = (float) Math.abs(MathUtility.clampAngleTo180(cart.rotationYaw)); if (yaw >= 45 && yaw <= 135) { halfWidth = cart.length / 2.0F; halfLength = cart.width / 2.0F; } AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(-(double) halfWidth, 0, -(double) halfLength, +(double) halfWidth, 0.2, +(double) halfLength); //Render bottom of cart GL11.glPushMatrix(); RenderUtility.renderCube(bounds, Blocks.iron_block); GL11.glPopMatrix(); //Render stuff on top of cart if (cart.getType() != CartTypes.EMPTY) { GL11.glPushMatrix(); if (cart.getType() == CartTypes.CHEST) { if (Holiday.isXMAS()) { this.bindTexture(xmasChestTexture); } else { this.bindTexture(chestTexture); } GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); GL11.glScalef(0.6f, 0.6f, 0.6f); GL11.glTranslated(-0.5, -1.2, -0.5); chestModel.renderAll(); } else if (cart.getType() == CartTypes.STACK) { ItemStack stack = cart.getInventory().getStackInSlot(0); try { if (stack != null) { //TODO implement a custom override for rendering items on cart using an interface as well event IItemRenderer renderer = MinecraftForgeClient.getItemRenderer(stack, IItemRenderer.ItemRenderType.ENTITY); if (renderer != null) { /** see if {@link net.minecraftforge.client.ForgeHooksClient#renderEntityItem(EntityItem, ItemStack, float, float, Random, TextureManager, RenderBlocks, int)} * will work much better */ EntityItem fakeItem = new EntityItem(cart.oldWorld()); fakeItem.setPosition(cart.x(), cart.y() + 0.5, cart.z()); renderer.renderItem(IItemRenderer.ItemRenderType.ENTITY, stack, RenderBlocks.getInstance(), fakeItem); } else if (stack.getItem() instanceof ItemBlock) { RenderUtility.renderCube(AxisAlignedBB.getBoundingBox(0, 0, 0, .8, .8, .8), Blocks.planks); } else { RenderItemOverlayUtility .renderIcon3D(stack.getItem().getIconFromDamage(stack.getItemDamage()), 1); } } } catch (Exception e) { AssemblyLine.INSTANCE.logger().error("Failed to render " + stack, e); RenderUtility.renderCube(AxisAlignedBB.getBoundingBox(0, 0, 0, .2, .1, .2), Blocks.wool); } RenderUtility.renderCube(AxisAlignedBB.getBoundingBox(0, 0, 0, .9, .1, .9), Blocks.planks); } else { GL11.glScalef(0.5f, 0.5f, 0.5f); GL11.glTranslated(-0.5, .3, -0.5); RenderUtility.renderCube(AxisAlignedBB.getBoundingBox(0, 0, 0, 1, 1, 1), Blocks.planks); } GL11.glPopMatrix(); } //End all GL11.glPopMatrix(); if (Engine.runningAsDev) { drawBounds(cart, xx, yy, zz); } }
From source file:com.builtbroken.atomic.content.effects.client.RenderRadOverlay.java
@SubscribeEvent public void renderOverlay(RenderGameOverlayEvent.Post event) { int width = event.resolution.getScaledWidth(); int height = event.resolution.getScaledHeight(); Minecraft mc = Minecraft.getMinecraft(); if (event.type == RenderGameOverlayEvent.ElementType.ALL) { //Start//from w w w. j a v a 2 s . com GL11.glPushMatrix(); GL11.glTranslatef(0, 0, 0.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_BLEND); //Position TODO config TODO fire event int left = 5; int top = 5; //Get data final float rad_player = interpolate(ClientProxy.PREV_RAD_PLAYER, ClientProxy.RAD_PLAYER, event.partialTicks); final float rad_area = interpolate(ClientProxy.PREV_RAD_EXPOSURE, ClientProxy.RAD_EXPOSURE, event.partialTicks); final float rad_dead_min = ConfigRadiation.RADIATION_DEATH_POINT / (60 * 20); //Radiation needed to die in 1 min //Format String remDisplay = formatDisplay("PER:", rad_player, "rem"); String radDisplay = formatDisplay("ENV: ", rad_area * 20, "rem/s"); //Render Render2DHelper.renderTextWithShadow(remDisplay, left, top, interpolate(startColor, endColor, rad_player / ConfigRadiation.RADIATION_DEATH_POINT).getRGB()); Render2DHelper.renderTextWithShadow(radDisplay, left, top + 10, interpolate(startColor, endColor, rad_area / rad_dead_min).getRGB()); if (AtomicScience.runningAsDev) { Render2DHelper.renderTextWithShadow("" + ClientProxy.RAD_REMOVE_TIMER, left + 60, top, endColor.getRGB()); } //Set prev ClientProxy.PREV_RAD_PLAYER = rad_player; ClientProxy.PREV_RAD_EXPOSURE = rad_area; //End GL11.glEnable(GL11.GL_BLEND); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glPopMatrix(); } }
From source file:com.builtbroken.atomic.content.items.cell.RendererItemCell.java
@Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { GL11.glPushMatrix(); preRender();// ww w .j av a2 s .co m applyRotation(type); render(type, item); postRender(); GL11.glPopMatrix(); }
From source file:com.builtbroken.atomic.content.machines.processing.boiler.render.RenderItemBoiler.java
@Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { GL11.glPushMatrix(); GL11.glScaled(0.0625f, 0.0625f, 0.0625f); if (type.equals(ItemRenderType.INVENTORY)) { GL11.glTranslatef(-0.5f, -0.8f, -0.5f); GL11.glRotatef(180f, 0, 1, 0);/*www . j a va 2 s . c om*/ } else if (type.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) { GL11.glRotatef(45f, 0, 1, 0); GL11.glTranslatef(1f, 12f, 9f); } else if (type.equals(ItemRenderType.EQUIPPED)) { GL11.glTranslatef(8f, 10f, 8f); } FMLClientHandler.instance().getClient().renderEngine.bindTexture(texture_on); model_base.renderAll(); model_core.renderAll(); GL11.glPopMatrix(); }
From source file:com.builtbroken.atomic.content.machines.processing.boiler.render.TESRChemBoiler.java
@Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float deltaFrame) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); GL11.glScaled(0.0625f, 0.0625f, 0.0625f); if (tile instanceof TileEntityChemBoiler) { TileEntityChemBoiler entityChemExtractor = (TileEntityChemBoiler) tile; ForgeDirection facing = entityChemExtractor.getFacingDirection(); switch (facing) { case NORTH: GL11.glRotatef(-90, 0, 1, 0); break; case SOUTH: GL11.glRotatef(90, 0, 1, 0); break; case EAST: GL11.glRotatef(180, 0, 1, 0); break; case WEST: //Good by default break; }//w ww . j a v a 2 s . c o m bindTexture(((TileEntityChemBoiler) tile).processTimer > 0 ? texture_on : texture_off); //Render main body model_base.renderAll(); //Render rotating parts GL11.glRotatef(((TileEntityChemBoiler) tile).rotate(deltaFrame), 0, 1, 0); model_core.renderAll(); } GL11.glPopMatrix(); }
From source file:com.builtbroken.atomic.content.machines.processing.centrifuge.render.RenderItemCentrifuge.java
@Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { GL11.glPushMatrix(); GL11.glScaled(0.0625f, 0.0625f, 0.0625f); if (type.equals(ItemRenderType.INVENTORY)) { GL11.glTranslatef(-0.5f, -0.8f, -0.5f); GL11.glRotatef(180f, 0, 1, 0);/*from w w w .j av a 2 s .c o m*/ } else if (type.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) { GL11.glRotatef(45f, 0, 1, 0); GL11.glTranslatef(1f, 12f, 9f); } else if (type.equals(ItemRenderType.EQUIPPED)) { GL11.glTranslatef(8f, 10f, 8f); } FMLClientHandler.instance().getClient().renderEngine.bindTexture(texture); model_body.renderAll(); model_core.renderAll(); GL11.glPopMatrix(); }
From source file:com.builtbroken.atomic.content.machines.processing.centrifuge.render.TESRChemCentrifuge.java
@Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float deltaFrame) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); GL11.glScaled(0.0625f, 0.0625f, 0.0625f); if (tile instanceof TileEntityChemCentrifuge) { TileEntityChemCentrifuge entityChemExtractor = (TileEntityChemCentrifuge) tile; ForgeDirection facing = entityChemExtractor.getFacingDirection(); switch (facing) { case NORTH: GL11.glRotatef(-90, 0, 1, 0); break; case SOUTH: GL11.glRotatef(90, 0, 1, 0); break; case EAST: GL11.glRotatef(180, 0, 1, 0); break; case WEST: //GL11.glRotatef(-90, 0, 1, 0); break; }/*from www .j ava 2 s.c o m*/ bindTexture(texture); //Render main body model_body.renderAll(); //Render rotating parts GL11.glRotatef(((TileEntityChemCentrifuge) tile).rotate(deltaFrame), 0, 1, 0); model_core.renderAll(); } GL11.glPopMatrix(); }