use of io.xol.chunkstories.api.world.chunk.DummyChunk in project chunkstories-api by Hugobros3.
the class VoxelItemRenderer method bakeVoxelRenderer.
/**
* Bake a single cell's content into a buffer
*/
private void bakeVoxelRenderer(CellData cell, VertexBuffer mesh) {
ByteBuffer buffer = ByteBuffer.allocateDirect(16384).order(ByteOrder.nativeOrder());
VoxelInHandLayoutBaker specialSauce = new VoxelInHandLayoutBaker(this.content, buffer);
// Dummy objects that point to our special sauce
ChunkRenderer chunkRenderer = new ChunkRenderer() {
@Override
public VoxelBakerHighPoly getHighpolyBakerFor(LodLevel lodLevel, ShadingType renderPass) {
return specialSauce;
}
@Override
public VoxelBakerCubic getLowpolyBakerFor(LodLevel lodLevel, ShadingType renderPass) {
return specialSauce;
}
};
VoxelRenderer voxelRenderer = cell.getVoxelRenderer();
if (voxelRenderer == null) {
voxelRenderer = cell.getVoxel().store().models().getVoxelModel("default");
}
// Render into a dummy chunk ( containing only that one voxel we want )
voxelRenderer.bakeInto(chunkRenderer, bakingContext, new DummyChunk() {
@Override
public int peekRaw(int x, int y, int z) {
// return bri.getData();
return 0;
}
}, cell);
// Flip the buffer and upload it
buffer.flip();
mesh.uploadData(buffer);
}
Aggregations