use of com.mojang.blaze3d.vertex.VertexConsumer in project MinecraftForge by MinecraftForge.
the class BakedRenderable method render.
@Override
public void render(PoseStack poseStack, MultiBufferSource bufferSource, Function<ResourceLocation, RenderType> renderTypeFunction, int lightmapCoord, int overlayCoord, float partialTicks, IModelData renderValues) {
var rt = renderTypeFunction.apply(InventoryMenu.BLOCK_ATLAS);
VertexConsumer bb = bufferSource.getBuffer(rt);
for (Direction direction : MODEL_FACINGS) {
for (BakedQuad quad : model.getQuads(null, direction, rand, renderValues)) {
bb.putBulkData(poseStack.last(), quad, 1, 1, 1, 1, lightmapCoord, overlayCoord, true);
}
}
}
use of com.mojang.blaze3d.vertex.VertexConsumer in project MinecraftForge by MinecraftForge.
the class IForgeVertexConsumer method putBulkData.
// Copy of putBulkData with alpha support
default void putBulkData(PoseStack.Pose matrixEntry, BakedQuad bakedQuad, float[] baseBrightness, float red, float green, float blue, float alpha, int[] lightmapCoords, int overlayCoords, boolean readExistingColor) {
int[] aint = bakedQuad.getVertices();
Vec3i faceNormal = bakedQuad.getDirection().getNormal();
Vector3f normal = new Vector3f((float) faceNormal.getX(), (float) faceNormal.getY(), (float) faceNormal.getZ());
Matrix4f matrix4f = matrixEntry.pose();
normal.transform(matrixEntry.normal());
int intSize = DefaultVertexFormat.BLOCK.getIntegerSize();
int vertexCount = aint.length / intSize;
try (MemoryStack memorystack = MemoryStack.stackPush()) {
ByteBuffer bytebuffer = memorystack.malloc(DefaultVertexFormat.BLOCK.getVertexSize());
IntBuffer intbuffer = bytebuffer.asIntBuffer();
for (int v = 0; v < vertexCount; ++v) {
((Buffer) intbuffer).clear();
intbuffer.put(aint, v * 8, 8);
float f = bytebuffer.getFloat(0);
float f1 = bytebuffer.getFloat(4);
float f2 = bytebuffer.getFloat(8);
float cr;
float cg;
float cb;
float ca;
if (readExistingColor) {
float r = (float) (bytebuffer.get(12) & 255) / 255.0F;
float g = (float) (bytebuffer.get(13) & 255) / 255.0F;
float b = (float) (bytebuffer.get(14) & 255) / 255.0F;
float a = (float) (bytebuffer.get(15) & 255) / 255.0F;
cr = r * baseBrightness[v] * red;
cg = g * baseBrightness[v] * green;
cb = b * baseBrightness[v] * blue;
ca = a * alpha;
} else {
cr = baseBrightness[v] * red;
cg = baseBrightness[v] * green;
cb = baseBrightness[v] * blue;
ca = alpha;
}
int lightmapCoord = applyBakedLighting(lightmapCoords[v], bytebuffer);
float f9 = bytebuffer.getFloat(16);
float f10 = bytebuffer.getFloat(20);
Vector4f pos = new Vector4f(f, f1, f2, 1.0F);
pos.transform(matrix4f);
applyBakedNormals(normal, bytebuffer, matrixEntry.normal());
((VertexConsumer) this).vertex(pos.x(), pos.y(), pos.z(), cr, cg, cb, ca, f9, f10, overlayCoords, lightmapCoord, normal.x(), normal.y(), normal.z());
}
}
}
Aggregations