diff --git a/include/data.inc b/include/data.inc index b6bef8b..c7e97c3 100644 --- a/include/data.inc +++ b/include/data.inc @@ -8,3 +8,11 @@ short index_buffer_configuration_offsets[] = { 768, 780, 798, 816, 840, 858, 882, 906, 936, 954, 978, 1002, 1032, 1056, 1086, 1116, }; +struct { + short offset; + short count; +} index_buffer_custom_offsets[] = { + {1152, 12}, // tallgrass.obj + {1164, 36}, // fence.obj + {1200, 36}, // torch.obj +}; diff --git a/minecraft/configuration.idx b/minecraft/configuration.idx index 58df8cc..9dd0708 100644 Binary files a/minecraft/configuration.idx and b/minecraft/configuration.idx differ diff --git a/minecraft/gen/fence.obj b/minecraft/gen/fence.obj new file mode 100644 index 0000000..0b05179 --- /dev/null +++ b/minecraft/gen/fence.obj @@ -0,0 +1,48 @@ +# Blender 5.0.0 +# www.blender.org +o Cube +v 0.250000 1.000000 -0.250000 +v 0.250000 -1.000000 -0.250000 +v 0.250000 1.000000 0.250000 +v 0.250000 -1.000000 0.250000 +v -0.250000 1.000000 -0.250000 +v -0.250000 -1.000000 -0.250000 +v -0.250000 1.000000 0.250000 +v -0.250000 -1.000000 0.250000 +vn -0.0000 1.0000 -0.0000 +vn -0.0000 -0.0000 1.0000 +vn -1.0000 -0.0000 -0.0000 +vn -0.0000 -1.0000 -0.0000 +vn 1.0000 -0.0000 -0.0000 +vn -0.0000 -0.0000 -1.0000 +vt 0.250000 1.250000 +vt 0.500000 1.000000 +vt 0.500000 1.250000 +vt 0.250050 0.000100 +vt 0.500000 0.999900 +vt 0.250050 0.999900 +vt 0.500000 0.000100 +vt 0.749950 0.999900 +vt 0.250000 0.000000 +vt 0.500000 -0.250000 +vt 0.500000 0.000000 +vt 0.000100 0.000100 +vt 0.000100 0.999900 +vt 0.749950 0.000100 +vt 0.999900 0.999900 +vt 0.250000 1.000000 +vt 0.250000 -0.250000 +vt 0.999900 0.000100 +s 0 +f 5/1/1 3/2/1 1/3/1 +f 3/4/2 8/5/2 4/6/2 +f 7/7/3 6/8/3 8/5/3 +f 2/9/4 8/10/4 6/11/4 +f 1/12/5 4/6/5 2/13/5 +f 5/14/6 2/15/6 6/8/6 +f 5/1/1 7/16/1 3/2/1 +f 3/4/2 7/7/2 8/5/2 +f 7/7/3 5/14/3 6/8/3 +f 2/9/4 4/17/4 8/10/4 +f 1/12/5 3/4/5 4/6/5 +f 5/14/6 1/18/6 2/15/6 diff --git a/minecraft/gen/mc.py b/minecraft/gen/mc.py index b77c26d..5149a5c 100644 --- a/minecraft/gen/mc.py +++ b/minecraft/gen/mc.py @@ -4,12 +4,15 @@ from pprint import pprint from itertools import chain from collections import defaultdict import functools +import os import mcregion import vec3 import vertex_buffer import data +FAST = "FAST" in os.environ + def wrap_n(nc, chunk_c): if nc < 0: nc = 15 @@ -19,14 +22,24 @@ def wrap_n(nc, chunk_c): chunk_c = chunk_c + 1 return nc, chunk_c -non_solid_blocks = { - data.BlockID.TALL_GRASS, - data.BlockID.MUSHROOM_1, - data.BlockID.MUSHROOM_2, - data.BlockID.FLOWER, - data.BlockID.ROSE, - data.BlockID.SAPLING, -} +custom_blocks = [ + { # "tallgrass" model + data.BlockID.TALL_GRASS, + data.BlockID.MUSHROOM_1, + data.BlockID.MUSHROOM_2, + data.BlockID.FLOWER, + data.BlockID.ROSE, + data.BlockID.SAPLING, + }, + { # "fence" model + data.BlockID.FENCE, + }, + { # "torch" model + data.BlockID.TORCH, + }, +] + +non_solid_blocks = set(chain.from_iterable(custom_blocks)) def neighbor_exists(level_table, chunk_x, chunk_z, nx, ny, nz): if ny > 127 or ny < 0: @@ -67,6 +80,8 @@ def devoxelize_region(level_table, level_table_keys): for chunk_x, chunk_z in level_table_keys: for block_index in range(128 * 16 * 16): yield from block_neighbors(level_table, chunk_x, chunk_z, block_index) + if FAST: + return def build_level_table(level_table, mem, locations): for location in locations: @@ -92,15 +107,6 @@ def build_block_configuration_table(): indices.extend(vertex_buffer.faces_by_normal[vertex_buffer.normals[j]]) yield indices -non_cube_blocks = { - data.BlockID.TALL_GRASS, - data.BlockID.MUSHROOM_1, - data.BlockID.MUSHROOM_2, - data.BlockID.FLOWER, - data.BlockID.ROSE, - data.BlockID.SAPLING, -} - def pack_instance_data(position, block_id): packed = struct.pack("