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:org.spoutcraft.client.gui.minimap.MapRenderer.java
License:Open Source License
private void drawFocusRound() { Waypoint focus = MinimapConfig.getInstance().getFocussedWaypoint(); if (focus != null) { GL11.glTranslated(-map.renderSize / 4d, map.renderSize / 4d, 0); GL11.glPushMatrix();//ww w. ja v a2s . co m GL11.glRotatef(this.direction - 180f, 0f, 0f, 1f); double px = Minecraft.theMinecraft.thePlayer.posX; double pz = Minecraft.theMinecraft.thePlayer.posZ; int x = focus.x; int z = focus.z; int radius = map.renderSize / 4 - 4; double dx = x - px; double dz = z - pz; double l = Math.sqrt(dx * dx + dz * dz); this.distanceToFocus = l; if (l > radius * 2) { double f = radius / l; int fx = (int) (f * dx); int fz = (int) (f * dz); RenderUtil.drawRectangle(fx - 1, fz - 1, fx + 1, fz + 1, 0xff00ffff); } GL11.glPopMatrix(); } }
From source file:org.spoutcraft.client.gui.minimap.MapRenderer.java
License:Open Source License
private void drawFocusSquare() { Waypoint focus = MinimapConfig.getInstance().getFocussedWaypoint(); if (focus != null) { GL11.glTranslated(-map.renderSize / 4d, map.renderSize / 4d - 4, 0); GL11.glRotatef(90f, 0, 0, 1f);//w w w.j a v a 2 s. c om RenderUtil.drawRectangle(map.renderSize / 4, 0, map.renderSize / 4 + 2, 2, 0xff0000); double px = Minecraft.theMinecraft.thePlayer.posX; double pz = Minecraft.theMinecraft.thePlayer.posZ; double x = focus.x; double z = focus.z; double dx = x - px; double dz = z - pz; double alpha = 0; if (dx == 0) { alpha = 0d; } else { alpha = Math.atan(dz / dx); } double l = Math.sqrt(dx * dx + dz * dz); this.distanceToFocus = l; if (true) { int fx; int fz; if (Math.abs(dx) > Math.abs(dz)) { if (dx > 0) { fx = map.renderSize / 4; } else { fx = -map.renderSize / 4; } fz = (int) (Math.tan(alpha) * fx); } else { if (dz > 0) { fz = map.renderSize / 4; } else { fz = -map.renderSize / 4; } fx = (int) (1 / Math.tan(alpha) * fz); } if (Math.abs(dx) >= (map.renderSize - 5) / 2 || Math.abs(dz) >= (map.renderSize - 5) / 2) { RenderUtil.drawRectangle(fx - 1, fz - 1, fx + 1, fz + 1, 0xff00ffff); } } } }
From source file:org.spoutcraft.client.gui.minimap.MapRenderer.java
License:Open Source License
private void renderWaypoints() { double playerX = Minecraft.theMinecraft.thePlayer.posX; double playerZ = Minecraft.theMinecraft.thePlayer.posZ; for (Waypoint pt : MinimapConfig.getInstance().getWaypoints(MinimapUtils.getWorldName())) { if (pt.enabled) { double wayX = playerX - pt.x; double wayY = playerZ - pt.z; int circleX = MathHelper.floor_double(playerX); int circleY = MathHelper.floor_double(playerZ); boolean render = false; if (MinimapConfig.getInstance().isSquare()) { render = Math.abs(playerX - pt.x) < map.renderSize && Math.abs(playerZ - pt.z) < map.renderSize; } else { render = MinimapUtils.insideCircle(circleX, circleY, map.renderSize / 2, pt.x, pt.z); }//from w ww . j a va 2s. com if (render) { GL11.glPushMatrix(); GL11.glTranslatef(32.0f, -32.0F, 0.0F); GL11.glRotatef(-(this.direction + 90.0F), 0.0F, 0.0F, 1.0F); GL11.glTranslatef(-32.0F, -32.0F, 0.0F); GL11.glTranslatef(-33F, 29F, 0F); switch (MinimapConfig.getInstance().getZoom()) { case 0: GL11.glTranslated(wayY, -wayX, 0F); break; case 1: GL11.glTranslated(wayY * 0.45F, -wayX * 0.45F, 0F); break; case 2: GL11.glTranslated(wayY * 0.25F, -wayX * 0.28F, 0F); break; case 3: GL11.glTranslated(wayY * 0.125F, -wayX * 0.125F, 0F); break; } GL11.glScalef(0.25F, 0.25F, 1F); GL11.glPopMatrix(); } } } GL11.glColor3f(1f, 1f, 1f); }
From source file:org.spoutcraft.client.gui.minimap.MapRenderer.java
License:Open Source License
private void drawDirections() { if (!MinimapConfig.getInstance().isDirections()) { return;/* ww w .j av a2 s . co m*/ } float dir = this.direction; GL11.glPushMatrix(); GL11.glScalef(0.5f, 0.5f, 1.0f); GL11.glTranslated((64.0D * Math.sin(Math.toRadians(-(dir)))), (64.0D * Math.cos(Math.toRadians(-(dir)))), 0.0D); Minecraft.theMinecraft.fontRenderer.drawString("N", -66, 60, 0xffffff); GL11.glPopMatrix(); dir += 90; GL11.glPushMatrix(); GL11.glScalef(0.5f, 0.5f, 1.0f); GL11.glTranslated((64.0D * Math.sin(Math.toRadians(-dir))), (64.0D * Math.cos(Math.toRadians(-dir))), 0.0D); Minecraft.theMinecraft.fontRenderer.drawString("E", -66, 60, 0xffffff); GL11.glPopMatrix(); dir += 90; GL11.glPushMatrix(); GL11.glScalef(0.5f, 0.5f, 1.0f); GL11.glTranslated((64.0D * Math.sin(Math.toRadians(-(dir)))), (64.0D * Math.cos(Math.toRadians(-(dir)))), 0.0D); Minecraft.theMinecraft.fontRenderer.drawString("S", -66, 60, 0xffffff); GL11.glPopMatrix(); dir += 90; GL11.glPushMatrix(); GL11.glScalef(0.5f, 0.5f, 1.0f); GL11.glTranslated((64.0D * Math.sin(Math.toRadians(-(dir)))), (64.0D * Math.cos(Math.toRadians(-(dir)))), 0.0D); Minecraft.theMinecraft.fontRenderer.drawString("W", -66, 60, 0xffffff); GL11.glPopMatrix(); }
From source file:org.spoutcraft.client.gui.server.ServerItem.java
License:Open Source License
public void render(int x, int y, int width, int height) { MCRenderDelegate r = (MCRenderDelegate) Spoutcraft.getRenderDelegate(); if (databaseId != -1) { String iconUrl = "http://cdn.spout.org/server/thumb/" + databaseId + ".png"; Texture icon = CustomTextureManager.getTextureFromUrl("Spoutcraft", iconUrl); if (icon == null) { CustomTextureManager.downloadTexture("Spoutcraft", iconUrl, true); icon = CustomTextureManager.getTextureFromJar("/res/icon/unknown_server.png"); }// ww w. j a v a 2s . c o m GL11.glPushMatrix(); GL11.glTranslated(x + 2, y + 2, 0); r.drawTexture(icon, 25, 25); GL11.glPopMatrix(); } int marginleft = 29; int ping = getPing(); FontRenderer font = SpoutClient.getHandle().fontRenderer; int margin1 = 0; int margin2 = 0; if (getPing() > 0 && (!isPolling() || showPingWhilePolling)) { if (isShowPing()) { String sping = getPing() + " ms"; int pingwidth = font.getStringWidth(sping); margin1 = pingwidth + 14; font.drawStringWithShadow(sping, x + width - pingwidth - 14, y + 2, 0xaaaaaa); } String sPlayers = getPlayers() + " / " + getMaxPlayers() + " players"; int playerswidth = font.getStringWidth(sPlayers); margin2 = playerswidth; font.drawStringWithShadow(sPlayers, x + width - playerswidth - 2, y + 11, 0xaaaaaa); } font.drawStringWithShadow(r.getFittingText(title, width - margin1 - marginleft), x + marginleft, y + 2, 0xffffff); String sMotd = ""; if ((getPing() == PollResult.PING_POLLING || isPolling()) && !showPingWhilePolling) { sMotd = showPing ? "Polling ..." : "Retrieving MOTD"; } else if (!showPingWhilePolling) { switch (getPing()) { case PollResult.PING_UNKNOWN: sMotd = ChatColor.RED + "Unknown Host!"; break; case PollResult.PING_TIMEOUT: sMotd = ChatColor.RED + "Operation timed out!"; break; case PollResult.PING_BAD_MESSAGE: sMotd = ChatColor.RED + "Bad Message (Server version likely outdated)!"; break; default: sMotd = ChatColor.GREEN + getMotd(); break; } } int color = 0xffffff; if ((getPing() == PollResult.PING_POLLING || isPolling()) && !showPingWhilePolling) { Color c1 = new Color(0, 0, 0); double darkness = 0; long t = System.currentTimeMillis() % 1000; darkness = Math.cos(t * 2 * Math.PI / 1000) * 0.2 + 0.2; c1.setBlue(1f - (float) darkness); color = c1.toInt(); } font.drawStringWithShadow(r.getFittingText(sMotd, width - 10 - margin2 - marginleft), x + marginleft, y + 11, color); GL11.glColor4f(1f, 1f, 1f, 1f); // Fancy icons int xOffset = 0; int yOffset = 0; if (isPolling() && isShowPing()) { xOffset = 1; yOffset = (int) (System.currentTimeMillis() / 100L & 7L); if (yOffset > 4) { yOffset = 8 - yOffset; } } else if (isShowPing()) { xOffset = 0; if (ping < 0L) { yOffset = 5; } else if (ping < 150L) { yOffset = 0; } else if (ping < 300L) { yOffset = 1; } else if (ping < 600L) { yOffset = 2; } else if (ping < 1000L) { yOffset = 3; } else { yOffset = 4; } } if (isShowPing()) { SpoutClient.getHandle().renderEngine.bindTexture("/gui/icons.png"); RenderUtil.drawTexturedModalRectangle(x + width - 2 - 10, y + 2, 0 + xOffset * 10, 176 + yOffset * 8, 10, 8, 0f); } if (port != DEFAULT_PORT) { font.drawStringWithShadow(ip + ":" + port, x + marginleft, y + 20, 0xaaaaaa); } else { font.drawStringWithShadow(ip, x + marginleft, y + 20, 0xaaaaaa); } // Icon drawing int iconMargin = 2; if (country != null) { String url = "http://cdn.spout.org/img/flag/" + country.toLowerCase() + ".png"; Texture icon = CustomTextureManager.getTextureFromUrl("Spoutcraft", url); if (icon != null) { GL11.glPushMatrix(); GL11.glTranslatef(x + width - iconMargin - 16, y + 20, 0); r.drawTexture(icon, 16, 11); GL11.glPopMatrix(); iconMargin += 5 + 16; } else { CustomTextureManager.downloadTexture("Spoutcraft", url); } } if (accessType != OPEN) { String name = "lock"; switch (accessType) { case WHITELIST: name = "whitelist"; break; case GRAYLIST: name = "graylist"; break; case BLACKLIST: name = "blacklist"; break; } Texture lockIcon = CustomTextureManager.getTextureFromJar("/res/" + name + ".png"); GL11.glPushMatrix(); GL11.glTranslatef(x + width - iconMargin - 7, y + 20, 0); r.drawTexture(lockIcon, 7, 11); GL11.glPopMatrix(); iconMargin += 5 + 7; } if (pollResult.getVersion() != null) { GL11.glPushMatrix(); versionWidth = font.getStringWidth("1.0.0"); if (isCompatible(SpoutClient.spoutcraftVersion)) { font.drawStringWithShadow(pollResult.getVersion(), x + width - versionWidth - 20, y + 21, 0x00FF00); } else { font.drawStringWithShadow(pollResult.getVersion(), x + width - versionWidth - 20, y + 21, 0xF44607); } GL11.glPopMatrix(); } else { GL11.glPushMatrix(); versionWidth = font.getStringWidth("Unknown"); font.drawStringWithShadow("Unknown", x + width - versionWidth - 20, y + 21, 0xFF0000); GL11.glPopMatrix(); } }
From source file:org.spoutcraft.client.gui.texturepacks.TextureItem.java
License:Open Source License
public void render(int x, int y, int width, int height) { MCRenderDelegate r = (MCRenderDelegate) SpoutClient.getInstance().getRenderDelegate(); FontRenderer font = SpoutClient.getHandle().fontRenderer; String sResolution = resolution + "x"; int sWidth = font.getStringWidth(sResolution); font.drawStringWithShadow(sResolution, x + width - sWidth - 2, y + 2, 0xffaaaaaa); String name = r.getFittingText(getName(), width - 29 - sWidth - 2 - x); font.drawStringWithShadow(name, x + 29, y + 2, 0xffffffff); String sStatus = ""; if (size > 1024 * 1024 * 9000) { sStatus = ChatColor.RED + "It's over 9000! "; }//from w ww . jav a 2 s. c o m if (size > 1024 * 1024) { sStatus += size / (1024 * 1024) + " MB"; } else if (size > 1024) { sStatus = size / 1024 + " KB"; } else { sStatus = size + " Bytes"; } if (isDownloading()) { sStatus = "Downloading: " + ChatColor.WHITE + download.getProgress() + "%"; } if (downloadFail != null) { sStatus = downloadFail; } if (installed) { sStatus = ChatColor.GREEN + "Installed"; } if (sStatus != null) { sWidth = font.getStringWidth(sStatus); font.drawStringWithShadow(sStatus, x + width - sWidth - 2, y + 11, 0xffaaaaaa); } String author = "by " + ChatColor.WHITE + getAuthor(); author = r.getFittingText(author, width - 29 - sWidth - 2 - x); font.drawStringWithShadow(author, x + 29, y + 11, 0xffaaaaaa); String desc = r.getFittingText(getDescription(), width - 2 - 29); font.drawStringWithShadow(desc, x + 29, y + 20, 0xffaaaaaa); String iconUrl = getIconUrl(); Texture icon = CustomTextureManager.getTextureFromUrl(iconUrl); if (icon == null) { CustomTextureManager.downloadTexture(iconUrl, true); } else { GL11.glPushMatrix(); GL11.glTranslated(x + 2, y + 2, 0); r.drawTexture(icon, 25, 25); GL11.glPopMatrix(); } }
From source file:org.terasology.componentSystem.MiniaturizerSystem.java
License:Apache License
public void renderTransparent() { for (EntityRef entity : entityManager.iteratorEntities(MiniaturizerComponent.class)) { MiniaturizerComponent min = entity.getComponent(MiniaturizerComponent.class); min.blockGrid.render();// w w w.j a v a 2 s. co m if (min.chunkMesh == null || min.renderPosition == null) continue; glPushMatrix(); Vector3f cameraPosition = CoreRegistry.get(WorldRenderer.class).getActiveCamera().getPosition(); GL11.glTranslated(min.renderPosition.x - cameraPosition.x, min.renderPosition.y - cameraPosition.y, min.renderPosition.z - cameraPosition.z); glScalef(MiniaturizerComponent.SCALE, MiniaturizerComponent.SCALE, MiniaturizerComponent.SCALE); glRotatef(min.orientation, 0, 1, 0); ShaderManager.getInstance().enableShader("chunk"); ShaderManager.getInstance().getShaderProgram("chunk").setFloat("blockScale", MiniaturizerComponent.SCALE); min.chunkMesh.render(ChunkMesh.RENDER_PHASE.OPAQUE); min.chunkMesh.render(ChunkMesh.RENDER_PHASE.BILLBOARD_AND_TRANSLUCENT); min.chunkMesh.render(ChunkMesh.RENDER_PHASE.WATER_AND_ICE); glPopMatrix(); } }
From source file:org.terasology.miniion.utilities.Zone.java
License:Apache License
public void render() { if (MinionSystem.getNewZone() != null && this.equals(MinionSystem.getNewZone())) { ShaderManager.getInstance().enableDefault(); worldProvider = CoreRegistry.get(WorldProvider.class); for (int i = 0; i < 2; i++) { if (i == 0) { glColorMask(false, false, false, false); } else { glColorMask(true, true, true, true); }/*from ww w . j a v a 2 s .co m*/ Vector3f cameraPosition = CoreRegistry.get(WorldRenderer.class).getActiveCamera().getPosition(); int camx = (int) cameraPosition.x; int camy = (int) cameraPosition.y; int camz = (int) cameraPosition.z; if (MinionSystem.getNewZone().startposition != null) { Vector3i renderpos = MinionSystem.getNewZone().startposition; GL11.glPushMatrix(); GL11.glTranslated(renderpos.x - cameraPosition.x, renderpos.y - cameraPosition.y, renderpos.z - cameraPosition.z); mesh.render(); GL11.glPopMatrix(); if (MinionSystem.getNewZone().endposition != null) { renderpos = MinionSystem.getNewZone().endposition; GL11.glPushMatrix(); GL11.glTranslated(renderpos.x - cameraPosition.x, renderpos.y - cameraPosition.y, renderpos.z - cameraPosition.z); mesh.render(); GL11.glPopMatrix(); if (!outofboundselection() && MinionSystem.isSelectionShown()) { for (int x = getMinBounds().x; x <= getMaxBounds().x; x++) { for (int z = getMinBounds().z; z <= getMaxBounds().z; z++) { for (int y = getMaxBounds().y; y >= getMinBounds().y; y--) { Block tmpblock; if (worldProvider.getBlock(x - camx, y - camy, z - camz) == null) { continue; } else { tmpblock = worldProvider.getBlock(x, y, z); } //!tmpblock.getBlockFamily().getURI().getFamily().matches("air") if (!tmpblock.isInvisible()) { if (x == minbounds.x || x == maxbounds.x) { GL11.glPushMatrix(); GL11.glTranslated(x - cameraPosition.x, y - cameraPosition.y, z - cameraPosition.z); mesh.render(); GL11.glPopMatrix(); } else if (z == minbounds.z || z == maxbounds.z) { GL11.glPushMatrix(); GL11.glTranslated(x - cameraPosition.x, y - cameraPosition.y, z - cameraPosition.z); mesh.render(); GL11.glPopMatrix(); } else { GL11.glPushMatrix(); GL11.glTranslated(x - cameraPosition.x, y - cameraPosition.y, z - cameraPosition.z); mesh.render(); GL11.glPopMatrix(); break; } } } } } } } } } } }
From source file:org.terasology.rendering.physics.BulletPhysicsRenderer.java
License:Apache License
public void render() { _discreteDynamicsWorld.stepSimulation(Terasology.getInstance().getDelta() / 1000f); TextureManager.getInstance().bindTexture("terrain"); ShaderManager.getInstance().enableShader("block"); FloatBuffer colorBuffer = BufferUtils.createFloatBuffer(3); colorBuffer.put(1).put(1).put(1);//from w w w. jav a 2 s.c om colorBuffer.flip(); int textured = GL20.glGetUniformLocation(ShaderManager.getInstance().getShader("block"), "textured"); GL20.glUniform1i(textured, 1); int colorOffset = GL20.glGetUniformLocation(ShaderManager.getInstance().getShader("block"), "colorOffset"); GL20.glUniform3(colorOffset, colorBuffer); int lightRef = GL20.glGetUniformLocation(ShaderManager.getInstance().getShader("block"), "light"); Player player = Terasology.getInstance().getActiveWorldRenderer().getPlayer(); FloatBuffer mBuffer = BufferUtils.createFloatBuffer(16); float[] mFloat = new float[16]; GL11.glPushMatrix(); GL11.glTranslated(-player.getPosition().x, -player.getPosition().y, -player.getPosition().z); for (BlockRigidBody b : _blocks) { Transform t = new Transform(); b.getMotionState().getWorldTransform(t); t.getOpenGLMatrix(mFloat); mBuffer.put(mFloat); mBuffer.flip(); GL11.glPushMatrix(); GL11.glMultMatrix(mBuffer); GL11.glScalef(0.5f, 0.5f, 0.5f); float lightValue = Terasology.getInstance().getActiveWorldRenderer() .getRenderingLightValueAt(new Vector3d(t.origin)); GL20.glUniform1f(lightRef, lightValue); BlockManager.getInstance().getBlock(b.getType()).render(); GL11.glPopMatrix(); } GL11.glPopMatrix(); ShaderManager.getInstance().enableShader(null); }
From source file:org.terasology.rendering.world.BlockGrid.java
License:Apache License
public void render() { ShaderManager.getInstance().enableDefault(); for (int i = 0; i < 2; i++) { if (i == 0) { glColorMask(false, false, false, false); } else {//from w ww . j av a 2s . c o m glColorMask(true, true, true, true); } for (GridPosition gp : _gridPositions) { GL11.glPushMatrix(); Vector3f cameraPosition = CoreRegistry.get(WorldRenderer.class).getActiveCamera().getPosition(); GL11.glTranslated(gp.position.x - cameraPosition.x, gp.position.y - cameraPosition.y, gp.position.z - cameraPosition.z); _mesh.render(); GL11.glPopMatrix(); } } }