use of net.minecraft.util.math.Matrix4f in project Hypnotic-Client by Hypnotic-Development.
the class RenderUtils method sideGradientFill.
public static void sideGradientFill(MatrixStack matrixStack, double x1, double y1, double x2, double y2, int color1, int color2, boolean dir) {
Matrix4f matrix = matrixStack.peek().getPositionMatrix();
double j;
if (x1 < x2) {
j = x1;
x1 = x2;
x2 = j;
}
if (y1 < y2) {
j = y1;
y1 = y2;
y2 = j;
}
float f1 = (float) (color1 >> 24 & 255) / 255.0F;
float g1 = (float) (color1 >> 16 & 255) / 255.0F;
float h1 = (float) (color1 >> 8 & 255) / 255.0F;
float k1 = (float) (color1 & 255) / 255.0F;
float f2 = (float) (color2 >> 24 & 255) / 255.0F;
float g2 = (float) (color2 >> 16 & 255) / 255.0F;
float h2 = (float) (color2 >> 8 & 255) / 255.0F;
float k2 = (float) (color2 & 255) / 255.0F;
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
RenderSystem.enableBlend();
RenderSystem.disableTexture();
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
bufferBuilder.vertex(matrix, (float) x1, (float) y2, 0.0F).color(!dir ? g2 : g1, !dir ? h2 : h1, !dir ? k2 : k1, !dir ? f2 : f1).next();
bufferBuilder.vertex(matrix, (float) x2, (float) y2, 0.0F).color(dir ? g2 : g1, dir ? h2 : h1, dir ? k2 : k1, dir ? f2 : f1).next();
bufferBuilder.vertex(matrix, (float) x2, (float) y1, 0.0F).color(dir ? g2 : g1, dir ? h2 : h1, dir ? k2 : k1, dir ? f2 : f1).next();
bufferBuilder.vertex(matrix, (float) x1, (float) y1, 0.0F).color(!dir ? g2 : g1, !dir ? h2 : h1, !dir ? k2 : k1, !dir ? f2 : f1).next();
bufferBuilder.end();
BufferRenderer.draw(bufferBuilder);
RenderSystem.enableTexture();
RenderSystem.disableBlend();
}
use of net.minecraft.util.math.Matrix4f in project Hypnotic-Client by Hypnotic-Development.
the class RenderUtils method drawOutlineBox.
public static void drawOutlineBox(MatrixStack matrixStack, Box bb, int color, boolean draw) {
Color color1 = ColorUtils.getColor(color);
Matrix4f matrix4f = matrixStack.peek().getPositionMatrix();
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
if (draw)
bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES, /*LINES*/
VertexFormats.POSITION_COLOR);
VoxelShape shape = VoxelShapes.cuboid(bb);
shape.forEachEdge((x1, y1, z1, x2, y2, z2) -> {
bufferBuilder.vertex(matrix4f, (float) x1, (float) y1, (float) z1).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
bufferBuilder.vertex(matrix4f, (float) x2, (float) y2, (float) z2).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
});
if (draw) {
bufferBuilder.end();
BufferRenderer.draw(bufferBuilder);
}
}
use of net.minecraft.util.math.Matrix4f in project Hypnotic-Client by Hypnotic-Development.
the class Matrix4x4 method toMinecraft.
public Matrix4f toMinecraft() {
Matrix4f matrix4f = new Matrix4f();
try (MemoryStack memoryStack = MemoryStack.stackPush()) {
FloatBuffer floatBuffer = memoryStack.mallocFloat(16);
floatBuffer.put(0, this.a00);
floatBuffer.put(1, this.a01);
floatBuffer.put(2, this.a02);
floatBuffer.put(3, this.a03);
floatBuffer.put(4, this.a10);
floatBuffer.put(5, this.a11);
floatBuffer.put(6, this.a12);
floatBuffer.put(7, this.a13);
floatBuffer.put(8, this.a20);
floatBuffer.put(9, this.a21);
floatBuffer.put(10, this.a22);
floatBuffer.put(11, this.a23);
floatBuffer.put(12, this.a30);
floatBuffer.put(13, this.a31);
floatBuffer.put(14, this.a32);
floatBuffer.put(15, this.a33);
matrix4f.read(floatBuffer, false);
return matrix4f;
}
}
use of net.minecraft.util.math.Matrix4f in project Hypnotic-Client by Hypnotic-Development.
the class Vertexer method vertexTri.
public static void vertexTri(MatrixStack matrices, VertexConsumer vertexConsumer, float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, Color c) {
Matrix4f model = matrices.peek().getPositionMatrix();
Matrix3f normal = matrices.peek().getNormalMatrix();
Vec3f normalVec = getNormal(normal, x1, y1, z1, x2, y2, z2);
float r = c.getRed() / 255f;
float g = c.getGreen() / 255f;
float b = c.getBlue() / 255f;
float a = c.getAlpha() / 255f;
vertexConsumer.vertex(model, x1, y1, z1).color(r, g, b, a).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next();
vertexConsumer.vertex(model, x2, y2, z2).color(r, g, b, a).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next();
vertexConsumer.vertex(model, x3, y3, z3).color(r, g, b, a).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next();
}
use of net.minecraft.util.math.Matrix4f in project HWG by cybercat-mods.
the class FireballRender method render.
public void render(FireballEntity FireballEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
matrixStack.push();
matrixStack.scale(0.5F, 0.5F, 0.5F);
matrixStack.multiply(this.dispatcher.getRotation());
matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(180.0F));
MatrixStack.Entry entry = matrixStack.peek();
Matrix4f matrix4f = entry.getPositionMatrix();
Matrix3f matrix3f = entry.getNormalMatrix();
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(LAYER);
produceVertex(vertexConsumer, matrix4f, matrix3f, i, 0.0F, 0, 0, 1);
produceVertex(vertexConsumer, matrix4f, matrix3f, i, 1.0F, 0, 1, 1);
produceVertex(vertexConsumer, matrix4f, matrix3f, i, 1.0F, 1, 1, 0);
produceVertex(vertexConsumer, matrix4f, matrix3f, i, 0.0F, 1, 0, 0);
matrixStack.pop();
super.render(FireballEntity, f, g, matrixStack, vertexConsumerProvider, i);
}
Aggregations