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:com.pahimar.ee3.core.handlers.DrawBlockHighlightHandler.java

License:LGPL

public void drawInWorldTransmutationOverlay(DrawBlockHighlightEvent event) {

    double x = event.target.blockX + 0.5F;
    double y = event.target.blockY + 0.5F;
    double z = event.target.blockZ + 0.5F;
    double iPX = event.player.prevPosX + (event.player.posX - event.player.prevPosX) * event.partialTicks;
    double iPY = event.player.prevPosY + (event.player.posY - event.player.prevPosY) * event.partialTicks;
    double iPZ = event.player.prevPosZ + (event.player.posZ - event.player.prevPosZ) * event.partialTicks;
    int texture = event.context.renderEngine.getTexture(Textures.EFFECT_WORLD_TRANSMUTATION);

    float xScale = 1;
    float yScale = 1;
    float zScale = 1;
    float xShift = 0.1F;
    float yShift = 0.1F;
    float zShift = 0.1F;
    int chargeLevel;
    int itemChargeLevel = 0;

    if (event.currentItem.getItem() instanceof IChargeable) {
        itemChargeLevel = ((IChargeable) event.currentItem.getItem()).getCharge(event.currentItem);
    }/*from  w w  w  .  java 2s  . c om*/
    chargeLevel = 1 + itemChargeLevel * 2;

    ForgeDirection sideHit = ForgeDirection.getOrientation(event.target.sideHit);

    switch (sideHit) {
    case UP: {
        xScale = chargeLevel + 0.1F;
        zScale = chargeLevel + 0.1F;
        xShift = 0;
        zShift = 0;
        break;
    }
    case DOWN: {
        xScale = chargeLevel + 0.1F;
        zScale = chargeLevel + 0.1F;
        xShift = 0;
        yShift = -yShift;
        zShift = 0;
        break;
    }
    case NORTH: {
        xScale = chargeLevel + 0.1F;
        yScale = chargeLevel + 0.1F;
        xShift = 0;
        yShift = 0;
        zShift = -zShift;
        break;
    }
    case SOUTH: {
        xScale = chargeLevel + 0.1F;
        yScale = chargeLevel + 0.1F;
        xShift = 0;
        yShift = 0;
        break;
    }
    case EAST: {
        yScale = chargeLevel + 0.1F;
        zScale = chargeLevel + 0.1F;
        yShift = 0;
        zShift = 0;
        break;
    }
    case WEST: {
        yScale = chargeLevel + 0.1F;
        zScale = chargeLevel + 0.1F;
        xShift = -xShift;
        yShift = 0;
        zShift = 0;
        break;
    }
    default:
        break;
    }

    GL11.glDepthMask(false);
    GL11.glDisable(GL11.GL_CULL_FACE);

    for (int i = 0; i < 6; i++) {
        ForgeDirection forgeDir = ForgeDirection.getOrientation(i);
        int zCorrection = i == 2 ? -1 : 1;
        GL11.glPushMatrix();
        GL11.glTranslated(-iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift);
        GL11.glScalef(1F * xScale, 1F * yScale, 1F * zScale);
        GL11.glRotatef(90, forgeDir.offsetX, forgeDir.offsetY, forgeDir.offsetZ);
        GL11.glTranslated(0, 0, 0.5f * zCorrection);
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
        renderPulsingQuad(texture, 0.75F);
        GL11.glPopMatrix();
    }

    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glDepthMask(true);
}

From source file:com.professorvennie.machinerycraft.client.renderer.item.ItemRenderPlasticChest.java

License:Creative Commons License

private void renderChest(float x, float y, float z, int metaData) {
    FMLClientHandler.instance().getClient().renderEngine
            .bindTexture(new ResourceLocation(Reference.MOD_ID, "textures/model/plastic_chest.png"));

    GL11.glPushMatrix(); //start
    GL11.glTranslatef(x, y, z); //size
    GL11.glRotatef(180, 1, 0, 0);
    GL11.glRotatef(-90, 0, 1, 0);/*www. ja  v a  2  s.c om*/
    modelChest.renderAll();
    GL11.glPopMatrix(); //end
}

From source file:com.professorvennie.machinerycraft.client.renderer.tileentity.TileEntityRendererCable.java

License:Creative Commons License

public void drawStriaght(ForgeDirection direction) {
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();//  w w w  .j a  v a 2 s.c  o  m
    {
        GL11.glTranslated(0.5F, 0.5F, 0.5F);
        if (direction.equals(ForgeDirection.SOUTH) || direction.equals(ForgeDirection.NORTH)) {
            GL11.glRotatef(90, 1, 0, 0);
        } else if (direction.equals(ForgeDirection.WEST) || direction.equals(ForgeDirection.EAST)) {
            GL11.glRotatef(90, 0, 0, 1);
        }
        GL11.glTranslated(-0.5F, -0.5F, -0.5F);

        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 0, 1 - 11 * pixel / 2, 10 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 1 - 11 * pixel / 2, 26 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1, 1 - 11 * pixel / 2, 26 * texturePixel, 0 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 0, 1 - 11 * pixel / 2, 10 * texturePixel, 0 * texturePixel);

        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 1 - 11 * pixel / 2, 10 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2,
                26 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 26 * texturePixel,
                0 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1, 1 - 11 * pixel / 2, 10 * texturePixel, 0 * texturePixel);

        tessellator.addVertexWithUV(11 * pixel / 2, 0, 11 * pixel / 2, 10 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1, 11 * pixel / 2, 26 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 11 * pixel / 2, 26 * texturePixel, 0 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 0, 11 * pixel / 2, 10 * texturePixel, 0 * texturePixel);

        tessellator.addVertexWithUV(11 * pixel / 2, 1, 11 * pixel / 2, 10 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 0, 11 * pixel / 2, 26 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 0, 11 * pixel / 2, 26 * texturePixel, 0 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 11 * pixel / 2, 10 * texturePixel, 0 * texturePixel);

        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 0, 11 * pixel / 2, 10 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 11 * pixel / 2, 26 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 1 - 11 * pixel / 2, 26 * texturePixel,
                0 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 0, 1 - 11 * pixel / 2, 10 * texturePixel,
                0 * texturePixel);

        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 11 * pixel / 2, 10 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 0, 11 * pixel / 2, 26 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 0, 1 - 11 * pixel / 2, 26 * texturePixel,
                0 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 1 - 11 * pixel / 2, 10 * texturePixel,
                0 * texturePixel);

        tessellator.addVertexWithUV(11 * pixel / 2, 0, 1 - 11 * pixel / 2, 10 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1, 1 - 11 * pixel / 2, 26 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1, 11 * pixel / 2, 26 * texturePixel, 0 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 0, 11 * pixel / 2, 10 * texturePixel, 0 * texturePixel);

        tessellator.addVertexWithUV(11 * pixel / 2, 1, 1 - 11 * pixel / 2, 10 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 0, 1 - 11 * pixel / 2, 26 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 0, 11 * pixel / 2, 26 * texturePixel, 0 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1, 11 * pixel / 2, 10 * texturePixel, 0 * texturePixel);
    }
    tessellator.draw();

    GL11.glTranslated(0.5F, 0.5F, 0.5F);
    if (direction.equals(ForgeDirection.SOUTH) || direction.equals(ForgeDirection.NORTH)) {
        GL11.glRotatef(-90, 1, 0, 0);
    } else if (direction.equals(ForgeDirection.WEST) || direction.equals(ForgeDirection.EAST)) {
        GL11.glRotatef(-90, 0, 0, 1);
    }
    GL11.glTranslated(-0.5F, -0.5F, -0.5F);
}

From source file:com.professorvennie.machinerycraft.client.renderer.tileentity.TileEntityRendererCable.java

License:Creative Commons License

public void drawConnector(ForgeDirection direction) {

    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();/*  w w  w  .  ja  v  a 2 s  . c o  m*/
    {
        GL11.glTranslated(0.5F, 0.5F, 0.5F);
        if (direction.equals(ForgeDirection.UP)) {
            //rotate
        } else if (direction.equals(ForgeDirection.DOWN)) {
            GL11.glRotatef(180, 1, 0, 0);
        } else if (direction.equals(ForgeDirection.SOUTH)) {
            GL11.glRotatef(90, 1, 0, 0);
        } else if (direction.equals(ForgeDirection.NORTH)) {
            GL11.glRotatef(270, 1, 0, 0);
        } else if (direction.equals(ForgeDirection.WEST)) {
            GL11.glRotatef(90, 0, 0, 1);
        } else if (direction.equals(ForgeDirection.EAST)) {
            GL11.glRotatef(270, 0, 0, 1);
        }
        GL11.glTranslated(-0.5F, -0.5F, -0.5F);

        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2,
                5 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 1 - 11 * pixel / 2, 10 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1, 1 - 11 * pixel / 2, 10 * texturePixel, 0 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 5 * texturePixel,
                0 * texturePixel);

        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 1 - 11 * pixel / 2, 5 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2,
                10 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 10 * texturePixel,
                0 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1, 1 - 11 * pixel / 2, 5 * texturePixel, 0 * texturePixel);

        tessellator.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 5 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1, 11 * pixel / 2, 10 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 11 * pixel / 2, 10 * texturePixel, 0 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 5 * texturePixel,
                0 * texturePixel);

        tessellator.addVertexWithUV(11 * pixel / 2, 1, 11 * pixel / 2, 5 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 10 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 10 * texturePixel,
                0 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 11 * pixel / 2, 5 * texturePixel, 0 * texturePixel);

        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 5 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 11 * pixel / 2, 10 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 1 - 11 * pixel / 2, 10 * texturePixel,
                0 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2,
                5 * texturePixel, 0 * texturePixel);

        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 11 * pixel / 2, 5 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 10 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2,
                10 * texturePixel, 0 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 1 - 11 * pixel / 2, 5 * texturePixel,
                0 * texturePixel);

        tessellator.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 10 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1, 1 - 11 * pixel / 2, 5 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1, 11 * pixel / 2, 5 * texturePixel, 0 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 10 * texturePixel,
                0 * texturePixel);

        tessellator.addVertexWithUV(11 * pixel / 2, 1, 1 - 11 * pixel / 2, 10 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 5 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 5 * texturePixel,
                0 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1, 11 * pixel / 2, 10 * texturePixel, 0 * texturePixel);
    }
    tessellator.draw();

    GL11.glTranslated(0.5F, 0.5F, 0.5F);
    if (direction.equals(ForgeDirection.UP)) {
        //rotate
    } else if (direction.equals(ForgeDirection.DOWN)) {
        GL11.glRotatef(-180, 1, 0, 0);
    } else if (direction.equals(ForgeDirection.SOUTH)) {
        GL11.glRotatef(-90, 1, 0, 0);
    } else if (direction.equals(ForgeDirection.NORTH)) {
        GL11.glRotatef(-270, 1, 0, 0);
    } else if (direction.equals(ForgeDirection.WEST)) {
        GL11.glRotatef(-90, 0, 0, 1);
    } else if (direction.equals(ForgeDirection.EAST)) {
        GL11.glRotatef(-270, 0, 0, 1);
    }
    GL11.glTranslated(-0.5F, -0.5F, -0.5F);
}

From source file:com.professorvennie.machinerycraft.client.renderer.tileentity.TileEntityRendererPlasticChest.java

License:Creative Commons License

@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) {
    if (tileEntity instanceof TileEntityPlasticChest) {
        TileEntityPlasticChest tileEntityPlasticChest = (TileEntityPlasticChest) tileEntity;
        ForgeDirection direction = null;

        if (tileEntityPlasticChest.getWorldObj() != null) {
            direction = tileEntityPlasticChest.getOrientation();
            //System.out.println(tileEntityPlasticChest.getOrientation());
        }/*w w w . ja  v  a2  s.com*/
        this.bindTexture(texture);

        GL11.glPushMatrix();
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
        GL11.glScalef(1.0F, -1.0F, -1.0F);
        GL11.glTranslatef(0.5F, 0.5F, 0.5F);
        short angle = 0;

        if (direction != null) {
            if (direction == ForgeDirection.NORTH) {
                angle = 180;
            } else if (direction == ForgeDirection.SOUTH) {
                angle = 0;
            } else if (direction == ForgeDirection.WEST) {
                angle = 90;
            } else if (direction == ForgeDirection.EAST) {
                angle = -90;
            }
        }

        GL11.glRotatef(angle, 0.0F, 1.0F, 0.0F);
        GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
        float adjustedLidAngle = tileEntityPlasticChest.prevLidAngle
                + (tileEntityPlasticChest.lidAngle - tileEntityPlasticChest.prevLidAngle) * tick;
        adjustedLidAngle = 1.0F - adjustedLidAngle;
        adjustedLidAngle = 1.0F - adjustedLidAngle * adjustedLidAngle * adjustedLidAngle;
        modelChest.chestLid.rotateAngleX = -(adjustedLidAngle * (float) Math.PI / 2.0F);
        modelChest.renderAll();
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glPopMatrix();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }
}

From source file:com.professorvennie.machinerycraft.machines.windmill.TileEntityRendererwindmill.java

License:Creative Commons License

public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
    int x1 = tileentity.xCoord;
    int y1 = tileentity.yCoord;
    int z1 = tileentity.zCoord;
    while (tileentity.getWorldObj().getBlockMetadata(x1, y1, z1) < 7
            && tileentity.getWorldObj().getBlock(x1, y1, z1).equals(ModBlocks.windmill)) {
        y1++;//from  w  w w.  j a  va2 s.com
    }

    int direction = tileentity.getWorldObj().getBlockMetadata(x1, y1, z1) - 8;
    int metadata = tileentity.getWorldObj().getBlockMetadata(tileentity.xCoord, tileentity.yCoord,
            tileentity.zCoord);

    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glTranslatef((float) x, (float) y, (float) z);

    GL11.glTranslatef(0.5F, 0, 0.5F);
    GL11.glRotatef(direction * 90, 0, 1, 0);
    GL11.glTranslatef(-0.5F, 0, -0.5F);

    if (metadata == 1) {
        TileEntity cable = tileentity.getWorldObj().getTileEntity(tileentity.xCoord - 1, tileentity.yCoord,
                tileentity.zCoord);
        if (cable instanceof TileEntityCable)
            drawConnector(ForgeDirection.EAST);

        cable = tileentity.getWorldObj().getTileEntity(tileentity.xCoord + 1, tileentity.yCoord,
                tileentity.zCoord);
        if (cable instanceof TileEntityCable)
            drawConnector(ForgeDirection.WEST);

        cable = tileentity.getWorldObj().getTileEntity(tileentity.xCoord, tileentity.yCoord,
                tileentity.zCoord + 1);
        if (cable instanceof TileEntityCable)
            drawConnector(ForgeDirection.SOUTH);

        cable = tileentity.getWorldObj().getTileEntity(tileentity.xCoord, tileentity.yCoord,
                tileentity.zCoord - 1);
        if (cable instanceof TileEntityCable)
            drawConnector(ForgeDirection.NORTH);
    }

    Tessellator tessellator = Tessellator.instance;
    this.bindTexture(texterwindmill);
    tessellator.startDrawingQuads();
    {

        if (metadata > 0 && metadata < 7) {
            tessellator.addVertexWithUV((8) / 2 * pixel, 0, 1 - (8) / 2 * pixel, 8 * (1F / textureWidth),
                    1 * (1F / textureHeight));
            tessellator.addVertexWithUV((8) / 2 * pixel, 1, 1 - (8) / 2 * pixel, 8 * (1F / textureWidth),
                    0 * (1F / textureHeight));
            tessellator.addVertexWithUV((8) / 2 * pixel, 1, (8) / 2 * pixel, 0 * (1F / textureWidth),
                    0 * (1F / textureHeight));
            tessellator.addVertexWithUV((8) / 2 * pixel, 0, (8) / 2 * pixel, 0 * (1F / textureWidth),
                    1 * (1F / textureHeight));

            tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 0, 1 - (8) / 2 * pixel, 8 * (1F / textureWidth),
                    1 * (1F / textureHeight));
            tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 1, 1 - (8) / 2 * pixel, 8 * (1F / textureWidth),
                    0 * (1F / textureHeight));
            tessellator.addVertexWithUV((8) / 2 * pixel, 1, 1 - (8) / 2 * pixel, 0 * (1F / textureWidth),
                    0 * (1F / textureHeight));
            tessellator.addVertexWithUV((8) / 2 * pixel, 0, 1 - (8) / 2 * pixel, 0 * (1F / textureWidth),
                    1 * (1F / textureHeight));

            tessellator.addVertexWithUV((8) / 2 * pixel, 0, (8) / 2 * pixel, 8 * (1F / textureWidth),
                    1 * (1F / textureHeight));
            tessellator.addVertexWithUV((8) / 2 * pixel, 1, (8) / 2 * pixel, 8 * (1F / textureWidth),
                    0 * (1F / textureHeight));
            tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 1, (8) / 2 * pixel, 0 * (1F / textureWidth),
                    0 * (1F / textureHeight));
            tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 0, (8) / 2 * pixel, 0 * (1F / textureWidth),
                    1 * (1F / textureHeight));

            tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 0, (8) / 2 * pixel, 8 * (1F / textureWidth),
                    1 * (1F / textureHeight));
            tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 1, (8) / 2 * pixel, 8 * (1F / textureWidth),
                    0 * (1F / textureHeight));
            tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 1, 1 - (8) / 2 * pixel, 0 * (1F / textureWidth),
                    0 * (1F / textureHeight));
            tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 0, 1 - (8) / 2 * pixel, 0 * (1F / textureWidth),
                    1 * (1F / textureHeight));
        }
        if (metadata > 7) {
        }
    }
    tessellator.draw();

    if (metadata > 7)
        drawRoatar(tileentity);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}

From source file:com.professorvennie.machinerycraft.machines.windmill.TileEntityRendererwindmill.java

License:Creative Commons License

private void drawRoatar(TileEntity tileentity) {
    TileEntityWindmill windmill = (TileEntityWindmill) tileentity.getWorldObj().getTileEntity(tileentity.xCoord,
            tileentity.yCoord, tileentity.zCoord);
    GL11.glTranslatef(0, 0.5F, 0.5F);//from  ww  w  . j  a va 2s  .com
    GL11.glRotatef(windmill.rotaion, 1, 0, 0);
    GL11.glTranslatef(0, -0.5F, -0.5F);

    Tessellator tessellator = Tessellator.instance;
    this.bindTexture(texterwindmill);
    tessellator.startDrawingQuads();
    {
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, 1 * pixel + 0.5F, 9 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 2.5F, 1 * pixel + 0.5F, 9 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 2.5F, -1 * pixel + 0.5F, 8 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, -1 * pixel + 0.5F, 8 * (1F / textureWidth),
                1 * (1F / textureHeight));

        tessellator.addVertexWithUV(-2 * pixel, 2.5F, 1 * pixel + 0.5F, 9 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, 1 * pixel + 0.5F, 9 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, -1 * pixel + 0.5F, 8 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 2.5F, -1 * pixel + 0.5F, 8 * (1F / textureWidth),
                0 * (1F / textureHeight));

        tessellator.addVertexWithUV(-2 * pixel, -1.5F, 1 * pixel + 0.5F, 9 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, 1 * pixel + 0.5F, 9 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, -1 * pixel + 0.5F, 8 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, -1.5F, -1 * pixel + 0.5F, 8 * (1F / textureWidth),
                1 * (1F / textureHeight));

        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, 1 * pixel + 0.5F, 9 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, -1.5F, 1 * pixel + 0.5F, 9 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, -1.5F, -1 * pixel + 0.5F, 8 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, -1 * pixel + 0.5F, 8 * (1F / textureWidth),
                0 * (1F / textureHeight));

        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, 2.5F, 9 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, 2.5F, 9 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, 0.5F + 1 * pixel, 8 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, 0.5F + 1 * pixel, 8 * (1F / textureWidth),
                1 * (1F / textureHeight));

        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, 2.5F, 9 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, 2.5F, 9 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, 0.5F + 1 * pixel, 8 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, 0.5F + 1 * pixel, 8 * (1F / textureWidth),
                0 * (1F / textureHeight));

        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, 0.5F - 1 * pixel, 9 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, 0.5F - 1 * pixel, 9 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, -1.5F, 8 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, -1.5F, 8 * (1F / textureWidth),
                1 * (1F / textureHeight));

        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, 0.5F - 1 * pixel, 9 * (1F / textureWidth),
                0 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, 0.5F - 1 * pixel, 9 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F - 1 * pixel, -1.5F, 8 * (1F / textureWidth),
                1 * (1F / textureHeight));
        tessellator.addVertexWithUV(-2 * pixel, 0.5F + 1 * pixel, -1.5F, 8 * (1F / textureWidth),
                0 * (1F / textureHeight));
    }
    tessellator.draw();
}

From source file:com.professorvennie.machinerycraft.machines.windmill.TileEntityRendererwindmill.java

License:Creative Commons License

public void drawConnector(ForgeDirection direction) {
    ResourceLocation texture = new ResourceLocation(Reference.MOD_ID, "textures/model/cable.png");

    float texturePixel = 1F / 32F;
    Tessellator tessellator = Tessellator.instance;
    this.bindTexture(texture);
    tessellator.startDrawingQuads();//  w  w  w  .j  a  va2  s . c  om
    {
        GL11.glTranslated(0.5F, 0.5F, 0.5F);
        if (direction.equals(ForgeDirection.EAST)) {
            GL11.glRotatef(-90, 1, 0, 0);
        } else if (direction.equals(ForgeDirection.SOUTH)) {
            GL11.glRotatef(-90, 0, 0, 1);
        } else if (direction.equals(ForgeDirection.NORTH)) {
            GL11.glRotatef(90, 0, 0, 1);
        } else if (direction.equals(ForgeDirection.WEST)) {
            GL11.glRotatef(90, 1, 0, 0);
        }
        GL11.glTranslated(-0.5F, -0.5F, -0.5F);

        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1 - 4 * pixel, 1 - 11 * pixel / 2, 10 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 1 - 11 * pixel / 2, 26 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1, 1 - 11 * pixel / 2, 14 * texturePixel, 0 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1 - 4 * pixel, 1 - 11 * pixel / 2, 10 * texturePixel,
                0 * texturePixel);

        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 1 - 11 * pixel / 2, 10 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2,
                14 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 14 * texturePixel,
                0 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1, 1 - 11 * pixel / 2, 10 * texturePixel, 0 * texturePixel);

        tessellator.addVertexWithUV(11 * pixel / 2, 1 - 4 * pixel, 11 * pixel / 2, 10 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1, 11 * pixel / 2, 14 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 11 * pixel / 2, 14 * texturePixel, 0 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1 - 4 * pixel, 11 * pixel / 2, 10 * texturePixel,
                0 * texturePixel);

        tessellator.addVertexWithUV(11 * pixel / 2, 1, 11 * pixel / 2, 10 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1 - 4 * pixel, 11 * pixel / 2, 14 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1 - 4 * pixel, 11 * pixel / 2, 14 * texturePixel,
                0 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 11 * pixel / 2, 10 * texturePixel, 0 * texturePixel);

        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1 - 4 * pixel, 11 * pixel / 2, 10 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 11 * pixel / 2, 14 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 1 - 11 * pixel / 2, 14 * texturePixel,
                0 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1 - 4 * pixel, 1 - 11 * pixel / 2, 10 * texturePixel,
                0 * texturePixel);

        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 11 * pixel / 2, 10 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1 - 4 * pixel, 11 * pixel / 2, 14 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1 - 4 * pixel, 1 - 11 * pixel / 2, 14 * texturePixel,
                0 * texturePixel);
        tessellator.addVertexWithUV(1 - 11 * pixel / 2, 1, 1 - 11 * pixel / 2, 10 * texturePixel,
                0 * texturePixel);

        tessellator.addVertexWithUV(11 * pixel / 2, 1 - 4 * pixel, 1 - 11 * pixel / 2, 10 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1, 1 - 11 * pixel / 2, 14 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1, 11 * pixel / 2, 14 * texturePixel, 0 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1 - 4 * pixel, 11 * pixel / 2, 10 * texturePixel,
                0 * texturePixel);

        tessellator.addVertexWithUV(11 * pixel / 2, 1, 1 - 11 * pixel / 2, 10 * texturePixel, 5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1 - 4 * pixel, 1 - 11 * pixel / 2, 14 * texturePixel,
                5 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1 - 4 * pixel, 11 * pixel / 2, 14 * texturePixel,
                0 * texturePixel);
        tessellator.addVertexWithUV(11 * pixel / 2, 1, 11 * pixel / 2, 10 * texturePixel, 0 * texturePixel);
    }
    tessellator.draw();

    GL11.glTranslated(0.5F, 0.5F, 0.5F);
    if (direction.equals(ForgeDirection.EAST)) {
        GL11.glRotatef(90, 1, 0, 0);
    } else if (direction.equals(ForgeDirection.SOUTH)) {
        GL11.glRotatef(90, 0, 0, 1);
    } else if (direction.equals(ForgeDirection.NORTH)) {
        GL11.glRotatef(-90, 0, 0, 1);
    } else if (direction.equals(ForgeDirection.WEST)) {
        GL11.glRotatef(-90, 1, 0, 0);
    }
    GL11.glTranslated(-0.5F, -0.5F, -0.5F);
}

From source file:com.runescape.client.revised.editor.modelviewer.Model3D.java

License:Open Source License

public void render(final float x, final float y, final float z, final float rx, final float ry, final float rz,
        final float sx, final float sy, final float sz) {
    GL11.glLoadIdentity();//from w w w . j a  va  2  s  . co m
    GL11.glTranslatef(x, y, z);
    GL11.glRotatef(rx, 1.0F, 0.0F, 0.0F);
    GL11.glRotatef(ry, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(rz, 0.0F, 0.0F, 1.0F);
    GL11.glScalef(sx, sy, sz);
    final short[] tri_x = this.triangle_viewspace_x;
    final short[] tri_y = this.triangle_viewspace_y;
    final short[] tri_z = this.triangle_viewspace_z;
    // final short[] tex_map_x = this.texture_map_x;
    // final short[] tex_map_y = this.texture_map_y;
    // final short[] tex_map_z = this.texture_map_z;
    final short[] textures = this.textures;
    final int[] vertices_x = this.vertices_x;
    final int[] vertices_y = this.vertices_y;
    final int[] vertices_z = this.vertices_z;
    final short[] colors = this.colors;
    final float model_scale = 4.0F;
    final float texture_scale = 1.0F;
    if (this.pointers != null) {
        //glEnable(GL_DEPTH_TEST);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    }
    Texture texture = null;
    for (int triangle = 0; triangle != this.triangle_count; ++triangle) {
        if ((this.alpha != null) && (this.alpha[triangle] == -1)) {
            continue;
        }
        final int point_a = tri_x[triangle];
        final int point_b = tri_y[triangle];
        final int point_c = tri_z[triangle];
        final int color = Model.hsl2rgb[colors[triangle] & 0xffff];
        int triangle_type;
        if (this.face_fill_attributes == null) {
            triangle_type = 0;
        } else {
            triangle_type = this.face_fill_attributes[triangle] & 3;
        }
        if ((textures != null) && (textures[triangle] != -1)) {
            final int id = textures[triangle] & 0xffff;
            if (ModelConstants.ENABLE_MODEL_TEXTURES && ((texture == null) && (id != -1))) {
                texture = TextureCache.get(id);
            }
            if (texture != null) {
                texture.bind();
            }
        }
        final boolean textured = ModelConstants.ENABLE_MODEL_TEXTURES && (texture != null);
        GL11.glBegin(GL11.GL_TRIANGLES);
        GL11.glColor4ub((byte) (color >>> 16), (byte) (color >>> 8), (byte) color,
                (byte) (this.alpha == null ? 0xff : ~this.alpha[triangle]));
        switch (triangle_type) {
        case 0://shaded triangle
        case 1://flat triangle
            if (textured) {
                GL11.glTexCoord2f(0.0F, 0.0F);
            }
            GL11.glVertex3f(vertices_x[point_a] / model_scale, vertices_y[point_a] / model_scale,
                    vertices_z[point_a] / model_scale);
            if (textured) {
                GL11.glTexCoord2f(0.0F, texture_scale / model_scale);
            }
            GL11.glVertex3f(vertices_x[point_b] / model_scale, vertices_y[point_b] / model_scale,
                    vertices_z[point_b] / model_scale);
            if (textured) {
                GL11.glTexCoord2f(texture_scale / model_scale, texture_scale / model_scale);
            }
            GL11.glVertex3f(vertices_x[point_c] / model_scale, vertices_y[point_c] / model_scale,
                    vertices_z[point_c] / model_scale);
            break;
        case 2://textured?
        case 3://textured?
            final int ptr = this.face_fill_attributes[triangle] >> 2;
            final int tex_point_a = this.texture_map_x[ptr];
            final int tex_point_b = this.texture_map_y[ptr];
            final int tex_point_c = this.texture_map_z[ptr];
            GL11.glTexCoord2f(0.0F, 0.0F);
            GL11.glVertex3f(vertices_x[tex_point_a] / model_scale, vertices_y[tex_point_a] / model_scale,
                    vertices_z[tex_point_a] / model_scale);
            GL11.glTexCoord2f(0.0F, texture_scale / model_scale);
            GL11.glVertex3f(vertices_x[tex_point_b] / model_scale, vertices_y[tex_point_b] / model_scale,
                    vertices_z[tex_point_b] / model_scale);
            GL11.glTexCoord2f(texture_scale / model_scale, texture_scale / model_scale);
            GL11.glVertex3f(vertices_x[tex_point_c] / model_scale, vertices_y[tex_point_c] / model_scale,
                    vertices_z[tex_point_c] / model_scale);
            break;
        }
        GL11.glEnd();
    }
    if (texture != null) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
    }
}

From source file:com.rvantwisk.cnctools.controls.opengl.OpenGLRenderer.java

License:Open Source License

protected void drawAxis(float length) {
    GL11.glPushMatrix();/* w w  w  .j  av a 2  s  . c om*/
    this.viewModel.ui_transform(length + length / 2.0f);

    float[][] axis = { { length, 0.0f, 0.0f }, { 0.0f, -length, 0.0f }, { 0.0f, 0.0f, length } };
    float[][] colors = { { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.5f, 1.0f } };
    String[] names = { "X", "Y", "Z" };

    GL11.glBegin(GL11.GL_LINES);
    for (int i = 0; i < 3; i++) {
        GL11.glColor3f(colors[i][0], colors[i][1], colors[i][2]);
        GL11.glVertex3f(0.0f, 0.0f, 0.0f);
        GL11.glVertex3f(axis[i][0], axis[i][1], axis[i][2]);
    }
    GL11.glEnd();

    // TODO optmize text rendering, lack of glutBitmapCharacter forces me to do it differently.
    for (int i = 0; i < 3; i++) {
        GL11.glPushMatrix();
        GL11.glColor3f(colors[i][0], colors[i][1], colors[i][2]);

        // http://breadmilkbeercigarettes.com/bmbc/shelves/users/bbb/src/java/SpinningTextureCube.php
        GL11.glTranslatef(Math.round(axis[i][0]), Math.round(axis[i][1]), Math.round(axis[i][2]));
        GL11.glRotatef(camera.getElevation() + 90f, 1.0f, 0.0f, 0.0f);
        GL11.glRotatef(-camera.getAzimuth(), 0.0f, 1.0f, 0.0f);
        SimpleText.drawString(names[i], 0.0f, 0.0f, 0.0f);

        //            GL11.glRasterPos3f(Math.round(axis[i][0]), Math.round(axis[i][1]), Math.round(axis[i][2]));
        //            SimpleText.drawString(names[i], 0, 0);

        GL11.glPopMatrix();

    }

    GL11.glPopMatrix();
}