Search in sources :

Example 21 with Matrix4f

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

the class Radar method drawPointer.

private void drawPointer(MatrixStack matrixStack) {
    Matrix4f matrix4f = matrixStack.peek().getPositionMatrix();
    Color color1 = color.getColor();
    RenderUtils.setup2DRender(false);
    BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
    matrixStack.scale(2.5f, 2.5f, 2.5f);
    matrixStack.translate(0, 1.5, 0);
    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, /*QUADS*/
    VertexFormats.POSITION_COLOR);
    bufferBuilder.vertex(matrix4f, 0, -4, 0).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, -1, 0, 0).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, 1, 0, 0).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.vertex(matrix4f, 0, -4, 0).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    bufferBuilder.end();
    BufferRenderer.draw(bufferBuilder);
    RenderUtils.end2DRender();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Color(java.awt.Color) BufferBuilder(net.minecraft.client.render.BufferBuilder)

Example 22 with Matrix4f

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

the class ESP method renderOutline.

void renderOutline(Entity e, Color color, MatrixStack stack) {
    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();
    Vec3d start = e.getPos().subtract(camPos);
    float x = (float) start.x;
    float y = (float) start.y;
    float z = (float) start.z;
    double r = Math.toRadians(-c.getYaw() + 90);
    float sin = (float) (Math.sin(r) * (e.getWidth() / 1.7));
    float cos = (float) (Math.cos(r) * (e.getWidth() / 1.7));
    stack.push();
    Matrix4f matrix = stack.peek().getPositionMatrix();
    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, x + sin, y, z + cos).color(red, green, blue, alpha).next();
    buffer.vertex(matrix, x - sin, y, z - cos).color(red, green, blue, alpha).next();
    buffer.vertex(matrix, x - sin, y, z - cos).color(red, green, blue, alpha).next();
    buffer.vertex(matrix, x - sin, y + e.getHeight(), z - cos).color(red, green, blue, alpha).next();
    buffer.vertex(matrix, x - sin, y + e.getHeight(), z - cos).color(red, green, blue, alpha).next();
    buffer.vertex(matrix, x + sin, y + e.getHeight(), z + cos).color(red, green, blue, alpha).next();
    buffer.vertex(matrix, x + sin, y + e.getHeight(), z + cos).color(red, green, blue, alpha).next();
    buffer.vertex(matrix, x + sin, y, z + cos).color(red, green, blue, alpha).next();
    buffer.end();
    BufferRenderer.draw(buffer);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    RenderSystem.disableBlend();
    stack.pop();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) 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 23 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project Paradise-Lost by devs-immortal.

the class InGameOverlayRendererMixin method renderInAercloudOverlay.

// Follows the same procedures as the renderUnderwaterOverlay method in the original class
private static void renderInAercloudOverlay(MinecraftClient minecraftClient, Block block, MatrixStack matrixStack) {
    minecraftClient.getTextureManager().bindTexture(new Identifier("the_aether:textures/block/aercloud_overlay.png"));
    // color[0] = red, color[1] = green, color[2] = blue
    int[] color = rgbFromMaterialColor(block.getDefaultMaterialColor());
    BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    // m and n move the overlay as the player rotates
    float m = -minecraftClient.player.yaw / 256.0F;
    float n = minecraftClient.player.pitch / 256.0F;
    Matrix4f matrix4f = matrixStack.peek().getModel();
    bufferBuilder.begin(7, VertexFormats.POSITION_COLOR_TEXTURE);
    // The reason it's 255-color[n] is because this function calculates colors backwards.
    bufferBuilder.vertex(matrix4f, -2.0F, -2.0F, -0.5F).color(255 - color[0], 255 - color[1], 255 - color[2], 0.4F).texture(4.0F + m, 4.0F + n).next();
    bufferBuilder.vertex(matrix4f, 2.0F, -2.0F, -0.5F).color(255 - color[0], 255 - color[1], 255 - color[2], 0.4F).texture(0.0F + m, 4.0F + n).next();
    bufferBuilder.vertex(matrix4f, 2.0F, 2.0F, -0.5F).color(255 - color[0], 255 - color[1], 255 - color[2], 0.4F).texture(0.0F + m, 0.0F + n).next();
    bufferBuilder.vertex(matrix4f, -2.0F, 2.0F, -0.5F).color(255 - color[0], 255 - color[1], 255 - color[2], 0.4F).texture(4.0F + m, 0.0F + n).next();
    bufferBuilder.end();
    // Overlays it on the screen
    BufferRenderer.draw(bufferBuilder);
    RenderSystem.disableBlend();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Identifier(net.minecraft.util.Identifier) BufferBuilder(net.minecraft.client.render.BufferBuilder)

Example 24 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project LittleMaidModelLoader-Fabric by SistrScarlet.

the class SmoothModelPart method renderSmoothCuboids.

private void renderSmoothCuboids(MatrixStack.Entry defaultEntry, MatrixStack.Entry childEntry, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) {
    Matrix4f defaultPosMat = defaultEntry.getModel();
    Matrix3f defaultNormal = defaultEntry.getNormal();
    Matrix4f childPosMat = childEntry.getModel();
    Matrix3f childNormal = childEntry.getNormal();
    ObjectList<Cuboid> cuboids = ((ModelPartAccessor) this).getCuboids();
    for (Cuboid cuboid : cuboids) {
        Quad[] quads = ((CuboidAccessor) cuboid).getQuads();
        // ここで値取ってこれと一致する頂点をーの方がいいかもね
        int indexQ = 0;
        for (Quad quad : quads) {
            Direction quadDirection = getQuadDirection(indexQ++);
            Vector3f defaultNormalVec = quad.direction.copy();
            defaultNormalVec.transform(defaultNormal);
            Vector3f smoothNormalVec = quad.direction.copy();
            smoothNormalVec.transform(childNormal);
            int indexV = 0;
            for (Vertex vertex : quad.vertices) {
                Vector4f posVec = new Vector4f(vertex.pos.getX() / 16.0F, vertex.pos.getY() / 16.0F, vertex.pos.getZ() / 16.0F, 1.0F);
                if (shouldRotate(indexV++, quadDirection, direction)) {
                    posVec.transform(childPosMat);
                    vertexConsumer.vertex(posVec.getX(), posVec.getY(), posVec.getZ(), red, green, blue, alpha, vertex.u, vertex.v, overlay, light, smoothNormalVec.getX(), smoothNormalVec.getY(), smoothNormalVec.getZ());
                } else {
                    posVec.transform(defaultPosMat);
                    vertexConsumer.vertex(posVec.getX(), posVec.getY(), posVec.getZ(), red, green, blue, alpha, vertex.u, vertex.v, overlay, light, defaultNormalVec.getX(), defaultNormalVec.getY(), defaultNormalVec.getZ());
                }
            }
        }
    }
}
Also used : ModelPartAccessor(net.sistr.littlemaidmodelloader.client.util.ModelPartAccessor) Direction(net.minecraft.util.math.Direction) Matrix4f(net.minecraft.util.math.Matrix4f) Vector4f(net.minecraft.client.util.math.Vector4f) Matrix3f(net.minecraft.util.math.Matrix3f) Vector3f(net.minecraft.client.util.math.Vector3f) CuboidAccessor(net.sistr.littlemaidmodelloader.client.util.CuboidAccessor)

Example 25 with Matrix4f

use of net.minecraft.util.math.Matrix4f in project LittleMaidModelLoader-Fabric by SistrScarlet.

the class ModelRenderer method doRender.

private void doRender(MatrixStack.Entry matrixEntryIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
    Matrix4f matrix4f = matrixEntryIn.getModel();
    Matrix3f matrix3f = matrixEntryIn.getNormal();
    for (ModelBoxBase modelBoxBase : this.cubeList) {
        for (ModelBoxBase.TexturedQuad quad : modelBoxBase.quadList) {
            // 互換性のためにnormalを@Nullableにしているため、ここで計算する
            if (quad.normal == null) {
                Vector3f n1 = quad.vertexPositions[0].position.copy();
                Vector3f n2 = quad.vertexPositions[2].position.copy();
                n1.subtract(quad.vertexPositions[1].position);
                n2.subtract(quad.vertexPositions[1].position);
                n2.cross(n1);
                n2.normalize();
                quad.normal = n2;
            }
            Vector3f normal = quad.normal.copy();
            normal.transform(matrix3f);
            float normalX = normal.getX();
            float normalY = normal.getY();
            float normalZ = normal.getZ();
            for (int i = 0; i < 4; ++i) {
                ModelBoxBase.PositionTextureVertex vertex = quad.vertexPositions[i];
                float f3 = vertex.position.getX() / 16.0F;
                float f4 = vertex.position.getY() / 16.0F;
                float f5 = vertex.position.getZ() / 16.0F;
                Vector4f vector4f = new Vector4f(f3, f4, f5, 1.0F);
                vector4f.transform(matrix4f);
                bufferIn.vertex(vector4f.getX(), vector4f.getY(), vector4f.getZ(), red, green, blue, alpha, vertex.textureU, vertex.textureV, packedOverlayIn, packedLightIn, normalX, normalY, normalZ);
            }
        }
    }
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Vector4f(net.minecraft.client.util.math.Vector4f) Matrix3f(net.minecraft.util.math.Matrix3f) Vector3f(net.minecraft.client.util.math.Vector3f)

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