Example usage for org.lwjgl.opengl GL11 glScalef

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

Introduction

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

Prototype

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

Source Link

Document

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

Usage

From source file:mods.railcraft.client.render.carts.CartContentRendererRedstoneFlux.java

License:Open Source License

@Override
public void render(RenderCart renderer, EntityMinecart cart, float light, float time) {
    super.render(renderer, cart, light, time);
    GL11.glPushMatrix();//from w w  w .jav  a2s  .c  om
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glTranslatef(0.0F, 0.3125F, 0.0F);
    GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    int x = (int) (Math.floor(cart.posX));
    int y = (int) (Math.floor(cart.posY));
    int z = (int) (Math.floor(cart.posZ));

    EntityCartRF cartRF = (EntityCartRF) cart;
    renderer.bindTex(TextureMap.locationBlocksTexture);

    GL11.glTranslatef(0, 0.0625f, 0);

    GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
    RenderFakeBlock.renderBlockForEntity(leadFrame, cart.worldObj, x, y, z, false, true);

    float scale = 0.99F;
    GL11.glScalef(scale, scale, scale);

    float bright = 0.5F + 0.5F * (float) ((double) cartRF.getRF() / (double) cartRF.getMaxRF());
    GL11.glColor4f(bright, bright, bright, 1.0f);

    RenderFakeBlock.renderBlockForEntity(redBlock, cart.worldObj, x, y, z, false, true);

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

From source file:mods.railcraft.client.render.carts.CartContentRendererTank.java

License:Open Source License

private void renderFilterItem(RenderCart renderer, EntityCartTank cart, float light, float time, int x, int y,
        int z) {/*from   ww  w  .  j  a va  2  s .c o m*/
    if (!cart.hasFilter())
        return;

    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    //        GL11.glEnable(GL11.GL_CULL_FACE);

    EntityItem item = new EntityItem(null, 0.0D, 0.0D, 0.0D, cart.getFilterItem().copy());
    item.getEntityItem().stackSize = 1;
    item.hoverStart = 0.0F;

    float scale = 1.2F;

    GL11.glPushMatrix();
    GL11.glRotatef(90.F, 0.0F, 1.0F, 0.0F);
    GL11.glTranslatef(0.0F, -0.6F, 0.68F);
    GL11.glScalef(scale, scale, scale);
    renderItem(item);
    GL11.glPopMatrix();

    GL11.glRotatef(-90.F, 0.0F, 1.0F, 0.0F);
    GL11.glTranslatef(0.0F, -0.6F, 0.68F);
    GL11.glScalef(scale, scale, scale);
    renderItem(item);

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

From source file:mods.railcraft.client.render.carts.CartContentRendererTNT.java

License:Open Source License

@Override
public void render(RenderCart renderer, EntityMinecart cart, float light, float time) {
    GL11.glPushMatrix();/* w  ww  .  ja  va 2s .  co  m*/
    //        GL11.glTranslatef(0.0F, 0.3125F, 0.0F);
    //        GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
    CartExplosiveBase tnt = (CartExplosiveBase) cart;
    if (tnt.isPrimed() && ((float) tnt.getFuse() - time) + 1.0F < 10F) {
        float scale = 1.0F - (((float) tnt.getFuse() - time) + 1.0F) / 10F;
        if (scale < 0.0F) {
            scale = 0.0F;
        }
        if (scale > 1.0F) {
            scale = 1.0F;
        }
        scale *= scale;
        scale *= scale;
        scale = 1.0F + scale * 0.3F;
        GL11.glScalef(scale, scale, scale);
    }
    super.render(renderer, cart, light, time);
    if (tnt.isPrimed() && (tnt.getFuse() / 5) % 2 == 0) {
        GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(770, 772);
        float alpha = (1.0F - (((float) tnt.getFuse() - time) + 1.0F) / 100F) * 0.8F;
        GL11.glColor4f(1.0F, 1.0F, 1.0F, alpha);
        GL11.glScalef(1.01f, 1.01f, 1.01f);
        super.render(renderer, cart, 1, time);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glPopAttrib();
    }
    GL11.glPopMatrix();
}

From source file:mods.railcraft.client.render.carts.CartModelRenderer.java

License:Open Source License

public boolean render(IRenderer renderer, EntityMinecart cart, float light, float time) {
    GL11.glPushMatrix();// w  ww  . ja va 2  s.c  o m
    GL11.glScalef(-1F, -1F, 1.0F);

    //        int j = 0xffffff;
    //        float c1 = (float) (j >> 16 & 0xff) / 255F;
    //        float c2 = (float) (j >> 8 & 0xff) / 255F;
    //        float c3 = (float) (j & 0xff) / 255F;
    //
    //        GL11.glColor4f(c1 * light, c2 * light, c3 * light, 1.0F);

    ResourceLocation texture = null;
    if (cart instanceof IAlternateCartTexture)
        texture = ((IAlternateCartTexture) cart).getTextureFile();

    if (texture == null)
        texture = minecartTextures;
    renderer.bindTex(texture);

    ModelBase core = CartModelManager.getCoreModel(cart.getClass());
    core.render(cart, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
    GL11.glPopMatrix();
    return true;
}

From source file:mods.railcraft.client.render.carts.LocomotiveRendererDefault.java

License:Open Source License

@Override
public void renderLocomotive(IRenderer renderer, EntityMinecart cart, int primaryColor, int secondaryColor,
        ResourceLocation emblemTexture, float light, float time) {
    GL11.glPushMatrix();/*from  www  . j a  v  a2  s . c  o  m*/
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glScalef(-1F, -1F, 1.0F);

    color[0] = primaryColor;
    color[1] = secondaryColor;

    for (int pass = 0; pass < textures.length; pass++) {
        renderer.bindTex(textures[pass]);

        int c = color[pass];

        float dim = 1.0F;
        float c1 = (float) (c >> 16 & 255) / 255.0F;
        float c2 = (float) (c >> 8 & 255) / 255.0F;
        float c3 = (float) (c & 255) / 255.0F;
        GL11.glColor4f(c1 * dim, c2 * dim, c3 * dim, 1);
        model.render(cart, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
    }
    GL11.glPopAttrib();

    if (emblemTexture != null) {
        renderer.bindTex(emblemTexture);
        Tessellator tess = Tessellator.instance;

        //            float size = 0.22F;
        //            float offsetX = -0.25F;
        //            float offsetY = -0.25F;
        //            float offsetZ = -0.46F;
        tess.startDrawingQuads();
        tess.addVertexWithUV(emblemOffsetX - emblemSize, emblemOffsetY - emblemSize, emblemOffsetZ, 0, 0);
        tess.addVertexWithUV(emblemOffsetX - emblemSize, emblemOffsetY + emblemSize, emblemOffsetZ, 0, 1);
        tess.addVertexWithUV(emblemOffsetX + emblemSize, emblemOffsetY + emblemSize, emblemOffsetZ, 1, 1);
        tess.addVertexWithUV(emblemOffsetX + emblemSize, emblemOffsetY + -emblemSize, emblemOffsetZ, 1, 0);

        tess.addVertexWithUV(emblemOffsetX + emblemSize, emblemOffsetY + -emblemSize, -emblemOffsetZ, 0, 0);
        tess.addVertexWithUV(emblemOffsetX + emblemSize, emblemOffsetY + emblemSize, -emblemOffsetZ, 0, 1);
        tess.addVertexWithUV(emblemOffsetX - emblemSize, emblemOffsetY + emblemSize, -emblemOffsetZ, 1, 1);
        tess.addVertexWithUV(emblemOffsetX - emblemSize, emblemOffsetY - emblemSize, -emblemOffsetZ, 1, 0);
        tess.draw();
    }
    GL11.glPopMatrix();
}

From source file:mods.railcraft.client.render.carts.LocomotiveRendererElectric.java

License:Open Source License

@Override
public void renderLocomotive(IRenderer renderer, EntityMinecart cart, int primaryColor, int secondaryColor,
        ResourceLocation emblemTexture, float light, float time) {
    super.renderLocomotive(renderer, cart, primaryColor, secondaryColor, emblemTexture, light, time);
    GL11.glPushMatrix();//from   w  w  w. j a  v a  2  s .  c  o m
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glScalef(-1F, -1F, 1.0F);
    GL11.glTranslatef(0.05F, 0.0F, 0.0F);

    if (((EntityLocomotive) cart).getMode() == EntityLocomotive.LocoMode.RUNNING) {
        renderer.bindTex(LAMP_TEX_ON);
        LAMP_ON.render(cart, -0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
    } else {
        renderer.bindTex(LAMP_TEX_OFF);
        LAMP_OFF.render(cart, -0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
    }

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

From source file:mods.railcraft.client.render.carts.RenderCart.java

License:Open Source License

public void renderCart(EntityMinecart cart, double x, double y, double z, float yaw, float time) {
    GL11.glPushMatrix();/*from   www  .  j a  v a2  s. c o  m*/
    long var10 = (long) cart.getEntityId() * 493286711L;
    var10 = var10 * var10 * 4392167121L + var10 * 98761L;
    float tx = (((float) (var10 >> 16 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
    float ty = (((float) (var10 >> 20 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
    float tz = (((float) (var10 >> 24 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
    GL11.glTranslatef(tx, ty, tz);
    double mx = cart.lastTickPosX + (cart.posX - cart.lastTickPosX) * (double) time;
    double my = cart.lastTickPosY + (cart.posY - cart.lastTickPosY) * (double) time;
    double mz = cart.lastTickPosZ + (cart.posZ - cart.lastTickPosZ) * (double) time;
    double d6 = 0.3;
    Vec3 vec3d = cart.func_70489_a(mx, my, mz);
    float pitch = cart.prevRotationPitch + (cart.rotationPitch - cart.prevRotationPitch) * time;
    if (vec3d != null) {
        Vec3 vec3d1 = cart.func_70495_a(mx, my, mz, d6);
        Vec3 vec3d2 = cart.func_70495_a(mx, my, mz, -d6);
        if (vec3d1 == null)
            vec3d1 = vec3d;
        if (vec3d2 == null)
            vec3d2 = vec3d;
        x += vec3d.xCoord - mx;
        y += (vec3d1.yCoord + vec3d2.yCoord) / 2D - my;
        z += vec3d.zCoord - mz;
        Vec3 vec3d3 = vec3d2.addVector(-vec3d1.xCoord, -vec3d1.yCoord, -vec3d1.zCoord);
        if (vec3d3.lengthVector() != 0.0D) {
            vec3d3 = vec3d3.normalize();
            yaw = (float) (Math.atan2(vec3d3.zCoord, vec3d3.xCoord) / Math.PI) * 180;
            pitch = (float) (Math.atan(vec3d3.yCoord) * 73D);
        }
    }
    if (cart instanceof IDirectionalCart) {
        yaw %= 360;
        if (yaw < 0)
            yaw += 360;
        yaw += 360;

        double serverYaw = cart.rotationYaw;
        serverYaw += 180;
        serverYaw %= 360;
        if (serverYaw < 0)
            serverYaw += 360;
        serverYaw += 360;

        if (Math.abs(yaw - serverYaw) > 90) {
            yaw += 180;
            pitch = -pitch;
        }

        ((IDirectionalCart) cart).setRenderYaw(yaw);
    }
    GL11.glTranslatef((float) x, (float) y, (float) z);

    boolean name = false;
    if (cart.hasCustomInventoryName()) {
        renderHaloText(cart, cart.getCommandSenderName(), 0, 0, 0, 64);
        name = true;
    }

    if (cart instanceof IRoutableCart) {
        String dest = ((IRoutableCart) cart).getDestination();
        if (!dest.isEmpty())
            renderHaloText(cart, dest, 0, name ? 0.5 : 0, 0, 64);
    }

    GL11.glRotatef(180F - yaw, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(-pitch, 0.0F, 0.0F, 1.0F);

    float f3 = (float) cart.getRollingAmplitude() - time;
    float f4 = (float) cart.getDamage() - time;
    if (f4 < 0.0F)
        f4 = 0.0F;
    if (f3 > 0.0F) {
        float angle = (MathHelper.sin(f3) * f3 * f4) / 10F;
        angle = Math.min(angle, 0.8f);
        angle = Math.copySign(angle, cart.getRollingDirection());
        GL11.glRotatef(angle, 1.0F, 0.0F, 0.0F);
    }
    float light = cart.getBrightness(time);
    //        light = light + ((1.0f - light) * 0.4f);

    boolean renderContents = renderCore(cart, light, time);

    if (renderContents) {
        float blockScale = 0.74F;
        GL11.glScalef(blockScale, blockScale, blockScale);
        GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
        renderContents(cart, light, time);
        GL11.glPopAttrib();
    }
    GL11.glPopMatrix();
}

From source file:mods.railcraft.client.render.carts.RenderItemLocomotive.java

License:Open Source License

private void render(ItemStack stack, float scale) {
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_DEPTH_TEST);/*from w ww. j  a va 2 s  .c  o  m*/
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glScalef(scale, scale, scale);

    entity.rotationYaw = 0;
    entity.rotationPitch = 0;
    entity.setModel(ItemLocomotive.getModel(stack));
    entity.setPrimaryColor(ItemLocomotive.getPrimaryColor(stack).ordinal());
    entity.setSecondaryColor(ItemLocomotive.getSecondaryColor(stack).ordinal());

    LocomotiveRenderer.INSTANCE.render(this, entity, 1.0F, 1.0F);

    GL11.glPopAttrib();
}

From source file:mods.railcraft.client.render.carts.RenderTunnelBore.java

License:Open Source License

public void render(EntityTunnelBore bore, double x, double y, double z, float yaw, float time) {
    // System.out.println("Render Yaw = " + f);
    GL11.glPushMatrix();/*from  w  ww  .  j a v a 2  s.c o m*/
    long var10 = (long) bore.getEntityId() * 493286711L;
    var10 = var10 * var10 * 4392167121L + var10 * 98761L;
    float tx = (((float) (var10 >> 16 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
    float ty = (((float) (var10 >> 20 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
    float tz = (((float) (var10 >> 24 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
    GL11.glTranslatef(tx, ty, tz);

    if (RenderManager.debugBoundingBox) {
        GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
        //            GL11.glDepthMask(false);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_BLEND);
        for (Entity part : bore.getParts()) {
            GL11.glPushMatrix();
            double posX = part.lastTickPosX + (part.posX - part.lastTickPosX) * (double) time
                    - RenderManager.renderPosX;
            double posY = part.lastTickPosY + (part.posY - part.lastTickPosY) * (double) time
                    - RenderManager.renderPosY;
            double posZ = part.lastTickPosZ + (part.posZ - part.lastTickPosZ) * (double) time
                    - RenderManager.renderPosZ;
            GL11.glTranslatef((float) posX, (float) posY, (float) posZ);
            float halfWidth = part.width / 2.0F;
            AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(-halfWidth, 0.0, -halfWidth, halfWidth,
                    part.height, halfWidth);
            RenderGlobal.drawOutlinedBoundingBox(axisalignedbb, 16777215);
            GL11.glPopMatrix();
        }
        //            GL11.glDepthMask(true);
        GL11.glPopAttrib();
    }

    GL11.glTranslatef((float) x, (float) y, (float) z);
    switch (bore.getFacing()) {
    case NORTH:
        yaw = 90;
        break;
    case EAST:
        yaw = 0;
        break;
    case SOUTH:
        yaw = 270;
        break;
    case WEST:
        yaw = 180;
        break;
    }
    GL11.glRotatef(yaw, 0.0F, 1.0F, 0.0F);
    float f3 = (float) bore.getRollingAmplitude() - time;
    float f4 = (float) bore.getDamage() - time;
    if (f4 < 0.0F) {
        f4 = 0.0F;
    }
    if (f3 > 0.0F) {
        float angle = (MathHelper.sin(f3) * f3 * f4) / 10F;
        angle = Math.min(angle, 0.8f);
        angle = Math.copySign(angle, bore.getRollingDirection());
        GL11.glRotatef(angle, 1.0F, 0.0F, 0.0F);
    }
    float light = bore.getBrightness(time);
    light = light + ((1.0f - light) * 0.4f);

    int j = 0xffffff;
    float c1 = (float) (j >> 16 & 0xff) / 255F;
    float c2 = (float) (j >> 8 & 0xff) / 255F;
    float c3 = (float) (j & 0xff) / 255F;

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

    IBoreHead head = bore.getBoreHead();
    if (head != null) {
        bindTexture(head.getBoreTexture());
        modelTunnelBore.setRenderBoreHead(true);
    } else {
        bindTexture(TEXTURE);
        modelTunnelBore.setRenderBoreHead(false);
    }

    GL11.glScalef(-1F, -1F, 1.0F);

    modelTunnelBore.setBoreHeadRotation(bore.getBoreRotationAngle());
    modelTunnelBore.setBoreActive(bore.isMinecartPowered());
    modelTunnelBore.render(0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
    GL11.glPopMatrix();
}

From source file:mods.railcraft.client.render.models.carts.ModelGift.java

License:Open Source License

@Override
public void render(Entity entity, float x, float y, float z, float yaw, float pitch, float time) {
    GL11.glPushMatrix();//from  ww  w  .  ja  v  a2s .  co m
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glTranslatef(0, 1, 1);
    GL11.glScalef(1.0F, -1.0F, -1.0F);
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    GL11.glRotatef(-90, 0.0F, 1.0F, 0.0F);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    this.chestKnob.rotateAngleX = this.chestLid.rotateAngleX;
    this.chestLid.render(0.0625F);
    this.chestKnob.render(0.0625F);
    this.chestBelow.render(0.0625F);
    GL11.glPopMatrix();
}