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:com.blogspot.jabelarminecraft.wildanimals.models.ModelSerpent.java

License:Open Source License

public void renderSerpent(EntitySerpent parEntity, float parTime, float parSwingAmount, float par4,
        float parHeadAngleY, float parHeadAngleX, float par7) {
    setRotationAngles(parTime, parSwingAmount, par4, parHeadAngleY, parHeadAngleX, par7, parEntity);

    // scale the whole thing for big or small entities
    GL11.glPushMatrix();/*www.  ja v  a 2 s.  com*/
    GL11.glScalef(parEntity.getScaleFactor(), parEntity.getScaleFactor(), parEntity.getScaleFactor());

    if (this.isChild) {
        float childScaleFactor = 0.5F;
        GL11.glPushMatrix();
        GL11.glScalef(1.0F * childScaleFactor, 1.0F * childScaleFactor, 1.0F * childScaleFactor);
        GL11.glTranslatef(0.0F, 24.0F * par7, 0.0F);
        head.render(par7);
        // flick tongue occasionally
        if (parEntity.ticksExisted % 60 == 0 && parSwingAmount <= 0.1F) {
            tongue.render(par7);
        }
        body1.render(par7); // all rest of body are children of body1
        GL11.glPopMatrix();
    } else {
        head.render(par7);
        // flick tongue occasionally

        if (parEntity.ticksExisted % 60 == 0 && parSwingAmount <= 0.1F) {
            tongue.render(par7);
        }
        body1.render(par7); // all rest of body are children of body1
    }

    // don't forget to pop the matrix for overall scaling
    GL11.glPopMatrix();
}

From source file:com.blogspot.jabelarminecraft.wildanimals.renderers.RenderThrowableSpawnEgg.java

License:Open Source License

/**
 * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
 * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
 * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
 * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
 *//*  w  ww  . j a  v  a2  s.  c  o  m*/
public void doRender(EntityWildAnimalsEgg parEntityWildAnimalsEgg, double parPosX, double parPosY,
        double parPosZ, float p_76986_8_, float parTweenFactor) {
    bindEntityTexture(parEntityWildAnimalsEgg);
    GL11.glPushMatrix();
    GL11.glTranslatef((float) parPosX, (float) parPosY, (float) parPosZ);
    GL11.glRotatef(parEntityWildAnimalsEgg.prevRotationYaw
            + (parEntityWildAnimalsEgg.rotationYaw - parEntityWildAnimalsEgg.prevRotationYaw) * parTweenFactor
            - 90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(parEntityWildAnimalsEgg.prevRotationPitch
            + (parEntityWildAnimalsEgg.rotationPitch - parEntityWildAnimalsEgg.prevRotationPitch)
                    * parTweenFactor,
            0.0F, 0.0F, 1.0F);
    Tessellator tessellator = Tessellator.instance;
    byte b0 = 0;
    float f2 = 0.0F;
    float f3 = 0.5F;
    float f4 = 0.0F;
    float f5 = 5 / 32.0F;
    float f6 = 0.0F;
    float f7 = 0.15625F;
    float f8 = 5 / 32.0F;
    float f9 = 10 / 32.0F;
    float scaleFactor = 0.05625F;
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    float f11 = -parTweenFactor;

    if (f11 > 0.0F) {
        float f12 = -MathHelper.sin(f11 * 3.0F) * f11;
        GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F);
    }

    GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
    GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
    GL11.glTranslatef(-4.0F, 0.0F, 0.0F);
    GL11.glNormal3f(scaleFactor, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, f6, f8);
    tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, f7, f8);
    tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, f7, f9);
    tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, f6, f9);
    tessellator.draw();
    GL11.glNormal3f(-scaleFactor, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, f6, f8);
    tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, f7, f8);
    tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, f7, f9);
    tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, f6, f9);
    tessellator.draw();

    for (int i = 0; i < 4; ++i) {
        GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
        GL11.glNormal3f(0.0F, 0.0F, scaleFactor);
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, f2, f4);
        tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, f3, f4);
        tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, f3, f5);
        tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, f2, f5);
        tessellator.draw();
    }

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
}

From source file:com.bluepowermod.client.render.RenderItemEngine.java

License:Open Source License

private void renderEngine(float x, float y, float z, float rotateAmount, float rotatex, float rotatey,
        float rotatez) {

    GL11.glPushMatrix();//from  w w w . java  2  s. co m
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glScalef(.034F, .034F, .034F);
    GL11.glTranslated(x, y, z);
    GL11.glRotatef(rotateAmount, rotatex, rotatey, rotatez);
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(textureLocation);

    model.renderAll();

    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}

From source file:com.bluepowermod.client.render.RenderPartItem.java

License:Open Source License

private void render(float x, float y, float z, float scale, ItemRenderType type, ItemStack item,
        Object... data) {//  w  ww .ja  v a 2 s.com

    boolean blend = GL11.glGetBoolean(GL11.GL_BLEND);
    boolean alpha = GL11.glGetBoolean(GL11.GL_ALPHA_TEST);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_ALPHA_TEST);

    GL11.glPushMatrix();
    GL11.glScalef(scale, scale, scale);
    GL11.glTranslatef(x, y, z);
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
    try {
        BPPart part = PartManager.getExample(item);
        part.renderItem(type, item, data);
    } catch (Exception ex) {
    }
    GL11.glPopMatrix();

    if (!blend)
        GL11.glDisable(GL11.GL_BLEND);
    if (!alpha)
        GL11.glDisable(GL11.GL_ALPHA_TEST);
}

From source file:com.builtbroken.assemblyline.client.FakeItemRender.java

/**
 * Renders an item at the position//from w w  w  .ja v a 2 s  .  c o m
 * <p>
 * Make sure to call {@link #setWorldPosition(World, double, double, double)} first
 *
 * @param xx   - render position offset from center
 * @param yy   - render position offset from center
 * @param zz   - render position offset from center
 * @param item - item to render
 */
public static void renderItemAtPosition(double xx, double yy, double zz, ItemStack item) {
    if (item != null) {
        //Start
        GL11.glPushMatrix();

        //Translate
        GL11.glTranslated(xx, yy, zz);
        final float scale = 1f;
        GL11.glScalef(scale, scale, scale);

        try {
            //Fix missing render manager
            renderItem.setRenderManager(RenderManager.instance);

            entityItem.setEntityItemStack(item);
            entityItem.hoverStart = 0.0F;

            //Render item using RenderItem class to save time
            renderItem.doRender(entityItem, 0, 0, 0, 0, 0);
        } catch (Exception e) {
            e.printStackTrace();
        }

        //End
        GL11.glPopMatrix();
    }
}

From source file:com.builtbroken.assemblyline.content.rail.carts.RenderCart.java

@Override
public void doRender(final Entity entity, final double xx, final double yy, final double zz,
        final float p_76986_8_, final float delta) {
    final EntityCart cart = (EntityCart) entity;
    float f5 = cart.prevRotationPitch + (cart.rotationPitch - cart.prevRotationPitch) * delta;

    double x2 = MathHelper.lerp(cart.lastRenderX, xx, delta);
    double y2 = MathHelper.lerp(cart.lastRenderY, yy, delta);
    double z2 = MathHelper.lerp(cart.lastRenderZ, zz, delta);

    //Start all/* w w  w  .  j a va 2  s.c o  m*/
    GL11.glPushMatrix();
    GL11.glTranslated(x2, y2, z2);
    GL11.glRotatef(180.0F - delta, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(-f5, 0.0F, 0.0F, 1.0F);

    //store last position
    cart.lastRenderX = x2;
    cart.lastRenderY = y2;
    cart.lastRenderZ = z2;

    float halfWidth = cart.width / 2.0F;
    float halfLength = cart.length / 2.0F;
    float yaw = (float) Math.abs(MathUtility.clampAngleTo180(cart.rotationYaw));
    if (yaw >= 45 && yaw <= 135) {
        halfWidth = cart.length / 2.0F;
        halfLength = cart.width / 2.0F;
    }
    AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(-(double) halfWidth, 0, -(double) halfLength,

            +(double) halfWidth, 0.2, +(double) halfLength);

    //Render bottom of cart
    GL11.glPushMatrix();
    RenderUtility.renderCube(bounds, Blocks.iron_block);
    GL11.glPopMatrix();

    //Render stuff on top of cart
    if (cart.getType() != CartTypes.EMPTY) {
        GL11.glPushMatrix();
        if (cart.getType() == CartTypes.CHEST) {
            if (Holiday.isXMAS()) {
                this.bindTexture(xmasChestTexture);
            } else {
                this.bindTexture(chestTexture);
            }
            GL11.glRotatef(180, 0.0F, 0.0F, 1.0F);
            GL11.glScalef(0.6f, 0.6f, 0.6f);
            GL11.glTranslated(-0.5, -1.2, -0.5);
            chestModel.renderAll();
        } else if (cart.getType() == CartTypes.STACK) {
            ItemStack stack = cart.getInventory().getStackInSlot(0);
            try {
                if (stack != null) {
                    //TODO implement a custom override for rendering items on cart using an interface as well event
                    IItemRenderer renderer = MinecraftForgeClient.getItemRenderer(stack,
                            IItemRenderer.ItemRenderType.ENTITY);
                    if (renderer != null) {
                        /** see if {@link net.minecraftforge.client.ForgeHooksClient#renderEntityItem(EntityItem, ItemStack, float, float, Random, TextureManager, RenderBlocks, int)}
                         *                  will work much better */
                        EntityItem fakeItem = new EntityItem(cart.oldWorld());
                        fakeItem.setPosition(cart.x(), cart.y() + 0.5, cart.z());
                        renderer.renderItem(IItemRenderer.ItemRenderType.ENTITY, stack,
                                RenderBlocks.getInstance(), fakeItem);

                    } else if (stack.getItem() instanceof ItemBlock) {
                        RenderUtility.renderCube(AxisAlignedBB.getBoundingBox(0, 0, 0, .8, .8, .8),
                                Blocks.planks);
                    } else {
                        RenderItemOverlayUtility
                                .renderIcon3D(stack.getItem().getIconFromDamage(stack.getItemDamage()), 1);
                    }
                }
            } catch (Exception e) {
                AssemblyLine.INSTANCE.logger().error("Failed to render " + stack, e);
                RenderUtility.renderCube(AxisAlignedBB.getBoundingBox(0, 0, 0, .2, .1, .2), Blocks.wool);
            }
            RenderUtility.renderCube(AxisAlignedBB.getBoundingBox(0, 0, 0, .9, .1, .9), Blocks.planks);
        } else {
            GL11.glScalef(0.5f, 0.5f, 0.5f);
            GL11.glTranslated(-0.5, .3, -0.5);
            RenderUtility.renderCube(AxisAlignedBB.getBoundingBox(0, 0, 0, 1, 1, 1), Blocks.planks);
        }
        GL11.glPopMatrix();
    }

    //End all
    GL11.glPopMatrix();
    if (Engine.runningAsDev) {
        drawBounds(cart, xx, yy, zz);
    }
}

From source file:com.builtbroken.atomic.content.machines.steam.generator.RenderItemSteamGenerator.java

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    GL11.glPushMatrix();/*from  www. j  a  v a2s. c o m*/
    if (type.equals(ItemRenderType.INVENTORY)) {
        GL11.glTranslatef(-0.5f, -1.1f, -0.5f);
        GL11.glScalef(1.4f, 1.4f, 1.4f);
    } else if (type.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) {
        GL11.glTranslatef(0.5f, 0.2f, 0.5f);
    } else if (type.equals(ItemRenderType.EQUIPPED)) {
        GL11.glTranslatef(0.5f, 0.2f, 0.5f);
    }
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(texture);
    model.renderAll();
    GL11.glPopMatrix();
}

From source file:com.builtbroken.gascan.content.BucketMaterialCanClient.java

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    GL11.glPushMatrix();/*w  w  w.  ja v a  2  s. c o  m*/
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);

    if (type == ItemRenderType.EQUIPPED) {
        GL11.glRotatef(-40, 0, 1, 0);
        //GL11.glRotatef(13, 1, 0, 0);
        GL11.glTranslatef(1f, -1.1f, 0.1f);

        final float scale = 0.0625f / 4;
        GL11.glScalef(scale, scale, scale);
        MODEL.renderAll();
    } else if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
        GL11.glRotatef(-90, 0, 1, 0);
        //GL11.glRotatef(-13, 1, 0, 0);
        GL11.glTranslatef(1f, 0.6f, 0.5f);

        final float scale = 0.0625f / 5;
        GL11.glScalef(scale, scale, scale);
        MODEL.renderAll();
    } else if (type == ItemRenderType.ENTITY) {
        GL11.glTranslatef(0f, 0, 0);

        final float scale = 0.0625f / 4;
        GL11.glScalef(scale, scale, scale);
        MODEL.renderAll();
    }

    GL11.glPopMatrix();
}

From source file:com.builtbroken.grappling.content.entity.RenderHook.java

@Override
public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) {
    GL11.glPushMatrix();/*  w  w  w . ja v a2  s .c o  m*/
    GL11.glTranslatef((float) x, (float) y, (float) z);
    GL11.glDisable(GL11.GL_LIGHTING);

    final float scale = 0.0625f / 3;
    GL11.glScalef(scale, scale, scale);

    FMLClientHandler.instance().getClient().renderEngine.bindTexture(getEntityTexture(entity));
    if (entity instanceof EntityHook) {
        final Hook hook = ((EntityHook) entity).hook;

        if (hook != null) {
            switch (hook.side) {
            //Bottom
            case 0:
                GL11.glRotatef(-90, 1, 0, 0);
                break;
            //Top
            case 1:
                GL11.glRotatef(90, 1, 0, 0);
                break;
            //North
            case 2:
                //Default rotation
                break;
            //South
            case 3:
                GL11.glRotatef(180, 0, 1, 0);
                break;
            case 4:
                GL11.glRotatef(90, 0, 1, 0);
                break;
            case 5:
                GL11.glRotatef(-90, 0, 1, 0);
                break;
            }
        }
    }
    MODEL.renderAll();

    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}

From source file:com.builtbroken.grappling.content.item.ItemHookRenderer.java

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    GL11.glPushMatrix();//ww w .  j  a  v  a 2 s. c  o  m

    FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);

    Entity entity = null;

    if (data != null && data.length >= 2 && data[1] instanceof Entity) {
        entity = (Entity) data[1];
    }

    if (type == ItemRenderType.EQUIPPED) {
        //TODO have rotation match aiming point
        GL11.glRotatef(-130, 0, 1, 0);
        //GL11.glRotatef(13, 1, 0, 0);
        GL11.glTranslatef(0.1f, 0.4f, -1.2f);

        final float scale = 0.0625f / 3;
        GL11.glScalef(scale, scale, scale);
        if (entity != null && entity == Minecraft.getMinecraft().thePlayer) {
            if (ClientHookHandler.hook != null) {
                MODEL.renderAllExcept("group5", "Component_20");
            } else {
                MODEL.renderAll();
            }
        } else {
            MODEL.renderAll();
        }
    } else if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
        GL11.glRotatef(140, 0, 1, 0);
        GL11.glRotatef(-13, 1, 0, 0);
        GL11.glTranslatef(-0.2f, 0.6f, -0.5f);

        final float scale = 0.0625f / 3;
        GL11.glScalef(scale, scale, scale);
        if (ClientHookHandler.hook != null) {
            MODEL.renderAllExcept("group5", "Component_20");
        } else {
            MODEL.renderAll();
        }
    } else if (type == ItemRenderType.ENTITY) {
        GL11.glTranslatef(0f, 0, -0.9f);

        final float scale = 0.0625f / 3;
        GL11.glScalef(scale, scale, scale);
        MODEL.renderAll();
    }

    GL11.glPopMatrix();
}