use of net.minecraft.client.util.math.Vector3f in project fabric by FabricMC.
the class AoCalculator method irregularFace.
private void irregularFace(MutableQuadViewImpl quad) {
final Vector3f faceNorm = quad.faceNormal();
Vector3f normal;
final float[] w = this.w;
final float[] aoResult = this.ao;
final int[] lightResult = this.light;
for (int i = 0; i < 4; i++) {
normal = quad.hasNormal(i) ? quad.copyNormal(i, vertexNormal) : faceNorm;
float ao = 0, sky = 0, block = 0, maxAo = 0;
int maxSky = 0, maxBlock = 0;
final float x = normal.getX();
if (!MathHelper.equalsApproximate(0f, x)) {
final Direction face = x > 0 ? Direction.EAST : Direction.WEST;
final AoFaceData fd = gatherInsetFace(quad, i, face);
AoFace.get(face).weightFunc.apply(quad, i, w);
final float n = x * x;
final float a = fd.weigtedAo(w);
final int s = fd.weigtedSkyLight(w);
final int b = fd.weigtedBlockLight(w);
ao += n * a;
sky += n * s;
block += n * b;
maxAo = a;
maxSky = s;
maxBlock = b;
}
final float y = normal.getY();
if (!MathHelper.equalsApproximate(0f, y)) {
final Direction face = y > 0 ? Direction.UP : Direction.DOWN;
final AoFaceData fd = gatherInsetFace(quad, i, face);
AoFace.get(face).weightFunc.apply(quad, i, w);
final float n = y * y;
final float a = fd.weigtedAo(w);
final int s = fd.weigtedSkyLight(w);
final int b = fd.weigtedBlockLight(w);
ao += n * a;
sky += n * s;
block += n * b;
maxAo = Math.max(maxAo, a);
maxSky = Math.max(maxSky, s);
maxBlock = Math.max(maxBlock, b);
}
final float z = normal.getZ();
if (!MathHelper.equalsApproximate(0f, z)) {
final Direction face = z > 0 ? Direction.SOUTH : Direction.NORTH;
final AoFaceData fd = gatherInsetFace(quad, i, face);
AoFace.get(face).weightFunc.apply(quad, i, w);
final float n = z * z;
final float a = fd.weigtedAo(w);
final int s = fd.weigtedSkyLight(w);
final int b = fd.weigtedBlockLight(w);
ao += n * a;
sky += n * s;
block += n * b;
maxAo = Math.max(maxAo, a);
maxSky = Math.max(maxSky, s);
maxBlock = Math.max(maxBlock, b);
}
aoResult[i] = (ao + maxAo) * 0.5f;
lightResult[i] = (((int) ((sky + maxSky) * 0.5f) & 0xF0) << 16) | ((int) ((block + maxBlock) * 0.5f) & 0xF0);
}
}
use of net.minecraft.client.util.math.Vector3f in project Biome-Makeover by Lemonszz.
the class BMBoatRender method render.
public void render(BMBoatEntity boatEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
matrixStack.push();
matrixStack.translate(0.0D, 0.375D, 0.0D);
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(180.0F - f));
float h = (float) boatEntity.getDamageWobbleTicks() - g;
float j = boatEntity.getDamageWobbleStrength() - g;
if (j < 0.0F) {
j = 0.0F;
}
if (h > 0.0F) {
matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(MathHelper.sin(h) * h * j / 10.0F * (float) boatEntity.getDamageWobbleSide()));
}
float k = boatEntity.interpolateBubbleWobble(g);
if (!MathHelper.approximatelyEquals(k, 0.0F)) {
matrixStack.multiply(new Quaternion(new Vector3f(1.0F, 0.0F, 1.0F), boatEntity.interpolateBubbleWobble(g), true));
}
matrixStack.scale(-1.0F, -1.0F, 1.0F);
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(90.0F));
this.model.setAngles(boatEntity, g, 0.0F, -0.1F, 0.0F, 0.0F);
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(this.model.getLayer(this.getTexture(boatEntity)));
this.model.render(matrixStack, vertexConsumer, i, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
VertexConsumer vertexConsumer2 = vertexConsumerProvider.getBuffer(RenderLayer.getWaterMask());
this.model.getBottom().render(matrixStack, vertexConsumer2, i, OverlayTexture.DEFAULT_UV);
matrixStack.pop();
super.render(boatEntity, f, g, matrixStack, vertexConsumerProvider, i);
}
use of net.minecraft.client.util.math.Vector3f 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());
}
}
}
}
}
Aggregations