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:valkyrienwarfare.addon.control.renderer.PropellerEngineTileEntityRenderer.java
License:Open Source License
@Override public void render(TileEntityPropellerEngine tileentity, double x, double y, double z, float partialTick, int destroyStage, float alpha) { IBlockState state = tileentity.getWorld().getBlockState(tileentity.getPos()); if (state.getBlock() instanceof BlockAirshipEngine) { EnumFacing facing = state.getValue(BlockAirshipEngine.FACING); IBlockState engineRenderState = getRenderState(state); IBlockState propellerRenderState = ValkyrienWarfareControl.INSTANCE.blocks.shipWheel .getStateFromMeta(14);//from w w w.java 2 s. c o m this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); GlStateManager.pushMatrix(); GlStateManager.disableLighting(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder BufferBuilder = tessellator.getBuffer(); double oldX = BufferBuilder.xOffset; double oldY = BufferBuilder.yOffset; double oldZ = BufferBuilder.zOffset; BufferBuilder.setTranslation(0, 0, 0); GL11.glTranslated(x, y, z); GlStateManager.disableAlpha(); GlStateManager.disableBlend(); int brightness = tileentity.getWorld().getCombinedLight(tileentity.getPos(), 0); // GL11.glScaled(1.2D, 1.2D, 1.2D); GL11.glTranslated(0.5D, 0.5D, 0.5D); switch (facing) { case UP: GL11.glRotated(-90, 1, 0, 0); break; case DOWN: GL11.glRotated(90, 1, 0, 0); break; case NORTH: GL11.glRotated(180, 0, 1, 0); break; case EAST: GL11.glRotated(90, 0, 1, 0); break; case SOUTH: GL11.glRotated(0, 0, 1, 0); break; case WEST: GL11.glRotated(270, 0, 1, 0); break; } GL11.glTranslated(-0.5D, -0.5D, -0.5D); FastBlockModelRenderer.renderBlockModel(BufferBuilder, tessellator, tileentity.getWorld(), engineRenderState, brightness); GL11.glPushMatrix(); GL11.glTranslated(0.5D, 0.21D, 0.5D); GL11.glRotated(tileentity.getPropellerAngle(partialTick), 0, 0, 1); GL11.glScaled(1.5D, 1.5D, 1); GL11.glTranslated(-0.5D, -0.21D, -0.5D); FastBlockModelRenderer.renderBlockModel(BufferBuilder, tessellator, tileentity.getWorld(), propellerRenderState, brightness); GL11.glPopMatrix(); GL11.glPopMatrix(); BufferBuilder.setTranslation(oldX, oldY, oldZ); } }
From source file:valkyrienwarfare.addon.control.renderer.ShipHelmTileEntityRenderer.java
License:Open Source License
@Override public void render(TileEntityShipHelm tileentity, double x, double y, double z, float partialTick, int destroyStage, float alpha) { if (tileentity instanceof TileEntityShipHelm) { IBlockState helmState = tileentity.getWorld().getBlockState(tileentity.getPos()); if (helmState.getBlock() != ValkyrienWarfareControl.INSTANCE.blocks.shipHelm) { return; }/*w ww . j a va 2 s. c o m*/ this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); GlStateManager.pushMatrix(); GlStateManager.disableLighting(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder BufferBuilder = tessellator.getBuffer(); double oldX = BufferBuilder.xOffset; double oldY = BufferBuilder.yOffset; double oldZ = BufferBuilder.zOffset; BufferBuilder.setTranslation(0, 0, 0); GL11.glTranslated(x, y, z); GlStateManager.disableAlpha(); GlStateManager.disableBlend(); double smoothCompassDif = (tileentity.compassAngle - tileentity.lastCompassAngle); if (smoothCompassDif < -180) { smoothCompassDif += 360; } if (smoothCompassDif > 180) { smoothCompassDif -= 360; } double smoothWheelDif = (tileentity.wheelRotation - tileentity.lastWheelRotation); if (smoothWheelDif < -180) { smoothWheelDif += 360; } if (smoothWheelDif > 180) { smoothWheelDif -= 360; } double smoothCompass = tileentity.lastCompassAngle + (smoothCompassDif) * partialTick + 180D; double smoothWheel = tileentity.lastWheelRotation + (smoothWheelDif) * partialTick; BlockPos originPos = tileentity.getPos(); IBlockState wheelState = ValkyrienWarfareControl.INSTANCE.blocks.shipWheel.getStateFromMeta(0); IBlockState compassState = ValkyrienWarfareControl.INSTANCE.blocks.shipWheel.getStateFromMeta(1); IBlockState glassState = ValkyrienWarfareControl.INSTANCE.blocks.shipWheel.getStateFromMeta(2); IBlockState helmStateToRender = ValkyrienWarfareControl.INSTANCE.blocks.shipWheel.getStateFromMeta(3); // TODO: Better rendering cache int brightness = tileentity.getWorld().getCombinedLight(tileentity.getPos(), 0); double multiplier = 2.0D; GL11.glTranslated((1D - multiplier) / 2.0D, 0, (1D - multiplier) / 2.0D); GL11.glScaled(multiplier, multiplier, multiplier); EnumFacing enumfacing = helmState.getValue(BlockShipHelm.FACING); double wheelAndCompassStateRotation = enumfacing.getHorizontalAngle(); GL11.glTranslated(0.5D, 0, 0.5D); GL11.glRotated(wheelAndCompassStateRotation, 0, 1, 0); GL11.glTranslated(-0.5D, 0, -0.5D); FastBlockModelRenderer.renderBlockModel(BufferBuilder, tessellator, tileentity.getWorld(), helmStateToRender, brightness); GL11.glPushMatrix(); GL11.glTranslated(.5, .522, 0); GL11.glRotated(smoothWheel, 0, 0, 1); GL11.glTranslated(-.5, -.522, 0); FastBlockModelRenderer.renderBlockModel(BufferBuilder, tessellator, tileentity.getWorld(), wheelState, brightness); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glTranslated(0.5D, 0, 0.5D); GL11.glRotated(smoothCompass, 0, 1, 0); GL11.glTranslated(-0.5D, 0, -0.5D); FastBlockModelRenderer.renderBlockModel(BufferBuilder, tessellator, tileentity.getWorld(), compassState, brightness); GL11.glPopMatrix(); GlStateManager.enableAlpha(); GlStateManager.enableBlend(); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); FastBlockModelRenderer.renderBlockModel(BufferBuilder, tessellator, tileentity.getWorld(), glassState, brightness); GlStateManager.disableAlpha(); GlStateManager.disableBlend(); GL11.glPopMatrix(); BufferBuilder.setTranslation(oldX, oldY, oldZ); GlStateManager.enableLighting(); GlStateManager.resetColor(); } }
From source file:valkyrienwarfare.addon.control.renderer.ShipTelegraphTileEntityRenderer.java
License:Open Source License
@Override public void render(TileEntityShipTelegraph tileentity, double x, double y, double z, float partialTick, int destroyStage, float alpha) { IBlockState telegraphState = tileentity.getWorld().getBlockState(tileentity.getPos()); if (telegraphState.getBlock() != ValkyrienWarfareControl.INSTANCE.blocks.shipTelegraph) { return;//from w ww . j a v a2 s . c o m } this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); GlStateManager.pushMatrix(); GlStateManager.disableLighting(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder BufferBuilder = tessellator.getBuffer(); double oldX = BufferBuilder.xOffset; double oldY = BufferBuilder.yOffset; double oldZ = BufferBuilder.zOffset; BufferBuilder.setTranslation(0, 0, 0); GL11.glTranslated(x, y, z); GlStateManager.disableAlpha(); GlStateManager.disableBlend(); BlockPos originPos = tileentity.getPos(); IBlockState glassState = ValkyrienWarfareControl.INSTANCE.blocks.shipWheel.getStateFromMeta(8); IBlockState dialState = ValkyrienWarfareControl.INSTANCE.blocks.shipWheel.getStateFromMeta(7); IBlockState leftHandleState = ValkyrienWarfareControl.INSTANCE.blocks.shipWheel.getStateFromMeta(6); IBlockState rightHandleState = ValkyrienWarfareControl.INSTANCE.blocks.shipWheel.getStateFromMeta(5); IBlockState helmStateToRender = ValkyrienWarfareControl.INSTANCE.blocks.shipWheel.getStateFromMeta(4); int brightness = tileentity.getWorld().getCombinedLight(tileentity.getPos(), 0); double multiplier = 1.5D; GL11.glTranslated((1D - multiplier) / 2.0D, 0, (1D - multiplier) / 2.0D); GL11.glScaled(multiplier, multiplier, multiplier); EnumFacing enumfacing = telegraphState.getValue(BlockShipTelegraph.FACING); double wheelAndCompassStateRotation = enumfacing.getHorizontalAngle(); GL11.glTranslated(0.5D, 0, 0.5D); GL11.glRotated(wheelAndCompassStateRotation, 0, 1, 0); GL11.glTranslated(-0.5D, 0, -0.5D); FastBlockModelRenderer.renderBlockModel(BufferBuilder, tessellator, tileentity.getWorld(), helmStateToRender, brightness); FastBlockModelRenderer.renderBlockModel(BufferBuilder, tessellator, tileentity.getWorld(), dialState, brightness); GL11.glPushMatrix(); GL11.glTranslated(0.497D, 0.857D, 0.5D); GL11.glRotated(tileentity.getHandleRenderRotation(), 0D, 0D, 1D); GL11.glTranslated(-0.497D, -0.857D, -0.5D); FastBlockModelRenderer.renderBlockModel(BufferBuilder, tessellator, tileentity.getWorld(), rightHandleState, brightness); FastBlockModelRenderer.renderBlockModel(BufferBuilder, tessellator, tileentity.getWorld(), leftHandleState, brightness); GL11.glPopMatrix(); GlStateManager.enableAlpha(); GlStateManager.enableBlend(); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); FastBlockModelRenderer.renderBlockModel(BufferBuilder, tessellator, tileentity.getWorld(), glassState, brightness); GlStateManager.disableAlpha(); GlStateManager.disableBlend(); GL11.glPopMatrix(); BufferBuilder.setTranslation(oldX, oldY, oldZ); GlStateManager.enableLighting(); GlStateManager.resetColor(); }
From source file:valkyrienwarfare.mod.client.render.PhysObjectRenderManager.java
License:Open Source License
public void updateTranslation(double partialTicks) { PhysicsWrapperEntity entity = parent.wrapper; Vector centerOfRotation = entity.wrapping.centerCoord; curPartialTick = partialTicks;/* w ww . jav a 2 s .c o m*/ double moddedX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks; double moddedY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks; double moddedZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks; // System.out.println(entity.roll - entity.prevRoll); double p0 = Minecraft.getMinecraft().player.lastTickPosX + (Minecraft.getMinecraft().player.posX - Minecraft.getMinecraft().player.lastTickPosX) * partialTicks; double p1 = Minecraft.getMinecraft().player.lastTickPosY + (Minecraft.getMinecraft().player.posY - Minecraft.getMinecraft().player.lastTickPosY) * partialTicks; double p2 = Minecraft.getMinecraft().player.lastTickPosZ + (Minecraft.getMinecraft().player.posZ - Minecraft.getMinecraft().player.lastTickPosZ) * partialTicks; Quaternion smoothRotation = getSmoothRotationQuat(partialTicks); double[] radians = smoothRotation.toRadians(); double moddedPitch = Math.toDegrees(radians[0]); double moddedYaw = Math.toDegrees(radians[1]); double moddedRoll = Math.toDegrees(radians[2]); parent.coordTransform.updateRenderMatrices(moddedX, moddedY, moddedZ, moddedPitch, moddedYaw, moddedRoll); if (offsetPos != null) { double offsetX = offsetPos.getX() - centerOfRotation.X; double offsetY = offsetPos.getY() - centerOfRotation.Y; double offsetZ = offsetPos.getZ() - centerOfRotation.Z; GlStateManager.translate(-p0 + moddedX, -p1 + moddedY, -p2 + moddedZ); GL11.glRotated(moddedPitch, 1D, 0, 0); GL11.glRotated(moddedYaw, 0, 1D, 0); GL11.glRotated(moddedRoll, 0, 0, 1D); GL11.glTranslated(offsetX, offsetY, offsetZ); // transformBuffer = BufferUtils.createFloatBuffer(16); } }
From source file:valkyrienwarfare.mod.client.render.PhysObjectRenderManager.java
License:Open Source License
public void inverseTransform(double partialTicks) { PhysicsWrapperEntity entity = parent.wrapper; Vector centerOfRotation = entity.wrapping.centerCoord; curPartialTick = partialTicks;/*w w w. j av a 2 s .com*/ double moddedX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks; double moddedY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks; double moddedZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks; double p0 = Minecraft.getMinecraft().player.lastTickPosX + (Minecraft.getMinecraft().player.posX - Minecraft.getMinecraft().player.lastTickPosX) * partialTicks; double p1 = Minecraft.getMinecraft().player.lastTickPosY + (Minecraft.getMinecraft().player.posY - Minecraft.getMinecraft().player.lastTickPosY) * partialTicks; double p2 = Minecraft.getMinecraft().player.lastTickPosZ + (Minecraft.getMinecraft().player.posZ - Minecraft.getMinecraft().player.lastTickPosZ) * partialTicks; Quaternion smoothRotation = getSmoothRotationQuat(partialTicks); double[] radians = smoothRotation.toRadians(); double moddedPitch = Math.toDegrees(radians[0]); double moddedYaw = Math.toDegrees(radians[1]); double moddedRoll = Math.toDegrees(radians[2]); // parent.coordTransform.updateRenderMatrices(moddedX, moddedY, moddedZ, // moddedPitch, moddedYaw, moddedRoll); if (offsetPos != null) { double offsetX = offsetPos.getX() - centerOfRotation.X; double offsetY = offsetPos.getY() - centerOfRotation.Y; double offsetZ = offsetPos.getZ() - centerOfRotation.Z; GL11.glTranslated(-offsetX, -offsetY, -offsetZ); GL11.glRotated(-moddedRoll, 0, 0, 1D); GL11.glRotated(-moddedYaw, 0, 1D, 0); GL11.glRotated(-moddedPitch, 1D, 0, 0); GlStateManager.translate(p0 - moddedX, p1 - moddedY, p2 - moddedZ); // transformBuffer = BufferUtils.createFloatBuffer(16); } }
From source file:vazkii.botania.client.core.handler.SubTileRadiusRenderHandler.java
License:Open Source License
public void renderRectangle(AxisAlignedBB aabb) { GL11.glPushMatrix();//from w ww . j ava 2 s. c o m GL11.glTranslated(aabb.minX - RenderManager.renderPosX, aabb.minY - RenderManager.renderPosY, aabb.minZ - RenderManager.renderPosZ); int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F); Color colorRGB = new Color(color); GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 32); double f = 1F / 16F; double x = aabb.maxX - aabb.minX - f; double z = aabb.maxZ - aabb.minZ - f; Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.addVertex(x, f, f); tessellator.addVertex(f, f, f); tessellator.addVertex(f, f, z); tessellator.addVertex(x, f, z); tessellator.draw(); x += f; z += f; double f1 = f + f / 4F; GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64); tessellator.startDrawingQuads(); tessellator.addVertex(x, f1, 0); tessellator.addVertex(0, f1, 0); tessellator.addVertex(0, f1, z); tessellator.addVertex(x, f1, z); tessellator.draw(); GL11.glPopMatrix(); }
From source file:vazkii.botania.client.core.handler.SubTileRadiusRenderHandler.java
License:Open Source License
public void renderCircle(ChunkCoordinates center, double radius) { GL11.glPushMatrix();// w w w. ja v a 2 s . c om double x = center.posX + 0.5; double y = center.posY; double z = center.posZ + 0.5; GL11.glTranslated(x - RenderManager.renderPosX, y - RenderManager.renderPosY, z - RenderManager.renderPosZ); int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F); Color colorRGB = new Color(color); GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 32); double f = 1F / 16F; int totalAngles = 360; int drawAngles = 360; int step = totalAngles / drawAngles; radius -= f; Tessellator tessellator = Tessellator.instance; tessellator.startDrawing(GL11.GL_TRIANGLE_FAN); tessellator.addVertex(0, f, 0); for (int i = 0; i < totalAngles + 1; i += step) { double rad = (totalAngles - i) * Math.PI / 180.0; double xp = Math.cos(rad) * radius; double zp = Math.sin(rad) * radius; tessellator.addVertex(xp, f, zp); } tessellator.addVertex(0, f, 0); tessellator.draw(); radius += f; double f1 = f + f / 4F; GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64); tessellator.startDrawing(GL11.GL_TRIANGLE_FAN); tessellator.addVertex(0, f1, 0); for (int i = 0; i < totalAngles + 1; i += step) { double rad = (totalAngles - i) * Math.PI / 180.0; double xp = Math.cos(rad) * radius; double zp = Math.sin(rad) * radius; tessellator.addVertex(xp, f1, zp); } tessellator.addVertex(0, f1, 0); tessellator.draw(); GL11.glPopMatrix(); }
From source file:vazkii.botania.client.core.handler.TiaraWingRenderHandler.java
License:Creative Commons License
private void renderHalo(EntityPlayer player, float partialTicks) { float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialTicks; float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialTicks; float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * partialTicks; GL11.glPushMatrix();//from w ww.ja v a 2 s . c o m GL11.glRotatef(yawOffset, 0, -1, 0); GL11.glRotatef(yaw - 270, 0, 1, 0); GL11.glRotatef(pitch, 0, 0, 1); GL11.glShadeModel(GL11.GL_SMOOTH); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); GL11.glDisable(GL11.GL_LIGHTING); GL11.glColor4f(1F, 1F, 1F, 1F); Minecraft.getMinecraft().renderEngine.bindTexture(textureHalo); GL11.glTranslated(0, -player.eyeHeight + (player.isSneaking() ? 0.0625 : 0), 0); GL11.glRotated(30, 1, 0, -1); GL11.glTranslatef(-0.1F, -0.5F, -0.1F); GL11.glRotatef(player.ticksExisted + partialTicks, 0, 1, 0); Tessellator tes = Tessellator.instance; tes.startDrawingQuads(); tes.addVertexWithUV(-0.5, 0, -0.5, 0, 0); tes.addVertexWithUV(-0.5, 0, 0.5, 0, 1); tes.addVertexWithUV(0.5, 0, 0.5, 1, 1); tes.addVertexWithUV(0.5, 0, -0.5, 1, 0); tes.draw(); GL11.glEnable(GL11.GL_LIGHTING); GL11.glShadeModel(GL11.GL_FLAT); GL11.glPopMatrix(); }
From source file:vazkii.botania.client.render.entity.RenderManaStorm.java
License:Open Source License
@Override public void doRender(Entity e, double x, double y, double z, float something, float pticks) { GL11.glPushMatrix();//from w ww. j av a 2 s. c om GL11.glTranslated(x, y, z); EntityManaStorm storm = (EntityManaStorm) e; float maxScale = 1.95F; float scale = 0.05F + ((float) storm.burstsFired / EntityManaStorm.TOTAL_BURSTS - (storm.deathTime == 0 ? 0 : storm.deathTime + pticks) / EntityManaStorm.DEATH_TIME) * maxScale; RenderHelper.renderStar(0x00FF00, scale, scale, scale, e.getUniqueID().getMostSignificantBits()); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
From source file:vazkii.botania.client.render.tile.RenderTileBellows.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { TileBellows bellows = (TileBellows) tileentity; GL11.glPushMatrix();/*ww w . ja va 2 s . c om*/ GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1F, 1F, 1F, 1F); GL11.glTranslated(d0, d1, d2); Minecraft.getMinecraft().renderEngine.bindTexture(texture); int meta = bellows.getWorldObj() != null ? bellows.getBlockMetadata() : 0; GL11.glTranslatef(0.5F, 1.5F, 0.5F); GL11.glScalef(1F, -1F, -1F); GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length, meta - 2), 0)], 0F, 1F, 0F); model.render(Math.max(0.1F, 1F - (bellows.movePos + bellows.moving * f + 0.1F))); GL11.glColor3f(1F, 1F, 1F); GL11.glScalef(1F, -1F, -1F); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }