List of usage examples for org.lwjgl.opengl GL11 glRotatef
public static native void glRotatef(@NativeType("GLfloat") float angle, @NativeType("GLfloat") float x, @NativeType("GLfloat") float y, @NativeType("GLfloat") float z);
From source file:de.keyle.dungeoncraft.editor.editors.world.render.Renderer.java
License:Open Source License
/** * Renders a rectangular decoration./* w ww. j av a2 s . co m*/ * * @param dimensions Dimension of the Texture * @param x Block X * @param y Block Y * @param z Block Z * @param rotate_degrees Degrees to rotate, use zero for no rotation * @param rotate_x Use 1.0f to rotate in the X direction (passed to glRotatef) * @param rotate_z Use 1.0f to rotate in the Z direction (passed to glRotatef) * @param x_off X offset, so it's not just in the center * @param z_off Z offset, so it's not just in the center */ public static void renderRectDecoration(TextureDimensions dimensions, float x, float y, float z, int rotate_degrees, float rotate_x, float rotate_z, float x_off, float z_off) { boolean do_rotate = false; float tx = 0, ty = 0, tz = 0; if (rotate_degrees != 0) { tx = x; ty = y; tz = z; x = x_off; y = 0; z = z_off; do_rotate = true; } float width = dimensions.getTexWidth() / TEX16; float width_h = width / 2f; float height = dimensions.getTexHeight() / TEX16; float top_tex_height; if (height > width) { top_tex_height = dimensions.getTexWidth() / 2f; } else { top_tex_height = dimensions.getTexHeight(); } // Math is for suckers; let's let the video hardware take care of rotation // Relatedly, is this how I should be drawing *everything?* Draw relative // to the origin for the actual verticies, and then translate? if (do_rotate) { GL11.glPushMatrix(); GL11.glTranslatef(tx, ty, tz); GL11.glRotatef((float) rotate_degrees, rotate_x, 0f, rotate_z); } // First draw the borders renderNonstandardVertical(dimensions, x - width_h, y + height, z - width_h, x + width_h, y, z - width_h); renderNonstandardVertical(dimensions, x - width_h, y + height, z + width_h, x + width_h, y, z + width_h); renderNonstandardVertical(dimensions, x + width_h, y + height, z - width_h, x + width_h, y, z + width_h); renderNonstandardVertical(dimensions, x - width_h, y + height, z + width_h, x - width_h, y, z - width_h); // Now the top renderNonstandardHorizontal(dimensions.getTexLeft(), dimensions.getTexTop(), dimensions.getTexWidth(), top_tex_height, x - width_h, z - width_h, x + width_h, z + width_h, y + height); if (do_rotate) { GL11.glPopMatrix(); } }
From source file:de.mineformers.powergrid.client.renderer.tileentity.TileCableRenderer.java
License:LGPL
@Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTick) { TileCable tile = (TileCable) tileentity; Tessellator tess = Tessellator.instance; this.bindTexture(TextureMap.locationBlocksTexture); EnumSet<ForgeDirection> cons = tile.getConnections(); this.bindBlock(); GL11.glPushMatrix();/*from ww w . j a v a 2 s. com*/ GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTranslated(x, y, z); drawBase(tess, cons); GL11.glTranslatef(0.5F, 0.5F, 0.5F); if (cons.contains(ForgeDirection.UP)) { drawConnection(tess); } if (cons.contains(ForgeDirection.DOWN)) { GL11.glRotatef(180, 1, 0, 0); drawConnection(tess); GL11.glRotatef(-180, 1, 0, 0); } if (cons.contains(ForgeDirection.EAST)) { GL11.glRotatef(-90, 0, 0, 1); drawConnection(tess); GL11.glRotatef(90, 0, 0, 1); } if (cons.contains(ForgeDirection.WEST)) { GL11.glRotatef(90, 0, 0, 1); drawConnection(tess); GL11.glRotatef(-90, 0, 0, 1); } if (cons.contains(ForgeDirection.NORTH)) { GL11.glRotatef(-90, 1, 0, 0); drawConnection(tess); GL11.glRotatef(90, 1, 0, 0); } if (cons.contains(ForgeDirection.SOUTH)) { GL11.glRotatef(90, 1, 0, 0); drawConnection(tess); GL11.glRotatef(-90, 1, 0, 0); } GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); }
From source file:de.mineformers.powergrid.client.renderer.tileentity.TileCableRenderer.java
License:LGPL
private void drawBase(Tessellator tess, EnumSet<ForgeDirection> cons) { /* Y Axis *///from ww w . j a v a2 s . c om drawBaseInverse(tess, cons); float offY = baseMod / 2F; if (!cons.contains(ForgeDirection.UP)) { this.drawBaseFluid(tess); this.bindBlock(); tess.startDrawingQuads(); tess.addVertexWithUV(0.25F, 0.75F, 0.75F, 0, offY + baseMod); tess.addVertexWithUV(0.75F, 0.75F, 0.75F, baseMod, offY + baseMod); tess.addVertexWithUV(0.75F, 0.75F, 0.25F, baseMod, offY + 0); tess.addVertexWithUV(0.25F, 0.75F, 0.25F, 0, offY + 0); tess.draw(); } if (!cons.contains(ForgeDirection.DOWN)) { GL11.glRotatef(-180, 1, 0, 0); GL11.glTranslatef(0, 0, -1); GL11.glTranslatef(0, -1F, 0); this.drawBaseFluid(tess); GL11.glTranslatef(0, 1F, 0); GL11.glTranslatef(0, 0, 1); GL11.glRotatef(180, 1, 0, 0); this.bindBlock(); tess.startDrawingQuads(); tess.addVertexWithUV(0.25F, 0.25F, 0.25F, 0, offY + 0); tess.addVertexWithUV(0.75F, 0.25F, 0.25F, baseMod, offY + 0); tess.addVertexWithUV(0.75F, 0.25F, 0.75F, baseMod, offY + baseMod); tess.addVertexWithUV(0.25F, 0.25F, 0.75F, 0, offY + baseMod); tess.draw(); } /* Z Axis */ if (!cons.contains(ForgeDirection.NORTH)) { GL11.glRotatef(-90, 1, 0, 0); GL11.glTranslatef(0, -1, 0); this.drawBaseFluid(tess); GL11.glTranslatef(0, 1, 0); GL11.glRotatef(90, 1, 0, 0); this.bindBlock(); tess.startDrawingQuads(); tess.addVertexWithUV(0.25F, 0.75F, 0.25F, baseMod, offY + 0); tess.addVertexWithUV(0.75F, 0.75F, 0.25F, 0, offY + 0); tess.addVertexWithUV(0.75F, 0.25F, 0.25F, 0, offY + baseMod); tess.addVertexWithUV(0.25F, 0.25F, 0.25F, baseMod, offY + baseMod); tess.draw(); } if (!cons.contains(ForgeDirection.SOUTH)) { GL11.glRotatef(90, 1, 0, 0); GL11.glTranslatef(0, 0, -1); this.drawBaseFluid(tess); GL11.glTranslatef(0, 0, 1); GL11.glRotatef(-90, 1, 0, 0); this.bindBlock(); tess.startDrawingQuads(); tess.addVertexWithUV(0.25F, 0.75F, 0.75F, 0, offY + 0); tess.addVertexWithUV(0.25F, 0.25F, 0.75F, 0, offY + baseMod); tess.addVertexWithUV(0.75F, 0.25F, 0.75F, baseMod, offY + baseMod); tess.addVertexWithUV(0.75F, 0.75F, 0.75F, baseMod, offY + 0); tess.draw(); } /* X Axis */ if (!cons.contains(ForgeDirection.EAST)) { GL11.glRotatef(-90, 0, 0, 1); GL11.glTranslatef(-1, 0, 0); this.drawBaseFluid(tess); GL11.glTranslatef(1, 0, 0); GL11.glRotatef(90, 0, 0, 1); this.bindBlock(); tess.startDrawingQuads(); tess.addVertexWithUV(0.75F, 0.75F, 0.75F, baseMod, offY); tess.addVertexWithUV(0.75F, 0.25F, 0.75F, baseMod, offY + baseMod); tess.addVertexWithUV(0.75F, 0.25F, 0.25F, 0, offY + baseMod); tess.addVertexWithUV(0.75F, 0.75F, 0.25F, 0, offY); tess.draw(); } if (!cons.contains(ForgeDirection.WEST)) { GL11.glRotatef(90, 0, 0, 1); GL11.glTranslatef(0, -1, 0); this.drawBaseFluid(tess); GL11.glTranslatef(0, 1, 0); GL11.glRotatef(-90, 0, 0, 1); this.bindBlock(); tess.startDrawingQuads(); tess.addVertexWithUV(0.25F, 0.75F, 0.75F, baseMod, offY + 0); tess.addVertexWithUV(0.25F, 0.75F, 0.25F, 0, offY + 0); tess.addVertexWithUV(0.25F, 0.25F, 0.25F, 0, offY + baseMod); tess.addVertexWithUV(0.25F, 0.25F, 0.75F, baseMod, offY + baseMod); tess.draw(); } }
From source file:de.mineformers.powergrid.client.renderer.tileentity.TileCableRenderer.java
License:LGPL
private void drawConnection(Tessellator tess) { float off = baseMod / 2F; drawConnectionInverse(tess);// ww w.j av a 2 s.com this.drawConnectionFluid(tess); this.bindBlock(); tess.startDrawingQuads(); tess.addVertexWithUV(0.25F, 0.5F, 0.25F, 0, 0); tess.addVertexWithUV(-0.25F, 0.5F, 0.25F, off * 2F, 0); tess.addVertexWithUV(-0.25F, 0.25F, 0.25F, off * 2F, off); tess.addVertexWithUV(0.25F, 0.25F, 0.25F, 0, off); tess.draw(); GL11.glRotatef(180, 0, 1, 0); this.drawConnectionFluid(tess); GL11.glRotatef(-180, 0, 1, 0); this.bindBlock(); tess.startDrawingQuads(); tess.addVertexWithUV(0.25F, 0.5F, -0.25F, off * 2, 0); tess.addVertexWithUV(0.25F, 0.25F, -0.25F, off * 2, off); tess.addVertexWithUV(-0.25F, 0.25F, -0.25F, 0, off); tess.addVertexWithUV(-0.25F, 0.5F, -0.25F, 0, 0); tess.draw(); GL11.glRotatef(90, 0, 1, 0); this.drawConnectionFluid(tess); GL11.glRotatef(-90, 0, 1, 0); this.bindBlock(); tess.startDrawingQuads(); tess.addVertexWithUV(-0.25F, 0.5F, -0.25F, 0, 0); tess.addVertexWithUV(-0.25F, 0.25F, -0.25F, 0, off); tess.addVertexWithUV(-0.25F, 0.25F, 0.25F, off * 2, off); tess.addVertexWithUV(-0.25F, 0.5F, 0.25F, off * 2, 0); tess.draw(); GL11.glRotatef(-90, 0, 1, 0); this.drawConnectionFluid(tess); GL11.glRotatef(90, 0, 1, 0); this.bindBlock(); tess.startDrawingQuads(); tess.addVertexWithUV(0.25F, 0.5F, -0.25F, off * 2, 0); tess.addVertexWithUV(0.25F, 0.5F, 0.25F, 0, 0); tess.addVertexWithUV(0.25F, 0.25F, 0.25F, 0, off); tess.addVertexWithUV(0.25F, 0.25F, -0.25F, off * 2, off); tess.draw(); }
From source file:de.mineformers.robots.client.gui.util.render.ModelDrawingHelper.java
License:LGPL
public void render(int par0, int par1, int par2) { GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glPushMatrix();//ww w . java 2 s . c o m GL11.glTranslatef((float) par0, (float) par1, 50.0F); GL11.glScalef((float) (-par2), (float) par2, (float) par2); GL11.glRotatef(180F, 0, 1, 0); /*current = System.currentTimeMillis(); if(current - last >= 0) { last = current; rotation += 0.1F; }*/ rotation += 0.3F; GL11.glRotatef(rotation, 0, 1, 0); RenderHelper.bindTexture(texture); model.justRender(false); if (tile.getStackInSlot(0) != null) { Tessellator tessellator = Tessellator.instance; GL11.glPushMatrix(); GL11.glTranslatef(0, 0.35F, -0.1F); GL11.glRotatef(180, 1, 0, 0); GL11.glScalef(0.5F, 0.5F, 1F); Icon icon = ModItems.module.getIcon(tile.getStackInSlot(0), 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; ItemStack itemstack = tile.getStackInSlot(0); 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); 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(); } GL11.glPopMatrix(); net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); GL11.glDisable(GL11.GL_TEXTURE_2D); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); }
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 va 2 s.co 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();/* w w w .j ava 2 s.c o m*/ 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. co 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); GL11.glRotatef(90, 0, 1, 0);/* w w w .j a va 2 s. com*/ 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); GL11.glRotatef(90, 0, 1, 0);//from w w w .ja va2 s. com modelAnalyzer.renderAll(0); GL11.glPopMatrix(); // end }