use of io.xol.chunkstories.voxel.VoxelTextureAtlased in project chunkstories by Hugobros3.
the class FarTerrainMeshRenderer method getBlocksTexturesSummary.
/**
* Dirty and stupid
*/
public Texture1D getBlocksTexturesSummary() {
if (!blocksTexturesSummaryDone) {
int size = 512;
ByteBuffer bb = ByteBuffer.allocateDirect(size * 4);
bb.order(ByteOrder.LITTLE_ENDIAN);
int counter = 0;
Iterator<VoxelTexture> i = world.getContent().voxels().textures().all();
while (i.hasNext() && counter < size) {
VoxelTextureAtlased voxelTexture = (VoxelTextureAtlased) i.next();
bb.put((byte) (voxelTexture.getColor().x() * 255));
bb.put((byte) (voxelTexture.getColor().y() * 255));
bb.put((byte) (voxelTexture.getColor().z() * 255));
bb.put((byte) (voxelTexture.getColor().w() * 255));
voxelTexture.positionInColorIndex = counter;
counter++;
}
// Padding
while (counter < size) {
bb.put((byte) (0));
bb.put((byte) (0));
bb.put((byte) (0));
bb.put((byte) (0));
counter++;
}
bb.flip();
blockTexturesSummary.uploadTextureData(size, bb);
blockTexturesSummary.setLinearFiltering(false);
blocksTexturesSummaryDone = true;
}
return blockTexturesSummary;
}
use of io.xol.chunkstories.voxel.VoxelTextureAtlased in project chunkstories by Hugobros3.
the class HeightmapArrayTexture method loadTopVoxels.
private void loadTopVoxels(HeightmapImplementation sum, ByteBuffer bb, int lod) {
bb.clear();
int[] data = sum.getVoxelData();
ScratchCell cell = new ScratchCell(world);
cell.sunlight = 15;
for (int i = 0; i < size[lod] * size[lod]; i++) {
int j = HeightmapImplementation.mainMimpmapOffsets[lod] + i;
int raw_data = data[j];
Voxel v = world.getContentTranslator().getVoxelForId(VoxelFormat.id(raw_data));
cell.voxel = v;
if (v.getDefinition().isLiquid())
bb.putInt(512);
else
bb.putInt(((VoxelTextureAtlased) v.getVoxelTexture(VoxelSide.TOP, cell)).positionInColorIndex);
}
bb.flip();
}
Aggregations