Example usage for org.lwjgl.opengl GL11 glRotatef

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

Introduction

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

Prototype

public static native void glRotatef(@NativeType("GLfloat") float angle, @NativeType("GLfloat") float x,
        @NativeType("GLfloat") float y, @NativeType("GLfloat") float z);

Source Link

Document

Manipulates the current matrix with a rotation matrix.

Usage

From source file:fexcraft.tmt.slim.ModelRendererTurbo.java

/**
 * Renders the shape./*from  w  ww  .  ja  va2s.  co  m*/
 * @param scale the scale of the shape. Usually is 0.0625.
 */
public void render(float scale, boolean flipAxis) {
    if (field_1402_i || !showModel) {
        return;
    }
    if (displayList != null && (!compiled || forcedRecompile)) {
        compileDisplayList(scale);
    }
    if (rotateAngleX != 0.0F || rotateAngleY != 0.0F || rotateAngleZ != 0.0F) {
        GL11.glPushMatrix();
        GL11.glTranslatef(rotationPointX * scale, rotationPointY * scale, rotationPointZ * scale);
        if (flipAxis) {
            if (rotateAngleZ != 0.0F) {
                GL11.glRotatef(rotateAngleZ * 57.29578F, 0.0F, 0.0F, 1.0F);
            }
            if (rotateAngleY != 0.0F) {
                GL11.glRotatef(rotateAngleY * 57.29578F, 0.0F, 1.0F, 0.0F);
            }
        } else {
            if (rotateAngleY != 0.0F) {
                GL11.glRotatef(rotateAngleY * 57.29578F, 0.0F, 1.0F, 0.0F);
            }
            if (rotateAngleZ != 0.0F) {
                GL11.glRotatef(rotateAngleZ * 57.29578F, 0.0F, 0.0F, 1.0F);
            }
        }
        if (rotateAngleX != 0.0F) {
            GL11.glRotatef(rotateAngleX * 57.29578F, 1.0F, 0.0F, 0.0F);
        }
        callDisplayList(scale);
        GL11.glPopMatrix();
    } else if (rotationPointX != 0.0F || rotationPointY != 0.0F || rotationPointZ != 0.0F) {
        GL11.glTranslatef(rotationPointX * scale, rotationPointY * scale, rotationPointZ * scale);
        callDisplayList(scale);
        GL11.glTranslatef(-rotationPointX * scale, -rotationPointY * scale, -rotationPointZ * scale);
    } else {
        callDisplayList(scale);
    }
}

From source file:fi.conf.ae.gl.GLGraphicRoutines.java

License:LGPL

public static void translateToAlign(float p1x, float p1y, float p1z, float p2x, float p2y, float p2z) {

    //Translate joint to the middle of the two points
    GL11.glTranslatef((p1x + p2x) * 0.5f, (p1y + p2y) * 0.5f, (p1z + p2z) * 0.5f);

    //Fix rotations so the drawn object will match the two points
    float zxAngle = (float) (Math.atan((p1x - p2x) / (p1z - p2z)) / Math.PI);
    float yzxAngle = (float) (Math
            .atan(Math.sqrt(Math.pow((p1x - p2x), 2) + Math.pow((p1z - p2z), 2)) / (p1y - p2y)) / Math.PI);

    if (p1z > p2z) {
        GL11.glRotatef(zxAngle * 180, 0, 1, 0);
    } else {// ww w  .j  av a2  s.  c  o m
        GL11.glRotatef(zxAngle * 180 + 180, 0, 1, 0);
    }

    if (p1y > p2y) {
        GL11.glRotatef(180 * yzxAngle, 1, 0, 0);
    } else {
        GL11.glRotatef(180 * yzxAngle + 180, 1, 0, 0);
    }

}

From source file:fi.conf.ae.gl.GLGraphicRoutines.java

License:LGPL

public static void rotateToAlign(float p1x, float p1y, float p1z, float p2x, float p2y, float p2z) {

    //Translate joint to the middle of the two points
    //GL11.glTranslatef((p1x+p2x)*0.5f, (p1y+p2y)*0.5f, (p1z+p2z)*0.5f);

    //Fix rotations so the drawn object will match the two points
    float zxAngle = (float) (Math.atan((p1x - p2x) / (p1z - p2z)) / Math.PI);
    float yzxAngle = (float) (Math
            .atan(Math.sqrt(Math.pow((p1x - p2x), 2) + Math.pow((p1z - p2z), 2)) / (p1y - p2y)) / Math.PI);

    if (p1z > p2z) {
        GL11.glRotatef(zxAngle * 180, 0, 1, 0);
    } else {//from w w w .j a  va2s.  c o m
        GL11.glRotatef(zxAngle * 180 + 180, 0, 1, 0);
    }

    if (p1y > p2y) {
        GL11.glRotatef(180 * yzxAngle, 1, 0, 0);
    } else {
        GL11.glRotatef(180 * yzxAngle + 180, 1, 0, 0);
    }

}

From source file:forestry.apiculture.render.BeeItemRenderer.java

License:Open Source License

private void renderBeeItem(IBee bee, float translateX, float translateY, float translateZ) {
    float yaw = 1;
    float pitch = 1;

    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_LIGHTING);/*from  w ww .  ja  v  a 2 s.  co  m*/
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_COLOR_MATERIAL);

    GL11.glPushMatrix();

    GL11.glScalef(2.0f, 2.0f, 2.0f);
    GL11.glTranslatef(translateX, translateY, translateZ);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(-((float) Math.atan(pitch / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F);

    entity.renderYawOffset = (float) Math.atan(yaw / 40.0F) * 20.0F;
    entity.rotationYaw = (float) Math.atan(yaw / 40.0F) * 40.0F;
    entity.rotationPitch = -((float) Math.atan(pitch / 40.0F)) * 20.0F;
    entity.rotationYawHead = entity.rotationYaw;

    RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, getWingYaw(bee));

    GL11.glPopMatrix();

    RenderHelper.disableStandardItemLighting();
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
    GL11.glPopAttrib();

}

From source file:forestry.apiculture.render.BeeItemRenderer.java

License:Open Source License

private void renderBeeInInventory(IBee bee) {

    /*//from  w ww .j a  v  a2  s.co  m
    GL11.glPushMatrix();
      //GL11.glTranslatef(-0.3f, -2.5f, 0f);
      GL11.glScalef(-1.0f, 1.0f, 1.0f);
      //GL11.glScalef((float)Math.PI / 2, 1.0f, 1.0f);
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);
      //GL11.glRotatef(-((float) Math.atan((double) (1 / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
      renderBeeHalo();
      GL11.glPopMatrix();
     */

    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    RenderHelper.enableStandardItemLighting();

    GL11.glPushMatrix();

    GL11.glTranslatef(-0.3f, -2.5f, 0f);
    GL11.glScalef(-3.0f, 3.0f, 3.0f);
    GL11.glRotatef(32.0F, 0.0F, 1.0F, 0.0F);
    GL11.glScalef(1.6f, 1f, 1f);

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    entity.renderYawOffset = 0;
    entity.rotationYaw = 0;
    entity.rotationPitch = 0;
    entity.rotationYawHead = entity.rotationYaw;

    RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, getWingYaw(bee));

    GL11.glPopMatrix();
    RenderHelper.disableStandardItemLighting();
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
    GL11.glPopAttrib();
}

From source file:forestry.arboriculture.render.LeavesRenderingHandler.java

License:Open Source License

private void renderItem(RenderBlocks renderer, ItemStack itemStack, float x, float y, float z) {
    Tessellator tessellator = Tessellator.instance;
    Block block = StackUtils.getBlock(itemStack);

    if (!(itemStack.getItem() instanceof ItemLeavesBlock) || block == null) {
        return;// www .j  ava  2  s  .  co  m
    }

    TileLeaves leaves = new TileLeaves();
    if (itemStack.hasTagCompound()) {
        leaves.readFromNBT(itemStack.getTagCompound());
    } else {
        leaves.setTree(TreeHelper.treeTemplates.get(0));
    }

    GL11.glEnable(GL11.GL_BLEND);

    IIcon leavesIcon = leaves.getIcon(Proxies.render.fancyGraphicsEnabled());
    if (leavesIcon == null) {
        return;
    }
    int color = leaves.getFoliageColour(Proxies.common.getPlayer());

    float r1 = (float) (color >> 16 & 255) / 255.0F;
    float g1 = (float) (color >> 8 & 255) / 255.0F;
    float b1 = (float) (color & 255) / 255.0F;
    GL11.glColor4f(r1, g1, b1, 1.0F);

    GL11.glTranslatef(x, y, z);

    block.setBlockBoundsForItemRender();
    renderer.setRenderBoundsFromBlock(block);

    GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, -1.0F, 0.0F);
    renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, leavesIcon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, leavesIcon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1.0F);
    renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, leavesIcon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, leavesIcon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(-1.0F, 0.0F, 0.0F);
    renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, leavesIcon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
    renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, leavesIcon);
    tessellator.draw();
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);

    // add fruit
    if (!leaves.hasFruit()) {
        return;
    }

    IIcon fruitTexture = leaves.getFruitTexture();
    if (fruitTexture == null) {
        return;
    }
    int fruitColor = leaves.getFruitColour();

    float r2 = (float) (fruitColor >> 16 & 255) / 255.0F;
    float g2 = (float) (fruitColor >> 8 & 255) / 255.0F;
    float b2 = (float) (fruitColor & 255) / 255.0F;
    GL11.glColor4f(r2, g2, b2, 1.0F);

    block.setBlockBoundsForItemRender();
    renderer.setRenderBoundsFromBlock(block);

    GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, -1.0F, 0.0F);
    renderer.renderFaceYNeg(block, 0.0D, 0.0D - OVERLAY_SHIFT, 0.0D, fruitTexture);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    renderer.renderFaceYPos(block, 0.0D, 0.0D + OVERLAY_SHIFT, 0.0D, fruitTexture);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1.0F);
    renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D - OVERLAY_SHIFT, fruitTexture);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D + OVERLAY_SHIFT, fruitTexture);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(-1.0F, 0.0F, 0.0F);
    renderer.renderFaceXNeg(block, 0.0D - OVERLAY_SHIFT, 0.0D, 0.0D, fruitTexture);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
    renderer.renderFaceXPos(block, 0.0D + OVERLAY_SHIFT, 0.0D, 0.0D, fruitTexture);
    tessellator.draw();
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}

From source file:forestry.core.render.CrateRenderingHandler.java

License:Open Source License

private void renderAsEntity(ItemStack stack, EntityItem entity) {
    GL11.glPushMatrix();//from w  ww .j a v  a2s  .c o m
    byte iterations = 1;
    if (stack.stackSize > 1) {
        iterations = 2;
    }
    if (stack.stackSize > 15) {
        iterations = 3;
    }
    if (stack.stackSize > 31) {
        iterations = 4;
    }

    Random rand = new Random(187L);

    float offsetZ = PIXEL + 0.021875F;

    GL11.glRotatef((((float) entity.age + 1.0F) / 20.0F + entity.hoverStart) * (180F / (float) Math.PI), 0.0F,
            1.0F, 0.0F);
    GL11.glTranslatef(-0.5F, -0.25F, -(offsetZ * (float) iterations / 2.0F));

    for (int count = 0; count < iterations; ++count) {
        if (count > 0) {
            float offsetX = (rand.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
            float offsetY = (rand.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
            GL11.glTranslatef(offsetX, offsetY, offsetZ);
        } else {
            GL11.glTranslatef(0f, 0f, offsetZ);
        }

        renderIn3D(stack);

        ItemStack contained = getContainedFromCrate(stack);

        if (contained != null) {
            GL11.glPushMatrix();
            float scale = 0.5f;
            GL11.glScalef(scale, scale, 1.1F);
            GL11.glTranslatef(10.0f * PIXEL, 8.0f * PIXEL, 0.003F);
            renderIn3D(contained);
            GL11.glPopMatrix();
        }
    }
    GL11.glPopMatrix();
}

From source file:forestry.core.render.CrateRenderingHandler.java

License:Open Source License

private void renderIn3D(ItemStack stack) {
    GL11.glPushMatrix();// w w  w. j  a  v a 2 s . c  o  m
    Tessellator tessellator = Tessellator.instance;
    if (RenderManager.instance.renderEngine == null) {
        return;
    }

    int meta = stack.getItemDamage();
    for (int pass = 0; pass < stack.getItem().getRenderPasses(meta); ++pass) {
        IIcon icon = stack.getItem().getIconFromDamageForRenderPass(meta, pass);
        if (icon == null) {
            continue;
        }

        if (renderItem.renderWithColor) {
            int color = stack.getItem().getColorFromItemStack(stack, pass);
            float c1 = (float) (color >> 16 & 255) / 255.0F;
            float c2 = (float) (color >> 8 & 255) / 255.0F;
            float c3 = (float) (color & 255) / 255.0F;

            GL11.glColor4f(c1, c2, c3, 1.0F);
        }

        float minU = icon.getMinU();
        float maxU = icon.getMaxU();
        float minV = icon.getMinV();
        float maxV = icon.getMaxV();

        if (stack.getItemSpriteNumber() == 0) {
            RenderManager.instance.renderEngine.bindTexture(BLOCK_TEXTURE);
        } else {
            RenderManager.instance.renderEngine.bindTexture(ITEM_TEXTURE);
        }

        ItemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(),
                icon.getIconHeight(), PIXEL);

        if (stack.hasEffect(pass)) {
            GL11.glDepthFunc(GL11.GL_EQUAL);
            GL11.glDisable(GL11.GL_LIGHTING);
            RenderManager.instance.renderEngine.bindTexture(GLINT_TEXTURE);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
            float f13 = 0.76F;
            GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F);
            GL11.glMatrixMode(GL11.GL_TEXTURE);
            GL11.glPushMatrix();
            float f14 = 0.125F;
            GL11.glScalef(f14, f14, f14);
            float f15 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
            GL11.glTranslatef(f15, 0.0F, 0.0F);
            GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
            ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, PIXEL);
            GL11.glPopMatrix();
            GL11.glPushMatrix();
            GL11.glScalef(f14, f14, f14);
            f15 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
            GL11.glTranslatef(-f15, 0.0F, 0.0F);
            GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
            ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, PIXEL);
            GL11.glPopMatrix();
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glDepthFunc(GL11.GL_LEQUAL);
        }
    }

    GL11.glPopMatrix();
}

From source file:forestry.core.render.CrateRenderingHandler.java

License:Open Source License

private void render(ItemRenderType type, ItemStack stack) {
    GL11.glPushMatrix();//ww w. j a va  2s . co  m
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    IIcon crateTexture = stack.getIconIndex();
    renderItem.renderIcon(0, 0, crateTexture, 16, 16);

    ItemStack contained = getContainedFromCrate(stack);

    if (contained != null) {

        int meta = contained.getItemDamage();

        float scale = 0.5f;
        GL11.glScalef(scale, scale, 1);
        GL11.glTranslatef(6f, 8f, 0);
        if (type == ItemRenderType.ENTITY) {
            GL11.glTranslatef(0, 0, -0.1f);
        }

        if (contained.getItem() instanceof ItemBlock) {
            GL11.glScalef(16f, 16f, 1f);
            GL11.glTranslatef(1f, 1f, 0.1f);
            GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
            renderIn3D(contained);
        } else {
            for (int pass = 0; pass < contained.getItem().getRenderPasses(meta); ++pass) {
                IIcon containedTexture = contained.getItem().getIconFromDamageForRenderPass(meta, pass);
                if (containedTexture == null) {
                    continue;
                }

                if (renderItem.renderWithColor) {
                    int color = contained.getItem().getColorFromItemStack(contained, pass);
                    float c1 = (float) (color >> 16 & 255) / 255.0F;
                    float c2 = (float) (color >> 8 & 255) / 255.0F;
                    float c3 = (float) (color & 255) / 255.0F;

                    GL11.glColor4f(c1, c2, c3, 1.0F);
                }

                renderItem.renderIcon(0, 0, containedTexture, 16, 16);
            }
        }
    }

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

From source file:forestry.core.render.EntitySnowFX.java

License:Open Source License

public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) {

    tessellator.draw();//from   w  w  w.j  a v  a 2 s  .c  o m
    GL11.glPushMatrix();

    GL11.glDepthMask(false);
    GL11.glEnable(3042);
    GL11.glBlendFunc(770, blendmode);

    Proxies.common.bindTexture(texture);

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    float f10 = 0.1F * particleScale;
    float f11 = (float) ((prevPosX + (posX - prevPosX) * f) - interpPosX);
    float f12 = (float) ((prevPosY + (posY - prevPosY) * f) - interpPosY);
    float f13 = (float) ((prevPosZ + (posZ - prevPosZ) * f) - interpPosZ);

    GL11.glRotatef((float) motionY, 0.0F, 1.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.setBrightness(0x0000f0);

    tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, 1.0F);
    tessellator.addVertexWithUV(f11 - f1 * f10 - f4 * f10, f12 - f2 * f10, f13 - f3 * f10 - f5 * f10, 0, 1);
    tessellator.addVertexWithUV((f11 - f1 * f10) + f4 * f10, f12 + f2 * f10, (f13 - f3 * f10) + f5 * f10, 1, 1);
    tessellator.addVertexWithUV(f11 + f1 * f10 + f4 * f10, f12 + f2 * f10, f13 + f3 * f10 + f5 * f10, 1, 0);
    tessellator.addVertexWithUV((f11 + f1 * f10) - f4 * f10, f12 - f2 * f10, (f13 + f3 * f10) - f5 * f10, 0, 0);

    tessellator.draw();

    GL11.glDisable(3042);
    GL11.glDepthMask(true);

    GL11.glPopMatrix();
    GL11.glBindTexture(3553 /* GL_TEXTURE_2D *//* GL_TEXTURE_2D */,
            Proxies.common.getClientInstance().renderEngine.getTexture("/particles.png"));
    tessellator.startDrawingQuads();
}