public void renderArrow( ProjectileConfusion proj, double par2, double par4, double par6, float par8, float par9) { this.bindEntityTexture(proj); GL11.glPushMatrix(); GL11.glTranslatef((float) par2, (float) par4, (float) par6); GL11.glRotatef( proj.prevRotationYaw + (proj.rotationYaw - proj.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef( proj.prevRotationPitch + (proj.rotationPitch - proj.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F); Tessellator tessellator = Tessellator.instance; byte b0 = 0; float f2 = 0.0F; float f3 = 0.5F; float f4 = (float) (0 + b0 * 10) / 32.0F; float f5 = (float) (5 + b0 * 10) / 32.0F; float f6 = 0.0F; float f7 = 0.15625F; float f8 = (float) (5 + b0 * 10) / 32.0F; float f9 = (float) (10 + b0 * 10) / 32.0F; float f10 = 0.05625F; GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F); GL11.glScalef(f10, f10, f10); GL11.glTranslatef(-4.0F, 0.0F, 0.0F); GL11.glNormal3f(f10, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f8); tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f8); tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f9); tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f9); tessellator.draw(); GL11.glNormal3f(-f10, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f8); tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f8); tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f9); tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f9); tessellator.draw(); for (int i = 0; i < 4; ++i) { GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); GL11.glNormal3f(0.0F, 0.0F, f10); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double) f2, (double) f4); tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double) f3, (double) f4); tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double) f3, (double) f5); tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double) f2, (double) f5); tessellator.draw(); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
static void drawTorus(float r, float R, int nsides, int rings) { float ringDelta = 2.0f * (float) Math.PI / rings; float sideDelta = 2.0f * (float) Math.PI / nsides; float theta = 0.0f, cosTheta = 1.0f, sinTheta = 0.0f; for (int i = rings - 1; i >= 0; i--) { float theta1 = theta + ringDelta; float cosTheta1 = (float) Math.cos(theta1); float sinTheta1 = (float) Math.sin(theta1); GL11.glBegin(GL11.GL_QUAD_STRIP); float phi = 0.0f; for (int j = nsides; j >= 0; j--) { phi += sideDelta; float cosPhi = (float) Math.cos(phi); float sinPhi = (float) Math.sin(phi); float dist = R + r * cosPhi; GL11.glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi); GL11.glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi); GL11.glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi); GL11.glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi); } GL11.glEnd(); theta = theta1; cosTheta = cosTheta1; sinTheta = sinTheta1; } }
private void renderMask() { glBegin(GL_QUADS); { // glColor3f(1.0f, 0.0f, 0.0f); for (int i = 0; i < maskFaces.size(); i++) { Vector3f n1 = maskNormals.get((int) (maskFaces.get(i).normal.x)); glNormal3f(n1.x, n1.y, n1.z); Vector3f v1 = maskVerticies.get((int) (maskFaces.get(i).vertex.x)); glVertex3f(v1.x, v1.y, v1.z); Vector3f n2 = maskNormals.get((int) (maskFaces.get(i).normal.y)); glNormal3f(n2.x, n2.y, n2.z); Vector3f v2 = maskVerticies.get((int) (maskFaces.get(i).vertex.y)); glVertex3f(v2.x, v2.y, v2.z); Vector3f n3 = maskNormals.get((int) (maskFaces.get(i).normal.z)); glNormal3f(n3.x, n3.y, n3.z); Vector3f v3 = maskVerticies.get((int) (maskFaces.get(i).vertex.z)); glVertex3f(v3.x, v3.y, v3.z); Vector3f n4 = maskNormals.get((int) (maskFaces.get(i).normal.w)); glNormal3f(n4.x, n4.y, n4.z); Vector3f v4 = maskVerticies.get((int) (maskFaces.get(i).vertex.w)); glVertex3f(v4.x, v4.y, v4.z); } } glEnd(); }
public void DrawTexturedCube() { t.bind(); glBegin(GL_QUADS); { // Front Face glNormal3f(0.0f, 0.0f, 0.5f); glTexCoord2f(0.0f, 0.125f); glVertex3f(-1.0f, -1.0f, 1.0f); glTexCoord2f(0.125f, 0.125f); glVertex3f(1.0f, -1.0f, 1.0f); glTexCoord2f(0.125f, 0.0f); glVertex3f(1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Back Face glNormal3f(0.0f, 0.0f, -0.5f); glTexCoord2f(0.25f, 0.125f); glVertex3f(-1.0f, -1.0f, -1.0f); glTexCoord2f(0.25f, 0.0f); glVertex3f(-1.0f, 1.0f, -1.0f); glTexCoord2f(0.125f, 0.0f); glVertex3f(1.0f, 1.0f, -1.0f); glTexCoord2f(0.125f, 0.125f); glVertex3f(1.0f, -1.0f, -1.0f); /* // Top Face glNormal3f( 0.0f, 0.5f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Bottom Face glNormal3f( 0.0f,-0.5f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Right Face glNormal3f( 0.5f, 0.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Left Face glNormal3f(-0.5f, 0.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); */ } glEnd(); }
public void draw() { float x = 0, y = 0, z = 0, X = (float) -Math.PI, Y = 0.0f, Z = 0.0f; Vector3f first = new Vector3f(); Vector3f second = new Vector3f(); Vector3f thrird = new Vector3f(); glPushMatrix(); { glTranslatef(translate.getX(), translate.getY(), translate.getZ()); glRotatef(angleOfRotation, rotate.getX(), rotate.getY(), rotate.getZ()); glScalef(scale.getX(), scale.getY(), scale.getZ()); glColor3f(color.getX(), color.getY(), color.getY()); glDisable(GL_CULL_FACE); glLineWidth(10); glBegin(GL_LINE_STRIP); { while (X < 2 * Math.PI) { while (Y < 2 * Math.PI) { x = size * (float) Math.cos(X) * (float) Math.cos(Y); y = size * (float) Math.cos(X) * (float) Math.sin(Y); z = size * (float) Math.sin(X); glVertex3f(x, y, z); first.setX(x); first.setY(y); first.setZ(z); x = size * (float) Math.cos(X) * (float) Math.cos(Y); y = size * (float) Math.cos(X) * (float) Math.sin(Y); z = size * (float) Math.sin(X); glVertex3f(x, y, z); second.setX(x); second.setY(y); second.setZ(z); x = size * (float) Math.cos(X) * (float) Math.cos(Y); y = size * (float) Math.cos(X) * (float) Math.sin(Y); z = size * (float) Math.sin(X); glVertex3f(x, y, z); Y += 0.1; thrird.setX(x); thrird.setY(y); thrird.setZ(z); first = thrird.crossProduct(first, second, thrird); glNormal3f(first.getX(), first.getY(), first.getZ()); } Y = 0; X += 0.1; } } glEnd(); glEnable(GL_CULL_FACE); glLineWidth(1); } glPopMatrix(); }
@Override protected void doFlush() { // TODO: Use fallback material modes for this if (!(activeMaterial.getShader() instanceof BasicShader)) { throw new IllegalStateException("Need Basic Shader in 1.1 mode"); } GL11.glNewList(displayList, GL11.GL_COMPILE); ((BasicShader) activeMaterial.getShader()).assign(true); GL11.glPushMatrix(); GL11.glBegin(renderMode); for (int i = 0; i < numVerticies; i += 1) { int index = i * 4; if (useColors) { GL11.glColor3f( colorBuffer.get(index), colorBuffer.get(index + 1), colorBuffer.get(index + 2)); } if (useNormals) { GL11.glNormal3f( normalBuffer.get(index), normalBuffer.get(index + 1), normalBuffer.get(index + 2)); } if (useTextures) { GL11.glTexCoord2f(uvBuffer.get((i * 2)), uvBuffer.get((i * 2) + 1)); } GL11.glVertex4f( vertexBuffer.get(index), vertexBuffer.get(index + 1), vertexBuffer.get(index + 2), vertexBuffer.get(index + 3)); } GL11.glEnd(); GL11.glPopMatrix(); GL11.glEndList(); }
public static void drawModel(Model m) { glFrontFace(GL_CCW); glCullFace(GL_BACK); glEnable(GL_CULL_FACE); glDepthFunc(GL_LEQUAL); glEnable(GL_DEPTH_TEST); for (Polygon p : m.mesh) { glBindTexture(GL_TEXTURE_2D, p.tex.id); glBegin(GL_TRIANGLES); { for (Vertex v : p.vertices) { glTexCoord2f(v.uv.x, v.uv.y); glNormal3f(v.norm.x, v.norm.y, v.norm.z); glVertex3f(v.pos.x, v.pos.y, v.pos.z); } } glEnd(); } glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); }
public static void floor() { glBindTexture(GL_TEXTURE_2D, Main.tex_floor); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); FloatBuffer color = BufferUtils.createFloatBuffer(4); color.put(1).put(0.8f).put(0.6f).put(1).flip(); glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color); color = BufferUtils.createFloatBuffer(4); color.put(0).put(0).put(0).put(1).flip(); glMaterial(GL_FRONT, GL_SPECULAR, color); glBegin(GL_QUADS); glNormal3f(0, 1, 0); for (int a = ZA_FLOOR_START; a < ZA_FLOOR_END; a += ZA_FLOOR_RES) { for (int b = ZA_FLOOR_START; b < ZA_FLOOR_END; b += ZA_FLOOR_RES) { glTexCoord2f(0, 0); glVertex3f(a, 0, b); glTexCoord2f(0, 1); glVertex3f(a, 0, b + ZA_FLOOR_RES); glTexCoord2f(1, 1); glVertex3f(a + ZA_FLOOR_RES, 0, b + ZA_FLOOR_RES); glTexCoord2f(1, 0); glVertex3f(a + ZA_FLOOR_RES, 0, b); } } glEnd(); glBindTexture(GL_TEXTURE_2D, ResourceLoader.white); color = BufferUtils.createFloatBuffer(4); color.put(1).put(0.8f).put(0.6f).put(1).flip(); glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color); }
public void drawGuiContainerForegroundLayer(int par1, int par2) { GL11.glNormal3f(0.0F, -1.0F, 0.0F); drawString(fontRenderer, "Lvl: " + targetPacket.lvl, 15, -14, 0xcccccc); drawString( fontRenderer, String.valueOf(targetPacket.getNationalPokedexNumber()), -30, -14, 0xcccccc); drawString(fontRenderer, "OT. Trainer", -20, 100, 0xcccccc); drawCenteredString(fontRenderer, String.valueOf(mc.thePlayer.username), 8, 115, 0xcccccc); drawString(fontRenderer, "HP:", 60, -7, 0xcccccc); drawString( fontRenderer, String.valueOf(targetPacket.HP), 200 - (String.valueOf(targetPacket.HP).length() * 3), -7, 0xcccccc); drawString(fontRenderer, "Attack:", 60, 13, 0xcccccc); drawString( fontRenderer, String.valueOf(targetPacket.Attack), 200 - (String.valueOf(targetPacket.Attack).length() * 3), 13, 0xcccccc); drawString(fontRenderer, "Defence:", 60, 32, 0xcccccc); drawString( fontRenderer, String.valueOf(targetPacket.Defence), 200 - (String.valueOf(targetPacket.Defence).length() * 3), 32, 0xcccccc); drawString(fontRenderer, "SP.Attack:", 60, 53, 0xcccccc); drawString( fontRenderer, String.valueOf(targetPacket.SpecialAttack), 200 - (String.valueOf(targetPacket.SpecialAttack).length() * 3), 53, 0xcccccc); drawString(fontRenderer, "SP.Defense:", 60, 73, 0xcccccc); drawString( fontRenderer, String.valueOf(targetPacket.SpecialDefence), 200 - (String.valueOf(targetPacket.SpecialDefence).length() * 3), 73, 0xcccccc); drawString(fontRenderer, "Speed:", 60, 93, 0xcccccc); drawString( fontRenderer, String.valueOf(targetPacket.Speed), 200 - (String.valueOf(targetPacket.Speed).length() * 3), 93, 0xcccccc); drawString(fontRenderer, "Happiness", 72, 115, 0xcccccc); drawCenteredString(fontRenderer, String.valueOf(targetPacket.friendship), 95, 130, 0xcccccc); drawString(fontRenderer, "Nature", 158, 115, 0xcccccc); drawCenteredString(fontRenderer, targetPacket.nature.toString(), 174, 130, -1); drawCenteredString(fontRenderer, "Growth", 8, 135, 0xcccccc); drawCenteredString(fontRenderer, targetPacket.growth.toString(), 8, 148, -1); drawString(fontRenderer, "Stats", 145, 166, -6250336); }
/** Renders an entity's name above its head */ protected void renderLivingLabel( T entityIn, String str, double x, double y, double z, int maxDistance) { double d0 = entityIn.getDistanceSqToEntity(this.renderManager.livingPlayer); if (d0 <= (double) (maxDistance * maxDistance)) { FontRenderer fontrenderer = this.getFontRendererFromRenderManager(); float f = 1.6F; float f1 = 0.016666668F * f; GlStateManager.pushMatrix(); GlStateManager.translate((float) x + 0.0F, (float) y + entityIn.height + 0.5F, (float) z); GL11.glNormal3f(0.0F, 1.0F, 0.0F); GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); GlStateManager.scale(-f1, -f1, f1); GlStateManager.disableLighting(); GlStateManager.depthMask(false); GlStateManager.disableDepth(); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); int i = 0; if (str.equals("deadmau5")) { i = -10; } int j = fontrenderer.getStringWidth(str) / 2; GlStateManager.disableTexture2D(); worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); worldrenderer .pos((double) (-j - 1), (double) (-1 + i), 0.0D) .color(0.0F, 0.0F, 0.0F, 0.25F) .endVertex(); worldrenderer .pos((double) (-j - 1), (double) (8 + i), 0.0D) .color(0.0F, 0.0F, 0.0F, 0.25F) .endVertex(); worldrenderer .pos((double) (j + 1), (double) (8 + i), 0.0D) .color(0.0F, 0.0F, 0.0F, 0.25F) .endVertex(); worldrenderer .pos((double) (j + 1), (double) (-1 + i), 0.0D) .color(0.0F, 0.0F, 0.0F, 0.25F) .endVertex(); tessellator.draw(); GlStateManager.enableTexture2D(); fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, i, 553648127); GlStateManager.enableDepth(); GlStateManager.depthMask(true); fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, i, -1); GlStateManager.enableLighting(); GlStateManager.disableBlend(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.popMatrix(); } }
/** * @param path Path of the .obj file * @param index GLUint */ public static void name(String path, int index) { int list = glGenLists(index); glNewList(list, GL_COMPILE); { Model m = null; try { m = OBJLoader.loadModel(new File(path)); } catch (FileNotFoundException e) { e.printStackTrace(); Display.destroy(); System.exit(1); } catch (IOException e) { e.printStackTrace(); Display.destroy(); System.exit(1); } float b; // glColor3f(0.3f, 0.20f, 0.13f); b = (float) Math.random(); glColor3f(b, 0, 0); int count = 0; glBegin(GL_TRIANGLES); for (Face face : m.faces) { count++; Vector3f n1 = m.normals.get((int) face.normal.x - 1); glNormal3f(n1.x, n1.y, n1.z); Vector3f v1 = m.vertices.get((int) face.vertex.x - 1); glVertex3f(v1.x, v1.y, v1.z); Vector3f n2 = m.normals.get((int) face.normal.y - 1); glNormal3f(n2.x, n2.y, n2.z); Vector3f v2 = m.vertices.get((int) face.vertex.y - 1); glVertex3f(v2.x, v2.y, v2.z); Vector3f n3 = m.normals.get((int) face.normal.z - 1); glNormal3f(n3.x, n3.y, n3.z); Vector3f v3 = m.vertices.get((int) face.vertex.z - 1); glVertex3f(v3.x, v3.y, v3.z); } glEnd(); System.out.println(count); } glEndList(); }
protected void renderLivingLabel( EntityLiving var1, String var2, double var3, double var5, double var7, int var9, int color, int color2) { // Spout end float var10 = var1.getDistanceToEntity(this.renderManager.livingPlayer); if (var10 <= (float) var9) { FontRenderer var11 = this.getFontRendererFromRenderManager(); float var12 = 1.6F; float var13 = 0.016666668F * var12; GL11.glPushMatrix(); GL11.glTranslatef((float) var3 + 0.0F, (float) var5 + 2.3F, (float) var7); GL11.glNormal3f(0.0F, 1.0F, 0.0F); GL11.glRotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); GL11.glScalef(-var13, -var13, var13); GL11.glDisable(2896 /*GL_LIGHTING*/); GL11.glDepthMask(false); GL11.glDisable(2929 /*GL_DEPTH_TEST*/); GL11.glEnable(3042 /*GL_BLEND*/); GL11.glBlendFunc(770, 771); Tessellator var14 = Tessellator.instance; byte var15 = 0; if (var2.equals("deadmau5")) { var15 = -10; } GL11.glDisable(3553 /*GL_TEXTURE_2D*/); var14.startDrawingQuads(); int var16 = var11.getStringWidth(var2) / 2; var14.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); var14.addVertex((double) (-var16 - 1), (double) (-1 + var15), 0.0D); var14.addVertex((double) (-var16 - 1), (double) (8 + var15), 0.0D); var14.addVertex((double) (var16 + 1), (double) (8 + var15), 0.0D); var14.addVertex((double) (var16 + 1), (double) (-1 + var15), 0.0D); var14.draw(); GL11.glEnable(3553 /*GL_TEXTURE_2D*/); var11.drawString( var2, -var11.getStringWidth(var2) / 2, var15, color); // Spout (changed to color var) GL11.glEnable(2929 /*GL_DEPTH_TEST*/); GL11.glDepthMask(true); var11.drawString( var2, -var11.getStringWidth(var2) / 2, var15, color2); // Spout (changed to color2 var) GL11.glEnable(2896 /*GL_LIGHTING*/); GL11.glDisable(3042 /*GL_BLEND*/); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glPopMatrix(); } }
public void initializeDisplayList() { list = glGenLists(1); glNewList(list, GL_COMPILE); { glBegin(GL_TRIANGLES); { // glColor3f(1.0f, 1.0f, 0.0f); for (int i = 0; i < triFaces.size(); i++) { // glColor3f(1.0f, 0.0f, 0.0f); Vector3f n1 = normals.get((int) (triFaces.get(i).normal.x - 1)); glNormal3f(n1.x, n1.y, n1.z); Vector3f v1 = verticies.get((int) (triFaces.get(i).vertex.x - 1)); glVertex3f(v1.x, v1.y, v1.z); // glColor3f(0.0f, 1.0f, 0.0f); Vector3f n2 = normals.get((int) (triFaces.get(i).normal.y - 1)); glNormal3f(n2.x, n2.y, n2.z); Vector3f v2 = verticies.get((int) (triFaces.get(i).vertex.y - 1)); glVertex3f(v2.x, v2.y, v2.z); // glColor3f(0.0f, 0.0f, 1.0f); Vector3f n3 = normals.get((int) (triFaces.get(i).normal.z - 1)); glNormal3f(n3.x, n3.y, n3.z); Vector3f v3 = verticies.get((int) (triFaces.get(i).vertex.z - 1)); glVertex3f(v3.x, v3.y, v3.z); } } glEnd(); glBegin(GL_QUADS); { // glColor3f(1.0f, 0.0f, 0.0f); for (int i = 0; i < quadFaces.size(); i++) { // glColor3f(1.0f, 0.0f, 0.0f); Vector3f n1 = normals.get((int) (quadFaces.get(i).normal.x - 1)); glNormal3f(n1.x, n1.y, n1.z); Vector3f v1 = verticies.get((int) (quadFaces.get(i).vertex.x - 1)); glVertex3f(v1.x, v1.y, v1.z); // glColor3f(0.0f, 1.0f, 0.0f); Vector3f n2 = normals.get((int) (quadFaces.get(i).normal.y - 1)); glNormal3f(n2.x, n2.y, n2.z); Vector3f v2 = verticies.get((int) (quadFaces.get(i).vertex.y - 1)); glVertex3f(v2.x, v2.y, v2.z); // glColor3f(0.0f, 0.0f, 1.0f); Vector3f n3 = normals.get((int) (quadFaces.get(i).normal.z - 1)); glNormal3f(n3.x, n3.y, n3.z); Vector3f v3 = verticies.get((int) (quadFaces.get(i).vertex.z - 1)); glVertex3f(v3.x, v3.y, v3.z); Vector3f n4 = normals.get((int) (quadFaces.get(i).normal.w - 1)); glNormal3f(n4.x, n4.y, n4.z); Vector3f v4 = verticies.get((int) (quadFaces.get(i).vertex.w - 1)); glVertex3f(v4.x, v4.y, v4.z); } } glEnd(); } glEndList(); }
protected void renderVert(Mesh m, Face face, int i) { Vert n1 = m.normals.get(face.normalIndices[i]); GL11.glNormal3f(n1.xf(), n1.yf(), n1.zf()); Vert v1 = m.getVertices().get(face.vertexIndices[i]); GL11.glVertex3f(v1.xf(), v1.yf(), v1.zf()); if (m.textureCoordinates.size() >= face.textureCoordinateIndices[i]) { UVPoint t1 = m.textureCoordinates.get(face.textureCoordinateIndices[i]); GL11.glTexCoord2f(t1.xf(), t1.yf()); } }
/** Used to render a player's name above their head */ protected void renderName(EntityPlayer par1EntityPlayer, double par2, double par4, double par6) { if (Minecraft.isGuiEnabled() && par1EntityPlayer != renderManager.livingPlayer) { float f = 1.6F; float f1 = 0.01666667F * f; float f2 = par1EntityPlayer.getDistanceToEntity(renderManager.livingPlayer); float f3 = par1EntityPlayer.isSneaking() ? 32F : 64F; if (f2 < f3) { String s = par1EntityPlayer.username; if (!par1EntityPlayer.isSneaking()) { if (par1EntityPlayer.isPlayerSleeping()) { renderLivingLabel(par1EntityPlayer, s, par2, par4 - 1.5D, par6, 64); } else { renderLivingLabel(par1EntityPlayer, s, par2, par4, par6, 64); } } else { FontRenderer fontrenderer = getFontRendererFromRenderManager(); GL11.glPushMatrix(); GL11.glTranslatef((float) par2 + 0.0F, (float) par4 + 2.3F, (float) par6); GL11.glNormal3f(0.0F, 1.0F, 0.0F); GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F); GL11.glScalef(-f1, -f1, f1); GL11.glDisable(GL11.GL_LIGHTING); GL11.glTranslatef(0.0F, 0.25F / f1, 0.0F); GL11.glDepthMask(false); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); Tessellator tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); int i = fontrenderer.getStringWidth(s) / 2; tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); tessellator.addVertex(-i - 1, -1D, 0.0D); tessellator.addVertex(-i - 1, 8D, 0.0D); tessellator.addVertex(i + 1, 8D, 0.0D); tessellator.addVertex(i + 1, -1D, 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDepthMask(true); fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, 0, 0x20ffffff); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glPopMatrix(); } } } }
/** Draws the debug or playername text above a living */ protected void renderLivingLabel( EntityLiving par1EntityLiving, String par2Str, double par3, double par5, double par7, int par9) { float f = par1EntityLiving.getDistanceToEntity(renderManager.livingPlayer); if (f > (float) par9) { return; } FontRenderer fontrenderer = getFontRendererFromRenderManager(); float f1 = 1.6F; float f2 = 0.01666667F * f1; GL11.glPushMatrix(); GL11.glTranslatef((float) par3 + 0.0F, (float) par5 + 2.3F, (float) par7); GL11.glNormal3f(0.0F, 1.0F, 0.0F); GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F); GL11.glScalef(-f2, -f2, f2); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthMask(false); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); Tessellator tessellator = Tessellator.instance; byte byte0 = 0; if (par2Str.equals("deadmau5")) { byte0 = -10; } GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); int i = fontrenderer.getStringWidth(par2Str) / 2; tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); tessellator.addVertex(-i - 1, -1 + byte0, 0.0D); tessellator.addVertex(-i - 1, 8 + byte0, 0.0D); tessellator.addVertex(i + 1, 8 + byte0, 0.0D); tessellator.addVertex(i + 1, -1 + byte0, 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); fontrenderer.drawString(par2Str, -fontrenderer.getStringWidth(par2Str) / 2, byte0, 0x20ffffff); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); fontrenderer.drawString(par2Str, -fontrenderer.getStringWidth(par2Str) / 2, byte0, -1); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glPopMatrix(); }
protected void a( pk p_147906_1_, String p_147906_2_, double p_147906_3_, double p_147906_5_, double p_147906_7_, int p_147906_9_) { double var10 = p_147906_1_.h(this.b.c); if (var10 <= p_147906_9_ * p_147906_9_) { avn var12 = c(); float var13 = 1.6F; float var14 = 0.016666668F * var13; bfl.E(); bfl.b( (float) p_147906_3_ + 0.0F, (float) p_147906_5_ + p_147906_1_.K + 0.5F, (float) p_147906_7_); GL11.glNormal3f(0.0F, 1.0F, 0.0F); bfl.b(-this.b.e, 0.0F, 1.0F, 0.0F); bfl.b(this.b.f, 1.0F, 0.0F, 0.0F); bfl.a(-var14, -var14, var14); bfl.f(); bfl.a(false); bfl.i(); bfl.l(); bfl.a(770, 771, 1, 0); bfx var15 = bfx.a(); bfd var16 = var15.c(); byte var17 = 0; if (p_147906_2_.equals("deadmau5")) { var17 = -10; } int var18 = var12.a(p_147906_2_) / 2; bfl.x(); var16.a(7, bms.f); var16.b(-var18 - 1, -1 + var17, 0.0D).a(0.0F, 0.0F, 0.0F, 0.25F).d(); var16.b(-var18 - 1, 8 + var17, 0.0D).a(0.0F, 0.0F, 0.0F, 0.25F).d(); var16.b(var18 + 1, 8 + var17, 0.0D).a(0.0F, 0.0F, 0.0F, 0.25F).d(); var16.b(var18 + 1, -1 + var17, 0.0D).a(0.0F, 0.0F, 0.0F, 0.25F).d(); var15.b(); bfl.w(); var12.a(p_147906_2_, -var12.a(p_147906_2_) / 2, var17, 553648127); bfl.j(); bfl.a(true); var12.a(p_147906_2_, -var12.a(p_147906_2_) / 2, var17, -1); bfl.e(); bfl.k(); bfl.c(1.0F, 1.0F, 1.0F, 1.0F); bfl.F(); } }
protected void func_22015_a( EntityPlayer p_22015_1_, double p_22015_2_, double p_22015_4_, double p_22015_6_) { if (Minecraft.func_22006_t() && p_22015_1_ != this.field_191_a.field_22188_h) { float var8 = 1.6F; float var9 = 0.016666668F * var8; float var10 = p_22015_1_.func_379_d(this.field_191_a.field_22188_h); float var11 = p_22015_1_.func_381_o() ? 32.0F : 64.0F; if (var10 < var11) { String var12 = p_22015_1_.field_771_i; if (!p_22015_1_.func_381_o()) { if (p_22015_1_.func_22051_K()) { this.func_22013_a(p_22015_1_, var12, p_22015_2_, p_22015_4_ - 1.5D, p_22015_6_, 64); } else { this.func_22013_a(p_22015_1_, var12, p_22015_2_, p_22015_4_, p_22015_6_, 64); } } else { FontRenderer var13 = this.func_6329_a(); GL11.glPushMatrix(); GL11.glTranslatef( (float) p_22015_2_ + 0.0F, (float) p_22015_4_ + 2.3F, (float) p_22015_6_); GL11.glNormal3f(0.0F, 1.0F, 0.0F); GL11.glRotatef(-this.field_191_a.field_1225_i, 0.0F, 1.0F, 0.0F); GL11.glRotatef(this.field_191_a.field_1224_j, 1.0F, 0.0F, 0.0F); GL11.glScalef(-var9, -var9, var9); GL11.glDisable(2896); GL11.glTranslatef(0.0F, 0.25F / var9, 0.0F); GL11.glDepthMask(false); GL11.glEnable(3042); GL11.glBlendFunc(770, 771); Tessellator var14 = Tessellator.field_1512_a; GL11.glDisable(3553); var14.func_977_b(); int var15 = var13.func_871_a(var12) / 2; var14.func_986_a(0.0F, 0.0F, 0.0F, 0.25F); var14.func_991_a((double) (-var15 - 1), -1.0D, 0.0D); var14.func_991_a((double) (-var15 - 1), 8.0D, 0.0D); var14.func_991_a((double) (var15 + 1), 8.0D, 0.0D); var14.func_991_a((double) (var15 + 1), -1.0D, 0.0D); var14.func_982_a(); GL11.glEnable(3553); GL11.glDepthMask(true); var13.func_873_b(var12, -var13.func_871_a(var12) / 2, 0, 553648127); GL11.glEnable(2896); GL11.glDisable(3042); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glPopMatrix(); } } } }
public void opengldrawtolist() { this.objectlist = GL11.glGenLists(1); GL11.glNewList(objectlist, GL11.GL_COMPILE); for (int i = 0; i < faces.size(); i++) { int[] tempfaces = (int[]) (faces.get(i)); // TODO magic int[] tempfacesnorms = (int[]) (facesnorms.get(i)); int[] tempfacestexs = (int[]) (facestexs.get(i)); //// Quad Begin Header //// int polytype; if (tempfaces.length == 3) { polytype = GL11.GL_TRIANGLES; } else if (tempfaces.length == 4) { polytype = GL11.GL_QUADS; } else { polytype = GL11.GL_POLYGON; } GL11.glBegin(polytype); //////////////////////////// for (int w = 0; w < tempfaces.length; w++) { if (tempfacesnorms[w] != 0) { float normtempx = ((float[]) vertexsetsnorms.get(tempfacesnorms[w] - 1))[0]; float normtempy = ((float[]) vertexsetsnorms.get(tempfacesnorms[w] - 1))[1]; float normtempz = ((float[]) vertexsetsnorms.get(tempfacesnorms[w] - 1))[2]; GL11.glNormal3f(normtempx, normtempy, normtempz); } if (tempfacestexs[w] != 0) { float textempx = ((float[]) vertexsetstexs.get(tempfacestexs[w] - 1))[0]; float textempy = ((float[]) vertexsetstexs.get(tempfacestexs[w] - 1))[1]; float textempz = ((float[]) vertexsetstexs.get(tempfacestexs[w] - 1))[2]; GL11.glTexCoord3f(textempx, 1f - textempy, textempz); } float tempx = ((float[]) vertexsets.get(tempfaces[w] - 1))[0]; float tempy = ((float[]) vertexsets.get(tempfaces[w] - 1))[1]; float tempz = ((float[]) vertexsets.get(tempfaces[w] - 1))[2]; GL11.glVertex3f(tempx, tempy, tempz); } //// Quad End Footer ///// GL11.glEnd(); /////////////////////////// } GL11.glEndList(); }
private static void setUpDisplayLists() { bunnyDisplayList = glGenLists(1); glNewList(bunnyDisplayList, GL_COMPILE); { Model m = null; try { m = OBJLoader.loadModel(new File(MODEL_LOCATION)); } catch (FileNotFoundException e) { e.printStackTrace(); Display.destroy(); System.exit(1); } catch (IOException e) { e.printStackTrace(); Display.destroy(); System.exit(1); } glColor3f(0.4f, 0.27f, 0.17f); glBegin(GL_TRIANGLES); for (Face face : m.faces) { Vector3f n1 = m.normals.get((int) face.normal.x - 1); glNormal3f(n1.x, n1.y, n1.z); Vector3f v1 = m.vertices.get((int) face.vertex.x - 1); glVertex3f(v1.x, v1.y, v1.z); Vector3f n2 = m.normals.get((int) face.normal.y - 1); glNormal3f(n2.x, n2.y, n2.z); Vector3f v2 = m.vertices.get((int) face.vertex.y - 1); glVertex3f(v2.x, v2.y, v2.z); Vector3f n3 = m.normals.get((int) face.normal.z - 1); glNormal3f(n3.x, n3.y, n3.z); Vector3f v3 = m.vertices.get((int) face.vertex.z - 1); glVertex3f(v3.x, v3.y, v3.z); } glEnd(); } glEndList(); }
public void renderBackground(float paramRed, float paramGreen, float paramBlue) { glPushMatrix(); glDisable(GL_BLEND); glBegin(GL_QUADS); glColor3f(paramRed, paramGreen, paramBlue); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glNormal3f(0f, 0f, 1.0f); glVertex2f(0, 0); glVertex2f(Display.getWidth(), 0); glVertex2f(Display.getWidth(), Display.getHeight()); glVertex2f(0, Display.getHeight()); glEnd(); glPopMatrix(); }
public static void render(float x, float y, float z, float size) { glColor3f(0.5f, 0.5f, 0.5f); // Sides glNormal3f(0, 0, -1); glBegin(GL_QUADS); glVertex3f(x + size, y, z); glVertex3f(x, y, z); glVertex3f(x, y + size, z); glVertex3f(x + size, y + size, z); glEnd(); glNormal3f(1, 0, 0); glBegin(GL_QUADS); glVertex3f(x + size, y + size, z); glVertex3f(x + size, y + size, z + size); glVertex3f(x + size, y, z + size); glVertex3f(x + size, y, z); glEnd(); glNormal3f(0, 0, 1); glBegin(GL_QUADS); glVertex3f(x + size, y + size, z + size); glVertex3f(x, y + size, z + size); glVertex3f(x, y, z + size); glVertex3f(x + size, y, z + size); glEnd(); glNormal3f(-1, 0, 0); glBegin(GL_QUADS); glVertex3f(x, y, z); glVertex3f(x, y, z + size); glVertex3f(x, y + size, z + size); glVertex3f(x, y + size, z); glEnd(); // Bottom glNormal3f(0, -1, 0); glBegin(GL_QUADS); glVertex3f(x, y, z); glVertex3f(x + size, y, z); glVertex3f(x + size, y, z + size); glVertex3f(x, y, z + size); glEnd(); // Top glNormal3f(0, 1, 0); glBegin(GL_QUADS); glVertex3f(x, y + size, z); glVertex3f(x, y + size, z + size); glVertex3f(x + size, y + size, z + size); glVertex3f(x + size, y + size, z); glEnd(); }
// // 3D DRAWING // public static void drawPolygon(Polygon p) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glBindTexture(GL_TEXTURE_2D, p.tex.id); glEnable(GL_TEXTURE_2D); glBegin(GL_POLYGON); { for (Vertex v : p.vertices) { glTexCoord2f(v.uv.x, v.uv.y); glNormal3f(v.norm.x, v.norm.y, v.norm.z); glVertex3f(v.pos.x, v.pos.y, v.pos.z); } } glEnd(); glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); }
protected void doQuad() { GL11.glPushMatrix(); { GL11.glScalef(getTexture().getImageWidth(), getTexture().getImageHeight(), 1f); GL11.glBegin(GL11.GL_TRIANGLE_STRIP); { GL11.glNormal3f(0f, 0f, 1f); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(-.5f, -.5f); GL11.glTexCoord2f(0, getTexture().getHeight()); GL11.glVertex2f(-.5f, 1f - .5f); GL11.glTexCoord2f(getTexture().getWidth(), 0); GL11.glVertex2f(1f - .5f, -.5f); GL11.glTexCoord2f(getTexture().getWidth(), getTexture().getHeight()); GL11.glVertex2f(1f - .5f, 1f - .5f); } GL11.glEnd(); } GL11.glPopMatrix(); }
public void renderExplosiveArrow( EntityExplosiveArrow par1EntityGlassArrow, double par2, double par4, double par6, float par8, float par9) { GL11.glPushMatrix(); GL11.glTranslatef((float) par2, (float) par4, (float) par6); GL11.glRotatef( par1EntityGlassArrow.prevRotationYaw + (par1EntityGlassArrow.rotationYaw - par1EntityGlassArrow.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef( par1EntityGlassArrow.prevRotationPitch + (par1EntityGlassArrow.rotationPitch - par1EntityGlassArrow.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F); Tessellator tessellator = Tessellator.instance; byte b0 = 0; float f2 = 0.0F; float f3 = 0.5F; float f4 = (float) (0 + b0 * 10) / 32.0F; float f5 = (float) (5 + b0 * 10) / 32.0F; float f6 = 0.0F; float f7 = 0.15625F; float f8 = (float) (5 + b0 * 10) / 32.0F; float f9 = (float) (10 + b0 * 10) / 32.0F; float f10 = 0.05625F; GL11.glEnable(GL12.GL_RESCALE_NORMAL); float f11 = (float) par1EntityGlassArrow.arrowShake - par9; if (f11 > 0.0F) { float f12 = -MathHelper.sin(f11 * 3.0F) * f11; GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F); } GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F); GL11.glScalef(f10, f10, f10); GL11.glTranslatef(-4.0F, 0.0F, 0.0F); GL11.glNormal3f(f10, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f8); tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f8); tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f9); tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f9); tessellator.draw(); GL11.glNormal3f(-f10, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f8); tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f8); tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f9); tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f9); tessellator.draw(); for (int i = 0; i < 4; ++i) { GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); GL11.glNormal3f(0.0F, 0.0F, f10); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double) f2, (double) f4); tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double) f3, (double) f4); tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double) f3, (double) f5); tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double) f2, (double) f5); tessellator.draw(); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
public void renderJavelin( EntityJavelin entityarrow, double d, double d1, double d2, float f, float f1) { bindEntityTexture(entityarrow); GL11.glPushMatrix(); GL11.glTranslatef((float) d, (float) d1, (float) d2); GL11.glRotatef( (entityarrow.prevRotationYaw + (entityarrow.rotationYaw - entityarrow.prevRotationYaw) * f1) - 90F, 0.0F, 1.0F, 0.0F); GL11.glRotatef( entityarrow.prevRotationPitch + (entityarrow.rotationPitch - entityarrow.prevRotationPitch) * f1, 0.0F, 0.0F, 1.0F); Tessellator tess = Tessellator.instance; int i = 0; float f2 = 0.0F; float f3 = 1.0F; float f4 = (0 + i * 10) / 32F; float f5 = (5 + i * 10) / 32F; float f6 = 0.0F; float f7 = 0.15625F; float f8 = (5 + i * 10) / 32F; float f9 = (10 + i * 10) / 32F; float f10 = 0.05625F; double length = 20D; GL11.glEnable(32826 /*GL_RESCALE_NORMAL_EXT*/); float f11 = entityarrow.arrowShake - f1; if (f11 > 0.0F) { float f12 = -MathHelper.sin(f11 * 3F) * f11; GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F); } GL11.glRotatef(45F, 1.0F, 0.0F, 0.0F); GL11.glScalef(f10, f10, f10); GL11.glTranslatef(-4F, 0.0F, 0.0F); GL11.glNormal3f(f10, 0.0F, 0.0F); tess.startDrawingQuads(); tess.addVertexWithUV(-length, -2D, -2D, f6, f8); tess.addVertexWithUV(-length, -2D, 2D, f7, f8); tess.addVertexWithUV(-length, 2D, 2D, f7, f9); tess.addVertexWithUV(-length, 2D, -2D, f6, f9); tess.draw(); GL11.glNormal3f(-f10, 0F, 0F); tess.startDrawingQuads(); tess.addVertexWithUV(-length, 2D, -2D, f6, f8); tess.addVertexWithUV(-length, 2D, 2D, f7, f8); tess.addVertexWithUV(-length, -2D, 2D, f7, f9); tess.addVertexWithUV(-length, -2D, -2D, f6, f9); tess.draw(); for (int j = 0; j < 4; j++) { GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F); GL11.glNormal3f(0.0F, 0.0F, f10); tess.startDrawingQuads(); tess.setColorOpaque_F(1F, 1F, 1F); tess.addVertexWithUV(-length, -2D, 0.0D, f2, f4); tess.addVertexWithUV(length, -2D, 0.0D, f3, f4); tess.addVertexWithUV(length, 2D, 0.0D, f3, f5); tess.addVertexWithUV(-length, 2D, 0.0D, f2, f5); tess.draw(); } GL11.glDisable(32826 /*GL_RESCALE_NORMAL_EXT*/); GL11.glPopMatrix(); }
// Mostly stolen from Sangar, like most of the things in this class. // Stolen with permission. @Optional.Method(modid = Mods.OpenComputers) private void drawSimpleBlock( MountPoint mountPoint, float frontOffset, boolean separateTopBottomTextures) { GL11.glRotatef( mountPoint.rotation.getW(), mountPoint.rotation.getX(), mountPoint.rotation.getY(), mountPoint.rotation.getZ()); GL11.glTranslatef(mountPoint.offset.getX(), mountPoint.offset.getY(), mountPoint.offset.getZ()); GL11.glBegin(GL11.GL_QUADS); // Front. GL11.glNormal3f(0, 0, 1); GL11.glTexCoord2f(frontOffset, 0.5f); GL11.glVertex3d(bounds.minX, bounds.minY, bounds.maxZ); GL11.glTexCoord2f(frontOffset + 0.5f, 0.5f); GL11.glVertex3d(bounds.maxX, bounds.minY, bounds.maxZ); GL11.glTexCoord2f(frontOffset + 0.5f, 0); GL11.glVertex3d(bounds.maxX, bounds.maxY, bounds.maxZ); GL11.glTexCoord2f(frontOffset, 0); GL11.glVertex3d(bounds.minX, bounds.maxY, bounds.maxZ); // Top. if (!separateTopBottomTextures) { GL11.glNormal3f(0, 1, 0); GL11.glTexCoord2f(1, 0.5f); GL11.glVertex3d(bounds.maxX, bounds.maxY, bounds.maxZ); GL11.glTexCoord2f(1, 1); GL11.glVertex3d(bounds.maxX, bounds.maxY, bounds.minZ); GL11.glTexCoord2f(0.5f, 1); GL11.glVertex3d(bounds.minX, bounds.maxY, bounds.minZ); GL11.glTexCoord2f(0.5f, 0.5f); GL11.glVertex3d(bounds.minX, bounds.maxY, bounds.maxZ); } else { GL11.glNormal3f(0, 1, 0); GL11.glTexCoord2f(1, 0); GL11.glVertex3d(bounds.maxX, bounds.maxY, bounds.maxZ); GL11.glTexCoord2f(1, 0.5f); GL11.glVertex3d(bounds.maxX, bounds.maxY, bounds.minZ); GL11.glTexCoord2f(0.5f, 0.5f); GL11.glVertex3d(bounds.minX, bounds.maxY, bounds.minZ); GL11.glTexCoord2f(0.5f, 0); GL11.glVertex3d(bounds.minX, bounds.maxY, bounds.maxZ); } // Bottom. GL11.glNormal3f(0, -1, 0); GL11.glTexCoord2f(0.5f, 0.5f); GL11.glVertex3d(bounds.minX, bounds.minY, bounds.maxZ); GL11.glTexCoord2f(0.5f, 1); GL11.glVertex3d(bounds.minX, bounds.minY, bounds.minZ); GL11.glTexCoord2f(1, 1); GL11.glVertex3d(bounds.maxX, bounds.minY, bounds.minZ); GL11.glTexCoord2f(1, 0.5f); GL11.glVertex3d(bounds.maxX, bounds.minY, bounds.maxZ); // Left. GL11.glNormal3f(1, 0, 0); GL11.glTexCoord2f(0, 0.5f); GL11.glVertex3d(bounds.maxX, bounds.maxY, bounds.maxZ); GL11.glTexCoord2f(0, 1); GL11.glVertex3d(bounds.maxX, bounds.minY, bounds.maxZ); GL11.glTexCoord2f(0.5f, 1); GL11.glVertex3d(bounds.maxX, bounds.minY, bounds.minZ); GL11.glTexCoord2f(0.5f, 0.5f); GL11.glVertex3d(bounds.maxX, bounds.maxY, bounds.minZ); // Right. GL11.glNormal3f(-1, 0, 0); GL11.glTexCoord2f(0, 1); GL11.glVertex3d(bounds.minX, bounds.minY, bounds.maxZ); GL11.glTexCoord2f(0, 0.5f); GL11.glVertex3d(bounds.minX, bounds.maxY, bounds.maxZ); GL11.glTexCoord2f(0.5f, 0.5f); GL11.glVertex3d(bounds.minX, bounds.maxY, bounds.minZ); GL11.glTexCoord2f(0.5f, 1); GL11.glVertex3d(bounds.minX, bounds.minY, bounds.minZ); GL11.glEnd(); }
@Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { GL11.glPushMatrix(); float f1 = 0.6666667F; float f2 = 0.16f * f1; FontRenderer fontrenderer = this.getFontRenderer(); int color = 0; int identifier = -1; int numConnected = -1; if (tileentity instanceof TileEntityMultiblockTester) { TileEntityMultiblockTester mbt = (TileEntityMultiblockTester) tileentity; color = mbt.getColor(); if (mbt.getMultiblockController() != null) { numConnected = mbt.getMultiblockController().getNumConnectedBlocks(); identifier = ((TestMultiblockController) mbt.getMultiblockController()).ordinal; } else { numConnected = -1; identifier = -1; } } GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT); GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_CULL_FACE); int xmod, zmod; for (int i = 0; i < 1; i++) { GL11.glPushMatrix(); if (i >= 2) { zmod = 1; } else { zmod = 0; } if (i % 2 != 0) { xmod = 1; } else { xmod = 0; } // GL11.glTranslatef((float)x + 0.5F, (float)y + 0.75F * f1, (float)z + 0.5F); // GL11.glTranslatef(0.0F, 0.5F * f1, 0.07F * f1); GL11.glTranslatef((float) x + 0.5f, (float) y + 0.9f, (float) z + 0.5f); GL11.glRotatef(90 * i, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.2f, 0f, 0.51f); GL11.glPushMatrix(); GL11.glTranslatef(-0.1F, -0.2F, 0.0f); GL11.glScalef(f2 * 0.5f, -f2 * 0.5f, f2 * 0.5f); GL11.glNormal3f(0.0F, 0.0F, -1.0F * f2); if (identifier == IMultiblockPart.INVALID_DISTANCE) { fontrenderer.drawString("XX", 0, 0, color); } else { fontrenderer.drawString(Integer.toString(identifier), 0, 0, color); } GL11.glPopMatrix(); GL11.glTranslatef(-0.2f, 0.0f, 0.0f); GL11.glScalef(f2 * 0.15f, -f2 * 0.15f, f2 * 0.15f); GL11.glNormal3f(0.0F, 0.0F, -1.0F * f2); fontrenderer.drawString(String.format("%d", numConnected), 0, 0, color); GL11.glPopMatrix(); } GL11.glPopAttrib(); GL11.glPopAttrib(); GL11.glPopAttrib(); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); GL11.glPopMatrix(); }
protected void renderCompletionLevel( TileEntity tile, String par2Str, double par3, double par5, double par7, int par9, boolean par10, int par11) { int j = 0; int i = tile.getBlockMetadata(); if (i == 0) { j = 0; } if (i == 1) { j = 90; } if (i == 2) { j = 180; } if (i == 3) { j = 270; } FontRenderer var12 = this.getFontRenderer(); float var13 = 1.6F; float var14 = 0.0116666668F * var13; GL11.glPushMatrix(); if (i == 0) GL11.glTranslatef((float) par3 + 0.60F, (float) par5 + 1.1F, (float) par7 + 1.41F); if (i == 1) GL11.glTranslatef((float) par3 + 1.51F, (float) par5 + 1.1F, (float) par7 + 0.50F); if (i == 2) GL11.glTranslatef((float) par3 + 0.60F, (float) par5 + 1.1F, (float) par7 - 0.41F); if (i == 3) GL11.glTranslatef((float) par3 - 0.31F, (float) par5 + 1.1F, (float) par7 + 0.51F); GL11.glRotatef(j + 180, 0.0F, 1.0F, 0.0F); GL11.glNormal3f(0.0F, 1.0F, 0.0F); if (!par10) { GL11.glScalef(-var14, -var14, var14); } else { GL11.glScalef(-var14 + 0.012f, -var14 + 0.012f, var14 + 0.012f); } GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); Tessellator var15 = Tessellator.instance; byte var16 = 0; GL11.glDisable(GL11.GL_TEXTURE_2D); int var17 = var12.getStringWidth(par2Str) / 2; GL11.glEnable(GL11.GL_TEXTURE_2D); var12.drawString(par2Str, -var12.getStringWidth(par2Str) / 2, var16, par11); var15.startDrawingQuads(); var15.addVertex((double) (-var17 - 1), (double) (-1 + var16), 0.0D); var15.addVertex((double) (-var17 - 1), (double) (8 + var16), 0.0D); var15.addVertex((double) (var17 + 1), (double) (8 + var16), 0.0D); var15.addVertex((double) (var17 + 1), (double) (-1 + var16), 0.0D); var15.draw(); var12.drawString(par2Str, -var12.getStringWidth(par2Str) / 2, var16, par11); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); }
protected void renderBarLevel( TileEntityFossilMachine tile, double par3, double par5, double par7, int par9) { int width = 40; int height = 10; int j = 0; int i = tile.getBlockMetadata(); if (i == 0) { j = 0; } if (i == 1) { j = 90; } if (i == 2) { j = 180; } if (i == 3) { j = 270; } float f2 = 1.6F; float f3 = 0.00666667F * f2; GL11.glPushMatrix(); float scaleFactor = MaemeConfig.scaleModelsUp ? 1.3f : 1; if (i == 0) GL11.glTranslatef((float) par3 + 0.60F, (float) par5 + 0.63F, (float) par7 + 1.41F); if (i == 1) GL11.glTranslatef((float) par3 + 1.51F, (float) par5 + 0.63F, (float) par7 + 0.50F); if (i == 2) GL11.glTranslatef((float) par3 + 0.60F, (float) par5 + 0.63F, (float) par7 - 0.41F); if (i == 3) GL11.glTranslatef((float) par3 - 0.31F, (float) par5 + 0.63F, (float) par7 + 0.51F); GL11.glNormal3f(0.0F, 1.0F, 0.0F); GL11.glRotatef(j + 180, 0.0F, 1.0F, 0.0F); GL11.glScalef(-f3, -f3, f3); GL11.glDisable(2896 /* GL_LIGHTING */); GL11.glDepthMask(false); GL11.glEnable(3042 /* GL_BLEND */); GL11.glBlendFunc(770, 771); Tessellator tessellator = Tessellator.instance; byte byte0 = -20; GL11.glDisable(3553 /* GL_TEXTURE_2D */); tessellator.startDrawingQuads(); float f8 = (float) (tile.completionRate / 2); tessellator.setColorRGBA_F(0.0039F, 0.03137F, 0.4196F, 1.0F); tessellator.addVertex(-25F + f8, -7 + byte0, 0.0D); tessellator.addVertex(-25F + f8, -6 + byte0, 0.0D); tessellator.addVertex(25D, -6 + byte0, 0.0D); tessellator.addVertex(25D, -7 + byte0, 0.0D); tessellator.setColorRGBA_F(0.0F, 0.8901F, 0.8901F, 1.0F); tessellator.addVertex(-25D, -7 + byte0, 0.0D); tessellator.addVertex(-25D, -6 + byte0, 0.0D); tessellator.addVertex(f8 - 25F, -6 + byte0, 0.0D); tessellator.addVertex(f8 - 25F, -7 + byte0, 0.0D); tessellator.draw(); GL11.glEnable(3553 /* GL_TEXTURE_2D */); GL11.glDepthMask(true); GL11.glEnable(2896 /* GL_LIGHTING */); GL11.glDisable(3042 /* GL_BLEND */); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glPopMatrix(); }