Java Code Examples for net.minecraft.client.renderer.Tessellator#startDrawing()

The following examples show how to use net.minecraft.client.renderer.Tessellator#startDrawing() . 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 File: RenderRing.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@SideOnly(Side.CLIENT)
public void renderInterpolated(RenderProgressingLine lastTickLine, float partialTick, float rotationYaw, float rotationPitch){
    GL11.glPushMatrix();
    double renderProgress = getInter(progress, lastTickLine.progress, partialTick);
    GL11.glTranslated((getInter(endX, lastTickLine.endX, partialTick) - startX) * renderProgress, (getInter(endY, lastTickLine.endY, partialTick) - startY) * renderProgress, (getInter(endZ, lastTickLine.endZ, partialTick) - startZ) * renderProgress);
    GL11.glRotatef(rotationYaw, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(rotationPitch, 0.0F, 0.0F, 1.0F);
    Tessellator tess = Tessellator.instance;
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    tess.startDrawing(GL11.GL_LINE_LOOP);
    tess.setColorOpaque_I(color);
    double size = 5 / 16D;
    for(int i = 0; i < PneumaticCraftUtils.circlePoints; i++) {
        tess.addVertex(0, PneumaticCraftUtils.sin[i] * size, PneumaticCraftUtils.cos[i] * size);
    }
    tess.draw();
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glPopMatrix();
}
 
Example 2
Source File: Render.java    From mapwriter with MIT License 6 votes vote down vote up
public static void drawCircle(double x, double y, double r) {
	GL11.glEnable(GL11.GL_BLEND);
       GL11.glDisable(GL11.GL_TEXTURE_2D);
       GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	Tessellator tes = Tessellator.instance;
       tes.startDrawing(GL11.GL_TRIANGLE_FAN);
       tes.addVertex(x, y, zDepth);
       // for some the circle is only drawn if theta is decreasing rather than ascending
       double end = Math.PI * 2.0;
       double incr = end / circleSteps;
       for (double theta = -incr; theta < end; theta += incr) {
       	tes.addVertex(x + (r * Math.cos(-theta)), y + (r * Math.sin(-theta)), zDepth);
       }
       tes.draw();
       GL11.glEnable(GL11.GL_TEXTURE_2D);
       GL11.glDisable(GL11.GL_BLEND);
}
 
Example 3
Source File: Render.java    From mapwriter with MIT License 6 votes vote down vote up
public static void drawArrow(double x, double y, double angle, double length) {
	// angle the back corners will be drawn at relative to the pointing angle
	double arrowBackAngle = 0.75D * Math.PI;
	GL11.glEnable(GL11.GL_BLEND);
       GL11.glDisable(GL11.GL_TEXTURE_2D);
       GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	Tessellator tes = Tessellator.instance;
       tes.startDrawing(GL11.GL_TRIANGLE_FAN);
       tes.addVertex(x + (length * Math.cos(angle)), y + (length * Math.sin(angle)), zDepth);
       tes.addVertex(x + (length * 0.5D * Math.cos(angle - arrowBackAngle)), y + (length * 0.5D * Math.sin(angle - arrowBackAngle)), zDepth);
       tes.addVertex(x + (length * 0.3D * Math.cos(angle + Math.PI)), y + (length * 0.3D * Math.sin(angle + Math.PI)), zDepth);
       tes.addVertex(x + (length * 0.5D * Math.cos(angle + arrowBackAngle)), y + (length * 0.5D * Math.sin(angle + arrowBackAngle)), zDepth);
       tes.draw();
       GL11.glEnable(GL11.GL_TEXTURE_2D);
       GL11.glDisable(GL11.GL_BLEND);
}
 
Example 4
Source File: GuiCheckBox.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void render(int mouseX, int mouseY, float partialTick){
    drawRect(x, y, x + CHECKBOX_WIDTH, y + CHECKBOX_HEIGHT, enabled ? -6250336 : 0xFF999999);
    drawRect(x + 1, y + 1, x + CHECKBOX_WIDTH - 1, y + CHECKBOX_HEIGHT - 1, enabled ? -16777216 : 0xFFAAAAAA);
    if(checked) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        if(enabled) {
            GL11.glColor4d(1, 1, 1, 1);
        } else {
            GL11.glColor4d(0.8, 0.8, 0.8, 1);
        }
        Tessellator t = Tessellator.instance;

        t.startDrawing(GL11.GL_LINE_STRIP);
        t.addVertex(x + 2, y + 5, zLevel);
        t.addVertex(x + 5, y + 7, zLevel);
        t.addVertex(x + 8, y + 3, zLevel);
        t.draw();
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }
    fontRenderer.drawString(I18n.format(text), x + 1 + CHECKBOX_WIDTH, y + CHECKBOX_HEIGHT / 2 - fontRenderer.FONT_HEIGHT / 2, enabled ? color : 0xFF888888);
}
 
Example 5
Source File: GuiRadioButton.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
private void drawCircle(int x, int y, int radius, int color){
    Tessellator t = Tessellator.instance;
    float f = (color >> 24 & 255) / 255.0F;
    float f1 = (color >> 16 & 255) / 255.0F;
    float f2 = (color >> 8 & 255) / 255.0F;
    float f3 = (color & 255) / 255.0F;
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(f1, f2, f3, f);
    t.startDrawing(GL11.GL_TRIANGLE_FAN);
    int points = 20;
    for(int i = 0; i < points; i++) {
        double sin = Math.sin((double)i / points * Math.PI * 2);
        double cos = Math.cos((double)i / points * Math.PI * 2);
        t.addVertex(x + sin * radius, y + cos * radius, zLevel);
    }
    t.draw();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
}
 
Example 6
Source File: GuiChargingStation.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
private void renderAirParticle(float particleProgress){
    int xStart = (width - xSize) / 2;
    int yStart = (height - ySize) / 2;
    float x = xStart + 117F;
    float y = yStart + 50.5F;
    if(particleProgress < 0.5F) {
        y += particleProgress * 56;
    } else if(particleProgress < 0.7F) {
        y += 28F;
        x -= (particleProgress - 0.5F) * 90;
    } else {
        y += 28F;
        x -= 18;
        y -= (particleProgress - 0.7F) * 70;
    }
    Tessellator tess = Tessellator.instance;
    tess.startDrawing(GL11.GL_LINES);
    tess.addVertex(x, y, zLevel);
    tess.addVertex(x, y + 1D, zLevel);
    tess.draw();
}
 
Example 7
Source File: ModelVacuumPump.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
private void drawPlusAndMinus(){
    double scale = 0.05D;
    GL11.glPushMatrix();
    GL11.glTranslated(0.26D, 13.95D / 16D, 0);
    GL11.glRotated(90, 1, 0, 0);
    GL11.glScaled(scale, scale, scale);
    GL11.glColor4d(0, 1, 0, 1);
    Tessellator tess = Tessellator.instance;
    tess.startDrawing(GL11.GL_LINES);
    tess.addVertex(-1, 0, 0);
    tess.addVertex(1, 0, 0);
    tess.addVertex(0, -1, 0);
    tess.addVertex(0, 1, 0);
    tess.draw();
    GL11.glTranslated(-0.52D / scale, 0, 0);
    GL11.glColor4d(1, 0, 0, 1);
    tess.startDrawing(GL11.GL_LINES);
    tess.addVertex(-1, 0, 0);
    tess.addVertex(1, 0, 0);
    tess.draw();
    GL11.glPopMatrix();
}
 
Example 8
Source File: RenderBlockArrows.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
private void drawArrow(float progress){
    double arrowBaseWidth = 0.4D;
    double arrowBaseLength = 0.8D;
    double arrowLength = 1.5D;
    double arrowWidth = 0.7D;
    double scale = 0.1D;
    GL11.glPushMatrix();
    GL11.glScaled(scale, scale, scale);
    GL11.glTranslatef(0, progress * 4, 0);
    Tessellator tess = Tessellator.instance;
    tess.startDrawing(GL11.GL_LINE_STRIP);
    tess.addVertex(-arrowBaseWidth, -arrowLength * 0.5D, 0);
    tess.addVertex(-arrowBaseWidth, -arrowLength * 0.5D + arrowBaseLength, 0);
    tess.addVertex(-arrowWidth, -arrowLength * 0.5D + arrowBaseLength, 0);
    tess.addVertex(0, arrowLength * 0.5D, 0);
    tess.addVertex(arrowWidth, -arrowLength * 0.5D + arrowBaseLength, 0);
    tess.addVertex(arrowBaseWidth, -arrowLength * 0.5D + arrowBaseLength, 0);
    tess.addVertex(arrowBaseWidth, -arrowLength * 0.5D, 0);
    tess.draw();
    GL11.glPopMatrix();
}
 
Example 9
Source File: RenderSearchItemBlock.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public static void renderSearch(double x, double y, double z, int itemCount, int totalCount){
    GL11.glPushMatrix();
    GL11.glTranslated(x, y, z);
    GL11.glColor4d(0, 1, 0, 0.5D);
    GL11.glRotatef(180.0F - RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(180.0F - RenderManager.instance.playerViewX, 1.0F, 0.0F, 0.0F);
    // GL11.glLineWidth(1.0F);
    double ratio = (double)itemCount / totalCount;
    double diff = (1 - ratio) / 1.5D;
    double size = 1 - diff;
    /*
    for(double i = size; i > 0; i -= 0.06D) {
        GL11.glPushMatrix();
        GL11.glScaled(i, i, i);
        renderCircle();
        GL11.glPopMatrix();
    }
    */
    Tessellator tess = Tessellator.instance;
    tess.startDrawing(GL11.GL_QUADS);
    tess.addVertexWithUV(-size, size, 0, 0, 1);
    tess.addVertexWithUV(-size, -size, 0, 0, 0);
    tess.addVertexWithUV(size, -size, 0, 1, 0);
    tess.addVertexWithUV(size, size, 0, 1, 1);

    tess.draw();

    GL11.glPopMatrix();
}
 
Example 10
Source File: BlockOverlay.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
private static void drawOutlinedBoundingBox(AxisAlignedBB par1AxisAlignedBB) {
    Tessellator var2 = Tessellator.instance;
    var2.startDrawing(3);
    var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
    var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
    var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.minY, par1AxisAlignedBB.maxZ);
    var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.maxZ);
    var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
    var2.draw();
    var2.startDrawing(3);
    var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
    var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
    var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ);
    var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ);
    var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
    var2.draw();
    var2.startDrawing(1);
    var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
    var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
    var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
    var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
    var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.minY, par1AxisAlignedBB.maxZ);
    var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ);
    var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.maxZ);
    var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ);
    var2.draw();
    var2.startDrawing(1);
    var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
    var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
    var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
    var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
    var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.minY, par1AxisAlignedBB.maxZ);
    var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ);
    var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.maxZ);
    var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ);
    var2.draw();
}
 
Example 11
Source File: RenderProgressingLine.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public void render(){
    Tessellator tess = Tessellator.instance;
    tess.startDrawing(GL11.GL_LINES);
    tess.addVertex(startX, startY, startZ);
    tess.addVertex(startX + (endX - startX) * progress, startY + (endY - startY) * progress, startZ + (endZ - startZ) * progress);
    tess.draw();
}
 
Example 12
Source File: RenderProgressingLine.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public void renderInterpolated(RenderProgressingLine lastTickLine, float partialTick){
    Tessellator tess = Tessellator.instance;
    tess.startDrawing(GL11.GL_LINES);
    tess.addVertex(getInter(startX, lastTickLine.startX, partialTick), getInter(startY, lastTickLine.startY, partialTick), getInter(startZ, lastTickLine.startZ, partialTick));
    tess.addVertex(getInter(startX, lastTickLine.startX, partialTick) + (getInter(endX, lastTickLine.endX, partialTick) - getInter(startX, lastTickLine.startX, partialTick)) * progress, getInter(startY, lastTickLine.startY, partialTick) + (getInter(startY, lastTickLine.startY, partialTick) - getInter(endY, lastTickLine.endY, partialTick)) * progress, getInter(startZ, lastTickLine.startZ, partialTick) + (getInter(endZ, lastTickLine.endZ, partialTick) - getInter(startZ, lastTickLine.startZ, partialTick)) * progress);
    tess.draw();
}
 
Example 13
Source File: RenderTargetCircle.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public void render(double size, float partialTicks){
    double renderRotationAngle = oldRotationAngle + (rotationAngle - oldRotationAngle) * partialTicks;
    Tessellator tessellator = Tessellator.instance;

    GL11.glPushMatrix();
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);

    // GL11.glLineWidth((float)size * 20F);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);

    GL11.glRotatef((float)renderRotationAngle, 0, 0, 1);
    tessellator.setNormal(0F, 1F, 0F);
    for(int j = 0; j < 2; j++) {
        tessellator.startDrawing(GL11.GL_TRIANGLE_STRIP);
        for(int i = 0; i < PneumaticCraftUtils.circlePoints / 4; i++) {
            tessellator.addVertex(PneumaticCraftUtils.cos[i] * size, PneumaticCraftUtils.sin[i] * size, 0);
            tessellator.addVertex(PneumaticCraftUtils.cos[i] * (size + 0.1D), PneumaticCraftUtils.sin[i] * (size + 0.1D), 0);
        }
        tessellator.draw();

        if(renderAsTagged) {
            GL11.glColor4d(1, 0, 0, 1);
            tessellator.startDrawing(GL11.GL_LINE_LOOP);
            for(int i = 0; i < PneumaticCraftUtils.circlePoints / 4; i++) {
                tessellator.addVertex(PneumaticCraftUtils.cos[i] * size, PneumaticCraftUtils.sin[i] * size, 0);
            }
            for(int i = PneumaticCraftUtils.circlePoints / 4 - 1; i >= 0; i--) {
                tessellator.addVertex(PneumaticCraftUtils.cos[i] * (size + 0.1D), PneumaticCraftUtils.sin[i] * (size + 0.1D), 0);
            }
            tessellator.draw();
            GL11.glColor4d(1, 1, 0, 0.5);
        }

        GL11.glRotatef(180, 0, 0, 1);
    }

    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
}
 
Example 14
Source File: RenderParachute.java    From archimedes-ships with MIT License 5 votes vote down vote up
public void renderParachute(EntityParachute entity, double x, double y, double z, float yaw, float pitch)
{
	GL11.glPushMatrix();
	GL11.glTranslatef((float) x, (float) y + 4F, (float) z);
	
	GL11.glPushMatrix();
	GL11.glEnable(GL12.GL_RESCALE_NORMAL);
	GL11.glScalef(0.0625F, -0.0625F, -0.0625F);
	bindEntityTexture(entity);
	model.render(entity, 0F, 0F, 0F, 0F, 0F, 1F);
	GL11.glDisable(GL12.GL_RESCALE_NORMAL);
	GL11.glPopMatrix();
	
	GL11.glColor4f(0F, 0F, 0F, 1F);
	GL11.glLineWidth(4F);
	Tessellator tess = Tessellator.instance;
	tess.startDrawing(GL11.GL_LINES);
	tess.addTranslation(0F, 0F, 0F);
	tess.addVertex(0D, -3D, 0D);
	tess.addVertex(-1D, 0D, 1D);
	
	tess.addVertex(0D, -3D, 0D);
	tess.addVertex(-1D, 0D, -1D);
	
	tess.addVertex(0D, -3D, 0D);
	tess.addVertex(1D, 0D, 1D);
	
	tess.addVertex(0D, -3D, 0D);
	tess.addVertex(1D, 0D, -1D);
	tess.draw();
	tess.setTranslation(0F, 0F, 0F);
	
	GL11.glPopMatrix();
}
 
Example 15
Source File: Render.java    From mapwriter with MIT License 5 votes vote down vote up
public static void drawTriangle(double x1, double y1, double x2, double y2, double x3, double y3) {
       GL11.glEnable(GL11.GL_BLEND);
       GL11.glDisable(GL11.GL_TEXTURE_2D);
       GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
       Tessellator tes = Tessellator.instance;
       tes.startDrawing(GL11.GL_TRIANGLES);
       tes.addVertex(x1, y1, zDepth);
       tes.addVertex(x2, y2, zDepth);
       tes.addVertex(x3, y3, zDepth);
       tes.draw();
       GL11.glEnable(GL11.GL_TEXTURE_2D);
       GL11.glDisable(GL11.GL_BLEND);
}
 
Example 16
Source File: GLUtils.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
public static void drawOutlinedBoundingBox(AltAxisAlignedBB par1AxisAlignedBB) {

        Tessellator var2 = Tessellator.instance;
        var2.startDrawing(3);
        var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
        var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
        var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.minY, par1AxisAlignedBB.maxZ);
        var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.maxZ);
        var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
        var2.draw();
        var2.startDrawing(3);
        var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
        var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
        var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ);
        var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ);
        var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
        var2.draw();
        var2.startDrawing(1);
        var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
        var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
        var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
        var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
        var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.minY, par1AxisAlignedBB.maxZ);
        var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ);
        var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.maxZ);
        var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ);
        var2.draw();
    }
 
Example 17
Source File: RenderCoordWireframe.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public void render(float partialTicks){
    /*
    Block block = Block.blocksList[world.getBlockId(x, y, z)];
    block.setBlockBoundsBasedOnState(world, x, y, z);
    double minX = block.getBlockBoundsMinX();
    double minY = block.getBlockBoundsMinY();
    double minZ = block.getBlockBoundsMinZ();
    double maxX = minX + (block.getBlockBoundsMaxX() - minX) * progress;
    double maxY = minY + (block.getBlockBoundsMaxY() - minY) * progress;
    double maxZ = minZ + (block.getBlockBoundsMaxX() - minZ) * progress;
    */
    double minX = 0;
    double minY = 0;
    double minZ = 0;
    double maxX = 1;
    double maxY = 1;
    double maxZ = 1;
    float progress = (ticksExisted % 20 + partialTicks) / 20;
    GL11.glDepthMask(false);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glLineWidth(1.0F);
    // GL11.glColor4d(0, 1, 1, progress < 0.5F ? progress + 0.5F : 1.5 - progress);
    GL11.glColor4d(0, progress < 0.5F ? progress + 0.5F : 1.5 - progress, 1, 1);
    GL11.glPushMatrix();
    // GL11.glTranslated(-0.5D, -0.5D, -0.5D);
    GL11.glTranslated(x, y, z);
    Tessellator tess = Tessellator.instance;

    tess.startDrawing(GL11.GL_LINES);
    tess.addVertex(minX, minY, minZ);
    tess.addVertex(minX, maxY, minZ);
    tess.addVertex(minX, minY, maxZ);
    tess.addVertex(minX, maxY, maxZ);

    tess.addVertex(maxX, minY, minZ);
    tess.addVertex(maxX, maxY, minZ);
    tess.addVertex(maxX, minY, maxZ);
    tess.addVertex(maxX, maxY, maxZ);

    tess.addVertex(minX, minY, minZ);
    tess.addVertex(maxX, minY, minZ);
    tess.addVertex(minX, minY, maxZ);
    tess.addVertex(maxX, minY, maxZ);

    tess.addVertex(minX, maxY, minZ);
    tess.addVertex(maxX, maxY, minZ);
    tess.addVertex(minX, maxY, maxZ);
    tess.addVertex(maxX, maxY, maxZ);

    tess.addVertex(minX, minY, minZ);
    tess.addVertex(minX, minY, maxZ);
    tess.addVertex(maxX, minY, minZ);
    tess.addVertex(maxX, minY, maxZ);

    tess.addVertex(minX, maxY, minZ);
    tess.addVertex(minX, maxY, maxZ);
    tess.addVertex(maxX, maxY, minZ);
    tess.addVertex(maxX, maxY, maxZ);

    tess.draw();

    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}
 
Example 18
Source File: RenderOutFrustrumTriangle.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public static void renderTriangle(Entity entity){
    double playerYaw = -RenderManager.instance.playerViewY;
    while(playerYaw >= 360D) {
        playerYaw -= 360;
    }
    while(playerYaw < 0) {
        playerYaw += 360;
    }
    double angle = playerYaw * Math.sin(Math.toRadians(RenderManager.instance.viewerPosX));
    //  double angle = playerYaw;
    // System.out.println("viewY: " + RenderManager.instance.playerViewY);

    ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
    int middleX = sr.getScaledWidth() / 2;
    int middleY = sr.getScaledHeight() / 2;
    int triangleX;
    int triangleY;
    double switchAngle = Math.toDegrees(Math.atan((double)middleX / middleY));
    // System.out.println("angle: " + angle + ", switch angle: " + switchAngle);
    float triangleAngle = 0;
    int distanceFromEdge = 1;
    if(angle < switchAngle) {
        triangleY = distanceFromEdge;
        triangleX = middleX + (int)(Math.tan(Math.toRadians(angle)) * middleY);
    } else if(angle > 360 - switchAngle) {
        triangleY = distanceFromEdge;
        triangleX = middleX - (int)(Math.tan(Math.toRadians(360 - angle)) * middleY);
    } else if(angle < 180 - switchAngle) {
        triangleAngle = 90;
        triangleX = sr.getScaledWidth() - distanceFromEdge;
        triangleY = middleY - (int)(Math.tan(Math.toRadians(90 - angle)) * middleX);
    } else if(angle < 180 + switchAngle) {
        triangleAngle = 180;
        triangleY = sr.getScaledHeight() - distanceFromEdge;
        triangleX = middleX + (int)(Math.tan(Math.toRadians(180 - angle)) * middleY);
    } else {
        triangleAngle = 270;
        triangleX = distanceFromEdge;
        triangleY = middleY + (int)(Math.tan(Math.toRadians(270 - angle)) * middleX);
    }

    Tessellator tessellator = Tessellator.instance;
    GL11.glPushMatrix();
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    // GL11.glEnable(GL11.GL_BLEND);
    // GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glLineWidth(2.0F);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);

    GL11.glTranslated(triangleX, triangleY, 0);
    GL11.glRotatef(triangleAngle, 0, 0, 1);
    tessellator.startDrawing(GL11.GL_LINE_LOOP);
    tessellator.addVertex(5, 5, -90F);
    tessellator.addVertex(15, 5, -90F);
    tessellator.addVertex(10, 0, -90F);
    tessellator.draw();

    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
}
 
Example 19
Source File: RenderProgressBar.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public static void render(double minX, double minY, double maxX, double maxY, double zLevel, int progress){
    //float red = 0.5F;
    // float green = 0.5F;
    // float blue = 0.5F;
    //float alpha = 0.3F;

    Tessellator tessellator = Tessellator.instance;
    GL11.glPushMatrix();
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    // GL11.glEnable(GL11.GL_BLEND);
    // GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glLineWidth(2.0F);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);

    double caseDistance = 0D;
    // draw the bar
    // GL11.glLineWidth((float)(maxY - minY) * 1.95F);
    tessellator.startDrawing(GL11.GL_QUADS);
    // tessellator.setColorRGBA_F(red, green, blue, alpha);
    tessellator.addVertex(minX + (maxX - minX) * caseDistance, minY + (maxY - minY) * caseDistance, zLevel);
    tessellator.addVertex(minX + (maxX - minX) * caseDistance, minY + (maxY - minY) * (1D - caseDistance), zLevel);
    tessellator.addVertex(minX + (maxX - minX) * caseDistance + (maxX - minX) * (1D - 2 * caseDistance) * progress / 100D, minY + (maxY - minY) * (1D - caseDistance), zLevel);
    tessellator.addVertex(minX + (maxX - minX) * caseDistance + (maxX - minX) * (1D - 2 * caseDistance) * progress / 100D, minY + (maxY - minY) * caseDistance, zLevel);

    tessellator.draw();

    GL11.glColor4f(0, 0, 0, 1);
    // draw the casing.
    tessellator.startDrawing(GL11.GL_LINE_LOOP);
    // tessellator.setColorRGBA_F(red, green, blue, alpha);
    tessellator.addVertex(minX, minY, zLevel);
    tessellator.addVertex(minX, maxY, zLevel);
    tessellator.addVertex(maxX, maxY, zLevel);
    tessellator.addVertex(maxX, minY, zLevel);
    tessellator.draw();

    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();

}
 
Example 20
Source File: ClientProxy.java    From NBTEdit with GNU General Public License v3.0 4 votes vote down vote up
private void drawBoundingBox(RenderGlobal r, float f, AxisAlignedBB aabb) {
	if (aabb == null)
		return;

	EntityLivingBase player = Minecraft.getMinecraft().renderViewEntity;

	double var8 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)f;
	double var10 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)f;
	double var12 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)f;

	aabb = aabb.getOffsetBoundingBox(-var8, -var10, -var12);

	GL11.glEnable(GL11.GL_BLEND);
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	GL11.glColor4f(1.0F, 0.0F, 0.0F, .5F);
	GL11.glLineWidth(3.5F);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glDepthMask(false);

	Tessellator var2 = Tessellator.instance;

	var2.startDrawing(3);
	var2.addVertex(aabb.minX, aabb.minY, aabb.minZ);
	var2.addVertex(aabb.maxX, aabb.minY, aabb.minZ);
	var2.addVertex(aabb.maxX, aabb.minY, aabb.maxZ);
	var2.addVertex(aabb.minX, aabb.minY, aabb.maxZ);
	var2.addVertex(aabb.minX, aabb.minY, aabb.minZ);
	var2.draw();
	var2.startDrawing(3);
	var2.addVertex(aabb.minX, aabb.maxY, aabb.minZ);
	var2.addVertex(aabb.maxX, aabb.maxY, aabb.minZ);
	var2.addVertex(aabb.maxX, aabb.maxY, aabb.maxZ);
	var2.addVertex(aabb.minX, aabb.maxY, aabb.maxZ);
	var2.addVertex(aabb.minX, aabb.maxY, aabb.minZ);
	var2.draw();
	var2.startDrawing(1);
	var2.addVertex(aabb.minX, aabb.minY, aabb.minZ);
	var2.addVertex(aabb.minX, aabb.maxY, aabb.minZ);
	var2.addVertex(aabb.maxX, aabb.minY, aabb.minZ);
	var2.addVertex(aabb.maxX, aabb.maxY, aabb.minZ);
	var2.addVertex(aabb.maxX, aabb.minY, aabb.maxZ);
	var2.addVertex(aabb.maxX, aabb.maxY, aabb.maxZ);
	var2.addVertex(aabb.minX, aabb.minY, aabb.maxZ);
	var2.addVertex(aabb.minX, aabb.maxY, aabb.maxZ);
	var2.draw();

	GL11.glDepthMask(true);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glDisable(GL11.GL_BLEND);

}