wheat, ladders

This commit is contained in:
Zack Buhman 2026-03-09 19:47:12 -05:00
parent 7428b86b9e
commit 50188813f8
16 changed files with 56 additions and 6 deletions

View File

@ -15,4 +15,5 @@ struct {
{1152, 12}, // tallgrass.obj {1152, 12}, // tallgrass.obj
{1164, 36}, // fence.obj {1164, 36}, // fence.obj
{1200, 36}, // torch.obj {1200, 36}, // torch.obj
{1236, 24}, // wheat.obj
}; };

Binary file not shown.

View File

@ -257,6 +257,7 @@ class Texture:
ORE_LAPIS = 160 ORE_LAPIS = 160
POWERED_RAIL = 163 POWERED_RAIL = 163
REDSTONE_DUST = 164 REDSTONE_DUST = 164
REDSTONE_DUST_LINE = 165
DETECTOR_RAIL = 195 DETECTOR_RAIL = 195
@ -319,6 +320,7 @@ tiles = [
Tile(BlockID.OBSIDIAN, Texture.OBSIDIAN), Tile(BlockID.OBSIDIAN, Texture.OBSIDIAN),
Tile(BlockID.TORCH, Texture.TORCH_LIT), Tile(BlockID.TORCH, Texture.TORCH_LIT),
Tile(BlockID.STAIRS_WOOD, Texture.PLANKS), # fixme Tile(BlockID.STAIRS_WOOD, Texture.PLANKS), # fixme
Tile(BlockID.WIRE, Texture.REDSTONE_DUST),
Tile(BlockID.ORE_EMERALD, Texture.ORE_EMERALD), Tile(BlockID.ORE_EMERALD, Texture.ORE_EMERALD),
Tile(BlockID.BLOCK_EMERALD, Texture.EMERALD), Tile(BlockID.BLOCK_EMERALD, Texture.EMERALD),
Tile(BlockID.FARMLAND, Texture.FARMLAND), # fixme Tile(BlockID.FARMLAND, Texture.FARMLAND), # fixme

View File

@ -37,10 +37,18 @@ custom_blocks = [
{ # "torch" model { # "torch" model
data.BlockID.TORCH, data.BlockID.TORCH,
}, },
{ # "wheat" model
data.BlockID.WHEAT,
},
] ]
non_solid_blocks = set(chain.from_iterable(custom_blocks)) non_solid_blocks = set(chain.from_iterable(custom_blocks))
hack_non_solid_blocks = set([
data.BlockID.LADDER,
data.BlockID.WIRE,
])
def neighbor_exists(level_table, chunk_x, chunk_z, nx, ny, nz): def neighbor_exists(level_table, chunk_x, chunk_z, nx, ny, nz):
if ny > 127 or ny < 0: if ny > 127 or ny < 0:
return False return False
@ -54,7 +62,7 @@ def neighbor_exists(level_table, chunk_x, chunk_z, nx, ny, nz):
n_block_index = mcregion.block_index_from_xyz(nx, ny, nz) n_block_index = mcregion.block_index_from_xyz(nx, ny, nz)
n_block_id = level_table[key].blocks[n_block_index] n_block_id = level_table[key].blocks[n_block_index]
has_neighbor = (n_block_id != data.BlockID.AIR) and (n_block_id not in non_solid_blocks) has_neighbor = (n_block_id != data.BlockID.AIR) and (n_block_id not in non_solid_blocks) and (n_block_id not in hack_non_solid_blocks)
return has_neighbor return has_neighbor
def block_neighbors(level_table, chunk_x, chunk_z, block_index): def block_neighbors(level_table, chunk_x, chunk_z, block_index):
@ -76,7 +84,7 @@ def block_neighbors(level_table, chunk_x, chunk_z, block_index):
yield i yield i
normal_indices = list(find_non_neighbors()) normal_indices = list(find_non_neighbors())
if block_id in non_solid_blocks or normal_indices: if block_id in non_solid_blocks or block_id in hack_non_solid_blocks or normal_indices:
yield center_position, block_id, block_data, normal_indices yield center_position, block_id, block_data, normal_indices
def devoxelize_region(level_table, level_table_keys): def devoxelize_region(level_table, level_table_keys):

View File

@ -73,6 +73,8 @@ def main():
write_custom_obj(f, vertex_buffer, index_buffer, index_lookup, "fence.obj") write_custom_obj(f, vertex_buffer, index_buffer, index_lookup, "fence.obj")
index_lookup = {} index_lookup = {}
write_custom_obj(f, vertex_buffer, index_buffer, index_lookup, "torch.obj") write_custom_obj(f, vertex_buffer, index_buffer, index_lookup, "torch.obj")
index_lookup = {}
write_custom_obj(f, vertex_buffer, index_buffer, index_lookup, "wheat.obj")
with open("../per_vertex.vtx", "wb") as f: with open("../per_vertex.vtx", "wb") as f:
build_vertex_buffer(f, vertex_buffer) build_vertex_buffer(f, vertex_buffer)

36
minecraft/gen/wheat.obj Normal file
View File

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -80,7 +80,8 @@ static unsigned int per_vertex_buffer;
static const int vertex_size = 8; static const int vertex_size = 8;
static const int per_vertex_size = (3 + 3 + 2) * 2; static const int per_vertex_size = (3 + 3 + 2) * 2;
static const int custom_block_types = 3; // also update index_buffer_custom_offsets in data.inc
static const int custom_block_types = 4;
static const int instance_cfg_length = 64 + custom_block_types; static const int instance_cfg_length = 64 + custom_block_types;
struct instance_cfg { struct instance_cfg {
@ -457,10 +458,10 @@ void load(const char * source_path)
load_texture_id_uniform_buffer(); load_texture_id_uniform_buffer();
view_state.up = XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f); view_state.up = XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f);
view_state.eye = XMVectorSet(50.5f, 40.25f, 59.0f, 1); view_state.eye = XMVectorSet(-55.5f, 48.25f, 50.0f, 1);
view_state.forward = XMVectorSet(0.93, -0.38, 0, 0); view_state.forward = XMVectorSet(-0.63, 0.78, 0, 0);
view_state.direction = view_state.forward; view_state.direction = view_state.forward;
view_state.pitch = -0.278; view_state.pitch = -0.11;
view_state.fov = 1.5; view_state.fov = 1.5;