Search in sources :

Example 6 with Matrix3f

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

the class Vertexer method vertexLine.

public static void vertexLine(MatrixStack matrices, VertexConsumer vertexConsumer, float x1, float y1, float z1, float x2, float y2, float z2, LineColor lineColor) {
    Matrix4f model = matrices.peek().getPositionMatrix();
    Matrix3f normal = matrices.peek().getNormalMatrix();
    Vec3f normalVec = getNormal(normal, x1, y1, z1, x2, y2, z2);
    int[] color1 = lineColor.getColor(x1, y1, z1, 0);
    int[] color2 = lineColor.getColor(x2, y2, z2, 1);
    vertexConsumer.vertex(model, x1, y1, z1).color(color1[0], color1[1], color1[2], color1[3]).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next();
    vertexConsumer.vertex(model, x2, y2, z2).color(color2[0], color2[1], color2[2], color2[3]).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 7 with Matrix3f

use of net.minecraft.util.math.Matrix3f 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 8 with Matrix3f

use of net.minecraft.util.math.Matrix3f 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)

Example 9 with Matrix3f

use of net.minecraft.util.math.Matrix3f in project wildmod by Osmiooo.

the class FireflyEntityRenderer method render.

@Override
public void render(FireflyEntity entity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
    matrixStack.push();
    // you may need to adjust this
    matrixStack.scale(1, 1, 1);
    matrixStack.translate(0, 0.3, 0);
    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);
    int j = getLight(i);
    vertex(vertexConsumer, matrix4f, matrix3f, j, 0.0F, 0, 0, 1);
    vertex(vertexConsumer, matrix4f, matrix3f, j, 1.0F, 0, 1, 1);
    vertex(vertexConsumer, matrix4f, matrix3f, j, 1.0F, 1, 1, 0);
    vertex(vertexConsumer, matrix4f, matrix3f, j, 0.0F, 1, 0, 0);
    matrixStack.pop();
    super.render(entity, 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)

Example 10 with Matrix3f

use of net.minecraft.util.math.Matrix3f in project MiniMap by pl3xgaming.

the class GL method drawLine.

public static void drawLine(MatrixStack matrixStack, float x0, float y0, float x1, float y1, float width, int color) {
    RenderSystem.setShader(GameRenderer::getRenderTypeLinesShader);
    RenderSystem.lineWidth(width);
    Matrix4f matrix4f = matrixStack.peek().getPositionMatrix();
    Matrix3f matrix3f = matrixStack.peek().getNormalMatrix();
    BufferBuilder buf = Tessellator.getInstance().getBuffer();
    buf.begin(VertexFormat.DrawMode.LINES, VertexFormats.LINES);
    buf.vertex(matrix4f, x0, y0, 0F).color(color).normal(matrix3f, 1F, 1F, 0F).next();
    buf.vertex(matrix4f, x1, y1, 0F).color(color).normal(matrix3f, 1F, 1F, 0F).next();
    buf.end();
    BufferRenderer.draw(buf);
    RenderSystem.lineWidth(1F);
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Matrix3f(net.minecraft.util.math.Matrix3f) BufferBuilder(net.minecraft.client.render.BufferBuilder) GameRenderer(net.minecraft.client.render.GameRenderer)

Aggregations

Matrix3f (net.minecraft.util.math.Matrix3f)12 Matrix4f (net.minecraft.util.math.Matrix4f)12 VertexConsumer (net.minecraft.client.render.VertexConsumer)4 MatrixStack (net.minecraft.client.util.math.MatrixStack)4 Vec3f (net.minecraft.util.math.Vec3f)4 Vector3f (net.minecraft.client.util.math.Vector3f)3 Vector4f (net.minecraft.client.util.math.Vector4f)3 Direction (net.minecraft.util.math.Direction)2 CuboidAccessor (net.sistr.littlemaidmodelloader.client.util.CuboidAccessor)2 ModelPartAccessor (net.sistr.littlemaidmodelloader.client.util.ModelPartAccessor)2 BufferBuilder (net.minecraft.client.render.BufferBuilder)1 GameRenderer (net.minecraft.client.render.GameRenderer)1