Java Code Examples for org.lwjgl.opengl.GL11#glTranslatef()

The following examples show how to use org.lwjgl.opengl.GL11#glTranslatef() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: GardenCollection   File: DecorativePotRenderer.java    License: MIT License 6 votes vote down vote up
private void renderInventoryBlock (BlockDecorativePot block, int metadata, int modelId, RenderBlocks renderer) {
    IIcon icon = renderer.getBlockIconFromSideAndMetadata(block, 1, metadata);

    float unit = .0625f;
    boxRenderer.setIcon(icon);
    boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);

    GL11.glRotatef(90, 0, 1, 0);
    GL11.glTranslatef(-.5f, -.5f, -.5f);

    boxRenderer.renderBox(null, block, 0, 0, 0, 0, 14 * unit, 0, 1, 1, 1, 0, ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_YPOS);
    boxRenderer.renderBox(null, block, 0, 0, 0, 1 * unit, 8 * unit, 1 * unit, 15 * unit, 16 * unit, 15 * unit, 0, ModularBoxRenderer.CUT_YPOS);

    boxRenderer.renderSolidBox(null, block, 0, 0, 0, 3 * unit, 6 * unit, 3 * unit, 13 * unit, 8 * unit, 13 * unit);
    boxRenderer.renderSolidBox(null, block, 0, 0, 0, 5 * unit, 3 * unit, 5 * unit, 11 * unit, 6 * unit, 11 * unit);
    boxRenderer.renderSolidBox(null, block, 0, 0, 0, 2 * unit, 0 * unit, 2 * unit, 14 * unit, 3 * unit, 14 * unit);

    GL11.glTranslatef(.5f, .5f, .5f);
}
 
Example 2
public void renderDynamic(double x, double y, double z, float partialTicks, int renderPass, boolean itemRender){
    if(renderPass == 0) {
        GL11.glPushMatrix(); // start
        // GL11.glDisable(GL11.GL_TEXTURE_2D);
        // GL11.glEnable(GL11.GL_BLEND);
        // GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

        // GL11.glColor4f(0.82F, 0.56F, 0.09F, 1.0F);
        GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); // size
        GL11.glRotatef(0, 0.0F, 1.0F, 0.0F);

        GL11.glScalef(1.0F, -1F, -1F); // to make your block have a normal
                                       // positioning. comment out to see what
                                       // happens

        FMLClientHandler.instance().getClient().getTextureManager().bindTexture(getModel().getModelTexture(null));

        PneumaticCraftUtils.rotateMatrixByMetadata(dir.ordinal());
        renderModule();
        getModel().renderStatic(0.0625F, null);
        getModel().renderDynamic(0.0625F, null, partialTicks);
        GL11.glPopMatrix();
    }
}
 
Example 3
private void render(float x, float y, float z, float scale){
    GL11.glPushMatrix();
    GL11.glRotatef(-90F, 1F, 0, 0);
    GL11.glScalef(scale, scale, scale);
    GL11.glTranslatef(x, y, z);
    GL11.glRotatef(-90F, 1F, 0, 0);
    if(model.getModelTexture(null) != null) FMLClientHandler.instance().getClient().getTextureManager().bindTexture(model.getModelTexture(null));
    //TODO refactor when all models are converted:
    if(model instanceof BaseModel) {
        GL11.glTranslated(0, 24 / 16D, 0);
        GL11.glScalef(0.0625F, 0.0625F, 0.0625F);
    }
    model.rotateModelBasedOnBlockMeta();
    model.renderDynamic(0.0625F, null, 0);
    model.renderStatic(1F / 16F, null);
    GL11.glPopMatrix();
}
 
Example 4
private void render(float x, float y, float z, float scale){

        GL11.glPushMatrix();
        GL11.glRotatef(-90F, 1F, 0, 0);
        // GL11.glDisable(GL11.GL_LIGHTING);

        // Scale, Translate, Rotate
        GL11.glScalef(scale, scale, scale);
        GL11.glTranslatef(x, y, z);
        GL11.glRotatef(-90F, 1F, 0, 0);

        // Bind texture
        FMLClientHandler.instance().getClient().getTextureManager().bindTexture(Textures.MODEL_AIR_CANNON);

        // Render
        model.renderModel(1F / 16F, 0F, 00F, false, false);

        // GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glPopMatrix();
    }
 
Example 5
private static void set2DMode(FloatBuffer matrixData) {
    Minecraft mc = Minecraft.getMinecraft();
    ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
    mc.entityRenderer.setupOverlayRendering();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    //GL11.glLoadMatrix(matrixData);

    GL11.glLoadIdentity();
    GL11.glOrtho(0, mc.displayWidth, 0, mc.displayHeight, -1, 1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();

    Matrix4f matrix = new Matrix4f();
    matrix.load(matrixData);
    GL11.glTranslatef(matrix.m30*sr.getScaleFactor(),-matrix.m31*sr.getScaleFactor(), 0f);

}
 
Example 6
public void renderTileEntityWrathCage(TileEntityWrathCage wrathCage, double x, double z, double par6, float par8) {
    if (!wrathCage.getSpawnerLogic().isMobSet())
        return;
    GL11.glPushMatrix();
    GL11.glTranslatef((float) x + 0.5F, (float) z, (float) par6 + 0.5F);
    renderMob(wrathCage.getSpawnerLogic(), x, z, par6, par8);
    GL11.glPopMatrix();
}
 
Example 7
Source Project: Artifacts   File: SpikesModel.java    License: MIT License 5 votes vote down vote up
public void render(TileEntity te, double x, double y, double z) {
	TileEntitySpikes es = (TileEntitySpikes)te;
	GL11.glPushMatrix();
	GL11.glTranslatef((float)x + 0.5f, (float)y - 0.5f, (float)z + 0.5f);
	//GL11.glScalef(0.5f, 0.5f, 0.5f);
	//FMLClientHandler.instance().getClient().renderEngine.bindTexture(es.getModelTexture());
	ResourceLocation rl = new ResourceLocation(es.getModelTexture());
	FMLClientHandler.instance().getClient().renderEngine.bindTexture(rl);
	this.render();
    GL11.glPopMatrix();
}
 
Example 8
Source Project: ExtraCells1   File: ItemRendererBusFluidExport.java    License: MIT License 5 votes vote down vote up
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{
	Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("extracells", "textures/blocks/texmap_export_bus.png"));
	GL11.glPushMatrix();
	GL11.glTranslatef(-1.0F, 0.5F, 0.5F);
	GL11.glScalef(1.0F, -1F, -1F);
	GL11.glRotatef(180F, 1, 0, 0);
	GL11.glRotatef(-90F, 0, 0, 1);
	model.render(0.0625f);
	cable.renderBase(-0.5, 0.5F, -0.5F, Colors.CLEAR);
	cable.renderExtend(-0.5, 0.5F, -0.5F, ForgeDirection.DOWN, Colors.CLEAR);
	GL11.glPopMatrix();
}
 
Example 9
@Override
protected void preRenderCallback(EntityDireWolf entity, float partialTick) {

  if (debugCounter == 4) {
    System.out.println("RenderDirewolf.preRenderCallback: ");
    mainModel = new ModelDireWolf();
    debugCounter++;
  }

  float scale = 1.25f;
  GL11.glPushMatrix();
  GL11.glTranslatef(0.1f, 0, 0);
  GL11.glScalef(scale - 0.1f, scale, scale);
}
 
Example 10
public static void glCleanup() {
	GL11.glEnable(GL11.GL_LIGHTING);
	GL11.glDisable(GL11.GL_BLEND);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glTranslatef(-.5f, 0, 0);
    GL11.glPopMatrix();
}
 
Example 11
Source Project: GardenCollection   File: ThinLogRenderer.java    License: MIT License 5 votes vote down vote up
@Override
public void renderInventoryBlock (Block block, int metadata, int modelId, RenderBlocks renderer) {
    block.setBlockBoundsForItemRender();
    renderer.setRenderBoundsFromBlock(block);
    GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);

    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, -1.0F, 0.0F);
    renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 0, metadata));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 1, metadata));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1.0F);
    renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 2, metadata));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 3, metadata));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(-1.0F, 0.0F, 0.0F);
    renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 4, metadata));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
    renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 5, metadata));
    tessellator.draw();
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}
 
Example 12
@Override
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
	GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
	GL11.glDisable(GL11.GL_LIGHTING);
	Drawing.drawBlock(block, ((BlockCarvableLayered)block).getBaseTex(), renderer);
	GL11.glEnable(GL11.GL_LIGHTING);
	Drawing.drawBlock(block, metadata, renderer);
	GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}
 
Example 13
@Override
public void renderItem(ItemRenderType type, ItemStack stack, Object... data) {
    RenderInfo info = renderers.get(stack.getItemDamage());

    tile = info.tile;
    renderer = info.renderer;

    if(stack.getItemDamage() == 0) {
        GL11.glTranslatef(0, 2/16f, 0);
    }

    super.renderItem(type, stack, data);
}
 
Example 14
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{
	Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("extracells", "textures/blocks/texmap_solderingstation.png"));
	GL11.glPushMatrix();
	GL11.glTranslatef(0.5F, 1.5F, 0.5F);
	GL11.glScalef(1.0F, -1F, -1F);
	model.renderAll(0.0625f);
	GL11.glPopMatrix();
}
 
Example 15
Source Project: Sakura_mod   File: ModelHaori.java    License: MIT License 4 votes vote down vote up
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5){

	    this.rightArm.isHidden = false;
	    this.leftArm.isHidden = false;
	    this.body.isHidden = false;
	    
	    setRotationAngles(f, f1, f2, f3, f4, f5, entity);
	    if (this.isChild)
	    {
	      float f6 = 2.0F;
	      GL11.glPushMatrix();
	      GL11.glScalef(1.5F / f6, 1.5F / f6, 1.5F / f6);
	      GL11.glTranslatef(0.0F, 16.0F * f5, 0.0F);
	      this.bipedHead.render(f5);
	      GL11.glPopMatrix();
	      GL11.glPushMatrix();
	      GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6);
	      GL11.glTranslatef(0.0F, 24.0F * f5, 0.0F);
	      this.bipedBody.render(f5);
	      this.rightArm.render(f5);
	      this.leftArm.render(f5);
	      this.bipedRightLeg.render(f5);
	      this.bipedLeftLeg.render(f5);
	      this.bipedHeadwear.render(f5);
	      
	      GL11.glPopMatrix();
	    }
	    else
	    {
	      GL11.glPushMatrix();
	      GL11.glScalef(1.01F, 1.01F, 1.01F);
	      this.bipedHead.render(f5);
	      GL11.glPopMatrix();
	      this.bipedBody.render(f5);
	      this.rightArm.render(f5);
	      this.leftArm.render(f5);
	      this.bipedRightLeg.render(f5);
	      this.bipedLeftLeg.render(f5);
	      this.bipedHeadwear.render(f5);
	    }
	  }
 
Example 16
@Override
protected void genResearchBackground(int par1, int par2, float par3) {
    int sw = (this.width - this.paneWidth) / 2;
    int sh = (this.height - this.paneHeight) / 2;

    float var10 = (this.width - this.paneWidth * 1.3F) / 2.0F;
    float var11 = (this.height - this.paneHeight * 1.3F) / 2.0F;

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    UtilsFX.bindTexture(this.tex1);

    GL11.glPushMatrix();
    GL11.glTranslatef(var10, var11, 0.0F);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glScalef(1.3F, 1.3F, 1.0F);
    drawTexturedModalRect(0, 0, 0, 0, this.paneWidth, this.paneHeight);
    GL11.glPopMatrix();

    Injector inj = new Injector(this, GuiResearchRecipe.class);

    ArrayList<List> reference = inj.getField("reference");
    inj.setField("tooltip", null);
    ResearchPage[] pages = inj.getField("pages");
    int page = inj.getField("page");
    int maxPages = inj.getField("maxPages");

    reference.clear();
    int current = 0;
    for (int a = 0; a < pages.length; a++) {
        if (((current == page) || (current == page + 1)) && (current < maxPages)) {
            ResearchPage rPage = pages[a];
            if (rPage instanceof ResearchPageAuraAspects) {
                drawAuraAspectPagePre(rPage, current % 2, sw, sh, par1, par2, page);
            } else if(rPage != null) {
                try {
                    Method m = Injector.getMethod("drawPage", GuiResearchRecipe.class, ResearchPage.class, int.class, int.class, int.class, int.class, int.class);
                    m.setAccessible(true);
                    m.invoke(this, pages[a], current % 2, sw, sh, par1, par2);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        current++;
        if (current > page + 1) {
            break;
        }
    }
    UtilsFX.bindTexture(this.tex1);
    float bob = MathHelper.sin(this.mc.thePlayer.ticksExisted / 3.0F) * 0.2F + 0.1F;
    if (!history.isEmpty()) {
        GL11.glEnable(GL11.GL_BLEND);
        drawTexturedModalRectScaled(sw + 118, sh + 189, 38, 202, 20, 12, bob);
    }
    if (page > 0) {
        GL11.glEnable(GL11.GL_BLEND);
        drawTexturedModalRectScaled(sw - 16, sh + 190, 0, 184, 12, 8, bob);
    }
    if (page < maxPages - 2) {
        GL11.glEnable(GL11.GL_BLEND);
        drawTexturedModalRectScaled(sw + 262, sh + 190, 12, 184, 12, 8, bob);
    }

    inj.setField("reference", reference);
}
 
Example 17
protected void upsideDown(EntityLiving entityliving)
{
    GL11.glRotatef(180F, 0.0F, 0.0F, -1F);
    GL11.glTranslatef(-0.35F, 0F, -0.55F);
}
 
Example 18
public static void drawString(String s, float x, float y, TrueTypeFont font, float scaleX, float scaleY, float rotationZ, float... rgba){
    Minecraft mc = Minecraft.getMinecraft();
    ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);

    if(mc.gameSettings.hideGUI){
        return;
    }
    float amt = 2F / sr.getScaleFactor();
    if(sr.getScaleFactor() == 1){
        amt = 2;
    }

    FloatBuffer matrixData = BufferUtils.createFloatBuffer(16);
    GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, matrixData);
    FontHelper.set2DMode(matrixData);
    GL11.glPushMatrix();
    y = mc.displayHeight-(y*sr.getScaleFactor())-(((font.getLineHeight()/amt)));
    float tx = (x*sr.getScaleFactor())+(font.getWidth(s)/2);
    float tranx = tx+2;
    float trany = y+(font.getLineHeight()/2);
    GL11.glTranslatef(tranx,trany,0);
    GL11.glRotatef(rotationZ, 0f, 0f, 1f);
    GL11.glTranslatef(-tranx,-trany,0);


    GL11.glEnable(GL11.GL_BLEND);
    if(s.contains(formatEscape)){
        String[] pars = s.split(formatEscape);
        float totalOffset = 0;
        for(int i = 0; i < pars.length; i++){
            String par = pars[i];
                float[] c = rgba;
                if(i > 0){
                    c = Formatter.getFormatted(par.charAt(0));
                    par = par.substring(1, par.length());
                }
                font.drawString((x*sr.getScaleFactor()+totalOffset), y, par, scaleX/amt, scaleY/amt, c);
                totalOffset += font.getWidth(par);
        }
    }else{
        font.drawString((x*sr.getScaleFactor()), y, s, scaleX/amt, scaleY/amt, rgba);
    }
    GL11.glPopMatrix();
    GL11.glDisable(GL11.GL_BLEND);
    FontHelper.set3DMode();
}
 
Example 19
Source Project: AdvancedRocketry   File: RendererCrystallizer.java    License: MIT License 4 votes vote down vote up
@Override
public void render(TileEntity tile, double x,
		double y, double z, float f,  int destroyStage, float a) {
	TileMultiblockMachine multiBlockTile = (TileMultiblockMachine)tile;

	if(!multiBlockTile.canRender())
		return;

	GL11.glPushMatrix();

	//Rotate and move the model into position
	GL11.glTranslated(x+.5f, y, z + 0.5f);
	EnumFacing front = RotatableBlock.getFront(tile.getWorld().getBlockState(tile.getPos())); //tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord));
	GL11.glRotatef((front.getFrontOffsetX() == 1 ? 180 : 0) + front.getFrontOffsetZ()*90f, 0, 1, 0);
	GL11.glTranslated(-.5f, 0, -1.5f);

	if(multiBlockTile.isRunning()) {

		float progress = multiBlockTile.getProgress(0)/(float)multiBlockTile.getTotalProgress(0);

		bindTexture(texture);
		model.renderPart("Hull");

		List<ItemStack> outputList = multiBlockTile.getOutputs();
		if(outputList != null && !outputList.isEmpty()) {
			ItemStack stack = outputList.get(0);
			EntityItem entity = new EntityItem(tile.getWorld());

			entity.setItem(stack);
			entity.hoverStart = 0;

			int rotation = (int)(tile.getWorld().getTotalWorldTime() % 360);
			GL11.glPushMatrix();
			GL11.glTranslatef(0, 1, 0);

			GL11.glPushMatrix();
			GL11.glTranslated(1, 0.2, 0.7);
			GL11.glRotatef(rotation, 0, 1, 0);
			GL11.glScalef(progress, progress, progress);
			zmaster587.libVulpes.render.RenderHelper.renderItem(multiBlockTile, stack, Minecraft.getMinecraft().getRenderItem());
			GL11.glPopMatrix();

			GL11.glPushMatrix();
			GL11.glTranslated(1, 0.2, 1.5);
			GL11.glRotatef(rotation, 0, 1, 0);
			GL11.glScalef(progress, progress, progress);
			zmaster587.libVulpes.render.RenderHelper.renderItem(multiBlockTile, stack, Minecraft.getMinecraft().getRenderItem());
			GL11.glPopMatrix();

			GL11.glPushMatrix();
			GL11.glTranslated(1, 0.2, 2.3);
			GL11.glRotatef(rotation, 0, 1, 0);
			GL11.glScalef(progress, progress, progress);
			zmaster587.libVulpes.render.RenderHelper.renderItem(multiBlockTile, stack, Minecraft.getMinecraft().getRenderItem());
			GL11.glPopMatrix();

			GL11.glPopMatrix();



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

			int color = Minecraft.getMinecraft().getItemColors().getColorFromItemstack(stack, 0);

			float divisor = 1/255f;

			GL11.glColor4f((color & 0xFF)*divisor*.5f, ((color & 0xFF00) >>> 8)*divisor*.5f,  ((color & 0xFF0000) >>> 16)*divisor*.5f, 0xE4*divisor);
			GL11.glDisable(GL11.GL_TEXTURE_2D);
			GL11.glTranslatef(0, 1.1f, 0);

			//Fill before emptying
			if(progress < 0.05)
				GL11.glScaled(1, 20*progress, 1);
			else
				GL11.glScaled(1, (1.1-(progress*1.111)), 1);

			GL11.glTranslatef(0, -1.1f, 0);
			model.renderPart("Liquid");
		}
		
		GL11.glEnable(GL11.GL_TEXTURE_2D);
		GL11.glDisable(GL11.GL_BLEND);
		GL11.glPopMatrix();

	}
	else {
		bindTexture(texture);
		model.renderPart("Hull");
	}
	GL11.glPopMatrix();
}
 
Example 20
Source Project: ldparteditor   File: SphereGL20.java    License: MIT License 3 votes vote down vote up
public void draw(float x, float y, float z) {
    GL11.glPushMatrix();
    GL11.glTranslatef(x, y, z);

    GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, bvertices);

    GL11.glDrawElements(GL11.GL_QUADS, bindices);

    GL11.glPopMatrix();
}