Search in sources :

Example 46 with Matrix4f

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();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) IMatrix4f(dev.hypnotic.utils.mixin.IMatrix4f) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer)

Example 47 with Matrix4f

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);
    }
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) IMatrix4f(dev.hypnotic.utils.mixin.IMatrix4f) VoxelShape(net.minecraft.util.shape.VoxelShape) Color(java.awt.Color) BufferBuilder(net.minecraft.client.render.BufferBuilder)

Example 48 with Matrix4f

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;
    }
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) MemoryStack(org.lwjgl.system.MemoryStack) FloatBuffer(java.nio.FloatBuffer)

Example 49 with 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();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Matrix3f(net.minecraft.util.math.Matrix3f) Vec3f(net.minecraft.util.math.Vec3f)

Example 50 with Matrix4f

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);
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Matrix3f(net.minecraft.util.math.Matrix3f) MatrixStack(net.minecraft.client.util.math.MatrixStack) VertexConsumer(net.minecraft.client.render.VertexConsumer)

Aggregations

Matrix4f (net.minecraft.util.math.Matrix4f)53 BufferBuilder (net.minecraft.client.render.BufferBuilder)18 IMatrix4f (dev.hypnotic.utils.mixin.IMatrix4f)13 Matrix3f (net.minecraft.util.math.Matrix3f)13 GameRenderer (net.minecraft.client.render.GameRenderer)11 Vec3d (net.minecraft.util.math.Vec3d)8 MatrixStack (net.minecraft.client.util.math.MatrixStack)7 VertexConsumer (net.minecraft.client.render.VertexConsumer)6 Color (java.awt.Color)5 Vec3f (net.minecraft.util.math.Vec3f)5 MinecraftClient (net.minecraft.client.MinecraftClient)3 Camera (net.minecraft.client.render.Camera)3 Tessellator (net.minecraft.client.render.Tessellator)3 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)3 Vector3f (net.minecraft.client.util.math.Vector3f)3 Vector4f (net.minecraft.client.util.math.Vector4f)3 FloatBuffer (java.nio.FloatBuffer)2 ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)2 Entity (net.minecraft.entity.Entity)2 LiteralText (net.minecraft.text.LiteralText)2