List of usage examples for org.lwjgl.opengl GL11 glTranslated
public static native void glTranslated(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y, @NativeType("GLdouble") double z);
From source file:com.bluepowermod.part.tube.TubeStack.java
License:Open Source License
@SideOnly(Side.CLIENT) public void render(float partialTick) { if (renderMode == RenderMode.AUTO) { renderMode = Minecraft.getMinecraft().gameSettings.fancyGraphics ? RenderMode.NORMAL : RenderMode.REDUCED;// ww w . ja v a 2s . c o m } final RenderMode finalRenderMode = renderMode; if (customRenderItem == null) { customRenderItem = new RenderItem() { @Override public boolean shouldBob() { return false; }; @Override public byte getMiniBlockCount(ItemStack stack, byte original) { return finalRenderMode == RenderMode.REDUCED ? (byte) 1 : original; } }; customRenderItem.setRenderManager(RenderManager.instance); renderedItem = new EntityItem(FMLClientHandler.instance().getWorldClient()); renderedItem.hoverStart = 0.0F; } renderedItem.setEntityItemStack(stack); double renderProgress = (oldProgress + (progress - oldProgress) * partialTick) * 2 - 1; GL11.glPushMatrix(); GL11.glTranslated(heading.offsetX * renderProgress * 0.5, heading.offsetY * renderProgress * 0.5, heading.offsetZ * renderProgress * 0.5); if (finalRenderMode != RenderMode.NONE) { GL11.glPushMatrix(); if (stack.stackSize > 5) { GL11.glScaled(0.8, 0.8, 0.8); } if (!(stack.getItem() instanceof ItemBlock)) { GL11.glScaled(0.8, 0.8, 0.8); GL11.glTranslated(0, -0.15, 0); } customRenderItem.doRender(renderedItem, 0, 0, 0, 0, 0); GL11.glPopMatrix(); } else { float size = 0.02F; GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glBegin(GL11.GL_QUADS); RenderHelper.drawColoredCube(new Vec3dCube(-size, -size, -size, size, size, size), 1, 1, 1, 1); GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); } if (color != TubeColor.NONE) { float size = 0.2F; int colorInt = ItemDye.field_150922_c[color.ordinal()]; float red = (colorInt >> 16) / 256F; float green = (colorInt >> 8 & 255) / 256F; float blue = (colorInt & 255) / 256F; GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_LIGHTING); GL11.glColor3f(red, green, blue); Minecraft.getMinecraft().renderEngine .bindTexture(new ResourceLocation(Refs.MODID, "textures/blocks/tubes/inside_color_border.png")); RenderHelper.drawTesselatedTexturedCube(new Vec3dCube(-size, -size, -size, size, size, size)); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_LIGHTING); } GL11.glPopMatrix(); }
From source file:com.builtbroken.assemblyline.client.FakeItemRender.java
/** * Renders an item at the position/*from ww w .j av a2s. c o m*/ * <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 w w . 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)//from w w w. j a va 2 s . c om 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/*from www .j av a 2 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.items.cell.RendererItemCell.java
protected void applyRotation(ItemRenderType type) { if (type.equals(ItemRenderType.ENTITY)) { GL11.glRotated(180, 0, 0, 1);/*w ww . j a v a2s. c o m*/ GL11.glRotated(90, 0, 1, 0); GL11.glScaled(0.75, 0.75, 0.75); GL11.glTranslated(-0.5, -0.6, 0); } else if (type.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) { GL11.glTranslated(1, 1, 0); GL11.glRotated(180, 0, 0, 1); } else if (type.equals(ItemRenderType.EQUIPPED)) { GL11.glRotated(180, 0, 0, 1); GL11.glTranslated(-1, -1, 0); } }
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();/*from w w w .ja v a 2s.c o m*/ 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; } 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.TESRChemCentrifuge.java
@Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float deltaFrame) { GL11.glPushMatrix();/* w w w .j a v a2 s. c o m*/ 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; } 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(); }
From source file:com.builtbroken.atomic.content.machines.processing.extractor.render.TESRChemExtractor.java
@Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float deltaFrame) { GL11.glPushMatrix();/*from w ww . j a v a 2s . c o m*/ GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); GL11.glScaled(0.0625f, 0.0625f, 0.0625f); if (tile instanceof TileEntityChemExtractor) { TileEntityChemExtractor entityChemExtractor = (TileEntityChemExtractor) 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; } bindTexture(texture); //Render main body model_base.renderAll(); //Render rotating parts GL11.glTranslated(-2.5, 1.5, 0); float rotation = ((TileEntityChemExtractor) tile).rotate(deltaFrame); GL11.glRotatef(rotation, 0, 0, 1); model_drum.renderAll(); } GL11.glPopMatrix(); }
From source file:com.builtbroken.atomic.content.machines.reactor.fission.core.TESRReactorCell.java
@Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float deltaFrame) { GL11.glPushMatrix();//from ww w. j a v a 2s . c om GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); GL11.glScaled(0.0625f, 0.0625f, 0.0625f); if (tile instanceof TileEntityReactorCell) { TileEntityReactorCell reactorCell = (TileEntityReactorCell) tile; if (reactorCell.isBottom()) { bindTexture(bottom_texture); bottom_model.renderAll(); } else if (reactorCell.isTop()) { bindTexture(top_texture); top_model.renderAll(); } else if (reactorCell.isMiddle()) { bindTexture(middle_texture); middle_model.renderAll(); } else { bindTexture(normal_texture); normal_model.renderAll(); } if (reactorCell.shouldRenderFuel()) { //TODO render fuel rods //TODO decrease in size as fuel is used //TODO decrease in color (green -> grey) as its used //TODO glow when running (blue or green? hmm) //TODO glow molten like if overheating } } GL11.glPopMatrix(); }