diff --git a/assets/cubyz/blocks/baobab_branch.zig.zon b/assets/cubyz/blocks/baobab_branch.zig.zon index 97d0afba..94d8a0f6 100644 --- a/assets/cubyz/blocks/baobab_branch.zig.zon +++ b/assets/cubyz/blocks/baobab_branch.zig.zon @@ -6,8 +6,15 @@ }, .absorbedLight = 0x202830, .rotation = .branch, - .model = "cubyz:branch", - .texture = "cubyz:baobab_log", + .model = .{ + .radius = 4, + }, + .texture_top = "cubyz:branch/baobab/dot", + .texture_bottom = "cubyz:branch/baobab/half_line", + .texture_right = "cubyz:branch/baobab/line", + .texture_left = "cubyz:branch/baobab/bend", + .texture_front = "cubyz:branch/baobab/intersection", + .texture_back = "cubyz:branch/baobab/cross", .item = .{ .material = .{ .density = 0.2, diff --git a/assets/cubyz/blocks/birch_branch.zig.zon b/assets/cubyz/blocks/birch_branch.zig.zon index e9c76b75..639b5c05 100644 --- a/assets/cubyz/blocks/birch_branch.zig.zon +++ b/assets/cubyz/blocks/birch_branch.zig.zon @@ -6,8 +6,15 @@ }, .absorbedLight = 0x202830, .rotation = .branch, - .model = "cubyz:branch", - .texture = "cubyz:birch_log", + .model = .{ + .radius = 4, + }, + .texture_top = "cubyz:branch/birch/dot", + .texture_bottom = "cubyz:branch/birch/half_line", + .texture_right = "cubyz:branch/birch/line", + .texture_left = "cubyz:branch/birch/bend", + .texture_front = "cubyz:branch/birch/intersection", + .texture_back = "cubyz:branch/birch/cross", .item = .{ .material = .{ .density = 0.3, diff --git a/assets/cubyz/blocks/cactus_arm.zig.zon b/assets/cubyz/blocks/cactus_arm.zig.zon index 01819a01..ce1857e4 100644 --- a/assets/cubyz/blocks/cactus_arm.zig.zon +++ b/assets/cubyz/blocks/cactus_arm.zig.zon @@ -6,8 +6,15 @@ }, .absorbedLight = 0x202830, .rotation = .branch, - .model = "cubyz:branch", - .texture = "cubyz:cactus", + .model = .{ + .radius = 4, + }, + .texture_top = "cubyz:branch/cactus/dot", + .texture_bottom = "cubyz:branch/cactus/half_line", + .texture_right = "cubyz:branch/cactus/line", + .texture_left = "cubyz:branch/cactus/bend", + .texture_front = "cubyz:branch/cactus/intersection", + .texture_back = "cubyz:branch/cactus/cross", .item = .{ .material = .{ .density = 0.8, diff --git a/assets/cubyz/blocks/mahogany_branch.zig.zon b/assets/cubyz/blocks/mahogany_branch.zig.zon index 74edd5d0..74074274 100644 --- a/assets/cubyz/blocks/mahogany_branch.zig.zon +++ b/assets/cubyz/blocks/mahogany_branch.zig.zon @@ -6,8 +6,15 @@ }, .absorbedLight = 0x202830, .rotation = .branch, - .model = "cubyz:branch", - .texture = "cubyz:mahogany_log", + .model = .{ + .radius = 4, + }, + .texture_top = "cubyz:branch/mahogany/dot", + .texture_bottom = "cubyz:branch/mahogany/half_line", + .texture_right = "cubyz:branch/mahogany/line", + .texture_left = "cubyz:branch/mahogany/bend", + .texture_front = "cubyz:branch/mahogany/intersection", + .texture_back = "cubyz:branch/mahogany/cross", .item = .{ .material = .{ .density = 0.5, diff --git a/assets/cubyz/blocks/oak_branch.zig.zon b/assets/cubyz/blocks/oak_branch.zig.zon index 93b8e264..dcc08545 100644 --- a/assets/cubyz/blocks/oak_branch.zig.zon +++ b/assets/cubyz/blocks/oak_branch.zig.zon @@ -6,8 +6,15 @@ }, .absorbedLight = 0x202830, .rotation = .branch, - .model = "cubyz:branch", - .texture = "cubyz:oak_log", + .model = .{ + .radius = 4, + }, + .texture_top = "cubyz:branch/oak/dot", + .texture_bottom = "cubyz:branch/oak/half_line", + .texture_right = "cubyz:branch/oak/line", + .texture_left = "cubyz:branch/oak/bend", + .texture_front = "cubyz:branch/oak/intersection", + .texture_back = "cubyz:branch/oak/cross", .item = .{ .material = .{ .density = 0.25, diff --git a/assets/cubyz/blocks/pine_branch.zig.zon b/assets/cubyz/blocks/pine_branch.zig.zon index d6000a4c..a21a878e 100644 --- a/assets/cubyz/blocks/pine_branch.zig.zon +++ b/assets/cubyz/blocks/pine_branch.zig.zon @@ -6,8 +6,15 @@ }, .absorbedLight = 0x202830, .rotation = .branch, - .model = "cubyz:branch", - .texture = "cubyz:pine_log", + .model = .{ + .radius = 4, + }, + .texture_top = "cubyz:branch/pine/dot", + .texture_bottom = "cubyz:branch/pine/half_line", + .texture_right = "cubyz:branch/pine/line", + .texture_left = "cubyz:branch/pine/bend", + .texture_front = "cubyz:branch/pine/intersection", + .texture_back = "cubyz:branch/pine/cross", .item = .{ .material = .{ .density = 0.25, diff --git a/assets/cubyz/blocks/textures/branch/baobab/bend.png b/assets/cubyz/blocks/textures/branch/baobab/bend.png new file mode 100644 index 00000000..699c8b54 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/baobab/bend.png differ diff --git a/assets/cubyz/blocks/textures/branch/baobab/cross.png b/assets/cubyz/blocks/textures/branch/baobab/cross.png new file mode 100644 index 00000000..822fe5f4 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/baobab/cross.png differ diff --git a/assets/cubyz/blocks/textures/branch/baobab/dot.png b/assets/cubyz/blocks/textures/branch/baobab/dot.png new file mode 100644 index 00000000..b87c9800 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/baobab/dot.png differ diff --git a/assets/cubyz/blocks/textures/branch/baobab/half_line.png b/assets/cubyz/blocks/textures/branch/baobab/half_line.png new file mode 100644 index 00000000..4f7fb509 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/baobab/half_line.png differ diff --git a/assets/cubyz/blocks/textures/branch/baobab/intersection.png b/assets/cubyz/blocks/textures/branch/baobab/intersection.png new file mode 100644 index 00000000..6212d92e Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/baobab/intersection.png differ diff --git a/assets/cubyz/blocks/textures/branch/baobab/line.png b/assets/cubyz/blocks/textures/branch/baobab/line.png new file mode 100644 index 00000000..aa92d5cb Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/baobab/line.png differ diff --git a/assets/cubyz/blocks/textures/branch/birch/bend.png b/assets/cubyz/blocks/textures/branch/birch/bend.png new file mode 100644 index 00000000..42d74ab6 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/birch/bend.png differ diff --git a/assets/cubyz/blocks/textures/branch/birch/cross.png b/assets/cubyz/blocks/textures/branch/birch/cross.png new file mode 100644 index 00000000..f14bd85c Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/birch/cross.png differ diff --git a/assets/cubyz/blocks/textures/branch/birch/dot.png b/assets/cubyz/blocks/textures/branch/birch/dot.png new file mode 100644 index 00000000..799693b0 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/birch/dot.png differ diff --git a/assets/cubyz/blocks/textures/branch/birch/half_line.png b/assets/cubyz/blocks/textures/branch/birch/half_line.png new file mode 100644 index 00000000..75d137d1 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/birch/half_line.png differ diff --git a/assets/cubyz/blocks/textures/branch/birch/intersection.png b/assets/cubyz/blocks/textures/branch/birch/intersection.png new file mode 100644 index 00000000..90cdaedf Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/birch/intersection.png differ diff --git a/assets/cubyz/blocks/textures/branch/birch/line.png b/assets/cubyz/blocks/textures/branch/birch/line.png new file mode 100644 index 00000000..b2a9501d Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/birch/line.png differ diff --git a/assets/cubyz/blocks/textures/branch/cactus/bend.png b/assets/cubyz/blocks/textures/branch/cactus/bend.png new file mode 100644 index 00000000..a4441370 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/cactus/bend.png differ diff --git a/assets/cubyz/blocks/textures/branch/cactus/cross.png b/assets/cubyz/blocks/textures/branch/cactus/cross.png new file mode 100644 index 00000000..56577e68 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/cactus/cross.png differ diff --git a/assets/cubyz/blocks/textures/branch/cactus/dot.png b/assets/cubyz/blocks/textures/branch/cactus/dot.png new file mode 100644 index 00000000..92b64f83 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/cactus/dot.png differ diff --git a/assets/cubyz/blocks/textures/branch/cactus/half_line.png b/assets/cubyz/blocks/textures/branch/cactus/half_line.png new file mode 100644 index 00000000..05e61068 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/cactus/half_line.png differ diff --git a/assets/cubyz/blocks/textures/branch/cactus/intersection.png b/assets/cubyz/blocks/textures/branch/cactus/intersection.png new file mode 100644 index 00000000..dab42f07 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/cactus/intersection.png differ diff --git a/assets/cubyz/blocks/textures/branch/cactus/line.png b/assets/cubyz/blocks/textures/branch/cactus/line.png new file mode 100644 index 00000000..59fd2fa8 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/cactus/line.png differ diff --git a/assets/cubyz/blocks/textures/branch/mahogany/bend.png b/assets/cubyz/blocks/textures/branch/mahogany/bend.png new file mode 100644 index 00000000..4229ffd5 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/mahogany/bend.png differ diff --git a/assets/cubyz/blocks/textures/branch/mahogany/cross.png b/assets/cubyz/blocks/textures/branch/mahogany/cross.png new file mode 100644 index 00000000..9e623f14 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/mahogany/cross.png differ diff --git a/assets/cubyz/blocks/textures/branch/mahogany/dot.png b/assets/cubyz/blocks/textures/branch/mahogany/dot.png new file mode 100644 index 00000000..7ea4124b Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/mahogany/dot.png differ diff --git a/assets/cubyz/blocks/textures/branch/mahogany/half_line.png b/assets/cubyz/blocks/textures/branch/mahogany/half_line.png new file mode 100644 index 00000000..a0fafd15 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/mahogany/half_line.png differ diff --git a/assets/cubyz/blocks/textures/branch/mahogany/intersection.png b/assets/cubyz/blocks/textures/branch/mahogany/intersection.png new file mode 100644 index 00000000..c86c5be9 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/mahogany/intersection.png differ diff --git a/assets/cubyz/blocks/textures/branch/mahogany/line.png b/assets/cubyz/blocks/textures/branch/mahogany/line.png new file mode 100644 index 00000000..05ee15d9 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/mahogany/line.png differ diff --git a/assets/cubyz/blocks/textures/branch/oak/bend.png b/assets/cubyz/blocks/textures/branch/oak/bend.png new file mode 100644 index 00000000..dd340bbf Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/oak/bend.png differ diff --git a/assets/cubyz/blocks/textures/branch/oak/cross.png b/assets/cubyz/blocks/textures/branch/oak/cross.png new file mode 100644 index 00000000..57e395a4 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/oak/cross.png differ diff --git a/assets/cubyz/blocks/textures/branch/oak/dot.png b/assets/cubyz/blocks/textures/branch/oak/dot.png new file mode 100644 index 00000000..9a18e02d Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/oak/dot.png differ diff --git a/assets/cubyz/blocks/textures/branch/oak/half_line.png b/assets/cubyz/blocks/textures/branch/oak/half_line.png new file mode 100644 index 00000000..36ae1f0d Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/oak/half_line.png differ diff --git a/assets/cubyz/blocks/textures/branch/oak/intersection.png b/assets/cubyz/blocks/textures/branch/oak/intersection.png new file mode 100644 index 00000000..af10a123 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/oak/intersection.png differ diff --git a/assets/cubyz/blocks/textures/branch/oak/line.png b/assets/cubyz/blocks/textures/branch/oak/line.png new file mode 100644 index 00000000..9b8102dc Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/oak/line.png differ diff --git a/assets/cubyz/blocks/textures/branch/pine/bend.png b/assets/cubyz/blocks/textures/branch/pine/bend.png new file mode 100644 index 00000000..17478cad Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/pine/bend.png differ diff --git a/assets/cubyz/blocks/textures/branch/pine/cross.png b/assets/cubyz/blocks/textures/branch/pine/cross.png new file mode 100644 index 00000000..3d957af7 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/pine/cross.png differ diff --git a/assets/cubyz/blocks/textures/branch/pine/dot.png b/assets/cubyz/blocks/textures/branch/pine/dot.png new file mode 100644 index 00000000..0c1474bb Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/pine/dot.png differ diff --git a/assets/cubyz/blocks/textures/branch/pine/half_line.png b/assets/cubyz/blocks/textures/branch/pine/half_line.png new file mode 100644 index 00000000..4a5ec191 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/pine/half_line.png differ diff --git a/assets/cubyz/blocks/textures/branch/pine/intersection.png b/assets/cubyz/blocks/textures/branch/pine/intersection.png new file mode 100644 index 00000000..ef578165 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/pine/intersection.png differ diff --git a/assets/cubyz/blocks/textures/branch/pine/line.png b/assets/cubyz/blocks/textures/branch/pine/line.png new file mode 100644 index 00000000..f2693e2e Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/pine/line.png differ diff --git a/assets/cubyz/blocks/textures/branch/willow/bend.png b/assets/cubyz/blocks/textures/branch/willow/bend.png new file mode 100644 index 00000000..56b0f512 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/willow/bend.png differ diff --git a/assets/cubyz/blocks/textures/branch/willow/cross.png b/assets/cubyz/blocks/textures/branch/willow/cross.png new file mode 100644 index 00000000..456e104a Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/willow/cross.png differ diff --git a/assets/cubyz/blocks/textures/branch/willow/dot.png b/assets/cubyz/blocks/textures/branch/willow/dot.png new file mode 100644 index 00000000..1c4697b4 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/willow/dot.png differ diff --git a/assets/cubyz/blocks/textures/branch/willow/half_line.png b/assets/cubyz/blocks/textures/branch/willow/half_line.png new file mode 100644 index 00000000..313bc383 Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/willow/half_line.png differ diff --git a/assets/cubyz/blocks/textures/branch/willow/intersection.png b/assets/cubyz/blocks/textures/branch/willow/intersection.png new file mode 100644 index 00000000..8fb2407b Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/willow/intersection.png differ diff --git a/assets/cubyz/blocks/textures/branch/willow/line.png b/assets/cubyz/blocks/textures/branch/willow/line.png new file mode 100644 index 00000000..de53a45d Binary files /dev/null and b/assets/cubyz/blocks/textures/branch/willow/line.png differ diff --git a/assets/cubyz/blocks/willow_branch.zig.zon b/assets/cubyz/blocks/willow_branch.zig.zon index dcf76315..8826f043 100644 --- a/assets/cubyz/blocks/willow_branch.zig.zon +++ b/assets/cubyz/blocks/willow_branch.zig.zon @@ -6,8 +6,15 @@ }, .absorbedLight = 0x202830, .rotation = .branch, - .model = "cubyz:branch", - .texture = "cubyz:willow_log", + .model = .{ + .radius = 4, + }, + .texture_top = "cubyz:branch/willow/dot", + .texture_bottom = "cubyz:branch/willow/half_line", + .texture_right = "cubyz:branch/willow/line", + .texture_left = "cubyz:branch/willow/bend", + .texture_front = "cubyz:branch/willow/intersection", + .texture_back = "cubyz:branch/willow/cross", .item = .{ .material = .{ .density = 0.5, diff --git a/assets/cubyz/models/branch.obj b/assets/cubyz/models/branch.obj deleted file mode 100644 index 942e9757..00000000 --- a/assets/cubyz/models/branch.obj +++ /dev/null @@ -1,237 +0,0 @@ -o unknown -v 0.25 0.75 0.75 -v 0.25 0.75 0.25 -v 0.25 0.25 0.25 -v 0.25 0.25 0.75 -v 0.75 0.25 0.75 -v 0.75 0.25 0.25 -v 0.75 0.75 0.25 -v 0.75 0.75 0.75 -v 0.75 0.25 0.75 -v 0.75 0.25 0.25 -v 1 0.25 0.25 -v 1 0.25 0.75 -v 1 0.75 0.75 -v 1 0.75 0.25 -v 0.75 0.75 0.25 -v 0.75 0.75 0.75 -v 0.75 0 0.75 -v 0.75 0.25 0.75 -v 0.25 0.25 0.75 -v 0.25 0 0.75 -v 0.75 0 0.25 -v 0.75 0.25 0.25 -v 0.25 0.25 0.25 -v 0.25 0 0.25 -v 0.75 0.25 0.25 -v 0.25 0.25 0.25 -v 0.25 0.25 0 -v 0.75 0.25 0 -v 0.75 0.75 0 -v 0.25 0.75 0 -v 0.25 0.75 0.25 -v 0.75 0.75 0.25 -v 0.75 0.25 1 -v 0.25 0.25 1 -v 0.25 0.25 0.75 -v 0.75 0.25 0.75 -v 0.75 0.75 0.75 -v 0.25 0.75 0.75 -v 0.25 0.75 1 -v 0.75 0.75 1 -v 0.25 1 0.75 -v 0.25 1 0.25 -v 0.25 0.75 0.25 -v 0.25 0.75 0.75 -v 0.75 0.75 0.75 -v 0.75 0.75 0.25 -v 0.75 1 0.25 -v 0.75 1 0.75 -v 0 0.25 0.75 -v 0 0.25 0.25 -v 0.25 0.25 0.25 -v 0.25 0.25 0.75 -v 0.25 0.75 0.75 -v 0.25 0.75 0.25 -v 0 0.75 0.25 -v 0 0.75 0.75 -vt 0.0625 0.1875 -vt 0.0625 0.0625 -vt 0.1875 0.0625 -vt 0.1875 0.1875 -vt 0.0625 0.1875 -vt 0.0625 0.0625 -vt 0.1875 0.0625 -vt 0.1875 0.1875 -vt 0.0625 0.1875 -vt 0.0625 0.0625 -vt 0.1875 0.0625 -vt 0.1875 0.1875 -vt 0.0625 0.1875 -vt 0.0625 0.0625 -vt 0.1875 0.0625 -vt 0.1875 0.1875 -vt 0.0625 0.0625 -vt 0.0625 0.1875 -vt 0 0.1875 -vt 0 0.0625 -vt 0 0.1875 -vt 0 0.0625 -vt 0.0625 0.0625 -vt 0.0625 0.1875 -vt 0.0625 0.1875 -vt 0.0625 0.0625 -vt 0 0.0625 -vt 0 0.1875 -vt 0.25 0.0625 -vt 0.25 0.1875 -vt 0.1875 0.1875 -vt 0.1875 0.0625 -vt 0.0625 0 -vt 0.0625 0.0625 -vt 0.1875 0.0625 -vt 0.1875 0 -vt 0 0.1875 -vt 0 0.0625 -vt 0.06249999999999999 0.0625 -vt 0.0625 0.1875 -vt 0.1875 0.0625 -vt 0.1875 0.1875 -vt 0.25 0.1875 -vt 0.25 0.0625 -vt 0.0625 0 -vt 0.0625 0.0625 -vt 0.1875 0.0625 -vt 0.1875 0 -vt 0.0625 0.1875 -vt 0.0625 0.0625 -vt 0.1875 0.0625 -vt 0.1875 0.1875 -vt 0.1875 0.0625 -vt 0.1875 0.1875 -vt 0.0625 0.1875 -vt 0.0625 0.0625 -vt 0.1875 0.0625 -vt 0.0625 0.0625 -vt 0.0625 0 -vt 0.1875 0 -vt 0.0625 0 -vt 0.1875 0 -vt 0.1875 0.0625 -vt 0.0625 0.0625 -vt 0.1875 0.0625 -vt 0.0625 0.0625 -vt 0.0625 0 -vt 0.1875 0 -vt 0.0625 0 -vt 0.1875 0 -vt 0.1875 0.0625 -vt 0.0625 0.0625 -vt 0.1875 0.25 -vt 0.0625 0.25 -vt 0.0625 0.1875 -vt 0.1875 0.1875 -vt 0.0625 0.1875 -vt 0.1875 0.1875 -vt 0.1875 0.25 -vt 0.0625 0.25 -vt 0.1875 0.25 -vt 0.0625 0.25 -vt 0.0625 0.1875 -vt 0.1875 0.1875 -vt 0.0625 0.1875 -vt 0.1875 0.1875 -vt 0.1875 0.25 -vt 0.0625 0.25 -vt 0 0.0625 -vt 0 0.1875 -vt 0.0625 0.1875 -vt 0.0625 0.0625 -vt 0.1875 0.1875 -vt 0.1875 0.0625 -vt 0.25 0.0625 -vt 0.25 0.1875 -vt 0.0625 0.1875 -vt 0.0625 0.25 -vt 0.1875 0.25 -vt 0.1875 0.1875 -vt 0.0625 0.1875 -vt 0.0625 0.25 -vt 0.1875 0.25 -vt 0.1875 0.1875 -vt 0.25 0.0625 -vt 0.25 0.1875 -vt 0.1875 0.1875 -vt 0.1875 0.0625 -vt 0.1875 0.1875 -vt 0.1875 0.0625 -vt 0.25 0.0625 -vt 0.25 0.1875 -vt 0.25 0.1875 -vt 0.25 0.0625 -vt 0.1875 0.0625 -vt 0.1875 0.1875 -vt 0.0625 0.0625 -vt 0.0625 0.1875 -vt 0 0.1875 -vt 0 0.0625 -vn -1 0 0 -vn 1 0 0 -vn 0 -1 0 -vn 0 1 0 -vn 0 -1 0 -vn 0 1 0 -vn 0 0 -1 -vn 0 0 1 -vn 0 0 1 -vn 1 0 0 -vn -1 0 0 -vn 0 0 -1 -vn 0 0 1 -vn 0 0 -1 -vn 0 -1 0 -vn 0 1 0 -vn -1 0 0 -vn 1 0 0 -vn 0 -1 0 -vn 0 1 0 -vn -1 0 0 -vn 1 0 0 -vn -1 0 0 -vn 1 0 0 -vn 0 0 -1 -vn 0 0 1 -vn 0 -1 0 -vn 0 1 0 -vn 0 0 -1 -vn 0 0 1 -f 1/1/1 2/2/1 3/3/1 4/4/1 -f 5/5/2 6/6/2 7/7/2 8/8/2 -f 4/9/3 3/10/3 6/11/3 5/12/3 -f 8/13/4 7/14/4 2/15/4 1/16/4 -f 9/17/5 10/18/5 11/19/5 12/20/5 -f 13/21/6 14/22/6 15/23/6 16/24/6 -f 10/25/7 15/26/7 14/27/7 11/28/7 -f 12/29/8 13/30/8 16/31/8 9/32/8 -f 17/33/9 18/34/9 19/35/9 20/36/9 -f 17/37/10 21/38/10 22/39/10 18/40/10 -f 19/41/11 23/42/11 24/43/11 20/44/11 -f 24/45/12 23/46/12 22/47/12 21/48/12 -f 5/49/13 8/50/13 1/51/13 4/52/13 -f 3/53/14 2/54/14 7/55/14 6/56/14 -f 25/57/15 26/58/15 27/59/15 28/60/15 -f 29/61/16 30/62/16 31/63/16 32/64/16 -f 26/65/17 31/66/17 30/67/17 27/68/17 -f 28/69/18 29/70/18 32/71/18 25/72/18 -f 33/73/19 34/74/19 35/75/19 36/76/19 -f 37/77/20 38/78/20 39/79/20 40/80/20 -f 34/81/21 39/82/21 38/83/21 35/84/21 -f 36/85/22 37/86/22 40/87/22 33/88/22 -f 41/89/23 42/90/23 43/91/23 44/92/23 -f 45/93/24 46/94/24 47/95/24 48/96/24 -f 43/97/25 42/98/25 47/99/25 46/100/25 -f 45/101/26 48/102/26 41/103/26 44/104/26 -f 49/105/27 50/106/27 51/107/27 52/108/27 -f 53/109/28 54/110/28 55/111/28 56/112/28 -f 50/113/29 55/114/29 54/115/29 51/116/29 -f 52/117/30 53/118/30 56/119/30 49/120/30 \ No newline at end of file diff --git a/src/chunk.zig b/src/chunk.zig index 29496e2b..c95035f3 100644 --- a/src/chunk.zig +++ b/src/chunk.zig @@ -47,6 +47,26 @@ pub const Neighbor = enum(u3) { // MARK: Neighbor pub fn relPos(self: Neighbor) Vec3i { return .{self.relX(), self.relY(), self.relZ()}; } + + pub fn fromRelPos(pos: Vec3i) ?Neighbor { + if(@reduce(.Add, @abs(pos)) != 1) { + return null; + } + return switch(pos[0]) { + 1 => return .dirPosX, + -1 => return .dirNegX, + else => switch(pos[1]) { + 1 => return .dirPosY, + -1 => return .dirNegY, + else => switch(pos[2]) { + 1 => return .dirUp, + -1 => return .dirDown, + else => return null, + }, + }, + }; + } + /// Index to bitMask for bitmap direction data pub inline fn bitMask(self: Neighbor) u6 { return @as(u6, 1) << @intFromEnum(self); diff --git a/src/rotation.zig b/src/rotation.zig index cd15454b..ccfcaee4 100644 --- a/src/rotation.zig +++ b/src/rotation.zig @@ -341,7 +341,7 @@ pub const RotationModes = struct { pub const Branch = struct { // MARK: Branch pub const id: []const u8 = "branch"; pub const dependsOnNeighbors = true; - var branchModels: std.StringHashMap(u16) = undefined; + var branchModels: std.AutoHashMap(u32, u16) = undefined; const BranchData = packed struct(u6) { enabledConnections: u6, @@ -374,35 +374,233 @@ pub const RotationModes = struct { branchModels.clearRetainingCapacity(); } - fn branchTransform(quad: *main.models.QuadInfo, data: BranchData) void { - for(&quad.corners) |*corner| { - if((!data.isConnected(Neighbor.dirNegX) and corner[0] == 0) or - (!data.isConnected(Neighbor.dirPosX) and corner[0] == 1) or - (!data.isConnected(Neighbor.dirNegY) and corner[1] == 0) or - (!data.isConnected(Neighbor.dirPosY) and corner[1] == 1) or - (!data.isConnected(Neighbor.dirDown) and corner[2] == 0) or - (!data.isConnected(Neighbor.dirUp) and corner[2] == 1)) return degenerateQuad(quad); + const Direction = enum(u2) { + negYDir = 0, + posXDir = 1, + posYDir = 2, + negXDir = 3, + }; + + const Pattern = union(enum) { + dot: void, + halfLine: struct { + dir: Direction, + }, + line: struct { + dir: Direction, + }, + bend: struct { + dir: Direction, + }, + intersection: struct { + dir: Direction, + }, + cross: void, + }; + + fn rotateQuad(originalCorners: [4]Vec2f, pattern: Pattern, min: f32, max: f32, side: Neighbor) main.models.QuadInfo { + var corners: [4]Vec2f = originalCorners; + + switch(pattern) { + .dot, .cross => {}, + inline else => |typ| { + const angle: f32 = @as(f32, @floatFromInt(@intFromEnum(typ.dir)))*std.math.pi/2.0; + corners = .{ + vec.rotate2d(originalCorners[0], angle, @splat(0.5)), + vec.rotate2d(originalCorners[1], angle, @splat(0.5)), + vec.rotate2d(originalCorners[2], angle, @splat(0.5)), + vec.rotate2d(originalCorners[3], angle, @splat(0.5)), + }; + }, + } + + const offX: f32 = @floatFromInt(@intFromBool(@reduce(.Add, side.textureX()) < 0)); + const offY: f32 = @floatFromInt(@intFromBool(@reduce(.Add, side.textureY()) < 0)); + + const corners3d = .{ + @as(Vec3f, @floatFromInt(side.textureX()))*@as(Vec3f, @splat(corners[0][0] - offX)) + @as(Vec3f, @floatFromInt(side.textureY()))*@as(Vec3f, @splat(corners[0][1] - offY)), + @as(Vec3f, @floatFromInt(side.textureX()))*@as(Vec3f, @splat(corners[1][0] - offX)) + @as(Vec3f, @floatFromInt(side.textureY()))*@as(Vec3f, @splat(corners[1][1] - offY)), + @as(Vec3f, @floatFromInt(side.textureX()))*@as(Vec3f, @splat(corners[2][0] - offX)) + @as(Vec3f, @floatFromInt(side.textureY()))*@as(Vec3f, @splat(corners[2][1] - offY)), + @as(Vec3f, @floatFromInt(side.textureX()))*@as(Vec3f, @splat(corners[3][0] - offX)) + @as(Vec3f, @floatFromInt(side.textureY()))*@as(Vec3f, @splat(corners[3][1] - offY)), + }; + + var offset: Vec3f = .{0.0, 0.0, 0.0}; + offset[@intFromEnum(side.vectorComponent())] = if(side.isPositive()) max else min; + + const res: main.models.QuadInfo = .{ + .corners = .{ + corners3d[0] + offset, + corners3d[1] + offset, + corners3d[2] + offset, + corners3d[3] + offset, + }, + .cornerUV = originalCorners, + .normal = @floatFromInt(side.relPos()), + .textureSlot = @intFromEnum(pattern), + }; + + return res; + } + + fn addQuads(pattern: Pattern, side: Neighbor, radius: f32, out: *main.List(main.models.QuadInfo)) void { + const min: f32 = (8.0 - radius)/16.0; + const max: f32 = (8.0 + radius)/16.0; + switch(pattern) { + .dot => { + out.append(rotateQuad(.{ + .{min, min}, + .{min, max}, + .{max, min}, + .{max, max}, + }, pattern, min, max, side)); + }, + .halfLine => { + out.append(rotateQuad(.{ + .{min, 0.0}, + .{min, max}, + .{max, 0.0}, + .{max, max}, + }, pattern, min, max, side)); + }, + .line => { + out.append(rotateQuad(.{ + .{min, 0.0}, + .{min, 1.0}, + .{max, 0.0}, + .{max, 1.0}, + }, pattern, min, max, side)); + }, + .bend => { + out.append(rotateQuad(.{ + .{0.0, 0.0}, + .{0.0, max}, + .{max, 0.0}, + .{max, max}, + }, pattern, min, max, side)); + }, + .intersection => { + out.append(rotateQuad(.{ + .{0.0, 0.0}, + .{0.0, max}, + .{1.0, 0.0}, + .{1.0, max}, + }, pattern, min, max, side)); + }, + .cross => { + out.append(rotateQuad(.{ + .{0.0, 0.0}, + .{0.0, 1.0}, + .{1.0, 0.0}, + .{1.0, 1.0}, + }, pattern, min, max, side)); + }, } } - fn degenerateQuad(quad: *main.models.QuadInfo) void { - for(&quad.corners) |*corner| { - corner.* = @splat(0.5); - } + fn getPattern(data: BranchData, side: Neighbor) ?Pattern { + const posX = Neighbor.fromRelPos(side.textureX()).?; + const negX = Neighbor.fromRelPos(side.textureX()).?.reverse(); + const posY = Neighbor.fromRelPos(side.textureY()).?; + const negY = Neighbor.fromRelPos(side.textureY()).?.reverse(); + + const connectedPosX = data.isConnected(posX); + const connectedNegX = data.isConnected(negX); + const connectedPosY = data.isConnected(posY); + const connectedNegY = data.isConnected(negY); + + const count: u6 = @as(u6, @intFromBool(connectedPosX)) + @as(u6, @intFromBool(connectedNegX)) + @as(u6, @intFromBool(connectedPosY)) + @as(u6, @intFromBool(connectedNegY)); + + return switch(count) { + 0 => { + if(data.isConnected(side)) { + return null; + } + + return .dot; + }, + 1 => { + var dir: Direction = .negXDir; + if(connectedNegY) { + dir = .negYDir; + } else if(connectedPosX) { + dir = .posXDir; + } else if(connectedPosY) { + dir = .posYDir; + } + return .{.halfLine = .{.dir = dir}}; + }, + 2 => { + if((connectedPosX and connectedNegX) or (connectedPosY and connectedNegY)) { + var dir: Direction = .negYDir; + if(connectedPosX and connectedNegX) { + dir = .posXDir; + } + + return .{.line = .{.dir = dir}}; + } + + var dir: Direction = .negXDir; + + if(connectedNegY) { + dir = .negYDir; + if(connectedPosX) { + dir = .posXDir; + } + } else if(connectedPosX) { + dir = .posXDir; + if(connectedPosY) { + dir = .posYDir; + } + } else if(connectedPosY) { + dir = .posYDir; + if(connectedNegX) { + dir = .negXDir; + } + } + + return .{.bend = .{.dir = dir}}; + }, + 3 => { + var dir: Direction = undefined; + if(!connectedPosY) dir = .negYDir; + if(!connectedNegX) dir = .posXDir; + if(!connectedNegY) dir = .posYDir; + if(!connectedPosX) dir = .negXDir; + + return .{.intersection = .{.dir = dir}}; + }, + 4 => { + return .cross; + }, + else => undefined, + }; } pub fn createBlockModel(zon: ZonElement) u16 { - const modelId = zon.as([]const u8, "cubyz:cube"); - if(branchModels.get(modelId)) |modelIndex| return modelIndex; + const radius = zon.get(f32, "radius", 4); + if(branchModels.get(@bitCast(radius))) |modelIndex| return modelIndex; - const baseModelIndex = main.models.getModelIndex(modelId); - const baseModel = main.models.models.items[baseModelIndex]; + var modelIndex: u16 = undefined; + for(0..64) |i| { + var quads = main.List(main.models.QuadInfo).init(main.stackAllocator); + defer quads.deinit(); - const modelIndex: u16 = baseModel.transformModel(branchTransform, .{BranchData.init(0)}); - for(1..64) |branchData| { - _ = baseModel.transformModel(branchTransform, .{BranchData.init(@truncate(branchData))}); + for(Neighbor.iterable) |neighbor| { + const pattern = getPattern(BranchData.init(@intCast(i)), neighbor); + + if(pattern) |pat| { + addQuads(pat, neighbor, radius, &quads); + } + } + + const index = main.models.Model.init(quads.items); + if(i == 0) { + modelIndex = index; + } } - branchModels.put(modelId, modelIndex) catch unreachable; + + branchModels.put(@bitCast(radius), modelIndex) catch unreachable; + return modelIndex; } diff --git a/src/vec.zig b/src/vec.zig index 85348cd6..460d2975 100644 --- a/src/vec.zig +++ b/src/vec.zig @@ -80,6 +80,19 @@ pub fn rotateZ(self: anytype, angle: @typeInfo(@TypeOf(self)).vector.child) @Typ }; } +pub fn rotate2d(self: anytype, angle: @typeInfo(@TypeOf(self)).vector.child, center: @TypeOf(self)) @TypeOf(self) { + if(@typeInfo(@TypeOf(self)).vector.len != 2) @compileError("Only available for vectors of length 2."); + + const sin = @sin(angle); + const cos = @cos(angle); + const pos = self - center; + + return @TypeOf(self){ + cos*pos[0] - sin*pos[1], + sin*pos[0] + cos*pos[1], + } + center; +} + pub const Mat4f = struct { // MARK: Mat4f rows: [4]Vec4f, pub fn identity() Mat4f {