Example usage for org.lwjgl.opengl GL11 glTranslatef

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

Introduction

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

Prototype

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

Source Link

Document

Manipulates the current matrix with a translation matrix along the x-, y- and z- axes.

Usage

From source file:com.mrcrayfish.furniture.render.tileentity.BlenderRenderer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileEntity, double posX, double posY, double posZ, float p_180535_8_,
        int p_180535_9_) {
    TileEntityBlender blender = (TileEntityBlender) tileEntity;
    ItemStack[] ingredients = blender.getIngredients();

    GL11.glPushMatrix();//from  w ww .  ja  v  a2 s.c  o m
    GL11.glTranslatef((float) posX + 0.5F, (float) posY + 0.2F, (float) posZ + 0.5F);
    GL11.glScalef(0.65F, 0.65F, 0.65F);
    entityFood.hoverStart = 0.0F;
    for (int i = 0; i < ingredients.length; i++) {
        if (ingredients[i] != null) {
            entityFood.setEntityItemStack(ingredients[i]);
            GL11.glRotatef(i * -90F, 0, 1, 0);
            GL11.glRotatef(blender.progress * 18F, 0, 1, 0);
            Minecraft.getMinecraft().getRenderManager().renderEntityWithPosYaw(entityFood, 0.0D, 0.2D, 0.0D,
                    0.0F, 0.0F);
        }
    }
    GL11.glPopMatrix();

    if (blender.isBlending() | blender.drinkCount > 0) {
        Tessellator tessellator = Tessellator.getInstance();
        GL11.glPushMatrix();
        GL11.glTranslatef((float) posX + 0.5F, (float) posY + 0.05F, (float) posZ + 0.5F);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glEnable(GL11.GL_BLEND);

        float alpha = blender.isBlending() ? (blender.progress / 200F) : (blender.drinkCount > 0 ? 1.0F : 0.0F);
        GL11.glColor4f(blender.currentRed / 255F, blender.currentGreen / 255F, blender.currentBlue / 255F,
                alpha);

        float height = blender.isBlending() ? 0.8F : (0.275F + (0.525F * (blender.drinkCount / 6F)));
        GL11.glBegin(GL11.GL_QUADS);

        // North Face
        GL11.glVertex3d(-0.2, 0.275, -0.2);
        GL11.glVertex3d(0.2, 0.275, -0.2);
        GL11.glVertex3d(0.2, height, -0.2);
        GL11.glVertex3d(-0.2, height, -0.2);

        // South Face
        GL11.glVertex3d(-0.2, 0.275, 0.2);
        GL11.glVertex3d(0.2, 0.275, 0.2);
        GL11.glVertex3d(0.2, height, 0.2);
        GL11.glVertex3d(-0.2, height, 0.2);

        // West Face
        GL11.glVertex3d(-0.2, 0.275, -0.2);
        GL11.glVertex3d(-0.2, 0.275, 0.2);
        GL11.glVertex3d(-0.2, height, 0.2);
        GL11.glVertex3d(-0.2, height, -0.2);

        // East Face
        GL11.glVertex3d(0.2, 0.275, -0.2);
        GL11.glVertex3d(0.2, 0.275, 0.2);
        GL11.glVertex3d(0.2, height, 0.2);
        GL11.glVertex3d(0.2, height, -0.2);

        // Top Face
        GL11.glVertex3d(-0.2, height, -0.2);
        GL11.glVertex3d(0.2, height, -0.2);
        GL11.glVertex3d(0.2, height, 0.2);
        GL11.glVertex3d(-0.2, height, 0.2);

        // Bottom Face
        GL11.glVertex3d(-0.2, 0.275, -0.2);
        GL11.glVertex3d(0.2, 0.275, -0.2);
        GL11.glVertex3d(0.2, 0.275, 0.2);
        GL11.glVertex3d(-0.2, 0.275, 0.2);

        GL11.glEnd();

        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.5F);

        GL11.glPopMatrix();
    }
}

From source file:com.mrcrayfish.furniture.render.tileentity.ChoppingBoardRenderer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileEntity, double posX, double posY, double posZ, float p_180535_8_,
        int p_180535_9_) {
    TileEntityChoppingBoard board = (TileEntityChoppingBoard) tileEntity;
    BlockChoppingBoard choppingBoard = (BlockChoppingBoard) tileEntity.getBlockType();
    int metadata = choppingBoard.getMetaFromState(tileEntity.getWorld().getBlockState(tileEntity.getPos()));

    if (board.getFood() != null) {
        entityFood.setEntityItemStack(board.getFood());

        GL11.glPushMatrix();//w w w.  j av a 2s  . c o  m
        this.entityFood.hoverStart = 0.0F;

        float xOffset = 0.0F;
        float zOffset = 0.0F;

        switch (metadata) {
        case 0:
            zOffset -= 0.1F;
            break;
        case 1:
            xOffset += 0.3F;
            zOffset += 0.2F;
            break;
        case 2:
            zOffset += 0.5F;
            break;
        case 3:
            xOffset -= 0.3F;
            zOffset += 0.2F;
            break;
        }

        GL11.glTranslatef((float) posX + 0.5F + xOffset, (float) posY + 0.02F, (float) posZ + 0.3F + zOffset);
        GL11.glRotatef(metadata * -90F, 0, 1, 0);
        GL11.glRotatef(180, 0, 1, 1);
        Minecraft.getMinecraft().getRenderManager().renderEntityWithPosYaw(entityFood, 0.0D, 0.0D, 0.075D, 0.0F,
                0.0F);
        GL11.glPopMatrix();
    }
}

From source file:com.mrcrayfish.furniture.render.tileentity.CookieRenderer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileEntity, double posX, double posY, double posZ, float p_180535_8_,
        int p_180535_9_) {
    GL11.glPushMatrix();// ww w.j a  v  a 2s .c  om
    this.entityItem.hoverStart = 0.0F;
    GL11.glTranslatef((float) posX + 0.5F, (float) posY + 0.05F, (float) posZ + 0.18F);
    GL11.glRotatef(180, 0, 1, 1);
    GL11.glScalef(0.9F, 0.9F, 0.9F);
    Block block = tileEntity.getBlockType();
    int metadata = block.getMetaFromState(tileEntity.getWorld().getBlockState(tileEntity.getPos()));
    for (int i = 0; i < metadata; i++) {
        Minecraft.getMinecraft().getRenderManager().renderEntityWithPosYaw(entityItem, 0.0D, 0.0D, 0.1D * i,
                0.0F, 0.0F);
    }
    GL11.glPopMatrix();
}

From source file:com.mrcrayfish.furniture.render.tileentity.CupRenderer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileEntity, double posX, double posY, double posZ, float p_180535_8_,
        int p_180535_9_) {
    TileEntityCup tileEntityCup = (TileEntityCup) tileEntity;
    if (tileEntityCup.getDrink() != null) {
        Tessellator tessellator = Tessellator.getInstance();
        GL11.glPushMatrix();/*from www . j  av a2  s  .  c  om*/
        GL11.glTranslatef((float) posX + 0.5F, (float) posY, (float) posZ + 0.5F);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glEnable(GL11.GL_BLEND);

        GL11.glColor4f(tileEntityCup.red / 255F, tileEntityCup.green / 255F, tileEntityCup.blue / 255F, 1.0F);

        GL11.glBegin(GL11.GL_QUADS);

        // North Face
        GL11.glVertex3d(-0.125, 0.5 * 0.0625, -0.125);
        GL11.glVertex3d(0.125, 0.5 * 0.0625, -0.125);
        GL11.glVertex3d(0.125, 0.4, -0.125);
        GL11.glVertex3d(-0.125, 0.4, -0.125);

        // South Face
        GL11.glVertex3d(-0.125, 0.5 * 0.0625, 0.125);
        GL11.glVertex3d(0.125, 0.5 * 0.0625, 0.125);
        GL11.glVertex3d(0.125, 0.4, 0.125);
        GL11.glVertex3d(-0.125, 0.4, 0.125);

        // West Face
        GL11.glVertex3d(-0.125, 0.5 * 0.0625, -0.125);
        GL11.glVertex3d(-0.125, 0.5 * 0.0625, 0.125);
        GL11.glVertex3d(-0.125, 0.4, 0.125);
        GL11.glVertex3d(-0.125, 0.4, -0.125);

        // East Face
        GL11.glVertex3d(0.125, 0.5 * 0.0625, -0.125);
        GL11.glVertex3d(0.125, 0.5 * 0.0625, 0.125);
        GL11.glVertex3d(0.125, 0.4, 0.125);
        GL11.glVertex3d(0.125, 0.4, -0.125);

        // Top Face
        GL11.glVertex3d(-0.125, 0.4, -0.125);
        GL11.glVertex3d(0.125, 0.4, -0.125);
        GL11.glVertex3d(0.125, 0.4, 0.125);
        GL11.glVertex3d(-0.125, 0.4, 0.125);

        // Bottom Face
        GL11.glVertex3d(-0.125, 0.5 * 0.0625, -0.125);
        GL11.glVertex3d(0.125, 0.5 * 0.0625, -0.125);
        GL11.glVertex3d(0.125, 0.5 * 0.0625, 0.125);
        GL11.glVertex3d(-0.125, 0.5 * 0.0625, 0.125);

        GL11.glEnd();

        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.5F);

        GL11.glPopMatrix();
    }
}

From source file:com.mrcrayfish.furniture.render.tileentity.MicrowaveRenderer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileEntity, double posX, double posY, double posZ, float p_180535_8_,
        int p_180535_9_) {
    TileEntityMicrowave microwave = (TileEntityMicrowave) tileEntity;
    Block block = tileEntity.getBlockType();
    int metadata = block.getMetaFromState(tileEntity.getWorld().getBlockState(tileEntity.getPos()));
    if (microwave.getItem() != null) {
        entityFood.setEntityItemStack(microwave.getItem());

        GL11.glPushMatrix();/*  www.  j  a v a2  s.  co  m*/
        this.entityFood.hoverStart = 0.0F;

        float xOffset = 0.0F;
        float zOffset = 0.0F;

        switch (metadata) {
        case 0:
            xOffset += 0.1F;
            break;
        case 1:
            xOffset += 0.2F;
            zOffset += 0.3F;
            break;
        case 2:
            xOffset -= 0.1F;
            zOffset += 0.4F;
            break;
        case 3:
            xOffset -= 0.2F;
            zOffset += 0.1F;
            break;
        }

        GL11.glTranslatef((float) posX + 0.5F + xOffset, (float) posY + 0.075F, (float) posZ + 0.3F + zOffset);
        GL11.glRotatef(metadata * -90F, 0, 1, 0);
        GL11.glRotatef(180, 0, 1, 1);
        Minecraft.getMinecraft().getRenderManager().renderEntityWithPosYaw(entityFood, 0.0D, 0.0D, 0.075D, 0.0F,
                0.0F);
        GL11.glPopMatrix();
    }
}

From source file:com.mrcrayfish.furniture.render.tileentity.PlateRenderer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileEntity, double posX, double posY, double posZ, float p_180535_8_,
        int p_180535_9_) {
    TileEntityPlate plate = (TileEntityPlate) tileEntity;
    if (plate.getFood() != null) {
        entityFood.setEntityItemStack(plate.getFood());

        GL11.glPushMatrix();/*from  w w  w.j a v  a2 s  .  c om*/
        this.entityFood.hoverStart = 0.0F;

        float xOffset = 0.0F;
        float zOffset = 0.0F;

        switch (plate.getRotation()) {
        case 0:
            zOffset -= 0.1F;
            break;
        case 1:
            xOffset += 0.3F;
            zOffset += 0.2F;
            break;
        case 2:
            zOffset += 0.5F;
            break;
        case 3:
            xOffset -= 0.3F;
            zOffset += 0.2F;
            break;
        }

        GL11.glTranslatef((float) posX + 0.5F + xOffset, (float) posY + 0.05F, (float) posZ + 0.3F + zOffset);
        GL11.glRotatef(plate.getRotation() * -90F, 0, 1, 0);
        GL11.glRotatef(180, 0, 1, 1);
        Minecraft.getMinecraft().getRenderManager().renderEntityWithPosYaw(entityFood, 0.0D, 0.0D, 0.075D, 0.0F,
                0.0F);
        GL11.glPopMatrix();
    }
}

From source file:com.mrcrayfish.furniture.render.tileentity.ToastRenderer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileEntity, double posX, double posY, double posZ, float p_180535_8_,
        int p_180535_9_) {
    TileEntityToaster tileEntityToaster = (TileEntityToaster) tileEntity;
    Block block = tileEntity.getBlockType();
    int metadata = block.getMetaFromState(tileEntity.getWorld().getBlockState(tileEntity.getPos()));

    for (int i = 0; i < 2; i++) {
        ItemStack slice = tileEntityToaster.getSlice(i);
        if (slice != null) {
            this.slots[i].setEntityItemStack(slice);
            GL11.glPushMatrix();//from   www .ja v a2  s.c o  m
            slots[i].hoverStart = 0.0F;
            GL11.glTranslatef((float) posX + 0.5F, (float) posY + 0.05F, (float) posZ + 0.3F);

            double xOffset = 0.0D;
            double zOffset = 0.0D;

            switch (metadata) {
            case 0:
                if (i == 1) {
                    zOffset += 0.27F;
                } else {
                    zOffset += 0.14F;
                }
                break;
            case 1:
                xOffset += 0.2F;
                if (i == 1) {
                    zOffset += 0.07F;
                } else {
                    zOffset -= 0.06F;
                }
                GL11.glRotatef(270, 0, 1, 0);
                break;
            case 2:
                if (i == 1) {
                    zOffset -= 0.13F;
                } else {
                    zOffset -= 0.26F;
                }
                GL11.glRotatef(180, 0, 1, 0);
                break;
            case 3:
                xOffset -= 0.2F;
                if (i == 1) {
                    zOffset += 0.07F;
                } else {
                    zOffset -= 0.06F;
                }
                GL11.glRotatef(90, 0, 1, 0);
                break;
            }

            double yOffset = tileEntityToaster.isToasting() ? -0.075 : 0.0;
            Minecraft.getMinecraft().getRenderManager().renderEntityWithPosYaw(slots[i], 0.0D + xOffset,
                    0.1D + yOffset, 0.0D + zOffset, 0.0F, 0.0F);
            GL11.glPopMatrix();
        }
    }
}

From source file:com.mrcrayfish.furniture.render.tileentity.WashingMachineRenderer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileEntity, double posX, double posY, double posZ, float p_180535_8_,
        int p_180535_9_) {
    TileEntityWashingMachine tileEntityWashingMachine = (TileEntityWashingMachine) tileEntity;
    Block block = tileEntity.getBlockType();
    int metadata = block.getMetaFromState(tileEntity.getWorld().getBlockState(tileEntity.getPos()));

    GL11.glPushMatrix();//from   ww w.  jav  a2s . c  o m
    GL11.glTranslatef((float) posX + 0.5F, (float) posY + 0.5F, (float) posZ + 0.5F);
    GL11.glRotatef(metadata * -90F, 0, 1, 0);
    this.armour.hoverStart = 0.0F;

    for (int i = 0; i < 4; i++) {
        if (tileEntityWashingMachine.getStackInSlot(i) != null) {
            double zOffset = getOffsetZ(metadata, i);
            armour.setEntityItemStack(tileEntityWashingMachine.getStackInSlot(i));
            GL11.glRotated(tileEntityWashingMachine.progress * 5, 0, 0, 1);
            Minecraft.getMinecraft().getRenderManager().renderEntityWithPosYaw(armour, 0.0, -0.35D, zOffset,
                    0.0F, 0.0F);
        }
    }

    GL11.glPopMatrix();
}

From source file:com.mtbs3d.minecrift.VRRenderer.java

License:LGPL

/**
 * sets up projection, view effects, camera position/rotation
 */// www  .j  a  v  a 2  s . co m
private void setupCameraTransform(float renderPartialTicks, int renderSceneNumber) {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();

    if (renderSceneNumber == 0) {
        // Left eye
        FloatBuffer leftProj = eyeRenderParams.gl_getLeftProjectionMatrix();
        GL11.glLoadMatrix(leftProj);
        //mc.checkGLError("Set left projection");
    } else {
        // Right eye
        FloatBuffer rightProj = eyeRenderParams.gl_getRightProjectionMatrix();
        GL11.glLoadMatrix(rightProj);
        //mc.checkGLError("Set right projection");
    }
    float var5;

    if (this.mc.playerController != null && this.mc.playerController.enableEverythingIsScrewedUpMode()) {
        var5 = 0.6666667F;
        GL11.glScalef(1.0F, var5, 1.0F);
    }

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    //First, IPD transformation
    if (renderSceneNumber == 0) {
        // Left eye
        FloatBuffer leftEyeTransform = eyeRenderParams.gl_getLeftViewportTransform();
        GL11.glMultMatrix(leftEyeTransform);
    } else {
        // Right eye
        FloatBuffer rightEyeTransform = eyeRenderParams.gl_getRightViewportTransform();
        GL11.glMultMatrix(rightEyeTransform);
    }

    // Camera height offset
    float cameraYOffset = 1.62f
            - (this.mc.vrSettings.getPlayerEyeHeight() - this.mc.vrSettings.neckBaseToEyeHeight);

    EntityLivingBase entity = this.mc.renderViewEntity;
    if (entity != null) {
        //Do in-game camera adjustments if renderViewEntity exists
        //A few game effects
        this.hurtCameraEffect(renderPartialTicks);

        if (this.mc.gameSettings.viewBobbing) {
            this.setupViewBobbing(renderPartialTicks);
        }

        var5 = this.mc.thePlayer.prevTimeInPortal
                + (this.mc.thePlayer.timeInPortal - this.mc.thePlayer.prevTimeInPortal) * renderPartialTicks;

        if (var5 > 0.0F) {
            byte var6 = 20;

            if (this.mc.thePlayer.isPotionActive(Potion.confusion)) {
                var6 = 7;
            }

            float var7 = 5.0F / (var5 * var5 + 5.0F) - var5 * 0.04F;
            var7 *= var7;
            GL11.glRotatef(((float) this.rendererUpdateCount + renderPartialTicks) * (float) var6, 0.0F, 1.0F,
                    1.0F);
            GL11.glScalef(1.0F / var7, 1.0F, 1.0F);
            GL11.glRotatef(-((float) this.rendererUpdateCount + renderPartialTicks) * (float) var6, 0.0F, 1.0F,
                    1.0F);
        }

        if (this.mc.gameSettings.thirdPersonView > 0) {
            float thirdPersonCameraDist = this.thirdPersonDistanceTemp
                    + (this.thirdPersonDistance - this.thirdPersonDistanceTemp) * renderPartialTicks;
            float thirdPersonYaw;
            float thirdPersonPitch;

            if (this.mc.gameSettings.debugCamEnable) {
                thirdPersonYaw = this.prevDebugCamYaw
                        + (this.debugCamYaw - this.prevDebugCamYaw) * renderPartialTicks;
                thirdPersonPitch = this.prevDebugCamPitch
                        + (this.debugCamPitch - this.prevDebugCamPitch) * renderPartialTicks;
                GL11.glTranslatef(0.0F, 0.0F, (float) (-thirdPersonCameraDist));
                GL11.glRotatef(thirdPersonYaw, 1.0F, 0.0F, 0.0F);
                GL11.glRotatef(thirdPersonPitch, 0.0F, 1.0F, 0.0F);
            } else {
                thirdPersonYaw = cameraYaw;
                thirdPersonPitch = cameraPitch;

                if (this.mc.gameSettings.thirdPersonView == 2) {
                    thirdPersonPitch += 180.0F;
                }

                float PIOVER180 = (float) (Math.PI / 180);

                //For doing camera collision detection
                double camX = renderOriginX + camRelX;
                double camY = renderOriginY + camRelY - cameraYOffset;
                double camZ = renderOriginZ + camRelZ;

                float camXOffset = -MathHelper.sin(thirdPersonYaw * PIOVER180)
                        * MathHelper.cos(thirdPersonPitch * PIOVER180) * thirdPersonCameraDist;
                float camZOffset = MathHelper.cos(thirdPersonYaw * PIOVER180)
                        * MathHelper.cos(thirdPersonPitch * PIOVER180) * thirdPersonCameraDist;
                float camYOffset = -MathHelper.sin(thirdPersonPitch * PIOVER180) * thirdPersonCameraDist;

                thirdPersonCameraDist = checkCameraCollision(camX, camY, camZ, camXOffset, camYOffset,
                        camZOffset, thirdPersonCameraDist);

                if (this.mc.gameSettings.thirdPersonView == 2) {
                    GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
                }

                GL11.glRotatef(cameraPitch - thirdPersonPitch, 1.0F, 0.0F, 0.0F);
                GL11.glRotatef(cameraYaw - thirdPersonYaw, 0.0F, 1.0F, 0.0F);
                GL11.glTranslatef(0.0F, 0.0F, (float) (-thirdPersonCameraDist));
                GL11.glRotatef(thirdPersonYaw - cameraYaw, 0.0F, 1.0F, 0.0F);
                GL11.glRotatef(thirdPersonPitch - cameraPitch, 1.0F, 0.0F, 0.0F);
            }
        }
    }

    if (!this.mc.gameSettings.debugCamEnable) {
        //           if (this.mc.vrSettings.useQuaternions)
        //            {
        //                //GL11.glMultMatrix(cameraMatrix4f);   // This doesn't work currently - we still need
        //                                                     // the weird +180...
        //
        //                // So do this instead...
        //                float[] rawYawPitchRoll = OculusRift.getEulerAngles(orientation.x,
        //                        orientation.y,
        //                        orientation.z,
        //                        orientation.w,
        //                        1f,
        //                        OculusRift.HANDED_L,
        //                        OculusRift.ROTATE_CCW);
        //
        //                if (this.mc.gameSettings.thirdPersonView == 2)
        //                    GL11.glRotatef(-rawYawPitchRoll[2], 0.0F, 0.0F, 1.0F);
        //                else
        //                    GL11.glRotatef(rawYawPitchRoll[2], 0.0F, 0.0F, 1.0F);
        //
        //                GL11.glRotatef(rawYawPitchRoll[1], 1.0F, 0.0F, 0.0F);
        //                GL11.glRotatef(rawYawPitchRoll[0] + 180.0F, 0.0F, 1.0F, 0.0F);
        //            }
        //            else
        //            {
        if (this.mc.gameSettings.thirdPersonView == 2)
            GL11.glRotatef(-this.cameraRoll, 0.0F, 0.0F, 1.0F);
        else
            GL11.glRotatef(this.cameraRoll, 0.0F, 0.0F, 1.0F);

        GL11.glRotatef(this.cameraPitch, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(this.cameraYaw + 180.0F, 0.0F, 1.0F, 0.0F);
        //            }
    }

    GL11.glTranslated(-camRelX, cameraYOffset - camRelY, -camRelZ);

    if (this.debugViewDirection > 0) {
        int var8 = this.debugViewDirection - 1;

        if (var8 == 1) {
            GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
        }

        if (var8 == 2) {
            GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
        }

        if (var8 == 3) {
            GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
        }

        if (var8 == 4) {
            GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
        }

        if (var8 == 5) {
            GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
        }
    }
}

From source file:com.mtbs3d.minecrift.VRRenderer.java

License:LGPL

public void renderGUIandWorld(float renderPartialTicks) {
    this.farPlaneDistance = (float) this.mc.gameSettings.ofRenderDistanceFine;

    if (Config.isFogFancy()) {
        this.farPlaneDistance *= 0.95F;
    }/*ww  w.  j av  a  2s .  c om*/

    if (Config.isFogFast()) {
        this.farPlaneDistance *= 0.83F;
    }

    if (this.prevFarPlaneDistance != this.farPlaneDistance) {
        _FBOInitialised = false;
        this.prevFarPlaneDistance = this.farPlaneDistance;
    }

    //Ensure FBO are in place and initialized
    if (!setupFBOs())
        return;

    boolean guiShowingThisFrame = false;
    int mouseX = 0;
    int mouseY = 0;
    ScaledResolution var15 = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth,
            this.mc.displayHeight);
    int var16 = var15.getScaledWidth();
    int var17 = var15.getScaledHeight();

    if ((this.mc.theWorld != null && !this.mc.gameSettings.hideGUI && this.mc.thePlayer.getSleepTimer() == 0)
            || this.mc.currentScreen != null || this.mc.loadingScreen.isEnabled()) {
        //Render all UI elements into guiFBO
        mouseX = Mouse.getX() * var16 / this.mc.displayWidth;
        mouseY = var17 - Mouse.getY() * var17 / this.mc.displayHeight - 1;

        guiFBO.bindRenderTarget();

        GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
        GL11.glClearColor(0, 0, 0, 0);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glLoadIdentity();
        GL11.glOrtho(0.0D, var15.getScaledWidth_double(), var15.getScaledHeight_double(), 0.0D, 1000.0D,
                3000.0D);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glLoadIdentity();
        GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
        guiShowingThisFrame = true;
    }

    // Display loading / progress window if necessary
    if (this.mc.loadingScreen.isEnabled()) {
        this.mc.loadingScreen.vrRender(var16, var17);
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    } else if (this.mc.theWorld != null && !this.mc.gameSettings.hideGUI && !this.blankGUIUntilWorldValid) {
        //Disable any forge gui crosshairs and helmet overlay (pumkinblur)
        if (Reflector.ForgeGuiIngame_renderCrosshairs.exists()) {
            Reflector.ForgeGuiIngame_renderCrosshairs.setValue(false);
            Reflector.ForgeGuiIngame_renderHelmet.setValue(false);
        }
        //Draw in game GUI
        this.mc.ingameGUI.renderGameOverlay(renderPartialTicks, this.mc.currentScreen != null, mouseX, mouseY);
        guiAchievement.updateAchievementWindow();
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    }

    if (this.blankGUIUntilWorldValid) {
        if (this.mc.theWorld != null)
            this.blankGUIUntilWorldValid = false;
    }

    if (this.mc.loadingScreen.isEnabled() == false && this.mc.currentScreen != null
            && !this.blankGUIUntilWorldValid) {
        try {
            this.mc.currentScreen.drawScreen(mouseX, mouseY, renderPartialTicks);
        } catch (Throwable var13) {
            CrashReport var11 = CrashReport.makeCrashReport(var13, "Rendering screen");
            throw new ReportedException(var11);
        }

        GL11.glDisable(GL11.GL_LIGHTING); //inventory messes up fog color sometimes... This fixes
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        drawMouseQuad(mouseX, mouseY);
    }

    //Setup render target
    if (mc.vrSettings.useDistortion) {
        preDistortionFBO.bindRenderTarget();
    } else if (this.mc.vrSettings.useSupersample) {
        postDistortionFBO.bindRenderTarget();
        eyeRenderParams._renderScale = 1.0f;
    } else {
        unbindFBORenderTarget();
        eyeRenderParams._renderScale = 1.0f;
    }

    GL11.glClearColor(0, 0, 0, 1);
    GL11.glEnable(GL11.GL_SCISSOR_TEST);

    if (this.mc.theWorld != null) {
        //If we're in-game, render in-game stuff
        this.mc.mcProfiler.startSection("level");

        if (this.mc.renderViewEntity == null) {
            this.mc.renderViewEntity = this.mc.thePlayer;
        }

        EntityLivingBase renderViewEntity = this.mc.renderViewEntity;
        this.mc.mcProfiler.endStartSection("center");

        //Used by fog comparison, 3rd person camera/block collision detection
        renderOriginX = renderViewEntity.lastTickPosX
                + (renderViewEntity.posX - renderViewEntity.lastTickPosX) * (double) renderPartialTicks;
        renderOriginY = renderViewEntity.lastTickPosY
                + (renderViewEntity.posY - renderViewEntity.lastTickPosY) * (double) renderPartialTicks;
        renderOriginZ = renderViewEntity.lastTickPosZ
                + (renderViewEntity.posZ - renderViewEntity.lastTickPosZ) * (double) renderPartialTicks;

        if (this.mc.currentScreen == null) {
            this.mc.mcProfiler.endStartSection("pick");
            getPointedBlock(renderPartialTicks);
        }

        // Update sound engine
        setSoundListenerOrientation();

    }

    //Update gui Yaw
    if (guiShowingThisFrame && !guiShowingLastFrame) {
        guiHeadYaw = this.cameraYaw - this.mc.lookaimController.getBodyYawDegrees();
    }
    guiShowingLastFrame = guiShowingThisFrame;

    //Now, actually render world
    for (int renderSceneNumber = 0; renderSceneNumber < 2; ++renderSceneNumber) {
        setupEyeViewport(renderSceneNumber);

        this.mc.mcProfiler.endStartSection("camera");
        //transform camera with pitch,yaw,roll + neck model + game effects 
        setupCameraTransform(renderPartialTicks, renderSceneNumber);

        if (this.mc.theWorld != null) {
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glPushMatrix();

            this.renderWorld(renderPartialTicks, 0L, renderSceneNumber);
            this.disableLightmap(renderPartialTicks);

            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glPopMatrix();
        } else {
            GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer on the framebuffer to black
            GL11.glDisable(GL11.GL_BLEND);
        }

        if (guiShowingThisFrame) {
            GL11.glPushMatrix();
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            guiFBO.bindTexture();

            // Prevent black border at top / bottom of GUI
            GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
            GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);

            if (this.mc.theWorld != null && this.mc.vrSettings.hudLockToHead) {
                GL11.glLoadIdentity();

                if (renderSceneNumber == 0)
                    GL11.glMultMatrix(eyeRenderParams.gl_getLeftViewportTransform());
                else
                    GL11.glMultMatrix(eyeRenderParams.gl_getRightViewportTransform());

                GL11.glRotatef(180f - this.mc.vrSettings.hudYawOffset, 0f, 1f, 0f);
                GL11.glRotatef(-this.mc.vrSettings.hudPitchOffset, 1f, 0f, 0f);
                //                    GL11.glRotatef(cameraRoll, 0f, 0f, 1f);

                GL11.glTranslatef(0.0f, 0.0f,
                        this.mc.vrSettings.hudDistance - this.mc.vrSettings.eyeProtrusion);
                GL11.glRotatef(180f, 0f, 1f, 0f);//Not sure why this is necessary... normals/backface culling maybe?
            } else {
                float guiYaw = 0f;
                if (this.mc.theWorld != null) {
                    if (this.mc.vrSettings.lookMoveDecoupled)
                        guiYaw = this.mc.lookaimController.getBodyYawDegrees();
                    else
                        guiYaw = guiHeadYaw + this.mc.lookaimController.getBodyYawDegrees();

                    guiYaw -= this.mc.vrSettings.hudYawOffset;
                } else
                    guiYaw = guiHeadYaw + this.mc.lookaimController.getBodyYawDegrees();
                GL11.glRotatef(-guiYaw, 0f, 1f, 0f);

                float guiPitch = 0f;

                if (this.mc.theWorld != null)
                    guiPitch = -this.mc.vrSettings.hudPitchOffset;

                //                    if( this.mc.vrSettings.allowMousePitchInput)
                //                        guiPitch += this.mc.lookaimController.getBodyPitchDegrees();

                GL11.glRotatef(guiPitch, 1f, 0f, 0f);

                GL11.glTranslatef(0.0f, 0.0f, this.mc.vrSettings.hudDistance);
                GL11.glRotatef(180f, 0f, 1f, 0f);//Not sure why this is necessary... normals/backface culling maybe?
            }

            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            if (this.mc.theWorld != null)
                GL11.glColor4f(1, 1, 1, this.mc.vrSettings.hudOpacity);
            else
                GL11.glColor4f(1, 1, 1, 1);
            if (!this.mc.vrSettings.hudOcclusion)
                GL11.glDisable(GL11.GL_DEPTH_TEST);

            drawQuad2(this.mc.displayWidth, this.mc.displayHeight,
                    this.mc.vrSettings.hudScale * this.mc.vrSettings.hudDistance);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glEnable(GL11.GL_DEPTH_TEST);

            GL11.glPopMatrix();

            unbindTexture();
            //mc.checkGLError("GUI");
        }

        if (calibrationHelper != null) {
            float x = lookX * mc.vrSettings.hudDistance;
            float y = lookY * mc.vrSettings.hudDistance;
            float z = lookZ * mc.vrSettings.hudDistance;

            GL11.glDisable(GL11.GL_DEPTH_TEST);
            GL11.glPushMatrix();
            GL11.glTranslatef(x, y, z);
            GL11.glRotatef(-this.cameraYaw, 0.0F, 1.0F, 0.0F);
            GL11.glRotatef(this.cameraPitch, 1.0F, 0.0F, 0.0F);
            GL11.glRotatef(this.cameraRoll, 0.0F, 0.0F, 1.0F);
            float textScale = (float) Math.sqrt((x * x + y * y + z * z));
            GL11.glScalef(-INITIAL_CALIBRATION_TEXT_SCALE * textScale,
                    -INITIAL_CALIBRATION_TEXT_SCALE * textScale, -INITIAL_CALIBRATION_TEXT_SCALE * textScale);
            String calibrating = "Calibrating " + calibrationHelper.currentPlugin.getName() + "...";
            mc.fontRenderer.drawStringWithShadow(calibrating, -mc.fontRenderer.getStringWidth(calibrating) / 2,
                    -8, /*white*/16777215);
            String calibrationStep = calibrationHelper.calibrationStep;
            //                mc.fontRenderer.drawStringWithShadow(calibrationStep, -mc.fontRenderer.getStringWidth(calibrationStep)/2, 8, /*white*/16777215);

            int column = 8;
            ArrayList<String> wrapped = new ArrayList<String>();
            Utils.wordWrap(calibrationStep, CALIBRATION_TEXT_WORDWRAP_LEN, wrapped);
            for (String line : wrapped) {
                mc.fontRenderer.drawStringWithShadow(line, -mc.fontRenderer.getStringWidth(line) / 2, column,
                        /*white*/16777215);
                column += 16;
            }

            GL11.glPopMatrix();
            GL11.glEnable(GL11.GL_DEPTH_TEST);
        }
    }
    GL11.glDisable(GL11.GL_SCISSOR_TEST);

    doDistortionAndSuperSample();
    checkLatencyTester();

    // Finish frame
    GL11.glFinish();

    // Get end frame timings
    endFrameTimeNanos = startVSyncPeriodNanos = System.nanoTime();
    long frameTime = endFrameTimeNanos - startFrameRenderNanos;
    addRenderFrameTimeNanos(frameTime);

    mc.checkGLError("After render world and GUI");
}