Example usage for org.lwjgl.opengl GL11 glTranslated

List of usage examples for org.lwjgl.opengl GL11 glTranslated

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glTranslated.

Prototype

public static native void glTranslated(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y,
        @NativeType("GLdouble") double z);

Source Link

Document

Double version of #glTranslatef Translatef .

Usage

From source file:hellfirepvp.astralsorcery.client.render.tile.TESRRitualPedestal.java

License:Open Source License

private void renderCrystalStack(TileRitualPedestal te, double x, double y, double z) {
    ItemStack i = te.getInventoryHandler().getStackInSlot(0);
    if (!i.isEmpty()) {
        Item it = i.getItem();//ww w .j  a  v  a 2s  .c  om
        if (it instanceof ItemTunedCrystalBase) {
            GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
            GL11.glPushMatrix();
            boolean celestial = it instanceof ItemTunedCelestialCrystal;
            Color c = celestial ? BlockCollectorCrystalBase.CollectorCrystalType.CELESTIAL_CRYSTAL.displayColor
                    : BlockCollectorCrystalBase.CollectorCrystalType.ROCK_CRYSTAL.displayColor;
            long sBase = 1553015L;
            sBase ^= (long) te.getPos().getX();
            sBase ^= (long) te.getPos().getY();
            sBase ^= (long) te.getPos().getZ();
            RenderingUtils.renderLightRayEffects(x + 0.5, y + 1.3, z + 0.5, c, sBase,
                    ClientScheduler.getClientTick(), 20, 50, 25);

            GL11.glTranslated(x + 0.5, y + 1, z + 0.5);
            GL11.glScaled(0.6, 0.6, 0.6);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            TESRCollectorCrystal.renderCrystal(celestial, true);

            GL11.glPopMatrix();
            GL11.glPopAttrib();
        }
    }
}

From source file:hellfirepvp.astralsorcery.client.util.BlockArrayRenderHelper.java

License:Open Source License

public void render3DGUI(double x, double y, float pTicks) {
    GuiScreen scr = Minecraft.getMinecraft().currentScreen;
    if (scr == null)
        return;/*from  www .  j a v a  2  s.c  o m*/

    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();
    Minecraft mc = Minecraft.getMinecraft();
    double sc = new ScaledResolution(mc).getScaleFactor();
    GL11.glTranslated(x + 16D / sc, y + 16D / sc, 512);

    double mul = 10.5;

    double size = 2;
    double minSize = 0.5;

    Vec3i max = blocks.getMax();
    Vec3i min = blocks.getMin();

    double maxLength = 0;
    double pointDst = max.getX() - min.getX();
    if (pointDst > maxLength)
        maxLength = pointDst;
    pointDst = max.getY() - min.getY();
    if (pointDst > maxLength)
        maxLength = pointDst;
    pointDst = max.getZ() - min.getZ();
    if (pointDst > maxLength)
        maxLength = pointDst;
    maxLength -= 5;

    if (maxLength > 0) {
        size = (size - minSize) * (1D - (maxLength / 20D));
    }

    double dr = -5.75 * size;
    GL11.glTranslated(dr, dr, dr);
    GL11.glRotated(rotX, 1, 0, 0);
    GL11.glRotated(rotY, 0, 1, 0);
    GL11.glRotated(rotZ, 0, 0, 1);
    GL11.glTranslated(-dr, -dr, -dr);

    GL11.glScaled(-size * mul, -size * mul, -size * mul);

    BlockRendererDispatcher brd = Minecraft.getMinecraft().getBlockRendererDispatcher();
    VertexFormat blockFormat = DefaultVertexFormats.BLOCK;

    TextureHelper.setActiveTextureToAtlasSprite();
    Tessellator tes = Tessellator.getInstance();
    VertexBuffer vb = tes.getBuffer();

    vb.begin(GL11.GL_QUADS, blockFormat);
    for (Map.Entry<BlockPos, BakedBlockData> data : renderAccess.blockRenderData.entrySet()) {
        BlockPos offset = data.getKey();
        BakedBlockData renderData = data.getValue();
        if (renderData.type != Blocks.AIR) {
            brd.renderBlock(renderData.state, offset, renderAccess, vb);
        }
    }
    tes.draw();

    for (Map.Entry<BlockPos, BakedBlockData> data : renderAccess.blockRenderData.entrySet()) {
        BlockPos offset = data.getKey();
        BakedBlockData renderData = data.getValue();
        if (renderData.tileEntity != null && renderData.tesr != null) {
            renderData.tileEntity.setWorld(Minecraft.getMinecraft().world);
            renderData.tesr.renderTileEntityAt(renderData.tileEntity, offset.getX(), offset.getY(),
                    offset.getZ(), pTicks, 0);
        }
    }

    GL11.glPopMatrix();
    GL11.glPopAttrib();
}

From source file:hellfirepvp.astralsorcery.client.util.RenderConstellation.java

License:Open Source License

public static void renderConstellationIntoWorldFlat(IConstellation c, Color rC, Vector3 offsetPos, double scale,
        double lineBreadth, float br) {
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();/*from  w w w. j  av a 2  s  . c  om*/
    Tessellator tes = Tessellator.getInstance();
    VertexBuffer vb = tes.getBuffer();

    double s = 1D / 31D * scale;

    GL11.glTranslated(-15.5D * s, 0, -15.5D * s);

    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    Blending.DEFAULT.apply();

    float fRed = ((float) rC.getRed()) / 255F;
    float fGreen = ((float) rC.getGreen()) / 255F;
    float fBlue = ((float) rC.getBlue()) / 255F;

    RenderAstralSkybox.TEX_CONNECTION.bind();
    vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
    for (StarConnection sc : c.getStarConnections()) {
        float brightness = br;
        brightness *= 0.8;
        float fAlpha = brightness < 0 ? 0 : brightness;

        Vector3 offset = offsetPos.clone().addX(sc.from.x * s).addZ(sc.from.y * s);
        Vector3 dirU = new Vector3(sc.to.x, 0, sc.to.y).subtract(sc.from.x, 0, sc.from.y).multiply(s);
        Vector3 dirV = dirU.clone().crossProduct(new Vector3(0, 1, 0)).setY(0).normalize()
                .multiply(lineBreadth * s);
        Vector3 offsetRender = offset.subtract(dirV.clone().divide(2));

        Vector3 pos = offsetRender.clone().add(dirU.clone().multiply(0)).add(dirV.clone().multiply(1));
        vb.pos(pos.getX(), pos.getY(), pos.getZ()).tex(1, 0).color(fRed, fGreen, fBlue, fAlpha).endVertex();
        pos = offsetRender.clone().add(dirU.clone().multiply(1)).add(dirV.clone().multiply(1));
        vb.pos(pos.getX(), pos.getY(), pos.getZ()).tex(0, 0).color(fRed, fGreen, fBlue, fAlpha).endVertex();
        pos = offsetRender.clone().add(dirU.clone().multiply(1)).add(dirV.clone().multiply(0));
        vb.pos(pos.getX(), pos.getY(), pos.getZ()).tex(0, 1).color(fRed, fGreen, fBlue, fAlpha).endVertex();
        pos = offsetRender.clone().add(dirU.clone().multiply(0)).add(dirV.clone().multiply(0));
        vb.pos(pos.getX(), pos.getY(), pos.getZ()).tex(1, 1).color(fRed, fGreen, fBlue, fAlpha).endVertex();

    }
    tes.draw();

    RenderAstralSkybox.TEX_STAR_1.bind();
    vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
    for (StarLocation sl : c.getStars()) {
        float fAlpha = br < 0 ? 0 : br;

        Vector3 offsetRender = offsetPos.clone().add(sl.x * s - s, 0.005, sl.y * s - s);
        Vector3 dirU = new Vector3(s * 2, 0, 0);
        Vector3 dirV = new Vector3(0, 0, s * 2);

        Vector3 pos = offsetRender.clone().add(dirU.clone().multiply(0)).add(dirV.clone().multiply(1));
        vb.pos(pos.getX(), pos.getY(), pos.getZ()).tex(1, 0).color(fRed, fGreen, fBlue, fAlpha).endVertex();
        pos = offsetRender.clone().add(dirU.clone().multiply(1)).add(dirV.clone().multiply(1));
        vb.pos(pos.getX(), pos.getY(), pos.getZ()).tex(0, 0).color(fRed, fGreen, fBlue, fAlpha).endVertex();
        pos = offsetRender.clone().add(dirU.clone().multiply(1)).add(dirV.clone().multiply(0));
        vb.pos(pos.getX(), pos.getY(), pos.getZ()).tex(0, 1).color(fRed, fGreen, fBlue, fAlpha).endVertex();
        pos = offsetRender.clone().add(dirU.clone().multiply(0)).add(dirV.clone().multiply(0));
        vb.pos(pos.getX(), pos.getY(), pos.getZ()).tex(1, 1).color(fRed, fGreen, fBlue, fAlpha).endVertex();
    }
    tes.draw();

    GL11.glPopMatrix();
    GL11.glPopAttrib();
}

From source file:hellfirepvp.astralsorcery.client.util.RenderingUtils.java

License:Open Source License

public static void renderLightRayEffects(double x, double y, double z, Color effectColor, long seed,
        long continuousTick, int dstJump, float scale, int countFancy, int countNormal) {
    rand.setSeed(seed);/*ww w .  j  a v  a2  s  . c  o m*/
    GL11.glPushMatrix();
    GL11.glTranslated(x, y, z);

    int fancy_count = !FMLClientHandler.instance().getClient().gameSettings.fancyGraphics ? countNormal
            : countFancy;

    Tessellator tes = Tessellator.getInstance();
    VertexBuffer vb = tes.getBuffer();

    RenderHelper.disableStandardItemLighting();
    float f1 = continuousTick / 400.0F;
    float f2 = 0.4F;

    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glDepthMask(false);
    GL11.glPushMatrix();
    for (int i = 0; i < fancy_count; i++) {
        GL11.glRotatef(rand.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(rand.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(rand.nextFloat() * 360.0F, 0.0F, 0.0F, 1.0F);
        GL11.glRotatef(rand.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(rand.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(rand.nextFloat() * 360.0F + f1 * 360.0F, 0.0F, 0.0F, 1.0F);
        vb.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
        float fa = rand.nextFloat() * 20.0F + 5.0F + f2 * 10.0F;
        float f4 = rand.nextFloat() * 2.0F + 1.0F + f2 * 2.0F;
        fa /= 30.0F / (Math.min(dstJump, 10 * scale) / 10.0F);
        f4 /= 30.0F / (Math.min(dstJump, 10 * scale) / 10.0F);
        vb.pos(0, 0, 0).color(effectColor.getRed(), effectColor.getGreen(), effectColor.getBlue(),
                (int) (255.0F * (1.0F - f2))).endVertex();
        vb.pos(-0.7D * f4, fa, -0.5F * f4)
                .color(effectColor.getRed(), effectColor.getGreen(), effectColor.getBlue(), 0).endVertex();
        vb.pos(0.7D * f4, fa, -0.5F * f4)
                .color(effectColor.getRed(), effectColor.getGreen(), effectColor.getBlue(), 0).endVertex();
        vb.pos(0.0D, fa, 1.0F * f4)
                .color(effectColor.getRed(), effectColor.getGreen(), effectColor.getBlue(), 0).endVertex();
        vb.pos(-0.7D * f4, fa, -0.5F * f4)
                .color(effectColor.getRed(), effectColor.getGreen(), effectColor.getBlue(), 0).endVertex();
        tes.draw();
    }
    GL11.glPopMatrix();
    GL11.glDepthMask(true);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    RenderHelper.enableStandardItemLighting();

    GL11.glPopMatrix();
}

From source file:hellfirepvp.astralsorcery.client.util.RenderingUtils.java

License:Open Source License

public static void removeStandartTranslationFromTESRMatrix(float partialTicks) {
    Entity rView = Minecraft.getMinecraft().getRenderViewEntity();
    if (rView == null)
        rView = Minecraft.getMinecraft().player;
    Entity entity = rView;/*from  ww w.ja  va 2  s .  co  m*/
    double tx = entity.lastTickPosX + ((entity.posX - entity.lastTickPosX) * partialTicks);
    double ty = entity.lastTickPosY + ((entity.posY - entity.lastTickPosY) * partialTicks);
    double tz = entity.lastTickPosZ + ((entity.posZ - entity.lastTickPosZ) * partialTicks);
    GL11.glTranslated(-tx, -ty, -tz);
}

From source file:hellfirepvp.astralsorcery.common.item.base.IGrindable.java

License:Open Source License

@SideOnly(Side.CLIENT)
public static void applyDefaultGrindstoneTransforms() {
    GL11.glTranslated(0.55, 0.75, 0.6);
    GL11.glRotated(125, 1, 0, 0);//from   w  w w.ja v  a  2s .c om
    GL11.glRotated(180, 0, 0, 1);
    /*GL11.glRotated(180, 0, 1, 0);
    GL11.glRotated(35, 1, 0, 0);
    GL11.glRotated(15, 0, 0, 1);*/
}

From source file:hellfirepvp.astralsorcery.common.item.wand.ItemArchitectWand.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)/*w  w w. j  a  v a 2 s . c  o m*/
public void onRenderInHandHUD(ItemStack lastCacheInstance, float fadeAlpha, float pTicks) {
    ItemStack blockStackStored = getStoredStateAsStack(lastCacheInstance);
    if (blockStackStored.isEmpty())
        return;

    int amtFound = 0;
    if (Mods.BOTANIA.isPresent()) {
        amtFound = ModIntegrationBotania.getItemCount(Minecraft.getMinecraft().player, lastCacheInstance,
                ItemUtils.createBlockState(blockStackStored));
    } else {
        Collection<ItemStack> stacks = ItemUtils.scanInventoryForMatching(
                new InvWrapper(Minecraft.getMinecraft().player.inventory), blockStackStored, false);
        for (ItemStack stack : stacks) {
            amtFound += stack.getCount();
        }
    }

    int height = 26;
    int width = 26;
    int offsetX = 30;
    int offsetY = 15;

    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    Blending.DEFAULT.apply();
    ClientRenderEventHandler.texHUDItemFrame.bind();

    GL11.glColor4f(1F, 1F, 1F, fadeAlpha * 0.9F);
    Tessellator tes = Tessellator.getInstance();
    VertexBuffer vb = tes.getBuffer();

    vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
    vb.pos(offsetX, offsetY + height, 10).tex(0, 1).endVertex();
    vb.pos(offsetX + width, offsetY + height, 10).tex(1, 1).endVertex();
    vb.pos(offsetX + width, offsetY, 10).tex(1, 0).endVertex();
    vb.pos(offsetX, offsetY, 10).tex(0, 0).endVertex();
    tes.draw();

    TextureHelper.refreshTextureBindState();
    TextureHelper.setActiveTextureToAtlasSprite();

    RenderHelper.enableGUIStandardItemLighting();
    RenderItem ri = Minecraft.getMinecraft().getRenderItem();
    ri.renderItemAndEffectIntoGUI(Minecraft.getMinecraft().player, blockStackStored, offsetX + 5, offsetY + 5);
    RenderHelper.disableStandardItemLighting();
    GlStateManager.enableAlpha(); //Because Mc item rendering..

    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glPushMatrix();
    GL11.glTranslated(offsetX + 14, offsetY + 16, 0);
    String amtString = String.valueOf(amtFound);
    if (amtFound == -1) {
        amtString = "";
    }
    GL11.glTranslated(-Minecraft.getMinecraft().fontRenderer.getStringWidth(amtString) / 3, 0, 0);
    GL11.glScaled(0.7, 0.7, 0.7);
    if (amtString.length() > 3) {
        GL11.glScaled(0.9, 0.9, 0.9);
    }
    int c = 0x00DDDDDD;
    Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(amtString, 0, 0, c);
    GlStateManager.color(1F, 1F, 1F, 1F);
    TextureHelper.refreshTextureBindState();

    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glPopMatrix();
    GL11.glPopAttrib();
}

From source file:info.plugmania.novacraft.event.gui.Render3DOverlayEvent.java

License:GNU General Public License

public void drawCylinder(Position position, float radius, int slices, int stacks, float lineWidth, int colour) {
    float red = (float) (colour >> 24 & 255) / 255.0F;
    float green = (float) (colour >> 16 & 255) / 255.0F;
    float blue = (float) (colour >> 8 & 255) / 255.0F;
    float alpha = (float) (colour & 255) / 255.0F;
    Cylinder cylinder = new Cylinder();
    enable();/* w  w w.  j a  v a2 s  .  c  o m*/
    GL11.glColor4f(red, green, blue, alpha);
    GL11.glTranslated(position.getX() - p.posX, position.getY() - p.posY, position.getZ() - p.posZ);
    GL11.glRotatef(600F, 1, 1, 1);
    GL11.glLineWidth(lineWidth);
    cylinder.setDrawStyle(GLU.GLU_SILHOUETTE);
    cylinder.draw(radius, radius, 2F, slices, stacks);
    disable();

}

From source file:info.plugmania.novacraft.event.gui.Render3DOverlayEvent.java

License:GNU General Public License

public void drawSphere(Position position, float size, int slices, int stacks, float lineWidth, int colour) {
    float red = (float) (colour >> 24 & 255) / 255.0F;
    float green = (float) (colour >> 16 & 255) / 255.0F;
    float blue = (float) (colour >> 8 & 255) / 255.0F;
    float alpha = (float) (colour & 255) / 255.0F;
    Sphere sphere = new Sphere();
    enable();//from  w  w w.  ja  va 2  s  .  c o  m
    GL11.glColor4f(red, green, blue, alpha);
    GL11.glTranslated(position.getX() - p.posX, position.getY() - p.posY, position.getZ() - p.posZ);
    GL11.glRotatef(600F, 1, 1, 1);
    GL11.glLineWidth(lineWidth);
    sphere.setDrawStyle(GLU.GLU_SILHOUETTE);
    sphere.draw(size, slices, stacks);
    disable();
}

From source file:ivorius.ivtoolkit.bezier.IvBezierPath3DRendererText.java

License:Apache License

public void render(IvBezierPath3D path) {
    if (path.isDirty()) {
        path.buildDistances();/*from ww w . j  av  a  2  s .  c o m*/
    }

    GL11.glEnable(GL11.GL_BLEND);
    OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);

    String plainText = "";
    ArrayList<String> modifiers = new ArrayList<>();
    modifiers.add("");

    for (int i = 0; i < text.length(); i++) {
        char character = text.charAt(i);

        if (character == '\u00A7' && i + 1 < text.length()) {
            modifiers.set(modifiers.size() - 1, modifiers.get(modifiers.size() - 1) + text.substring(i, i + 2));
            i++;
        } else {
            plainText = plainText + character;
            modifiers.add(modifiers.get(modifiers.size() - 1));
        }
    }

    for (int i = 0; i < plainText.length(); i++) {
        int charIndex = inwards ? i : plainText.length() - i - 1;
        char character = plainText.charAt(charIndex);

        if (character != ' ') {
            double totalProgress = (spreadToFill ? ((double) i / (double) text.length()) : (i * 0.5)) + shift;
            double finalProgress = ((totalProgress % 1.0) + 1.0) % 1.0;

            if (finalProgress >= capBottom && finalProgress <= capTop) {
                IvBezierPoint3DCachedStep cachedStep = path.getCachedStep(finalProgress);
                double[] position = cachedStep.getPosition();
                double[] rotation = path.getNaturalRotation(cachedStep, 0.01);

                double red = IvMathHelper.mix(cachedStep.getLeftPoint().getRed(),
                        cachedStep.getRightPoint().getRed(), cachedStep.getInnerProgress());
                double green = IvMathHelper.mix(cachedStep.getLeftPoint().getGreen(),
                        cachedStep.getRightPoint().getGreen(), cachedStep.getInnerProgress());
                double blue = IvMathHelper.mix(cachedStep.getLeftPoint().getBlue(),
                        cachedStep.getRightPoint().getBlue(), cachedStep.getInnerProgress());
                double alpha = IvMathHelper.mix(cachedStep.getLeftPoint().getAlpha(),
                        cachedStep.getRightPoint().getAlpha(), cachedStep.getInnerProgress());

                double textSize = IvMathHelper.mix(cachedStep.getLeftPoint().getFontSize(),
                        cachedStep.getRightPoint().getFontSize(), cachedStep.getInnerProgress());

                GL11.glPushMatrix();
                GL11.glTranslated(position[0], position[1], position[2]);
                GL11.glScaled(-textSize / 12.0, -textSize / 12.0, -textSize / 12.0);
                GL11.glRotatef((float) rotation[0] + (inwards ? 0.0f : 180.0f), 0.0f, 1.0f, 0.0f);
                GL11.glRotatef((float) rotation[1], 1.0f, 0.0f, 0.0f);
                fontRenderer.drawString(modifiers.get(charIndex) + character, 0, 0,
                        ((int) (red * 255.0) << 16) + ((int) (green * 255.0) << 8) + ((int) (blue * 255.0)));
                GL11.glPopMatrix();
            }
        }
    }

    GL11.glDisable(GL11.GL_BLEND);
}