use of net.minecraft.util.math.Matrix4f 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());
}
}
}
}
}
use of net.minecraft.util.math.Matrix4f in project JexClient by DustinRepo.
the class ColorOptionButton method drawGradientRect.
protected void drawGradientRect(MatrixStack matrixStack, float left, float top, float right, float bottom, int startColor, int endColor) {
Matrix4f matrix = matrixStack.peek().getPositionMatrix();
float f = (float) (startColor >> 24 & 255) / 255.0F;
float g = (float) (startColor >> 16 & 255) / 255.0F;
float h = (float) (startColor >> 8 & 255) / 255.0F;
float i = (float) (startColor & 255) / 255.0F;
float j = (float) (endColor >> 24 & 255) / 255.0F;
float k = (float) (endColor >> 16 & 255) / 255.0F;
float l = (float) (endColor >> 8 & 255) / 255.0F;
float m = (float) (endColor & 255) / 255.0F;
RenderSystem.disableTexture();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
bufferBuilder.vertex(matrix, (float) right, (float) top, (float) 0).color(g, h, i, f).next();
bufferBuilder.vertex(matrix, (float) left, (float) top, (float) 0).color(1, 1, 1, f).next();
bufferBuilder.vertex(matrix, (float) left, (float) bottom, (float) 0).color(0, 0, 0, j).next();
bufferBuilder.vertex(matrix, (float) right, (float) bottom, (float) 0).color(k, l, m, j).next();
tessellator.draw();
RenderSystem.disableBlend();
RenderSystem.enableTexture();
}
use of net.minecraft.util.math.Matrix4f in project JexClient by DustinRepo.
the class WaypointEditScreen method drawGradientRect.
protected void drawGradientRect(MatrixStack matrixStack, float left, float top, float right, float bottom, int startColor, int endColor) {
Matrix4f matrix = matrixStack.peek().getPositionMatrix();
float f = (float) (startColor >> 24 & 255) / 255.0F;
float g = (float) (startColor >> 16 & 255) / 255.0F;
float h = (float) (startColor >> 8 & 255) / 255.0F;
float i = (float) (startColor & 255) / 255.0F;
float j = (float) (endColor >> 24 & 255) / 255.0F;
float k = (float) (endColor >> 16 & 255) / 255.0F;
float l = (float) (endColor >> 8 & 255) / 255.0F;
float m = (float) (endColor & 255) / 255.0F;
RenderSystem.disableTexture();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
bufferBuilder.vertex(matrix, (float) right, (float) top, (float) 0).color(g, h, i, f).next();
bufferBuilder.vertex(matrix, (float) left, (float) top, (float) 0).color(1, 1, 1, f).next();
bufferBuilder.vertex(matrix, (float) left, (float) bottom, (float) 0).color(0, 0, 0, j).next();
bufferBuilder.vertex(matrix, (float) right, (float) bottom, (float) 0).color(k, l, m, j).next();
tessellator.draw();
RenderSystem.disableBlend();
RenderSystem.enableTexture();
}
Aggregations