Search in sources :

Example 11 with Matrix3f

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

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

the class SmoothModelPart2 method renderSmoothCuboids.

private void renderSmoothCuboids(MatrixStack.Entry defaultEntry, MatrixStack.Entry parentEntry, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) {
    Matrix4f defaultPosMat = defaultEntry.getModel();
    Matrix3f defaultNormal = defaultEntry.getNormal();
    Matrix4f parentPosMat = parentEntry.getModel();
    Matrix3f parentNormal = parentEntry.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(parentNormal);
            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 (shouldFollowParent(indexV++, quadDirection, direction)) {
                    posVec.transform(parentPosMat);
                    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)

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