Search in sources :

Example 41 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method getRenderPosition.

public static Vec3d getRenderPosition(double x, double y, double z, MatrixStack matrixStack) {
    Matrix4f matrix = matrixStack.peek().getPositionMatrix();
    double minX = x - mc.getEntityRenderDispatcher().camera.getPos().x;
    double minY = y - mc.getEntityRenderDispatcher().camera.getPos().y;
    double minZ = z - mc.getEntityRenderDispatcher().camera.getPos().z;
    Vector4f vector4f = new Vector4f((float) minX, (float) minY, (float) minZ, 1.f);
    vector4f.transform(matrix);
    return new Vec3d(vector4f.getX(), vector4f.getY(), vector4f.getZ());
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) IMatrix4f(dev.hypnotic.utils.mixin.IMatrix4f) Vector4f(net.minecraft.util.math.Vector4f) Vec3d(net.minecraft.util.math.Vec3d)

Example 42 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method line.

public static void line(Vec3d start, Vec3d end, Color color, MatrixStack matrices) {
    float red = color.getRed() / 255f;
    float green = color.getGreen() / 255f;
    float blue = color.getBlue() / 255f;
    float alpha = color.getAlpha() / 255f;
    Camera c = mc.gameRenderer.getCamera();
    Vec3d camPos = c.getPos();
    start = start.subtract(camPos);
    end = end.subtract(camPos);
    Matrix4f matrix = matrices.peek().getPositionMatrix();
    float x1 = (float) start.x;
    float y1 = (float) start.y;
    float z1 = (float) start.z;
    float x2 = (float) end.x;
    float y2 = (float) end.y;
    float z2 = (float) end.z;
    BufferBuilder buffer = Tessellator.getInstance().getBuffer();
    RenderSystem.setShader(GameRenderer::getPositionColorShader);
    GL11.glDepthFunc(GL11.GL_ALWAYS);
    RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
    RenderSystem.defaultBlendFunc();
    RenderSystem.enableBlend();
    buffer.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR);
    buffer.vertex(matrix, x1, y1, z1).color(red, green, blue, alpha).next();
    buffer.vertex(matrix, x2, y2, z2).color(red, green, blue, alpha).next();
    buffer.end();
    BufferRenderer.draw(buffer);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    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) Camera(net.minecraft.client.render.Camera) Vec3d(net.minecraft.util.math.Vec3d)

Example 43 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method renderOutlineIntern.

public static void renderOutlineIntern(Vec3d start, Vec3d dimensions, MatrixStack stack, BufferBuilder buffer) {
    Camera c = mc.gameRenderer.getCamera();
    Vec3d camPos = c.getPos();
    start = start.subtract(camPos);
    Vec3d end = start.add(dimensions);
    Matrix4f matrix = stack.peek().getPositionMatrix();
    float x1 = (float) start.x;
    float y1 = (float) start.y;
    float z1 = (float) start.z;
    float x2 = (float) end.x;
    float y2 = (float) end.y;
    float z2 = (float) end.z;
    buffer.vertex(matrix, x1, y1, z1).next();
    buffer.vertex(matrix, x1, y1, z2).next();
    buffer.vertex(matrix, x1, y1, z2).next();
    buffer.vertex(matrix, x2, y1, z2).next();
    buffer.vertex(matrix, x2, y1, z2).next();
    buffer.vertex(matrix, x2, y1, z1).next();
    buffer.vertex(matrix, x2, y1, z1).next();
    buffer.vertex(matrix, x1, y1, z1).next();
    buffer.vertex(matrix, x1, y2, z1).next();
    buffer.vertex(matrix, x1, y2, z2).next();
    buffer.vertex(matrix, x1, y2, z2).next();
    buffer.vertex(matrix, x2, y2, z2).next();
    buffer.vertex(matrix, x2, y2, z2).next();
    buffer.vertex(matrix, x2, y2, z1).next();
    buffer.vertex(matrix, x2, y2, z1).next();
    buffer.vertex(matrix, x1, y2, z1).next();
    buffer.vertex(matrix, x1, y1, z1).next();
    buffer.vertex(matrix, x1, y2, z1).next();
    buffer.vertex(matrix, x2, y1, z1).next();
    buffer.vertex(matrix, x2, y2, z1).next();
    buffer.vertex(matrix, x2, y1, z2).next();
    buffer.vertex(matrix, x2, y2, z2).next();
    buffer.vertex(matrix, x1, y1, z2).next();
    buffer.vertex(matrix, x1, y2, z2).next();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) IMatrix4f(dev.hypnotic.utils.mixin.IMatrix4f) Camera(net.minecraft.client.render.Camera) Vec3d(net.minecraft.util.math.Vec3d)

Example 44 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method gradientFill.

public static void gradientFill(MatrixStack matrixStack, double x1, double y1, double x2, double y2, int color1, int color2) {
    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(g1, h1, k1, f1).next();
    bufferBuilder.vertex(matrix, (float) x2, (float) y2, 0.0F).color(g1, h1, k1, f1).next();
    bufferBuilder.vertex(matrix, (float) x2, (float) y1, 0.0F).color(g2, h2, k2, f2).next();
    bufferBuilder.vertex(matrix, (float) x1, (float) y1, 0.0F).color(g2, h2, k2, f2).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 45 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method drawFilledBox.

public static void drawFilledBox(MatrixStack matrixStack, Box bb, Color color, boolean draw) {
    Matrix4f matrix4f = matrixStack.peek().getPositionMatrix();
    Color color1 = color;
    setup3DRender(true);
    BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
    if (draw)
        bufferBuilder.begin(VertexFormat.DrawMode.QUADS, /*QUADS*/
        VertexFormats.POSITION_COLOR);
    float minX = (float) bb.minX;
    float minY = (float) bb.minY;
    float minZ = (float) bb.minZ;
    float maxX = (float) bb.maxX;
    float maxY = (float) bb.maxY;
    float maxZ = (float) bb.maxZ;
    bufferBuilder.vertex(matrix4f, minX, minY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, minY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, minY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, minY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, maxY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, maxY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, maxY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, maxY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, minY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, maxY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, maxY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, minY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, minY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, maxY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, maxY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, minY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, minY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, minY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, maxX, maxY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, maxY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, minY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, minY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, maxY, maxZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, minX, maxY, minZ).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    if (draw) {
        bufferBuilder.end();
        BufferRenderer.draw(bufferBuilder);
    }
    end3DRender();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) IMatrix4f(dev.hypnotic.utils.mixin.IMatrix4f) Color(java.awt.Color) BufferBuilder(net.minecraft.client.render.BufferBuilder)

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