use of net.minecraft.client.renderer.WorldRenderer in project SecurityCraft by Geforce132.
the class GuiUtils method drawGradientRect.
private static void drawGradientRect(int p_73733_1_, int p_73733_2_, int p_73733_3_, int p_73733_4_, int p_73733_5_, int p_73733_6_, float zLevel) {
float f = (p_73733_5_ >> 24 & 255) / 255.0F;
float f1 = (p_73733_5_ >> 16 & 255) / 255.0F;
float f2 = (p_73733_5_ >> 8 & 255) / 255.0F;
float f3 = (p_73733_5_ & 255) / 255.0F;
float f4 = (p_73733_6_ >> 24 & 255) / 255.0F;
float f5 = (p_73733_6_ >> 16 & 255) / 255.0F;
float f6 = (p_73733_6_ >> 8 & 255) / 255.0F;
float f7 = (p_73733_6_ & 255) / 255.0F;
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glShadeModel(GL11.GL_SMOOTH);
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
worldrenderer.setColorRGBA_F(f1, f2, f3, f);
worldrenderer.addVertex(p_73733_3_, p_73733_2_, zLevel);
worldrenderer.addVertex(p_73733_1_, p_73733_2_, zLevel);
worldrenderer.setColorRGBA_F(f5, f6, f7, f4);
worldrenderer.addVertex(p_73733_1_, p_73733_4_, zLevel);
worldrenderer.addVertex(p_73733_3_, p_73733_4_, zLevel);
tessellator.draw();
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
use of net.minecraft.client.renderer.WorldRenderer in project watson by totemo.
the class PlayerEditSet method drawVectors.
// --------------------------------------------------------------------------
/**
* Draw direction vectors indicating motion of the miner.
*
* @param colour the colour to draw the vectors.
*/
public synchronized void drawVectors(ARGB colour) {
DisplaySettings settings = Controller.instance.getDisplaySettings();
if (settings.areVectorsShown() && isVisible() && !_edits.isEmpty()) {
final Tessellator tess = Tessellator.getInstance();
final WorldRenderer wr = tess.getWorldRenderer();
wr.startDrawing(GL11.GL_LINES);
// TODO: Make the vector colour and thickness configurable.
wr.setColorRGBA_I(colour.getRGB(), colour.getAlpha());
GL11.glLineWidth(0.5f);
// Unit X and Y vectors used for cross products to get arrow axes.
Vec3 unitX = new Vec3(1, 0, 0);
Vec3 unitY = new Vec3(0, 1, 0);
// We only need to draw vectors if there are at least 2 edits.
Iterator<BlockEdit> it = _edits.iterator();
if (it.hasNext()) {
BlockEdit prev = it.next();
while (it.hasNext()) {
BlockEdit next = it.next();
// Work out whether to link edits with vectors.
boolean show = (next.creation && settings.isLinkedCreations()) || (!next.creation && settings.isLinkedDestructions());
if (show) {
Vec3 pPos = new Vec3(0.5 + prev.x, 0.5 + prev.y, 0.5 + prev.z);
Vec3 nPos = new Vec3(0.5 + next.x, 0.5 + next.y, 0.5 + next.z);
// Vector difference, from prev to next.
Vec3 diff = nPos.subtract(pPos);
// Compute length. We want to scale the arrow heads by the length,
// so can't avoid the sqrt() here.
double length = diff.lengthVector();
if (length >= settings.getMinVectorLength()) {
// Draw the vector.
wr.addVertex(pPos.xCoord, pPos.yCoord, pPos.zCoord);
wr.addVertex(nPos.xCoord, nPos.yCoord, nPos.zCoord);
// Length from arrow tip to midpoint of vector as a fraction of
// the total vector length. Scale the arrow in proportion to the
// square root of the length up to a maximum size.
double arrowSize = UNIT_VECTOR_ARROW_SIZE * Math.sqrt(length);
if (arrowSize > MAX_ARROW_SIZE) {
arrowSize = MAX_ARROW_SIZE;
}
double arrowScale = arrowSize / length;
// Position of the tip and tail of the arrow, sitting in the
// middle of the vector.
Vec3 tip = new Vec3(pPos.xCoord * (0.5 - arrowScale) + nPos.xCoord * (0.5 + arrowScale), pPos.yCoord * (0.5 - arrowScale) + nPos.yCoord * (0.5 + arrowScale), pPos.zCoord * (0.5 - arrowScale) + nPos.zCoord * (0.5 + arrowScale));
Vec3 tail = new Vec3(pPos.xCoord * (0.5 + arrowScale) + nPos.xCoord * (0.5 - arrowScale), pPos.yCoord * (0.5 + arrowScale) + nPos.yCoord * (0.5 - arrowScale), pPos.zCoord * (0.5 + arrowScale) + nPos.zCoord * (0.5 - arrowScale));
// Fin axes, perpendicular to vector. Scale by vector length.
// If the vector is colinear with the Y axis, use the X axis for
// the cross products to derive the fin directions.
Vec3 fin1;
if (Math.abs(unitY.dotProduct(diff)) > 0.9 * length) {
fin1 = unitX.crossProduct(diff).normalize();
} else {
fin1 = unitY.crossProduct(diff).normalize();
}
Vec3 fin2 = fin1.crossProduct(diff).normalize();
Vec3 draw1 = new Vec3(fin1.xCoord * arrowScale * length, fin1.yCoord * arrowScale * length, fin1.zCoord * arrowScale * length);
Vec3 draw2 = new Vec3(fin2.xCoord * arrowScale * length, fin2.yCoord * arrowScale * length, fin2.zCoord * arrowScale * length);
// Draw four fins.
wr.addVertex(tip.xCoord, tip.yCoord, tip.zCoord);
wr.addVertex(tail.xCoord + draw1.xCoord, tail.yCoord + draw1.yCoord, tail.zCoord + draw1.zCoord);
wr.addVertex(tip.xCoord, tip.yCoord, tip.zCoord);
wr.addVertex(tail.xCoord - draw1.xCoord, tail.yCoord - draw1.yCoord, tail.zCoord - draw1.zCoord);
wr.addVertex(tip.xCoord, tip.yCoord, tip.zCoord);
wr.addVertex(tail.xCoord + draw2.xCoord, tail.yCoord + draw2.yCoord, tail.zCoord + draw2.zCoord);
wr.addVertex(tip.xCoord, tip.yCoord, tip.zCoord);
wr.addVertex(tail.xCoord - draw2.xCoord, tail.yCoord - draw2.yCoord, tail.zCoord - draw2.zCoord);
}
// if we are drawing this vector
prev = next;
}
// if
}
// while
tess.draw();
}
// if
}
// if drawing
}
use of net.minecraft.client.renderer.WorldRenderer in project watson by totemo.
the class BlockModel method renderTaperedBox.
// --------------------------------------------------------------------------
/**
* Render a tapered wireframe box shape (either a pyramid or inverted pyramid,
* with the point sliced off).
*
* @param xBot1 bottom x 1.
* @param zBot1 bottom z 1.
* @param xBot2 bottom x 2.
* @param zBot2 bottom z 2.
* @param yBot bottom y.
* @param xTop1 top x 1.
* @param zTop1 top z 1.
* @param xTop2 top x 2.
* @param zTop2 top z 2.
* @param yTop top y.
* @param colour colour.
* @param lineWidth line width.
*/
protected void renderTaperedBox(double xBot1, double zBot1, double xBot2, double zBot2, double yBot, double xTop1, double zTop1, double xTop2, double zTop2, double yTop, ARGB colour, float lineWidth) {
Tessellator tess = Tessellator.getInstance();
WorldRenderer wr = tess.getWorldRenderer();
// Bottom face.
wr.startDrawing(GL11.GL_LINE_LOOP);
wr.setColorRGBA(colour.getRed(), colour.getGreen(), colour.getBlue(), colour.getAlpha());
GL11.glLineWidth(lineWidth);
wr.addVertex(xBot1, yBot, zBot1);
wr.addVertex(xBot2, yBot, zBot1);
wr.addVertex(xBot2, yBot, zBot2);
wr.addVertex(xBot1, yBot, zBot2);
tess.draw();
// Top face.
wr.startDrawing(GL11.GL_LINE_LOOP);
wr.setColorRGBA(colour.getRed(), colour.getGreen(), colour.getBlue(), colour.getAlpha());
GL11.glLineWidth(lineWidth);
wr.addVertex(xTop1, yTop, zTop1);
wr.addVertex(xTop2, yTop, zTop1);
wr.addVertex(xTop2, yTop, zTop2);
wr.addVertex(xTop1, yTop, zTop2);
tess.draw();
// Vertical lines joining top and bottom.
wr.startDrawing(GL11.GL_LINES);
wr.setColorRGBA(colour.getRed(), colour.getGreen(), colour.getBlue(), colour.getAlpha());
GL11.glLineWidth(lineWidth);
wr.addVertex(xBot1, yBot, zBot1);
wr.addVertex(xTop1, yTop, zTop1);
wr.addVertex(xBot2, yBot, zBot1);
wr.addVertex(xTop2, yTop, zTop1);
wr.addVertex(xBot1, yBot, zBot2);
wr.addVertex(xTop1, yTop, zTop2);
wr.addVertex(xBot2, yBot, zBot2);
wr.addVertex(xTop2, yTop, zTop2);
tess.draw();
}
use of net.minecraft.client.renderer.WorldRenderer in project CodeChickenLib by Chicken-Bones.
the class CCRenderState method startDrawing.
public static WorldRenderer startDrawing(int mode, VertexFormat format) {
WorldRenderer r = Tessellator.getInstance().getWorldRenderer();
r.begin(mode, format);
if (hasColour)
r.color(colour >>> 24, colour >> 16 & 0xFF, colour >> 8 & 0xFF, alphaOverride >= 0 ? alphaOverride : colour & 0xFF);
if (hasBrightness)
r.lightmap(brightness >> 16 & 65535, brightness & 65535);
return r;
}
use of net.minecraft.client.renderer.WorldRenderer in project CodeChickenLib by Chicken-Bones.
the class RenderUtils method renderBlockOverlaySide.
public static void renderBlockOverlaySide(int x, int y, int z, int side, double tx1, double tx2, double ty1, double ty2) {
double[] points = new double[] { x - 0.009, x + 1.009, y - 0.009, y + 1.009, z - 0.009, z + 1.009 };
WorldRenderer r = Tessellator.getInstance().getWorldRenderer();
switch(side) {
case 0:
r.pos(points[0], points[2], points[4]).tex(tx1, ty1).endVertex();
r.pos(points[1], points[2], points[4]).tex(tx2, ty1).endVertex();
r.pos(points[1], points[2], points[5]).tex(tx2, ty2).endVertex();
r.pos(points[0], points[2], points[5]).tex(tx1, ty2).endVertex();
break;
case 1:
r.pos(points[1], points[3], points[4]).tex(tx2, ty1).endVertex();
r.pos(points[0], points[3], points[4]).tex(tx1, ty1).endVertex();
r.pos(points[0], points[3], points[5]).tex(tx1, ty2).endVertex();
r.pos(points[1], points[3], points[5]).tex(tx2, ty2).endVertex();
break;
case 2:
r.pos(points[0], points[3], points[4]).tex(tx2, ty1).endVertex();
r.pos(points[1], points[3], points[4]).tex(tx1, ty1).endVertex();
r.pos(points[1], points[2], points[4]).tex(tx1, ty2).endVertex();
r.pos(points[0], points[2], points[4]).tex(tx2, ty2).endVertex();
break;
case 3:
r.pos(points[1], points[3], points[5]).tex(tx2, ty1).endVertex();
r.pos(points[0], points[3], points[5]).tex(tx1, ty1).endVertex();
r.pos(points[0], points[2], points[5]).tex(tx1, ty2).endVertex();
r.pos(points[1], points[2], points[5]).tex(tx2, ty2).endVertex();
break;
case 4:
r.pos(points[0], points[3], points[5]).tex(tx2, ty1).endVertex();
r.pos(points[0], points[3], points[4]).tex(tx1, ty1).endVertex();
r.pos(points[0], points[2], points[4]).tex(tx1, ty2).endVertex();
r.pos(points[0], points[2], points[5]).tex(tx2, ty2).endVertex();
break;
case 5:
r.pos(points[1], points[3], points[4]).tex(tx2, ty1).endVertex();
r.pos(points[1], points[3], points[5]).tex(tx1, ty1).endVertex();
r.pos(points[1], points[2], points[5]).tex(tx1, ty2).endVertex();
r.pos(points[1], points[2], points[4]).tex(tx2, ty2).endVertex();
break;
}
}
Aggregations