add support for slabs

This commit is contained in:
Zack Buhman 2026-03-23 13:18:10 -05:00
parent 5a18050878
commit d7db5d666c
20 changed files with 54 additions and 9 deletions

View File

@ -16,7 +16,8 @@ struct {
{1152, 3180}, // candle.obj
{4332, 1584}, // custom_mushroom.obj
{5916, 36}, // fence.obj
{5952, 24}, // stair.obj
{5976, 12}, // tall_grass.obj
{5988, 2082}, // wall_torch.obj
{5952, 24}, // slab.obj
{5976, 24}, // stair.obj
{6000, 12}, // tall_grass.obj
{6012, 2082}, // wall_torch.obj
};

View File

@ -26,7 +26,7 @@ namespace world {
};
// also update index_buffer_custom_offsets in include/minecraft_data.inc
const int custom_block_types = 6;
const int custom_block_types = 7;
const int instance_cfg_length = 64 + custom_block_types;
struct instance_cfg_entry {

Binary file not shown.

View File

@ -24,6 +24,7 @@ Lilac Grass,37,,15,tall_grass,two_sided,,
Spider Plant,38,,13,tall_grass,two_sided,,
Spider Plant,39,,13,tall_grass,two_sided,,
Red Mushroom,40,,14,custom_mushroom,,,
Slab,44,"0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15",4,slab,slab_oriented,,
Start/Finish Line,45,,16,,,,
Shadow Block,49,,20,,,,
Wall Torch,50,"1,2,3,4",62,wall_torch,"emits_light,torch_oriented",,

1 name block id data linear texture index custom mesh properties notes
24 Spider Plant 38 13 tall_grass two_sided
25 Spider Plant 39 13 tall_grass two_sided
26 Red Mushroom 40 14 custom_mushroom
27 Slab 44 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 4 slab slab_oriented
28 Start/Finish Line 45 16
29 Shadow Block 49 20
30 Wall Torch 50 1,2,3,4 62 wall_torch emits_light,torch_oriented

View File

@ -85,9 +85,11 @@ def get_special(block_id, block_data):
return 1
if "stair_oriented" in decl.properties:
return 2
if "slab_oriented" in decl.properties:
return 3
return 0
if __name__ == "__main__":
from pprint import pprint
#print(sorted_custom_mesh)
pprint(sorted_decls)
print(sorted_custom_mesh)
#pprint(sorted_decls)

View File

@ -125,9 +125,13 @@ def build_block_instances(blocks):
light_sources = []
for position, block_id, block_data, normal_indices in blocks:
if block_id == 44:
print("bd", block_data)
if block_ids.is_light_source(block_id, block_data):
light_sources.append((position, block_id, block_data))
if not block_ids.is_cube_block(block_id, block_data):
if block_id == 44:
print(block_id)
custom_mesh_index = block_ids.get_custom_mesh_index(block_id, block_data)
non_cube_blocks[custom_mesh_index].append((position, block_id, block_data))
continue

View File

@ -17,4 +17,4 @@ def write_obj(vertex_buffer, index_buffer, index_lookup, path):
state = obj.parse_obj_from_filename(path)
obj_state.append_triangles(state, vertex_buffer, index_buffer, index_lookup)
index_count = len(index_buffer) - index_start
print(f"{index_start}, {index_count}, // {path}")
print(f"{{{index_start}, {index_count}}}, // {path}")

35
minecraft/gen/slab.obj Normal file
View File

@ -0,0 +1,35 @@
# Blender 5.0.0
# www.blender.org
o Plane
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v 1.000000 -1.000000 -1.000000
v -1.000000 -1.000000 -1.000000
v 1.000000 0.000000 0.000000
v -1.000000 -0.000000 0.000000
vn 1.0000 -0.0000 -0.0000
vn -1.0000 -0.0000 -0.0000
vn -0.0000 0.7071 0.7071
vn -0.0000 0.7071 -0.7071
vn -0.0000 -1.0000 -0.0000
vt 0.500000 0.500000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 0.500000 0.500000
vt 0.000000 0.500000
vt 1.000000 0.500000
vt 1.000000 1.000000
vt 0.000000 0.500000
vt 0.000000 1.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 1.000000 0.500000
s 0
f 5/1/1 1/2/1 3/3/1
f 6/4/2 4/2/2 2/3/2
f 2/3/3 5/5/3 6/6/3
f 5/7/4 4/8/4 6/9/4
f 1/2/5 4/10/5 3/11/5
f 2/3/3 1/2/3 5/5/3
f 5/7/4 3/12/4 4/8/4
f 1/2/5 2/3/5 4/10/5

Binary file not shown.

View File

@ -41,5 +41,6 @@ void main()
Position = fs_in.Position.xzy;
Normal = vec4(normalize(fs_in.Normal.xzy), two_sided);
Color = texture_color.xyz;
//Color = vec3(normalize(fs_in.Normal.xzy));
Block = vec4(fs_in.BlockID, fs_in.Data, fs_in.TextureID, fs_in.Special);
}

View File

@ -105,8 +105,9 @@ namespace hud {
font::bitmap::draw_string(ter_best, " elevate: q/e", 10, y); y += ter_best.desc->glyph_height;
font::bitmap::draw_string(ter_best, " warp: l", 10, y); y += ter_best.desc->glyph_height;
font::bitmap::draw_string(ter_best, "gamepad:", 10, y); y += ter_best.desc->glyph_height;
font::bitmap::draw_string(ter_best, " move: right stick", 10, y); y += ter_best.desc->glyph_height;
font::bitmap::draw_string(ter_best, " look: left stick", 10, y); y += ter_best.desc->glyph_height;
font::bitmap::draw_string(ter_best, " move: left stick", 10, y); y += ter_best.desc->glyph_height;
font::bitmap::draw_string(ter_best, " look: right stick", 10, y); y += ter_best.desc->glyph_height;
font::bitmap::draw_string(ter_best, " elevate: left/right trigger", 10, y); y += ter_best.desc->glyph_height;
font::bitmap::draw_string(ter_best, " warp: a", 10, y); y += ter_best.desc->glyph_height;