28 lines
848 B
Python
28 lines
848 B
Python
|
#!/usr/bin/python3
|
||
|
|
||
|
from mesh.base import BaseMesh
|
||
|
from mesh.chunk_builder import build_chunk_mesh
|
||
|
|
||
|
|
||
|
class ChunkMesh(BaseMesh):
|
||
|
def __init__(self, chunk):
|
||
|
super().__init__()
|
||
|
self.app = chunk.app
|
||
|
self.chunk = chunk
|
||
|
self.ctx = self.app.ctx
|
||
|
self.program = self.app.shader_program.chunk
|
||
|
|
||
|
self.vbo_format = "3u1 1u1 1u1 1u1 1u1"
|
||
|
self.format_size = sum(int(fmt[:1]) for fmt in self.vbo_format.split())
|
||
|
self.attributes = ("in_position", "voxel_id", "face_id", "ao_id", "flip_id")
|
||
|
self.vao = self.get_vao()
|
||
|
|
||
|
def get_vertex_data(self):
|
||
|
mesh = build_chunk_mesh(
|
||
|
chunk_voxels=self.chunk.voxels,
|
||
|
format_size=self.format_size,
|
||
|
chunk_pos=self.chunk.position,
|
||
|
world_voxels=self.chunk.world.voxels
|
||
|
)
|
||
|
|
||
|
return mesh
|