Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20a1ba9502 | ||
|
|
737a297436 | ||
|
|
b72b90c50d | ||
|
|
fc3494466e | ||
|
|
937fbd6ede | ||
|
|
307b52ae1f | ||
|
|
6e84fe9b1b | ||
|
|
236a643d04 | ||
|
|
247f7ef9fe | ||
|
|
b3d08d4a8c | ||
|
|
8ddbd6f514 | ||
|
|
b9258a68fd | ||
|
|
7f87dbca35 | ||
|
|
8bee8322c3 | ||
|
|
a3ace75c81 | ||
|
|
87500e13da | ||
|
|
bf2cb25836 | ||
|
|
50b7b86944 | ||
|
|
3571106251 | ||
|
|
7b7228a248 | ||
|
|
7fd0e3ec5b | ||
|
|
0f0795c47f | ||
|
|
0522bda250 | ||
|
|
075c49200e | ||
|
|
01f299aa4f | ||
|
|
31e1942870 | ||
|
|
56d92cdb46 | ||
|
|
186ee9a817 | ||
|
|
9db3929750 | ||
|
|
f7bfdb4a0b | ||
|
|
67c4a366c7 | ||
|
|
31134f1494 | ||
|
|
030f54b886 | ||
|
|
f2fe8736f2 | ||
|
|
7cd7335f03 | ||
|
|
f782c8116e | ||
|
|
c9e463bb9a | ||
|
|
87dd8e1190 | ||
|
|
3bffb82560 | ||
|
|
f181bf4de9 | ||
|
|
7dd6bfc40c | ||
|
|
0d080a8d94 | ||
|
|
613af7d7ea | ||
|
|
b10641ee3c | ||
|
|
5b10d63970 | ||
|
|
fcdd8306d2 | ||
|
|
01fb83d05f | ||
|
|
34024bab96 | ||
|
|
40df66e7cc | ||
|
|
61c628876f | ||
|
|
9aebddde86 | ||
|
|
8ae566d627 | ||
|
|
6c4f2e640a | ||
|
|
949a076ec7 | ||
|
|
14961d903b | ||
|
|
ccac320e0e | ||
|
|
ff3e66ae3e | ||
|
|
7c92f046a1 | ||
|
|
9de6a0b5a9 | ||
|
|
4603a64e10 | ||
|
|
36a172d07f | ||
|
|
cb85c94f56 | ||
|
|
3ba7ef92ad | ||
|
|
c326c363a0 | ||
|
|
7543fe3cb7 | ||
|
|
93480150e5 | ||
|
|
201d3be322 | ||
|
|
b6aca99d0c | ||
|
|
44f58bc9c2 | ||
|
|
03c97ae3f2 | ||
|
|
836132b6ef | ||
|
|
3a6ca792aa | ||
|
|
a8bfaaee36 | ||
|
|
902da64588 | ||
|
|
e27eedb654 | ||
|
|
a07e2e567f | ||
|
|
9cf23f8ad6 | ||
|
|
04623ea226 | ||
|
|
983104a173 | ||
|
|
4f9a792dea | ||
|
|
a585dff09d | ||
|
|
d584e418f5 | ||
|
|
a41d39cc78 | ||
|
|
3ac613cb58 | ||
|
|
ecccfddf7d | ||
|
|
361fb72b27 | ||
|
|
bebdcf6049 | ||
|
|
07772f2093 | ||
|
|
13c1683d5e | ||
|
|
e20ca4f016 |
@@ -10,13 +10,10 @@ target/
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
|
||||
# RustRover
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
/assets/maps/autosave
|
||||
|
||||
# Blender-Backup-Dateien (bei jedem Save neu geschrieben)
|
||||
*.blend1
|
||||
|
||||
# Added by cargo
|
||||
|
||||
|
||||
@@ -18,6 +18,12 @@ version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618"
|
||||
|
||||
[[package]]
|
||||
name = "adler2"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
||||
|
||||
[[package]]
|
||||
name = "ahash"
|
||||
version = "0.8.12"
|
||||
@@ -31,6 +37,15 @@ dependencies = [
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.21"
|
||||
@@ -122,6 +137,24 @@ version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
version = "0.72.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895"
|
||||
dependencies = [
|
||||
"bitflags 2.13.0",
|
||||
"cexpr",
|
||||
"clang-sys",
|
||||
"itertools",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"rustc-hash 2.1.3",
|
||||
"shlex 1.3.0",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bit-set"
|
||||
version = "0.9.1"
|
||||
@@ -249,7 +282,16 @@ dependencies = [
|
||||
"find-msvc-tools",
|
||||
"jobserver",
|
||||
"libc",
|
||||
"shlex",
|
||||
"shlex 2.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cexpr"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
|
||||
dependencies = [
|
||||
"nom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -275,6 +317,17 @@ dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clang-sys"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"libc",
|
||||
"libloading",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "codespan-reporting"
|
||||
version = "0.13.1"
|
||||
@@ -345,6 +398,15 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "coreaudio-sys"
|
||||
version = "0.2.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9b4739a805a62757a83e5654fa3faabec0442666b263bb2287d5a8185bfd953"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.3.0"
|
||||
@@ -354,6 +416,15 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8498c871161e1742aaa9d52551b2d6ebdd4c3d45a3be423e3728f33b955be550"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.21"
|
||||
@@ -418,6 +489,12 @@ version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.2"
|
||||
@@ -434,12 +511,32 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fdeflate"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c"
|
||||
dependencies = [
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "find-msvc-tools"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e634e2e0ebac1ee034020da1ca582e17ffe4e0f5e985823721e168928136dcb"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"miniz_oxide 0.9.1",
|
||||
"zlib-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.1.5"
|
||||
@@ -552,6 +649,12 @@ dependencies = [
|
||||
"xml-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
|
||||
|
||||
[[package]]
|
||||
name = "glow"
|
||||
version = "0.17.0"
|
||||
@@ -681,6 +784,15 @@ dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.18"
|
||||
@@ -811,6 +923,19 @@ version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
|
||||
|
||||
[[package]]
|
||||
name = "libpulse-sys"
|
||||
version = "1.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d74371848b22e989f829cc1621d2ebd74960711557d8b45cfe740f60d0a05e61"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"pkg-config",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
version = "0.1.17"
|
||||
@@ -871,6 +996,32 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
|
||||
dependencies = [
|
||||
"adler2",
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c"
|
||||
dependencies = [
|
||||
"adler2",
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "naga"
|
||||
version = "29.0.3"
|
||||
@@ -891,7 +1042,7 @@ dependencies = [
|
||||
"log",
|
||||
"num-traits",
|
||||
"once_cell",
|
||||
"rustc-hash",
|
||||
"rustc-hash 1.1.0",
|
||||
"spirv",
|
||||
"thiserror 2.0.18",
|
||||
"unicode-ident",
|
||||
@@ -927,6 +1078,27 @@ dependencies = [
|
||||
"jni-sys 0.3.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"minimal-lexical",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-derive"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
@@ -1319,6 +1491,19 @@ version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
|
||||
|
||||
[[package]]
|
||||
name = "png"
|
||||
version = "0.18.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61"
|
||||
dependencies = [
|
||||
"bitflags 2.13.0",
|
||||
"crc32fast",
|
||||
"fdeflate",
|
||||
"flate2",
|
||||
"miniz_oxide 0.8.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polling"
|
||||
version = "3.11.0"
|
||||
@@ -1492,6 +1677,35 @@ dependencies = [
|
||||
"bitflags 2.13.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8fcfdb36bda0c880c5931cdc7a2bcdc8ba4556847b9d912bca70bc94708711ad"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
||||
|
||||
[[package]]
|
||||
name = "renderdoc-sys"
|
||||
version = "1.1.0"
|
||||
@@ -1504,6 +1718,12 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.4.1"
|
||||
@@ -1628,12 +1848,24 @@ dependencies = [
|
||||
"zmij",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
||||
|
||||
[[package]]
|
||||
name = "simd-adler32"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea"
|
||||
|
||||
[[package]]
|
||||
name = "simd_cesu8"
|
||||
version = "1.1.1"
|
||||
@@ -1832,6 +2064,23 @@ dependencies = [
|
||||
"strict-num",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyaudio"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db2bb6a423a786a941cbc5a6544693727d832ec2c088d7da097a9d3bcf0431b5"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"coreaudio-sys",
|
||||
"js-sys",
|
||||
"libpulse-sys",
|
||||
"ndk",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "1.1.1+spec-1.1.0"
|
||||
@@ -2146,7 +2395,10 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"bladeink",
|
||||
"bytemuck",
|
||||
"png",
|
||||
"pollster",
|
||||
"serde_json",
|
||||
"tinyaudio",
|
||||
"wgpu",
|
||||
"winit",
|
||||
]
|
||||
@@ -2223,7 +2475,7 @@ dependencies = [
|
||||
"portable-atomic",
|
||||
"profiling",
|
||||
"raw-window-handle",
|
||||
"rustc-hash",
|
||||
"rustc-hash 1.1.0",
|
||||
"smallvec",
|
||||
"thiserror 2.0.18",
|
||||
"wgpu-core-deps-apple",
|
||||
@@ -2339,6 +2591,22 @@ dependencies = [
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.11"
|
||||
@@ -2348,6 +2616,12 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows"
|
||||
version = "0.62.2"
|
||||
@@ -2787,6 +3061,12 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zlib-rs"
|
||||
version = "0.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34b31d188d9d685a4f9c7b46d6e36631b07058d2cfe190267adce54dc230bf12"
|
||||
|
||||
[[package]]
|
||||
name = "zmij"
|
||||
version = "1.0.21"
|
||||
|
||||
@@ -6,6 +6,9 @@ edition = "2024"
|
||||
[dependencies]
|
||||
bladeink = "1.2.5"
|
||||
bytemuck = { version = "1.25.0", features = ["derive"] }
|
||||
png = "0.18.1"
|
||||
pollster = "0.4.0"
|
||||
serde_json = "1"
|
||||
tinyaudio = { version = "2", default-features = false, features = ["pulse"] }
|
||||
wgpu = "29.0.3"
|
||||
winit = "0.30.13"
|
||||
|
||||
@@ -2,7 +2,19 @@
|
||||
|
||||
## Anwendung ausführen
|
||||
|
||||
- Cargo installieren (Falls noch nicht vorhanden): `sudo apt install cargo`
|
||||
- Repository Klonen: `git clone https://git.bnd.wtf/irrlicht/wds.git`
|
||||
Das Projekt nutzt Rust-Edition 2024 und braucht daher eine aktuelle
|
||||
Toolchain (Rust ≥ 1.85). Das `cargo` aus den Distributions-Paketquellen
|
||||
(`apt`) ist dafür in der Regel zu alt — stattdessen Rust über
|
||||
[rustup](https://rustup.rs/) installieren:
|
||||
|
||||
- Rust installieren (falls noch nicht vorhanden):
|
||||
`curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
|
||||
(danach neue Shell öffnen oder `source "$HOME/.cargo/env"`)
|
||||
- Repository klonen: `git clone https://git.bnd.wtf/irrlicht/wds.git`
|
||||
- In den Ordner wechseln: `cd wds`
|
||||
- Anwendung bauen und ausführen: `cargo run`
|
||||
|
||||
Alternativ ohne Fenster/GPU in der Konsole: `cargo run -- --cli`
|
||||
|
||||
Ohne Hauptmenü direkt in eine Szene (`assets/maps/<szene>/`) starten:
|
||||
`cargo run -- --scene <szene>`.
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
Alles Inhaltliche kommt aus vier Quellen: **Blender** (Welt), **Ink**
|
||||
(Dialoge/Story), **signals.toml** (Verdrahtung), **Assets-Ordner**
|
||||
(Texturen/Sounds). Fehler in Inhalten stürzen nie ab — sie werden beim
|
||||
Start in der Konsole gemeldet (`[model]`, `[audio]`, `[tex]`, …).
|
||||
|
||||
## 3D / Blender
|
||||
|
||||
- **Format:** glTF Binary (`.glb`) in einen **Szenen-Ordner**
|
||||
`assets/maps/<szene>/` (siehe [Szenen](#szenen)).
|
||||
- **Beim Export anhaken:** „Include → Custom Properties" (sonst fehlen die
|
||||
Properties unten) **und** „Include → Textures" / „Data → Images"
|
||||
(sonst fehlen die Texturen).
|
||||
- **Maßstab:** 1 Blender-Meter = 1 Engine-Meter. Augenhöhe 1,6 m,
|
||||
Türen/Durchgänge ≥ 2 m hoch und ≥ 0,8 m breit denken.
|
||||
- **Texturen:** Bild im Material als Base Color zuweisen — es wird beim
|
||||
Export in die `.glb` eingebettet und mitgeladen (kein `assets/textures/`
|
||||
mehr). Format **PNG** (Export „Images: PNG" oder „Automatic"). Fehlt das
|
||||
Bild, erscheint die Platzhalter-Textur.
|
||||
- **Kacheln / Skalieren:** über einen **Mapping-Node** vor dem
|
||||
Image-Texture-Node (Location/Scale). Die Engine backt das
|
||||
(`KHR_texture_transform`) beim Laden in die UVs ein.
|
||||
|
||||
### Custom Properties auf Mesh-Objekten
|
||||
|
||||
| Property | Wirkung |
|
||||
|---|---|
|
||||
| *(keine)* | nur sichtbar, kein Anfassen |
|
||||
| `collide = 1` | sichtbar **und** solide (Spieler kollidiert mit der konvexen Hülle des Meshes — Dellen/Löcher werden überspannt) |
|
||||
| `collide = proxy` | unsichtbares Kollisionsvolumen (für Fein-Collider neben Sichtgeometrie) |
|
||||
| `signal = <name>` **mit** collide | Klick-Ziel: Anklicken feuert das Signal `<name>` |
|
||||
| `signal = <name>` **ohne** collide | unsichtbare Trigger-Zone: Betreten feuert `<name>` einmal (erneut erst nach Verlassen; „nur einmal überhaupt" selbst per KV-Flag bauen) |
|
||||
|
||||
- `collide = 0` schaltet ab, ohne die Property zu löschen.
|
||||
- Objektname ist der Interact-Key: Blender-Suffixe (`Ding.001`) werden beim
|
||||
Signal-Lookup automatisch gestrippt — `[Ding]` in signals.toml trifft alle.
|
||||
|
||||
### Custom Properties auf Empties
|
||||
|
||||
| Property | Wirkung |
|
||||
|---|---|
|
||||
| `role = spawn` | Spieler-Startpunkt: Fußpunkt = Empty-Position, Blick entlang der **grünen Y-Achse** des Empties (unrotiert = Blick wie Blenders Vorderansicht, Numpad 1). Der Empty-Name ist der Spawn-Name für `scene <szene> <spawn>`. |
|
||||
| `sound = <name>` | Ambient-Loop `assets/sounds/<name>.wav` an dieser Position |
|
||||
| `radius = <m>` | Hörradius des Sounds (linear leiser bis Stille; Default 8) |
|
||||
|
||||
## Szenen
|
||||
|
||||
- **Eine Szene = ein Ordner** `assets/maps/<szene>/`. Alle `.glb` darin
|
||||
werden zusammen geladen — Raum und Möbel dürfen also getrennte Dateien
|
||||
sein.
|
||||
- **Wechseln** per Action `scene <szene>` oder `scene <szene> <spawn>` —
|
||||
aus signals.toml, als Ink-Tag (`# scene cinema lobby`) oder in der Konsole.
|
||||
Typisch: eine Tür-Zone (`signal = zur_lobby` ohne collide) und in
|
||||
signals.toml `[zur_lobby]` → `"scene cinema lobby"`.
|
||||
- **Spawn:** ohne Namen der erste `role = spawn`-Empty der Szene; mit Namen
|
||||
der gleichnamige. Mehrere Eingänge = mehrere Spawn-Empties.
|
||||
- **Hauptmenü** ist die Szene `title`: dieselben Regeln, die Kamera steht am
|
||||
Spawn und schaut entlang seiner Y-Achse (auch nach oben/unten). Fehlt der
|
||||
Ordner, bleibt der Hintergrund schwarz.
|
||||
- **Startszene** des Spiels steht in signals.toml unter `[init]`
|
||||
(`"scene props"`). Zum Testen ohne Hauptmenü: `cargo run -- --scene <szene>`.
|
||||
- Der Story-Zustand (KV) bleibt über Szenenwechsel erhalten; nur
|
||||
„Neues Spiel" leert ihn.
|
||||
|
||||
## Audio
|
||||
|
||||
- **Format:** WAV, **mono, 16 bit, 44100 Hz** — nichts anderes. Ablage in
|
||||
`assets/sounds/`, angesprochen ohne Endung (`pickup` → `pickup.wav`).
|
||||
- **Ambient:** per Empty (siehe oben), loopt immer — Loop-Punkt sauber schneiden.
|
||||
- **Einmal-SFX:** per Action `play_sound <name>` (aus signals.toml oder Ink-Tag).
|
||||
|
||||
## Dialoge / Ink
|
||||
|
||||
- `.ink` nach `assets/interactions/` — wird beim Build automatisch
|
||||
kompiliert (bei Bedarf von Hand: `./tools/build-dialogues.sh`).
|
||||
- Gestartet per Action `start_ink <datei>.ink.json`.
|
||||
- **Variablen:** alle Ink-`VAR` landen automatisch im Spiel-KV und synchen
|
||||
in beide Richtungen — `_`-Prefix (`VAR _tmp = 0`) bleibt Ink-lokal.
|
||||
- **Tags feuern Actions:** `# set has_key true`, `# play_sound klick`,
|
||||
`# mode play` … (gleiche Verben wie signals.toml). Unbekannte Tags sind
|
||||
erlaubt (reine Metadaten).
|
||||
|
||||
## signals.toml (`assets/signals.toml`)
|
||||
|
||||
- Verdrahtet Signal → Aktionen. Signal-Namen: Objektname (Klick), Wert der
|
||||
`signal`-Property (Zonen/Klick-Ziele), oder frei (aus Ink).
|
||||
- Verben: `start_ink`, `set`, `inc`, `clear`, `debug_log`, `play_sound`,
|
||||
`mode play|free|menu`.
|
||||
- `$self` = auslösender Objektname (für generische Einträge wie
|
||||
`set $self true`).
|
||||
- `[init]` feuert einmal beim Start — Ort für KV-Defaults.
|
||||
|
||||
## Testen
|
||||
|
||||
- `cargo run` — Konsole zeigt beim Start, was ankam: Objekte, Dreiecke,
|
||||
Empties und **jede Custom Property**. Fehlt eine → Export-Haken prüfen.
|
||||
- Im Spiel (Konsole = das Terminal, aus dem gestartet wurde): `noclip` zum
|
||||
freien Fliegen, `kv` zeigt alle Variablen, `signal <name>` feuert jedes
|
||||
Signal von Hand, `reload` lädt signals.toml neu.
|
||||
|
After Width: | Height: | Size: 72 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
@@ -0,0 +1,279 @@
|
||||
// Cinema 24/7 -- Navigation
|
||||
// Lobby -> Foyer -> Labyrinth-Etagen -> Eingang Theater 4
|
||||
//
|
||||
// Variablen:
|
||||
// past_it -- Spieler ist an Theater 4 vorbeigegangen (bool)
|
||||
// snaks -- Spieler hat Snacks mitgenommen (0/1)
|
||||
// had_sweets -- Spieler hat süße Snacks gewählt (0/1)
|
||||
//
|
||||
// Übergang zu cinema_f4r4.ink via # start_ink Tag bei Eintreten in Theater 4.
|
||||
// KV-Store überträgt snaks/had_sweets/past_it automatisch ans nächste Script.
|
||||
|
||||
VAR past_it = false
|
||||
VAR snaks = 0
|
||||
VAR had_sweets = 0
|
||||
|
||||
-> the_cinema
|
||||
|
||||
|
||||
== the_cinema ==
|
||||
|
||||
The lobby has a very retro, synth-wave, neon, 70s look to it. The carpet alone makes your eyes hurt. This is not a cheeky metaphor for its ugliness. Your eyes really hurt when you stare at it for any length of time because the shades of blue and red, mixed together on it in geometric patterns, are so bright they make your vision dance in the low light. At a glance, something in the part of your brain that is responsible for processing visual data seems to short-circuit and you see the patterns move against each other, impossibly on the static floor.
|
||||
|
||||
* [>>>]
|
||||
-
|
||||
|
||||
Better look to the ceiling with its wavy cutouts backlit by colorful LED.
|
||||
|
||||
The ticket booth is unmanned of course, as is the snack dispensary. Which seems well stocked at least. The popcorn even looks fresh. Well, it smells fresh at least. The scent of pleasantly burned sugar is heavy in the air.
|
||||
|
||||
The ribbon barrier is closed but easy enough to bypass. Is it closed? It looks open. Though abandoned. But not for long. Not the abandonment of disrepair, only the momentary abandonment place like this experience between beginning and end of the shows. When all the visitors sit in their seats and the staff takes this moment to slip away for a quick smoke break. Something like that. Full behind doors but empty in the open.
|
||||
|
||||
* [>>>]
|
||||
-
|
||||
|
||||
You can even hear sounds that must be a film playing. Screams and gunfire. You hope someone left the door to that particular theatre open and that is why you can hear it so clearly. Because if the sound insulation is that shit, the movie going experience can't be very good here.
|
||||
|
||||
* [Slip under the ticket barrier]
|
||||
You raise the ribbon of the barrier and duck under it. Almost without a thought.
|
||||
-> the_foliar
|
||||
* [Go to the ticket booth]
|
||||
The graspable of the ticket booth is plastered with advertisements, movie posters and prohibition signs informing visitors of behaviours and attire within the cinema. The slip you took for a "closed" sign that hangs in the middle of the glass says the following.
|
||||
|
||||
"No tickets required. Proceed with caution."
|
||||
|
||||
On the little table where someone would place their tickets, there is another slip reading:
|
||||
|
||||
"Warning:
|
||||
|
||||
Everyone is free to enter.
|
||||
|
||||
But it is advised only to visit the auditoriums where no film is currently being played.
|
||||
|
||||
As the films are a bit extreme for most audiences.
|
||||
|
||||
Thank you for your visit!"
|
||||
** [Go into the cinema]
|
||||
You can open the flimsy barrier from here. It is secured right next to where you stand. So you enter the foliar.
|
||||
-> the_foliar
|
||||
** [Leave the cinema] You leave.
|
||||
-> END
|
||||
|
||||
-> the_foliar
|
||||
|
||||
|
||||
== the_foliar ==
|
||||
|
||||
The foliar is big. With couches to wait and meet and lounge on. The room is only broken up by advertising columns. Some of them display movie posters, though most are empty.
|
||||
|
||||
A long bar stretches the length of the back wall. Behind it chips and candy are stacked on shelves like those of an actual bar. It even has a mirrored backwall, which visually multiplies the colourful packaging. This pattern is only broken by enormous popcorn machines, which are full to the brim.
|
||||
|
||||
Do you want to grab a snack?
|
||||
* [Of course]
|
||||
~ snaks = 1
|
||||
** [Sweet] You grab a sweet snack. You are lucky. They have your favourite.
|
||||
~ had_sweets = 1
|
||||
** [Salty] You grab a salty snack. You are lucky. They have your favourite.
|
||||
* [I don't think so] You better not risk it.
|
||||
-
|
||||
To both sides of the room are stairs. This is a multi-floor cinema.
|
||||
-> groundfloor
|
||||
|
||||
|
||||
== groundfloor ==
|
||||
|
||||
+ [Go to the right staircase]
|
||||
{not (f1 > 0 or f2 > 0):
|
||||
You choose the right staircase to ascend to the first floor.
|
||||
|
||||
Pictures of actors in film scenes decorate the walls. They are probably supposed to be famous. Iconically recognisable. You know none of them. However, some catch your eye as familiar until you take a second look. They are certainly not cheap generic-property knockoffs to avoid copyright infringement. It's just a coincidence.
|
||||
|
||||
A big number: 1 marks the landing to the next floor.
|
||||
}
|
||||
{f1 > 0 or f2 > 0:
|
||||
You enter the first floor.
|
||||
}
|
||||
-> f1.r
|
||||
+ [Go to the left staircase]
|
||||
{not (f1 > 0 or f2 > 0):
|
||||
You choose the left staircase to ascend.
|
||||
|
||||
Pictures of actors in film scenes decorate the walls. They are probably supposed to be famous. Iconically recognisable. You know none of them. However, some catch your eye as familiar until you take a second look. They are certainly not cheap generic-property knockoffs to avoid copyright infringement. It's just a coincidence.
|
||||
|
||||
A big number: 2 marks the landing to the next floor.
|
||||
}
|
||||
{f1 > 0 or f2 > 0:
|
||||
You enter the second floor.
|
||||
}
|
||||
-> f2.l
|
||||
|
||||
|
||||
// ── Etagen-Labyrinth ────────────────────────────────────────────────────────
|
||||
// Die Stockwerk-Verbindungen sind absichtlich nicht-euklidisch.
|
||||
// Treppenauf/-ab führen nicht zu linear benachbarten Etagen.
|
||||
|
||||
== f1 ==
|
||||
= r
|
||||
+ [Go down the corridor.] -> f1.l
|
||||
+ [Take the stairs up.]
|
||||
You enter the fifth floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f5.r
|
||||
+ [Take the stairs down.]
|
||||
You enter the sixth floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f6.r
|
||||
|
||||
= l
|
||||
+ [Go down the corridor.] -> f1.r
|
||||
+ [Take the stairs up.]
|
||||
You enter the third floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f3.l
|
||||
+ [Take the stairs down.]
|
||||
You enter the seventh floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f7.l
|
||||
|
||||
|
||||
== f2 ==
|
||||
= r
|
||||
+ [Go down the corridor.] -> f2.l
|
||||
+ [Take the stairs up.]
|
||||
You enter the sixth floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f6.r
|
||||
+ [Take the stairs down.]
|
||||
You enter the seventh floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f7.r
|
||||
|
||||
= l
|
||||
+ [Go down the corridor.] -> f2.r
|
||||
+ [Take the stairs up.]
|
||||
You enter the fifth floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f5.l
|
||||
+ [Take the stairs down.]
|
||||
You enter the first floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f1.l
|
||||
|
||||
|
||||
== f3 ==
|
||||
= r
|
||||
+ [Go down the corridor.] -> f3.l
|
||||
+ [Take the stairs up.]
|
||||
You are back on the ground floor.
|
||||
-> groundfloor
|
||||
+ [Take the stairs down.]
|
||||
You enter the second floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f2.r
|
||||
|
||||
= l
|
||||
+ [Go down the corridor.] -> f3.r
|
||||
+ [Take the stairs up.]
|
||||
You enter the sixth floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f6.l
|
||||
+ [Take the stairs down.]
|
||||
You enter the seventh floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f7.l
|
||||
|
||||
|
||||
== f4 ==
|
||||
= r
|
||||
+ [Go down the corridor.]
|
||||
{not past_it:
|
||||
You go down the corridor. It is empty. Some of the doors are closed. Some are slightly open. When you get close to the door of theatre 4 you can hear soft sounds. There is no film playing in the theatre according to the sign beside the door.
|
||||
- else:
|
||||
The corridor is still the same. And there are still the same faint noises coming out of theatre 4.
|
||||
}
|
||||
** [Enter]
|
||||
So you enter. # start_ink cinema_f4r4.ink.json
|
||||
-> END
|
||||
** [Go past it.]
|
||||
~ past_it = true
|
||||
You go past it.
|
||||
You walk closer to one wall. You want to run your fingers along it while you walk, but can't quite bring yourself to do so. To move the final millimetre closer to the wall. As if you are on tracks. Soon you are at the other side of the floor.
|
||||
-> f4.l
|
||||
+ [Take the stairs up.]
|
||||
You enter the fifth floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f5.l
|
||||
+ [Take the stairs down.]
|
||||
You are back on the ground floor.
|
||||
-> groundfloor
|
||||
|
||||
= l
|
||||
+ [Go down the corridor.]
|
||||
{not past_it:
|
||||
You go down the corridor. It is empty. Some of the doors are closed. Some are slightly open. When you get close to the door of theatre 4 you can hear soft sounds. There is no film playing in the theatre according to the sign beside the door.
|
||||
- else:
|
||||
The corridor is still the same. And there are still the same faint noises coming out of theatre 4.
|
||||
}
|
||||
** [Enter]
|
||||
So you enter. # start_ink cinema_f4r4.ink.json
|
||||
-> END
|
||||
** [Go past it.]
|
||||
~ past_it = true
|
||||
You go past it.
|
||||
You walk closer to one wall. You want to run your fingers along it while you walk, but can't quite bring yourself to do so. To move the final millimetre closer to the wall. As if you are on tracks. Soon you are at the other side of the floor.
|
||||
-> f4.r
|
||||
+ [Take the stairs up.]
|
||||
You enter the seventh floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f7.l
|
||||
+ [Take the stairs down.]
|
||||
You are back on the ground floor.
|
||||
-> groundfloor
|
||||
|
||||
|
||||
== f5 ==
|
||||
= r
|
||||
+ [Go down the corridor.] -> f5.l
|
||||
+ [Take the stairs up.]
|
||||
You enter the second floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f2.r
|
||||
+ [Take the stairs down.]
|
||||
You enter the third floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f3.l
|
||||
|
||||
= l
|
||||
+ [Go down the corridor.] -> f5.r
|
||||
+ [Take the stairs up.]
|
||||
You enter the first floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f1.l
|
||||
+ [Take the stairs down.]
|
||||
You enter the sixth floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f6.l
|
||||
|
||||
|
||||
== f6 ==
|
||||
= r
|
||||
+ [Go down the corridor.] -> f6.l
|
||||
+ [Take the stairs up.]
|
||||
You enter the first floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f1.r
|
||||
+ [Take the stairs down.]
|
||||
You enter the fourth floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.}}
|
||||
-> f4.r
|
||||
|
||||
= l
|
||||
+ [Go down the corridor.] -> f6.r
|
||||
+ [Take the stairs up.]
|
||||
You are back on the ground floor.
|
||||
-> groundfloor
|
||||
+ [Take the stairs down.]
|
||||
You enter the third floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f3.l
|
||||
|
||||
|
||||
== f7 ==
|
||||
= r
|
||||
+ [Go down the corridor.] -> f7.l
|
||||
+ [Take the stairs up.]
|
||||
You enter the third floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f3.r
|
||||
+ [Take the stairs down.]
|
||||
You enter the fifth floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f5.r
|
||||
|
||||
= l
|
||||
+ [Go down the corridor.] -> f7.r
|
||||
+ [Take the stairs up.]
|
||||
You enter the fourth floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.}}
|
||||
-> f4.l
|
||||
+ [Take the stairs down.]
|
||||
You enter the second floor. {~It looks like all the others.|||{~It looks the same as all the others.|More hallway. More carpet.|Just another floor}}
|
||||
-> f2.l
|
||||
|
||||
@@ -0,0 +1,856 @@
|
||||
// Cinema 24/7 -- Theater 4: Nails
|
||||
// Begegnung mit Nails, der Schattenkünstlerin.
|
||||
//
|
||||
// Variablen:
|
||||
// favor_nails -- Nails' Stimmung; > 0 = Sympathie, < 0 = Genervtheit
|
||||
// past_it -- aus cinema.ink via KV: Spieler ist an Theater 4 vorbeigegangen
|
||||
// snaks -- aus cinema.ink via KV: Spieler hat Snacks (0/1)
|
||||
// had_sweets -- aus cinema.ink via KV: Spieler hat Süßes gewählt (0/1)
|
||||
// fallbear -- temporär: Bär verliert Gleichgewicht beim Ausweichen
|
||||
// boop_success -- temporär: Einhorn-Nase boopen erfolgreich (0/1)
|
||||
//
|
||||
// Stub-Knoten (noch zu schreiben):
|
||||
// the_show, cbear, shadow_battle, apprentice, quitter,
|
||||
// her_portfolio, performance, practice, seeulater
|
||||
|
||||
VAR favor_nails = 0
|
||||
VAR past_it = false
|
||||
VAR snaks = 0
|
||||
VAR had_sweets = 0
|
||||
VAR fallbear = false
|
||||
VAR boop_success = false
|
||||
|
||||
-> f4r4
|
||||
|
||||
|
||||
== f4r4 ==
|
||||
|
||||
You push the door open to a few steps bringing you the level where the seats are. The theatre screen is lit in a faint pink that floods the dingy room with a pleasant atmosphere. The seats lie in shadow, but they look empty.
|
||||
|
||||
+ [Go to the screen] -> f4r4.to_the_screen
|
||||
+ [Sit down in the closest seat] -> f4r4.frontrow_to_show
|
||||
+ [Go to the back] -> f4r4.backseat
|
||||
|
||||
= to_the_screen
|
||||
You go through the aisle to the very front. You are so close to the screen here that your entire field of view is absorbed by this shade of pink, if you angle your head right.
|
||||
|
||||
+ [Go closer to the screen so your shadow falls on it]
|
||||
You take a few more steps until your silhouette emerges as a dark shape from the dark lower border of the screen.
|
||||
++ [Raise your arms] You raise your arms to see your shadow do the same.
|
||||
++ [Walk to the side] You walk a few steps to the side to see your shadow do the same.
|
||||
--
|
||||
Until the enormous shape of a wolf jumps at you from the side. You only see it come for a second before you flinch away.
|
||||
|
||||
But there is no impact, it is just another shadow. It looked very real out of the corner of your eye. On a second look, you see that it is the projection of masterfully interwoven fingers, cast from the back of the theatre.
|
||||
-> f4r4.first_duet
|
||||
+ [Turn back to the seats]
|
||||
But you turn away from it and to the seats again. From here you have a better view of the theatre and can see a shape, sitting in the elevated rows on the back half of the room.
|
||||
-
|
||||
A voice comes from there.
|
||||
|
||||
Her: OMG! I totally don't believe it? Is that an audience? OK. OK. OK, sit down. The show is about to start.
|
||||
++ [Take a seat]
|
||||
You sit down in the front row and look up to the screen.
|
||||
-> f4r4.the_show
|
||||
++ [Go to the person]
|
||||
You are more curious about this person than the show. So you decide to make your way up the dark rows of seats to get a better look.
|
||||
-> f4r4.the_performer
|
||||
|
||||
= frontrow_to_show
|
||||
You slump down in the closest seat. You are fairly far to the front. So you can lie your head down on the back of the seat to look up into the abyss of pink.
|
||||
|
||||
You have huffed out only one deep breath before the shadow of a giant hand rips the light and colour of the screen apart.
|
||||
|
||||
+ [I'm startled]
|
||||
You startle at that and turn around in your seat to look for the source of the shadow.
|
||||
|
||||
Against the glare of the projector you can just about make out two hands which are raised over the rows of seats.
|
||||
|
||||
You raise a hand against the bright light. But before your eyes can adjust to the dark, you hear a voice.
|
||||
|
||||
Her: Eyes front, please. Or you'll miss the show.
|
||||
|
||||
The voice has the twang of mock annoyance.
|
||||
++ [Turn to the screen] You comply and look to the screen again. -> f4r4.the_show
|
||||
++ [Go to investigate] You get up and go towards the back, where the figure is. -> f4r4.the_performer
|
||||
--
|
||||
+ [This is fine.]
|
||||
++ [I turn to look for the shadow maker]
|
||||
You turn around in your seat to look for the source of the shadow.
|
||||
|
||||
Against the glare of the projector you can just about make out two hands which are raised over the landscape of cushioned backrests.
|
||||
|
||||
You raise a hand against the bright light. But before your eyes can adjust to the dark, you hear a voice.
|
||||
|
||||
Her: Eyes front, please. Or you'll miss the show.
|
||||
|
||||
The voice has the twang of mock annoyance.
|
||||
+++ [Turn to the screen] You comply and look to the screen again. -> f4r4.the_show
|
||||
+++ [Go to investigate] You get up and go towards the back, where the figure is. -> f4r4.the_performer
|
||||
---
|
||||
++ [I keep looking at the screen]
|
||||
You keep your eyes on the screen unperturbed and follow the movements of the shadows with your eyes.
|
||||
-> f4r4.silent_show
|
||||
|
||||
= backseat
|
||||
When you are at the cinema, do you always prefer the seats at the very back? You make your way there now, automatically. You shimmy into the aisles and pick a seat. You sit down. It is comfortable. It is fine. You relax, with the whole room in view.
|
||||
-> f4r4.the_show
|
||||
|
||||
= the_performer
|
||||
Her: No. It's fine. You can sit down in the front as well. Just there will be fine.
|
||||
|
||||
+ [Continue to the back]
|
||||
~ favor_nails = favor_nails - 1
|
||||
You continue your way despite her protests.
|
||||
|
||||
Her: Just sit down! Urgh. Now I have to delay the performance.
|
||||
|
||||
You have reached the row where the figure sits and huffs unhappily at you. You can still only see their outline in the dark. Something about it is strange. Their head is oddly big. It has a weird shape, too.
|
||||
|
||||
Her: Fine, you can sit in the back row if you have to. No respect for the craft.
|
||||
|
||||
+ [Take a seat where you are] She sounds annoyed. You decide to obey and sit down in the middle row. -> f4r4.the_show
|
||||
- (just_sit_damnit)
|
||||
* [Who are you?]
|
||||
You: Who are you?
|
||||
|
||||
Her: Only the greatest visual artist you will ever meet. Not that you would be able to appreciate it, since you refuse to sit down for the performance to start.
|
||||
|
||||
++ [That's not really an answer.]
|
||||
~ favor_nails = favor_nails - 3
|
||||
You: That's not really an answer.
|
||||
|
||||
Her: Oh mahhai, unbelievable. Don't be such a pain in the ass just sit down or get out of my theatre.
|
||||
|
||||
+++ [What kind of performance?]
|
||||
~ favor_nails = favor_nails - 1
|
||||
You: What kind of performance?
|
||||
|
||||
Her: Are you for fudging real? Just sit down and find out?
|
||||
-> just_sit_damnit
|
||||
+++ [Can I sit with you?]
|
||||
Her: I need some space to perform. Just keep a little bit of a distance.
|
||||
++++ [Sit down across the aisle] You just sit down in the first seat across the aisle from her. -> f4r4.the_show
|
||||
++++ [Take a seat two places away from her]
|
||||
You shimmy into the aisle where she is and sit down with a double seat of space to her. A side glance in her direction subjects ruffled knit fabrics and jangling bracelets.
|
||||
-> f4r4.the_show
|
||||
++++ [Sit down in the back row]
|
||||
You'd actually prefer to sit in the back row. So you go and take your seat, your back against the wall, with the whole theatre in view.
|
||||
-> f4r4.the_show
|
||||
+++ [You just sit your ass down across the aisle from her]
|
||||
You just sit down in the first seat across the aisle from her.
|
||||
-> f4r4.the_show
|
||||
+++ [Sit down in the back row]
|
||||
You prefer to sit in the back row. So you go and take your seat, your back against the wall, with the whole theatre in view.
|
||||
-> f4r4.the_show
|
||||
--
|
||||
* [Can I sit with you?]
|
||||
~ favor_nails = favor_nails + 1
|
||||
You: Can I sit with you?
|
||||
|
||||
Her: Oh. Well, actually I need a bit of space to perform. But you can sit here if you want.
|
||||
|
||||
You can just make out a hand with long, pink acrylic nails and glittering rings gesturing to a place two seats away from her.
|
||||
|
||||
You shimmy into the aisle and take the seat. A side glance in her direction subjects ruffled knit fabrics and jangling bracelets.
|
||||
-> f4r4.the_show
|
||||
* [Sit down across the aisle from her]
|
||||
You sit down in the first seat across the aisle from her.
|
||||
-> f4r4.the_show
|
||||
* [Sit down in the back row]
|
||||
You prefer to sit in the back row. So you go and take your seat, your back against the wall, with the whole theatre in view.
|
||||
-> f4r4.the_show
|
||||
|
||||
= first_duet
|
||||
* [Try to see the one making the shadow]
|
||||
You turn, raising your hand against the light of the projector. But too late, the glare has already gotten into your eyes and you can't make out anything in the darkness of the room.
|
||||
|
||||
An amused voice comes out of the darkness.
|
||||
|
||||
Her: Watch out, here it comes again.
|
||||
|
||||
++ [Turn to the screen]
|
||||
Turn back towards the screen and see the wolf pace your shadow. Readying itself for the next attack.
|
||||
-> f4r4.first_duet
|
||||
++ [Go investigate]
|
||||
You start up the aisle between the seats.
|
||||
|
||||
A voice comes out of the darkness.
|
||||
|
||||
Her: Whahat? Don't tell me you didn't like that. That was A-Class theatre. You know I don't get an audience here often. Take a seat and I'll show you a real show.
|
||||
-> f4r4.the_performer
|
||||
* (bunny)[Make the shadow figure of a bunny, to run from the wolf]
|
||||
You position your hands to make the figure of a bunny.
|
||||
++ Its ears wiggle nervously. [] The ears of the wolf twitch in turn, with anticipation.
|
||||
++ It rubs its nose with its front paws in an attempt to be too cute to be eaten. [] But there is only a low hungry growl from the back of the theatre.
|
||||
--
|
||||
Your bunny decides to make a run for it.
|
||||
|
||||
The wolf jumps after it with graceful movements. It is quick and deadly.
|
||||
|
||||
++ [The bunny flees off screen]
|
||||
Your bunny flees to the side of the screen and jumps into the unlit void. Trusting that nonexistence will keep it safe from the jaws of the predator.
|
||||
-> f4r4.quitter
|
||||
++ [The bunny flees across the screen]
|
||||
Your bunny hops across the screen. You have to be fast and clever and change directions often to get away from the monster chasing you.
|
||||
--
|
||||
Soon you are short of breath and turn once more to see the wolf mid-air just above you. Maw wide, ready to consume you. The running is over. You only have a second to decide what to do.
|
||||
|
||||
++ [Accept your fate]
|
||||
So you accept your fate and cower the bunny down in a final primal reflex, before the wolf is on top of you and swallows you whole.
|
||||
|
||||
You are blacked out by the shape of it for a moment and can see the hands raised above the seats silhouetted against the rays of beamer light. Maybe it is just the perspective or something, but they seem gigantic.
|
||||
|
||||
Then the shadow of the wolf moves beside you again. The light punches you in the face and it wags its tail. A voice comes from the back of the room.
|
||||
|
||||
Her: Ahhh! That was SOOOOO FUN. More. More. More.
|
||||
|
||||
+++ [I think I need to catch my breath first.]
|
||||
You: I think I need to catch my breath first.
|
||||
|
||||
Her: Hm. Okie doke. You wanna see one of my specialities?
|
||||
|
||||
++++ [Sure.] You: Sure.
|
||||
You take your front row seat and look up to the screen.
|
||||
-> f4r4.the_show
|
||||
++++ [Who are you?]
|
||||
You: Who are you?
|
||||
|
||||
Her: I'm the baddest bitch alive. Now sit your ass down and let me put on a show.
|
||||
----
|
||||
-> f4r4.the_show
|
||||
++++ [Sit] You indulge her and sit. -> f4r4.the_show
|
||||
++++ [Go up to her] You make your way up the aisles to her. -> f4r4.the_performer
|
||||
+++ [OK. But next time I won't be such easy prey.]
|
||||
You: OK. But next time I won't be such easy prey.
|
||||
|
||||
Her: Uh. You want a shadow battle? Bring it oooooon.
|
||||
-> f4r4.shadow_battle
|
||||
---
|
||||
++ (cheat)[Turn into a crocodile]
|
||||
So you dissolve the bunny to spread your arms wide. Creating the long jaws of a crocodile. It is a desperate move and unexpected enough that the wolf can't stop before plunging dead first into the trap you just created. You snap your arms together.
|
||||
|
||||
The wolf's whine becomes a whiny voice.
|
||||
|
||||
Her: NOOOOOOO. That's not fair. Not fair. Not fair.
|
||||
|
||||
+++ [Says who?]
|
||||
You: Says who?
|
||||
|
||||
Her: Says ME! You can't just change the rules like that.
|
||||
|
||||
You: I wasn't aware there were any rules.
|
||||
|
||||
Her: But I wanted to eat you!
|
||||
|
||||
++++ [You can eat my ass.]
|
||||
She laughs.
|
||||
|
||||
Her: EW! I don't even know you.
|
||||
|
||||
+++++ [We can change that.]
|
||||
~ favor_nails = favor_nails + 1
|
||||
You: We can change that.
|
||||
|
||||
Her: WOW. You coming on strong. I can't even tell if you're cute from up here. We will have to meet somewhere where it is light, some time.
|
||||
|
||||
++++++ [It's a date.] You: It's a date.
|
||||
She giggles.
|
||||
------
|
||||
Her: I wanna practice some more of my figures. Do you wanna watch?
|
||||
-> f4r4.practice
|
||||
++++++ [How about now?] You: How about now?
|
||||
------
|
||||
Her: I wanna practice some more of my figures. Do you wanna watch?
|
||||
-> f4r4.practice
|
||||
+++++ [I don't know you either.]
|
||||
You: I don't know you either.
|
||||
|
||||
Her: You know my work. So you already know I'm fab as fuck.
|
||||
|
||||
++++++ [True.] You: True.
|
||||
Her: Do you wanna see some more?
|
||||
+++++++ [Sure.] You: Sure. -> f4r4.the_show
|
||||
+++++++ [I would actually like to get to know you.]
|
||||
You: I would actually like to get to know you.
|
||||
|
||||
Her: HHHM. I actually wanna practice some more figures. But we can grab snacks after.
|
||||
|
||||
++++++++ [Can I watch you practice?]
|
||||
You: Can I watch you practice?
|
||||
Her: Sure.
|
||||
-> f4r4.practice
|
||||
++++++++ [Should I come back later to pick you up?]
|
||||
You: Should I come back later to pick you up?
|
||||
Her: If you want.
|
||||
--------
|
||||
You: OK, I will see you in a bit.
|
||||
-> f4r4.seeulater
|
||||
-------
|
||||
Her: Nice. What do you want to see? My portfolio or a Full Performance?
|
||||
+++++++ [Portfolio] You: Your portfolio? Now I'm curious. -> f4r4.her_portfolio
|
||||
+++++++ [Performance] You: I would like to see a performance. -> f4r4.performance
|
||||
-----
|
||||
++++ [No don't eat me. I can get you popcorn instead.]
|
||||
Her: NAWWW! OK. Fair is fair.
|
||||
+++ [Sorry.]
|
||||
You: Sorry. But I don't want to die today.
|
||||
|
||||
Her: Well, you shouldn't have been a bunny then, gorgeous. A wolf has to eat.
|
||||
* [Make the shadow figure of a bear, to confront the wolf]
|
||||
You make a bear...
|
||||
|
||||
Do you know how to make a bear shadow figure?
|
||||
|
||||
++ [YES]
|
||||
OK. You make a bear. But due to your position relative to the screen it is too tiny to confront the wolf.
|
||||
++ [NO] You don't make a bear. -> f4r4.first_duet
|
||||
--
|
||||
The wolf is watching you impatiently.
|
||||
++ [Make the bear bigger] You decide to make a bigger bear.
|
||||
++ [Do something else] -> f4r4.first_duet
|
||||
--
|
||||
But the beast on the screen beside you has clearly had enough and is readying its next attack.
|
||||
++ [Make your way to the back of the room]
|
||||
You can't compete from down here. So you start to make your way up the aisles to some high ground.
|
||||
|
||||
As soon as you step out of the light of the screen a voice comes from the back.
|
||||
|
||||
Her: No! Where are you going? I thought we were going to play?
|
||||
|
||||
You squint up and into the dark and see two abnormally large hands raised over the seats and backlit by the projector.
|
||||
|
||||
+++ [I'm just coming up to project better.]
|
||||
You: I'm just coming up to project better.
|
||||
|
||||
Her: I think you'll need a little more than that to get on my level.
|
||||
|
||||
++++ [I'm sure.] You: I'm sure.
|
||||
Her: You can still show me what you've got, though. Come here.
|
||||
-> f4r4.deathmatch
|
||||
++++ [We will see.] You: We will see.
|
||||
Her: OK. A challenge? IT. IS. ON.
|
||||
-> f4r4.deathmatch
|
||||
+++ [Who are you?]
|
||||
You: Who are you?
|
||||
|
||||
Her: Ähm, Hellooho? I'm just the greatest show master in this place. Maybe in the world. Your pleasure.
|
||||
|
||||
++++ [How was I supposed to know that?]
|
||||
~ favor_nails = favor_nails - 1
|
||||
|
||||
Her: OK I forgive you, that you have no taste. I'll even put on a show, yes? Sit down.
|
||||
|
||||
+++++ [Sit] You sit in the seat nearest to you. -> f4r4.the_show
|
||||
+++++ [Go up to her] You continue to go up to her. -> f4r4.the_performer
|
||||
+++++ [I thought we were going to make a wolf and bear death match?]
|
||||
You: I thought we were going to make a wolf and bear death match?
|
||||
Her: Ya. OK. You can come here so I can obliterate you.
|
||||
-> f4r4.deathmatch
|
||||
++++ [I think they have failed to put up a poster for you downstairs.]
|
||||
Her: What do you expect? There is no fudging respect for real art in this place. So lame. Sit down and I'm gonna give you the real off the hook showy show stuff.
|
||||
|
||||
+++++ [Sit] You sit in the seat nearest to you. -> f4r4.the_show
|
||||
+++++ [Go up to her] You continue to go up to her. -> f4r4.the_performer
|
||||
+++++ [I thought we were going to make a wolf and bear death match?]
|
||||
You: I thought we were going to make a wolf and bear death match?
|
||||
Her: Ya. OK. Come here and bring it on then.
|
||||
-> f4r4.deathmatch
|
||||
++ [Run to the back of the room]
|
||||
You are just a tiny thing down here, without a fighting chance. You bolt up the aisle to get yourself some size.
|
||||
|
||||
There is a startled squeak from the back of the room.
|
||||
|
||||
+++ [Ignore it]
|
||||
You charge on. To a spot where you will be big enough. You jump on to a seat for more high ground and make a much better sized bear.
|
||||
-> f4r4.bear
|
||||
+++ [Look up]
|
||||
You look up and slow down. Squinting into the darkness you can see a figure in one of the raised rows. Your opponent.
|
||||
|
||||
You arrive at a spot where you will be big enough. You jump on to a seat for more high ground and make a much better sized bear.
|
||||
-> f4r4.bear
|
||||
++ [Clamber over the seats like a crazy person]
|
||||
You are just a tiny thing down here, begging to be eaten alive. You jump and clamber over the backs of the seats to get yourself some size.
|
||||
|
||||
There is laughter from the back of the theatre.
|
||||
|
||||
Her: HAHAHA what are you doing? The wolf is not actually gonna eat you, you know?
|
||||
|
||||
+++ [Continue] You don't stop. Only slow down a little to look up.
|
||||
+++ [Halt] You stop to look up.
|
||||
---
|
||||
You can see two giant backlit hands. Forming a wolf.
|
||||
|
||||
+++ [Best to be sure it won't eat me.]
|
||||
Her: Jup. OK?
|
||||
|
||||
You have made enough ground and are standing up on a seat now. You make a bear that is much better sized.
|
||||
|
||||
You: Jup. Much better. Thanks. Let's GO.
|
||||
-> f4r4.bear
|
||||
+++ [I was just trying to get some high ground for a counterattack.]
|
||||
Her: Oh! You think you can challenge me? Bring it on.
|
||||
|
||||
You have made enough ground and are standing up on a seat now. You make a bear that is much better sized.
|
||||
|
||||
You: Let's go.
|
||||
-> f4r4.bear
|
||||
* [Mime your bloody death from the wolf attack]
|
||||
Your reaction time is a bit off. But it is not too late yet to mime your bloody murder by the claws of the beast. You put some theatricality into your death scene.
|
||||
|
||||
Your reward is amused laughter from the back of the theatre as the wolf dissolves into hands.
|
||||
|
||||
++ [Take a bow]
|
||||
You take a theatrical bow. Which is rewarded with some fluttery applause.
|
||||
++ [Try to see the shadow maker]
|
||||
You raise your hand and squint against the beamer's glare to see your attacker. You can only just about see two very large hands.
|
||||
--
|
||||
Her: Do another one. Do another one!
|
||||
|
||||
++ [Ok. Attack me again.] You: Ok. Attack me again. -> f4r4.unicorn
|
||||
++ [Make your own shadow puppet]
|
||||
You decide to try your own hand at shadow puppeteering.
|
||||
|
||||
Do you even know how to do that?
|
||||
|
||||
+++ [Yes]
|
||||
Alright. You make a...
|
||||
++++ [Wolf] A small wolf.
|
||||
++++ (bunny_puppet)[Bunny] A bunny.
|
||||
++++ [Butterfly] A butterfly.
|
||||
++++ [Spider] A scuttling spider.
|
||||
----
|
||||
Her: Sorry. Not sorry. I'm not impressed. But it is also veeeerrrrryyyy hard to impress me.
|
||||
+++ [No]
|
||||
You don't really know how but you can still make a shadow figure with your full body.
|
||||
|
||||
So you make...
|
||||
++++ [A worm] A worm, by raising your hand over your head and making a wave with your whole body.
|
||||
++++ (kitty)[Yourself cat ears]
|
||||
Your hands into cat ears. They turn and twitch.
|
||||
+++++ [Miou.]
|
||||
~ favor_nails = favor_nails + 1
|
||||
You: Miou.
|
||||
Her: Naw
|
||||
++++ [Yourself antlers] Your hands into majestic antlers protruding from your head.
|
||||
++++ [A T-pose] A T-pose. You had other ideas, but I guess you like being trash.
|
||||
Her: Hmmm. OK? What are you supposed to be?
|
||||
----
|
||||
---
|
||||
Her: I possibly see the tiniest bit of talent here. Maybe if you work at it, we could make a show together. If you try to upstage me, you are out, though.
|
||||
-> f4r4.apprentice
|
||||
* [Try to replicate the wolf]
|
||||
You try to figure out how exactly the shape of the wolf is made and to interlock your own fingers to replicate the effect.
|
||||
|
||||
++ [Observe] You observe...
|
||||
--
|
||||
++ [Build the finger form] Arrange the fingers...
|
||||
--
|
||||
++ [Project]
|
||||
// TODO: per Shuffle zufällig zwischen "passable" und "ugly" wechseln.
|
||||
// Inklecate unterstützt keine mehrzeiligen {~}-Sequenzen -- braucht
|
||||
// VAR wolf_ugly + { shuffle: - ... - ... }-Syntax oder zwei Pfade.
|
||||
And... you create a passable attempt. Much smaller and a little crooked, maybe.
|
||||
--
|
||||
|
||||
= unicorn
|
||||
Her: OK. OK. Do this one.
|
||||
|
||||
The hands resolve themselves into the shape of a unicorn.
|
||||
|
||||
+ [Try to pacify the beast]
|
||||
You hold out your hand in an attempt to pacify the beast.
|
||||
|
||||
The unicorn huffs and scuffs a hoof against the floor.
|
||||
|
||||
++ [Shhh. Easy. It's fine.]
|
||||
The unicorn doesn't seem convinced. It shakes its head in irritation.
|
||||
|
||||
+++ {snaks} [Present the snacks you picked up as a peace offering]
|
||||
You: Here I have something for you.
|
||||
|
||||
You hold out the sweets you picked up earlier.
|
||||
|
||||
Her: OMG! You have snacks? I want some. I want some! Get up here!
|
||||
|
||||
She sounds so excited, you have to oblige.
|
||||
-> f4r4.snacksharing
|
||||
+++ [Persist in being soothing]
|
||||
You still persist in making soothing noises and hold your hands up.
|
||||
|
||||
But it doesn't help.
|
||||
+++ [Prepare for an attack]
|
||||
You step back a little and square your stance for the next attack.
|
||||
---
|
||||
++ [Prepare for an attack]
|
||||
You step back a little and square your stance for the next attack.
|
||||
--
|
||||
+ [Prepare for the attack]
|
||||
You square your stance in anticipation for the next attack.
|
||||
-
|
||||
It scuffs its hoofs, rears up and charges you.
|
||||
|
||||
+ [Dodge]
|
||||
In the last moment you perform a jump-roll to the side.
|
||||
|
||||
Her: Hey! You can't dodge-roll in two dimensions!
|
||||
|
||||
++ [Worth a try!]
|
||||
You: Worth a try!
|
||||
|
||||
Now you are in the position of squaring off with the unicorn again. It charges once more.
|
||||
|
||||
+++ [Dodge]
|
||||
You dodge-roll again and hear a frustrated shout from the back of the theatre.
|
||||
|
||||
As you get back up again you see the shadow unicorn is already on top of you. Trampling you to death instead.
|
||||
|
||||
Her: There, serves you right, you jumping Jack. Are you trying to steal my scene? You know, for a moment there I thought this was kind of fun. Tell me: what are your acting references?
|
||||
++++ [Get impaled]
|
||||
---
|
||||
---
|
||||
++ [Oh Yeah? Watch me!]
|
||||
You: OH Yeah? Watch me!
|
||||
|
||||
You proceed to dodge-roll across the stage like a hedgehog on speed.
|
||||
|
||||
Between rolls you see the bewildered unicorn watch you from the side.
|
||||
|
||||
+++ [You could probably surprise it and boop it on the nose]
|
||||
~ boop_success = RANDOM(0, 1) == 1
|
||||
{boop_success:
|
||||
You jump-roll towards it, get up and manage a quick boop on its nose before dodge-rolling away again.
|
||||
- else:
|
||||
You jump-roll towards it. But unfortunately it wasn't that distracted and before you can boop it, it has lowered its horn and is making you into crazy-person-shashlik.
|
||||
}
|
||||
{not boop_success: -> after_boop}
|
||||
++++[Celebrate your victory]
|
||||
You stop to raise your hands up into the air to celebrate your victory. Meanwhile there is sarcastic clapping from the backseats.
|
||||
|
||||
Her: wow. OK. Great show, I guess. Very... acrobatic
|
||||
---- (after_boop)
|
||||
+++ [Continue rolling]
|
||||
You can't stop now. So you dodge-roll until you become nauseous and you are out of breath.
|
||||
|
||||
You just collapse on the floor and take some deep breaths. It's getting warm in the beamer light.
|
||||
|
||||
On the screen beside you, you can see the shadow unicorn come up to you cautiously and sniff you.
|
||||
|
||||
++++ [Raise a hand]
|
||||
You raise a hand to show up on the screen. The unicorn raises its head out of reach again.
|
||||
|
||||
Her: OH Good. You are not dead.
|
||||
++++ [Sit up]
|
||||
You sit up and the unicorn steps back from your shadow. Satisfied you are ok.
|
||||
|
||||
Her: Oh Good. You are not dead.
|
||||
----
|
||||
---
|
||||
++ [Just wanted to make it a bit more interesting.]
|
||||
You: Just wanted to make it a bit more interesting.
|
||||
|
||||
Her: Convince me of your acting talent first. We can workshop it once I have decided you are worth it to share a stage with me.
|
||||
|
||||
The unicorn charges again.
|
||||
|
||||
+++ [Dodge]
|
||||
You dodge-roll again.
|
||||
|
||||
Her: HEY!
|
||||
|
||||
As you get back up again you see the shadow unicorn is already on top of you. Trampling you to death.
|
||||
|
||||
Her: There, serves you right, you jumping Jack. Are you trying to steal my scene? Tell me: what are your acting references?
|
||||
++++ [Get impaled]
|
||||
---
|
||||
--
|
||||
You try even harder for your second death scene. Now that you know you have an appreciative scene partner and audience. You cheat to the side of the screen to see the unicorn and its movement. It has got you through the solar plexus and you convulse with the jerks of its head. When it finally pulls its horn up and out, you go with the movement and fall face first to the floor. You just about manage to make it a stage fall and not knock your teeth out on the thin scratchy carpet.
|
||||
|
||||
You stay on the floor until you hear clapping.
|
||||
|
||||
Her: I have to say, that wasn't bad. I mean I clearly carried the scene. But it really makes the action more lively with an acting partner. Tell me: what are your references?
|
||||
|
||||
* [I did some acting in school.] You: I did some acting in school.
|
||||
Her: Wouldn't go boasting with that.
|
||||
* [I actually have a degree in acting.] You: I actually have a degree in acting.
|
||||
Her: Well, there is no such thing as a legitimate art adjudication, you know.
|
||||
* [I am just a natural.] You: I am just a natural.
|
||||
Her: Ha. Sure thing sweety. Don't talk about a natural when I'm at the table.
|
||||
-
|
||||
Her: I can accept this as a first audition, I think. I know I'm hard to impress. The competition is very absent, though. But I think I really saw a bit of style in there. Deep, deep down. Maybe I can make a passable partner of you. Yas. I totally see the vision.
|
||||
-> f4r4.snacksharing
|
||||
|
||||
= snacksharing
|
||||
You go up the aisle towards the dark silhouette. It is too dark to make much out. When you are a few rows away you see the form move. You see arms and shoulders and above them something which is not the shape of a head.
|
||||
|
||||
When you are at her row, she is just stepping out onto the aisle. Her high-heeled shoes make no sound on the carpet. She straightens her frilly dress and puts one of the straps that slipped off her shoulder back in its rightful place.
|
||||
|
||||
When you look up to her face, your eyes adjust enough for you to see. A mess of long fingers unfurls itself into the clear shape of two gigantic but delicate hands, bedecked in rings and acrylic nails, growing from a slender neck with a y2K choker.
|
||||
|
||||
+ [I think she is cool.]
|
||||
She is very cool indeed.
|
||||
|
||||
You hold out the snacks.
|
||||
|
||||
Her: Yummy. Oh maaaan it's been tooooo long.
|
||||
|
||||
She grabs the package from your hand.
|
||||
|
||||
Her: I don't know. I guess I've just been so focused on perfecting my performance lately. I guess I haven't really had any time to get out. And walking up and down all the stairs. Urgh. Hate that.
|
||||
|
||||
One of her hands faces to the front and forms a snout with three fingers to the front while the Pinky and index finger perk up. Her makeshift foxface looks down to the package of snacks.
|
||||
|
||||
{had_sweets:
|
||||
Her: MMHHhhh Yum! Sweets. I always need something sweet.
|
||||
|
||||
She tears at the plastic wrapping and tosses a piece up into her hand which folds into a fist briefly. A second later, when her hand resumes the foxface the piece of candy is gone.
|
||||
|
||||
Her: Hm. OK. Ordinary candy.
|
||||
|
||||
She studies the package again.
|
||||
|
||||
Her: Didn't even know they had those here. Sweet. But that's it. You should try some of the local sorts. They pack a little more ZING.
|
||||
- else:
|
||||
Her: Huh. Salty snacks. OK I guess. Sorry, I normally prefer sweets. But I'd still like to try some.
|
||||
|
||||
She tears at the plastic wrapping and tosses a piece up into her hand which folds into a fist briefly. A second later, when her hand resumes the foxface the snack is gone.
|
||||
|
||||
Her: Hm? Is it just a normal snack?
|
||||
|
||||
She studies the package again.
|
||||
|
||||
Her: Didn't even know they had those here. You should try some of the local stuff. It's a little more interesting.
|
||||
}
|
||||
+ [I think she is scary.]
|
||||
You are a little intimidated.
|
||||
|
||||
Her: What? Don't worry, I don't bite. Well, nah you've seen the worst of my bite down there during the show.
|
||||
|
||||
One of her hands faces to the front and forms a snout with three fingers to the front while the Pinky and index finger perk up. She opens and closes the fingers a little as she talks. It looks like someone comically ventriloquising a hand puppet. It doesn't look genuine.
|
||||
|
||||
Her: Or maybe I will bite if you keep these sweets you promised me.
|
||||
|
||||
You raise your hand with the package and she snatches it from you. Her makeshift foxface looks down at the bag of snacks.
|
||||
|
||||
{had_sweets:
|
||||
Her: MMHHhhh Yum! Sweets. I always need something sweet.
|
||||
|
||||
She tears at the plastic wrapping and tosses a piece up into her hand which folds into a fist briefly. A second later, when her hand resumes the foxface the piece of candy is gone.
|
||||
|
||||
Her: Hm. OK. Ordinary candy.
|
||||
|
||||
She studies the package again.
|
||||
|
||||
Her: Didn't even know they had those here. Sweet. But that's it. You should try some of the local sorts. They pack a little more ZING.
|
||||
- else:
|
||||
Her: Huh. Salty snacks. OK I guess. I normally prefer sweets. But I guess this is a total emergency situation.
|
||||
|
||||
She tears at the plastic wrapping and tosses a piece up into her hand which folds into a fist briefly. A second later, when her hand resumes the foxface the snack is gone.
|
||||
|
||||
Her: Hm? Is it just a normal snack?
|
||||
|
||||
She studies the package again.
|
||||
|
||||
Her: Didn't even know they had those here. You should try some of the local stuff. It's a little more interesting.
|
||||
}
|
||||
-
|
||||
-> END
|
||||
|
||||
= deathmatch
|
||||
Her: If you are a grizzly bear, then I will be a dragon.
|
||||
|
||||
You: Then I will be the winter wind. Blowing out your flame and freezing you.
|
||||
|
||||
Her: Then I will be the ocean. Then you could never blow away.
|
||||
|
||||
You: My wind will be waves then. Sitting on top of you. Disturbing your depths.
|
||||
|
||||
Her: I will be the moon then. So you will have to bow to my every will.
|
||||
|
||||
+ [Flirt... yes please]
|
||||
~ favor_nails = favor_nails + 1
|
||||
+ [I will be the earth so you can only be as bright as I want you to be.]
|
||||
|
||||
-
|
||||
Her: Then I am the sun. So only I can decide where the light is.
|
||||
|
||||
The screen blacks out except for a small globe of light.
|
||||
-> END
|
||||
|
||||
= bear
|
||||
The wolf is snarling and fierce as before, but its tail twitches a little. You have intimidated it, by the looks of it.
|
||||
|
||||
Your bear is on its hind legs and looming tall.
|
||||
|
||||
You must never underestimate how dangerous a desperate animal is.
|
||||
|
||||
+ [Check your stance.]
|
||||
You are standing a bit unsafely on the chairs. So, you take your eyes off your opponent for a second to check your stance.
|
||||
|
||||
As you shift your right foot into a safer position the projector light on your cheek is disturbed. You can see out of the corner of your eye how the shadow grazes you. As you snap your attention up to the screen you see the wolf on your bear's hump. Biting down savagely.
|
||||
|
||||
You don't even have to think about it, as you raise your paws and beat at the side of the wolf. The force of it is enough to send it flying off of you and skidding to the edge of the screen. It is up on its feet again in seconds.
|
||||
|
||||
++ [Roar at it.]
|
||||
Your bear is not very hurt but furious. You send out a roar. A warning and a threat.
|
||||
|
||||
But the wolf will not back down. It charges again.
|
||||
++ [Run to it to attack.]
|
||||
You have no time to lose either, so you jump from the seat. The bear gallops towards the wolf.
|
||||
--
|
||||
++ [Bite] The bear is quick on four feet and opens its massive jaws to welcome the wolf.
|
||||
++ [Thrash] The bear stands tall and swipes a paw at the beast.
|
||||
--
|
||||
The wolf has left itself enough of an opening to jump back in time.
|
||||
|
||||
++ [Bite] You bite. But it jumps over you.
|
||||
++ [Thrash] You thrash. But it jumps around you.
|
||||
--
|
||||
You try a few more attacks. But the wolf is careful and nimble now.
|
||||
|
||||
It is baiting you. Cunning. You can already start to feel the strength of your attacks receding.
|
||||
|
||||
+ [Start your first attack]
|
||||
You are ready.
|
||||
|
||||
++ [Swipe a paw at the wolf]
|
||||
As the wolf jumps toward you the bear stands tall and swipes a massive paw down.
|
||||
|
||||
The wolf is quick but not quick enough to escape the attack completely. You catch it across its back and its jowls as it jumps away again.
|
||||
++ [Bite at the wolf.]
|
||||
The wolf jumps forward and the bear comes down to all four legs to bite at it.
|
||||
|
||||
The wolf is quick and jumps back from the bear's teeth, which scrape its back but don't manage the catch. A pained howling is your only reward.
|
||||
--
|
||||
The wolf paces for a moment.
|
||||
|
||||
++ [Wait] You wait to see its next move.
|
||||
Then it jumps forward again, jaws snapping.
|
||||
|
||||
+++ [Bite] The bear snaps its jaws right back. But the wolf has left itself enough of an opening to jump back in time.
|
||||
+++ [Thrash] But the bear is ready and strikes. The wolf has left itself enough of an opening to jump back in time.
|
||||
+++ [Dodge]
|
||||
~ fallbear = RANDOM(0, 1) == 1
|
||||
{fallbear:
|
||||
You only have to take a step back to be out of reach. But it only takes a step to destabilise you. And you fall.
|
||||
- else:
|
||||
It is slower so, the bear can just step back out of reach.
|
||||
}
|
||||
{not fallbear: -> after_dodge_inner}
|
||||
You can mostly brake your fall by catching the seats. You hang awkwardly in the row.
|
||||
|
||||
++++ [Admit defeat]
|
||||
You: Well played.
|
||||
|
||||
Her: Are you giving up?
|
||||
|
||||
You: What can I say. You got me.
|
||||
|
||||
You disentangle yourself from the seats. The wolf meanwhile resolves itself into a set of triumphant hands.
|
||||
|
||||
Her: Haha. Yes I did. But don't be embarrassed, I can tell you! You totally never stood a chance. I am the master of the craft. You wanna see some of my other specialities?
|
||||
|
||||
+++++ [Yes] You: Yes -> f4r4.her_portfolio
|
||||
++++ [Get back up]
|
||||
You quickly disentangle yourself from your compromised position. The wolf is already sniffing interestedly at the spot where you disappeared. Hungry for its kill.
|
||||
|
||||
++++ [Turn into a crocodile to ambush it]
|
||||
It is right above you now. An easy kill for an ambush predator. Your arms become the strong, crushing maw of a crocodile in a second. Jumping up as if from the watering hole. Swallowing the front half of the wolf in one bite. There isn't even enough time for it to scream in pain. You have become a swift and merciless death.
|
||||
|
||||
You slide back to the depths. Drawing the carcass of the wolf along.
|
||||
|
||||
Her: That was sooooooo not fair!
|
||||
|
||||
She sounds a little out of breath.
|
||||
|
||||
You: Well nature isn't fair.
|
||||
|
||||
Her: You shape shifted. That has nothing to do with nature.
|
||||
|
||||
You: It's called a plot twist.
|
||||
|
||||
Her: Ya a bad one. And what even happened to the bear? This isn't very narratively satisfying.
|
||||
|
||||
You: I'm sure the crocodile is satisfied.
|
||||
|
||||
Her: Oh my god. Just because you wanted to win. This makes no sense whatsoever!? If you could be bothered to stick to a storyline I would have destroyed you.
|
||||
|
||||
+++++ [OK. I'm sorry.]
|
||||
Her: Ya u better be. Now sit your ass down and I'm gonna show you how it's done.
|
||||
-> f4r4.the_show
|
||||
+++++ [You might have. If you were more flexible.]
|
||||
Her: Ah!? What did you just say? You can accuse me of many things but this is just slander! How dare you.
|
||||
-----
|
||||
---- (after_dodge_inner)
|
||||
---
|
||||
++ [Attack]
|
||||
But yours will be the next move.
|
||||
|
||||
+++ [Bite] The bear comes forward to snap its jaws. But the wolf has left itself enough of an opening to jump back in time.
|
||||
+++ [Thrash] The bear is ready and strikes. The wolf has left itself enough of an opening to jump back in time.
|
||||
---
|
||||
--
|
||||
You try a few more attacks. But the wolf is careful and nimble now.
|
||||
|
||||
++ [Bite] You bite. But it jumps over you.
|
||||
++ [Thrash] You thrash. But it jumps around you.
|
||||
--
|
||||
It is baiting you. Cunning. You can already start to feel the strength of your attacks receding.
|
||||
|
||||
= cbear
|
||||
// TODO: Gegenangriff-Bär -- Bär greift aus erhöhter Position an
|
||||
-> END
|
||||
|
||||
= the_show
|
||||
// TODO: Die eigentliche Vorstellung -- Nails' Schattentheater
|
||||
// Übergang in silent_show (stilles Beobachten) oder interaktiv
|
||||
-> silent_show
|
||||
|
||||
= silent_show
|
||||
A second shadowy hand joined the first. They wrap around each other and devolve into a mass of darkness with pins of light, shining between the bends of fingers which you no longer can tell apart or identify.
|
||||
|
||||
The splotch bulges and warps. Forming shapes you almost recognise. Organic shapes. No symmetry or clean edges.
|
||||
|
||||
Does your brain try to identify and categorise the shapes?
|
||||
|
||||
Do you see the pattern formed by projector light in the middle? Is it the fur pattern of an imaginary animal?
|
||||
|
||||
Do you see landscapes or stars?
|
||||
|
||||
The profiles of faces you know but can't place crown the edges of the shadow. There and gone in a moment.
|
||||
|
||||
Are you trying to figure out if the curtains are blue? There are no curtains. And if there were it would be rude to figure out the colour. Don't be distracted. Focus on the show. Someone is performing for you here.
|
||||
|
||||
The ink on the screen devolves itself into a shape your brain can grasp easily now. It is a Swan. Swimming on the water. It is perfect. Wings folded. The body smooth as a pebble. The neck long and arcing, bending up and around and down.
|
||||
|
||||
It dips its head into the water, gracefully. Kissing the ripples of the surface demurely before pulling back and shaking off water.
|
||||
|
||||
-> END
|
||||
|
||||
= shadow_battle
|
||||
// TODO: Schattenkampf -- Nails' wolf vs. Spieler's bear, freie Wahl
|
||||
-> END
|
||||
|
||||
= apprentice
|
||||
// TODO: Nails nimmt Spieler als Lehrling an
|
||||
-> END
|
||||
|
||||
= quitter
|
||||
// TODO: Hase flüchtet vom Bildschirm -- feige Niederlage
|
||||
-> END
|
||||
|
||||
= her_portfolio
|
||||
// TODO: Nails zeigt ihr Shadow-Portfolio
|
||||
-> END
|
||||
|
||||
= performance
|
||||
// TODO: Nails' volle Vorstellung
|
||||
-> END
|
||||
|
||||
= practice
|
||||
// TODO: Nails übt neue Figuren, Spieler schaut zu
|
||||
-> END
|
||||
|
||||
= seeulater
|
||||
// TODO: Verabredung für später -- Spieler kommt nochmal
|
||||
-> END
|
||||
@@ -10,7 +10,7 @@ VAR quest_mushroom_done = false
|
||||
|
||||
- quest_mushroom_active && mushrooms_collected >= 10:
|
||||
# color whisper
|
||||
Du hast {mushrooms_collected} Pilze dabei — mehr als genug!
|
||||
Du hast {mushrooms_collected} Pilze dabei -- mehr als genug!
|
||||
* [Hier, nimm sie.]
|
||||
~ quest_mushroom_done = true
|
||||
# color whisper
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"inkVersion":21,"root":[[["ev",{"VAR?":"quest_mushroom_done"},"/ev",{"->":".^.b","c":true},{"b":["\n","#","^color whisper","/#","^Danke nochmal für die Pilze. Das Rezept ist fast fertig.","\n",{"->":"ende"},{"->":"0.4"},null]}],["ev",{"VAR?":"quest_mushroom_active"},{"VAR?":"mushrooms_collected"},10,">=","&&","/ev",{"->":".^.b","c":true},{"b":["\n","#","^color whisper","/#","^Du hast ","ev",{"VAR?":"mushrooms_collected"},"out","/ev","^ Pilze dabei — mehr als genug!","\n","ev","str","^Hier, nimm sie.","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Lass mich noch ein paar behalten.","/str","/ev",{"*":".^.c-1","flg":20},{"->":"0.4"},{"c-0":["\n","ev",true,"/ev",{"VAR=":"quest_mushroom_done","re":true},"#","^color whisper","/#","^Wunderbar, vielen Dank! Das wird ein gutes Süppchen.","\n",{"->":"ende"},{"#f":5}],"c-1":["\n","#","^color whisper","/#","^Wie du willst. Komm wieder, wenn du sie loswerden möchtest.","\n",{"->":"ende"},{"#f":5}]}]}],["ev",{"VAR?":"quest_mushroom_active"},"/ev",{"->":".^.b","c":true},{"b":["\n","#","^color whisper","/#","^Du hast schon ","ev",{"VAR?":"mushrooms_collected"},"out","/ev","^ von 10 Pilzen. Mach ruhig weiter.","\n",{"->":"ende"},{"->":"0.4"},null]}],[{"->":".^.b"},{"b":["\n","#","^color whisper","/#","^TEST1 Hallo! Ich bräuchte 10 Pilze für ein Rezept. Hättest du Lust, welche zu sammeln?","\n","ev","str","^Klar, ich helfe.","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Vielleicht später.","/str","/ev",{"*":".^.c-1","flg":20},{"->":"0.4"},{"c-0":["\n","ev",true,"/ev",{"VAR=":"quest_mushroom_active","re":true},"#","^color whisper","/#","^Danke! Ich warte hier.","\n",{"->":"ende"},{"#f":5}],"c-1":["\n","#","^color whisper","/#","^Schade. Komm gerne nochmal vorbei.","\n",{"->":"ende"},{"#f":5}]}]}],"nop","\n",["done",{"#n":"g-0"}],null],"done",{"ende":[["ev","str","^Bis dann","/str","/ev",{"*":".^.c-0","flg":20},{"c-0":["\n","#","^person_farewell","/#","end",{"#f":5}]}],null],"global decl":["ev",0,{"VAR=":"mushrooms_collected"},false,{"VAR=":"quest_mushroom_active"},false,{"VAR=":"quest_mushroom_done"},"/ev","end",null]}],"listDefs":{}}
|
||||
{"inkVersion":21,"root":[[["ev",{"VAR?":"quest_mushroom_done"},"/ev",{"->":".^.b","c":true},{"b":["\n","#","^color whisper","/#","^Danke nochmal für die Pilze. Das Rezept ist fast fertig.","\n",{"->":"ende"},{"->":"0.4"},null]}],["ev",{"VAR?":"quest_mushroom_active"},{"VAR?":"mushrooms_collected"},10,">=","&&","/ev",{"->":".^.b","c":true},{"b":["\n","#","^color whisper","/#","^Du hast ","ev",{"VAR?":"mushrooms_collected"},"out","/ev","^ Pilze dabei -- mehr als genug!","\n","ev","str","^Hier, nimm sie.","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Lass mich noch ein paar behalten.","/str","/ev",{"*":".^.c-1","flg":20},{"->":"0.4"},{"c-0":["\n","ev",true,"/ev",{"VAR=":"quest_mushroom_done","re":true},"#","^color whisper","/#","^Wunderbar, vielen Dank! Das wird ein gutes Süppchen.","\n",{"->":"ende"},{"#f":5}],"c-1":["\n","#","^color whisper","/#","^Wie du willst. Komm wieder, wenn du sie loswerden möchtest.","\n",{"->":"ende"},{"#f":5}]}]}],["ev",{"VAR?":"quest_mushroom_active"},"/ev",{"->":".^.b","c":true},{"b":["\n","#","^color whisper","/#","^Du hast schon ","ev",{"VAR?":"mushrooms_collected"},"out","/ev","^ von 10 Pilzen. Mach ruhig weiter.","\n",{"->":"ende"},{"->":"0.4"},null]}],[{"->":".^.b"},{"b":["\n","#","^color whisper","/#","^TEST1 Hallo! Ich bräuchte 10 Pilze für ein Rezept. Hättest du Lust, welche zu sammeln?","\n","ev","str","^Klar, ich helfe.","/str","/ev",{"*":".^.c-0","flg":20},"ev","str","^Vielleicht später.","/str","/ev",{"*":".^.c-1","flg":20},{"->":"0.4"},{"c-0":["\n","ev",true,"/ev",{"VAR=":"quest_mushroom_active","re":true},"#","^color whisper","/#","^Danke! Ich warte hier.","\n",{"->":"ende"},{"#f":5}],"c-1":["\n","#","^color whisper","/#","^Schade. Komm gerne nochmal vorbei.","\n",{"->":"ende"},{"#f":5}]}]}],"nop","\n",["done",{"#n":"g-0"}],null],"done",{"ende":[["ev","str","^Bis dann","/str","/ev",{"*":".^.c-0","flg":20},{"c-0":["\n","#","^person_farewell","/#","end",{"#f":5}]}],null],"global decl":["ev",0,{"VAR=":"mushrooms_collected"},false,{"VAR=":"quest_mushroom_active"},false,{"VAR=":"quest_mushroom_done"},"/ev","end",null]}],"listDefs":{}}
|
||||
@@ -1,284 +0,0 @@
|
||||
// Game: Generic
|
||||
// Format: Standard
|
||||
// entity 0
|
||||
{
|
||||
"classname" "worldspawn"
|
||||
"wad" ""
|
||||
// brush 0
|
||||
{
|
||||
( -112 -672 -80 ) ( -112 -720 -80 ) ( -112 -720 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
( -112 -720 -80 ) ( -64 -720 -80 ) ( -64 -720 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -720 -112 ) ( -64 -672 -112 ) ( -112 -672 -112 ) placeholder 64 224 0 0.2 0.2
|
||||
( -112 -672 -80 ) ( -64 -720 -80 ) ( -112 -720 -80 ) placeholder 64 224 0 0.2 0.2
|
||||
( -64 -672 -112 ) ( -64 -672 -96 ) ( -112 -672 -80 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -112 -672 -80 ) ( -64 -672 -96 ) ( -64 -720 -80 ) placeholder 64 224 0 0.2 0.2
|
||||
( -64 -720 -80 ) ( -64 -672 -96 ) ( -64 -672 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 1
|
||||
{
|
||||
( 0 -128 -16 ) ( 0 -127 -16 ) ( 0 -128 -15 ) placeholder 0 0 0 1 1
|
||||
( 0 -128 -16 ) ( 0 -128 -15 ) ( 1 -128 -16 ) placeholder -32 0 0 1 1
|
||||
( 0 -128 -16 ) ( 1 -128 -16 ) ( 0 -127 -16 ) placeholder -32 0 0 1 1
|
||||
( 64 -96 0 ) ( 64 -95 0 ) ( 65 -96 0 ) placeholder -32 0 0 1 1
|
||||
( 64 -96 0 ) ( 65 -96 0 ) ( 64 -96 1 ) placeholder -32 0 0 1 1
|
||||
( 64 -96 0 ) ( 64 -96 1 ) ( 64 -95 0 ) placeholder 0 0 0 1 1
|
||||
}
|
||||
// brush 2
|
||||
{
|
||||
( 64 -144 -32 ) ( 64 -143 -32 ) ( 64 -144 -31 ) placeholder -16 -16 0 1 1
|
||||
( 64 -144 -32 ) ( 64 -144 -31 ) ( 65 -144 -32 ) placeholder -32 -16 0 1 1
|
||||
( 64 -144 -32 ) ( 65 -144 -32 ) ( 64 -143 -32 ) placeholder -32 16 0 1 1
|
||||
( 192 -80 -16 ) ( 192 -79 -16 ) ( 193 -80 -16 ) placeholder -32 16 0 1 1
|
||||
( 192 -80 -16 ) ( 193 -80 -16 ) ( 192 -80 -15 ) placeholder -32 -16 0 1 1
|
||||
( 192 -80 -16 ) ( 192 -80 -15 ) ( 192 -79 -16 ) placeholder -16 -16 0 1 1
|
||||
}
|
||||
// brush 3
|
||||
{
|
||||
( 80 16 32 ) ( 80 15 32 ) ( 80 16 31 ) placeholder 0 -16 180 1 1
|
||||
( 144 -96 16 ) ( 145 -96 16 ) ( 144 -96 15 ) placeholder 16 -16 0 1 -1
|
||||
( 144 -96 16 ) ( 144 -97 16 ) ( 145 -96 16 ) placeholder 16 0 0 1 -1
|
||||
( 80 16 32 ) ( 81 16 32 ) ( 80 15 32 ) placeholder 16 0 0 1 -1
|
||||
( 80 16 32 ) ( 80 16 31 ) ( 81 16 32 ) placeholder 16 -16 0 1 -1
|
||||
( 144 -96 16 ) ( 144 -96 15 ) ( 144 -97 16 ) placeholder 0 -16 180 1 1
|
||||
}
|
||||
// brush 4
|
||||
{
|
||||
( 224 -48 -80 ) ( 224 16 -80 ) ( 224 -96 -56 ) placeholder -128 -60 0 1 2
|
||||
( 224 -96 -56 ) ( 288 -96 -80 ) ( 224 -48 -80 ) placeholder -32 8 0 1 -2
|
||||
( 224 16 -80 ) ( 272 -32 -56 ) ( 224 -96 -56 ) placeholder -134.26993 -44.949593 0 1 2
|
||||
( 272 -32 -56 ) ( 288 -96 -40 ) ( 224 -96 -56 ) placeholder -32 112 0 1 1
|
||||
( 224 -96 -56 ) ( 288 -96 -40 ) ( 288 -96 -80 ) placeholder -32 -16.941177 0 1 -2
|
||||
( 288 -96 -80 ) ( 288 16 -80 ) ( 224 16 -80 ) placeholder -32 144 0 1 1
|
||||
( 272 -32 -56 ) ( 304 -32 -56 ) ( 288 -96 -40 ) placeholder -32 112 0 1 1
|
||||
( 288 16 -80 ) ( 304 -32 -56 ) ( 272 -32 -56 ) placeholder -32 -24 0 1 -2
|
||||
( 288 -96 -80 ) ( 304 -32 -56 ) ( 288 16 -80 ) placeholder 144 -52 0 1 2
|
||||
( 288 -96 -40 ) ( 304 -32 -56 ) ( 288 -96 -80 ) placeholder 118.95169 -69.728745 0 1 2
|
||||
}
|
||||
// brush 5
|
||||
{
|
||||
( -144 -560 -80 ) ( -144 -559 -80 ) ( -144 -560 -79 ) placeholder -80 96 0 0.2 0.2
|
||||
( -144 -320 -80 ) ( -144 -320 -79 ) ( -143 -320 -80 ) placeholder -32 96 0 0.2 0.2
|
||||
( -144 -560 -80 ) ( -143 -560 -80 ) ( -144 -559 -80 ) placeholder -32 80 0 0.2 0.2
|
||||
( -16 -432 16 ) ( -16 -431 16 ) ( -15 -432 16 ) placeholder -32 80 0 0.2 0.2
|
||||
( -16 -304 -48 ) ( -15 -304 -48 ) ( -16 -304 -47 ) placeholder -32 96 0 0.2 0.2
|
||||
( 304 -432 -48 ) ( 304 -432 -47 ) ( 304 -431 -48 ) placeholder -80 96 0 0.2 0.2
|
||||
}
|
||||
// brush 6
|
||||
{
|
||||
( -160 -240 -16 ) ( -160 -241 -16 ) ( -160 -240 -17 ) placeholder -240 96 180 1 1
|
||||
( -64 -304 -32 ) ( -63 -304 -32 ) ( -64 -304 -33 ) placeholder 208 96 0 1 -1
|
||||
( -64 -352 -80 ) ( -64 -353 -80 ) ( -63 -352 -80 ) placeholder 208 240 0 1 -1
|
||||
( -160 -240 16 ) ( -159 -240 16 ) ( -160 -241 16 ) placeholder 208 240 0 1 -1
|
||||
( -160 192 -16 ) ( -160 192 -17 ) ( -159 192 -16 ) placeholder 208 96 0 1 -1
|
||||
( -144 -352 -32 ) ( -144 -352 -33 ) ( -144 -353 -32 ) placeholder -240 96 180 1 1
|
||||
}
|
||||
// brush 7
|
||||
{
|
||||
( 162.74516600406096 -112 -80 ) ( 163.4522727852475 -111.29289321881345 -80 ) ( 162.74516600406096 -112 -79 ) placeholder 190.39192 0 0 0.70710677 1
|
||||
( 162.74516600406096 -112 -80 ) ( 162.74516600406096 -112 -79 ) ( 163.45227278524752 -112.70710678118652 -80 ) placeholder -38.156433 0 0 0.70710677 1
|
||||
( 162.74516600406096 -112 -80 ) ( 163.45227278524752 -112.70710678118652 -80 ) ( 163.4522727852475 -111.29289321881345 -80 ) placeholder -2.27417 3.882248 315 1 1
|
||||
( 253.25483399593907 -112 -48 ) ( 253.96194077712562 -111.29289321881353 -48 ) ( 253.9619407771256 -112.70710678118664 -48 ) placeholder -2.27417 3.882248 315 1 1
|
||||
( 253.25483399593907 -112 -64 ) ( 253.25483399593907 -112 -63 ) ( 253.96194077712562 -111.29289321881353 -64 ) placeholder -6.156433 0 0 0.70710677 1
|
||||
( 253.25483399593907 -112 -64 ) ( 253.9619407771256 -112.70710678118664 -64 ) ( 253.25483399593907 -112 -63 ) placeholder 97.60808 0 180 0.70710677 -1
|
||||
}
|
||||
// brush 8
|
||||
{
|
||||
( -32 96 -80 ) ( -32 97 -80 ) ( -32 96 -79 ) placeholder 0 0 0 1 1
|
||||
( 96 272 -64 ) ( 97 272.625 -64 ) ( 96 272 -63 ) placeholder 0 0 0 1 1
|
||||
( -32 96 -80 ) ( -31 96.625 -80 ) ( -32 97 -80 ) placeholder -73.70788 15.668304 32.00539 1.1792476 0.87100387
|
||||
( 96 272 -32 ) ( 96 273 -32 ) ( 97 272.625 -32 ) placeholder -73.70788 15.668304 32.00539 1.1792476 0.87100387
|
||||
( -32 96 -80 ) ( -32 96 -79 ) ( -31 96.625 -80 ) placeholder 0 0 0 1 1
|
||||
( 96 272 -64 ) ( 96 272 -63 ) ( 96 273 -64 ) placeholder -80 0 0 1 1
|
||||
}
|
||||
// brush 9
|
||||
{
|
||||
( -64 -672 -96 ) ( -64 -720 -80 ) ( -64 -720 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
( -64 -672 -96 ) ( -16 -672 -80 ) ( -64 -720 -80 ) placeholder 80 224 0 0.2 0.2
|
||||
( -64 -720 -80 ) ( -16 -720 -80 ) ( -16 -720 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -720 -112 ) ( -16 -672 -112 ) ( -64 -672 -112 ) placeholder 80 224 0 0.2 0.2
|
||||
( -64 -720 -80 ) ( -16 -672 -80 ) ( -16 -720 -80 ) placeholder 80 224 0 0.2 0.2
|
||||
( -16 -672 -112 ) ( -16 -672 -80 ) ( -64 -672 -96 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -720 -80 ) ( -16 -672 -80 ) ( -16 -672 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 10
|
||||
{
|
||||
( -16 -672 -80 ) ( -16 -720 -80 ) ( -16 -720 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
( -16 -672 -80 ) ( 32 -672 -48 ) ( -16 -720 -80 ) placeholder -160 224 0 0.2 0.2
|
||||
( -16 -720 -80 ) ( 32 -720 -80 ) ( 32 -720 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -720 -80 ) ( 32 -672 -48 ) ( 32 -720 -80 ) placeholder -160 224 0 0.2 0.2
|
||||
( 32 -720 -112 ) ( 32 -672 -112 ) ( -16 -672 -112 ) placeholder -160 224 0 0.2 0.2
|
||||
( 32 -672 -112 ) ( 32 -672 -48 ) ( -16 -672 -80 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -720 -80 ) ( 32 -672 -48 ) ( 32 -672 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 11
|
||||
{
|
||||
( 32 -672 -48 ) ( 32 -720 -80 ) ( 32 -720 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
( 32 -720 -80 ) ( 80 -720 -80 ) ( 80 -720 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 80 -720 -80 ) ( 32 -720 -80 ) placeholder -144 224 0 0.2 0.2
|
||||
( 80 -720 -112 ) ( 80 -672 -112 ) ( 32 -672 -112 ) placeholder -144 224 0 0.2 0.2
|
||||
( 80 -672 -112 ) ( 80 -672 -80 ) ( 32 -672 -48 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 80 -672 -80 ) ( 80 -720 -80 ) placeholder -144 224 0 0.2 0.2
|
||||
( 80 -720 -80 ) ( 80 -672 -80 ) ( 80 -672 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 12
|
||||
{
|
||||
( -112 -624 -80 ) ( -112 -672 -80 ) ( -112 -672 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
( -112 -672 -80 ) ( -64 -672 -96 ) ( -64 -672 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -672 -112 ) ( -64 -624 -112 ) ( -112 -624 -112 ) placeholder 64 208 0 0.2 0.2
|
||||
( -112 -624 -80 ) ( -64 -624 -80 ) ( -112 -672 -80 ) placeholder 64 208 0 0.2 0.2
|
||||
( -64 -624 -112 ) ( -64 -624 -80 ) ( -112 -624 -80 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -112 -672 -80 ) ( -64 -624 -80 ) ( -64 -672 -96 ) placeholder 64 208 0 0.2 0.2
|
||||
( -64 -672 -96 ) ( -64 -624 -80 ) ( -64 -624 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 13
|
||||
{
|
||||
( -112 -384 -112 ) ( -112 -383 -112 ) ( -112 -384 -111 ) placeholder -192 -64 0 0.2 0.2
|
||||
( -112 -624 -112 ) ( -112 -624 -111 ) ( -111 -624 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -112 -384 -112 ) ( -111 -384 -112 ) ( -112 -383 -112 ) placeholder 64 192 0 0.2 0.2
|
||||
( 16 -256 -80 ) ( 16 -255 -80 ) ( 17 -256 -80 ) placeholder 64 192 0 0.2 0.2
|
||||
( 16 -576 -80 ) ( 17 -576 -80 ) ( 16 -576 -79 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -256 -80 ) ( -64 -256 -79 ) ( -64 -255 -80 ) placeholder -192 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 14
|
||||
{
|
||||
( -64 -624 -80 ) ( -64 -672 -96 ) ( -64 -672 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
( -64 -624 -80 ) ( -16 -672 -80 ) ( -64 -672 -96 ) placeholder 80 208 0 0.2 0.2
|
||||
( -64 -672 -96 ) ( -16 -672 -80 ) ( -16 -672 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -672 -112 ) ( -16 -624 -112 ) ( -64 -624 -112 ) placeholder 80 208 0 0.2 0.2
|
||||
( -64 -624 -80 ) ( -16 -624 -80 ) ( -16 -672 -80 ) placeholder 80 208 0 0.2 0.2
|
||||
( -16 -624 -112 ) ( -16 -624 -80 ) ( -64 -624 -80 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -672 -80 ) ( -16 -624 -80 ) ( -16 -624 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 15
|
||||
{
|
||||
( -112 -528 -80 ) ( -112 -576 -80 ) ( -112 -576 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
( -112 -528 -80 ) ( -64 -528 -48 ) ( -112 -576 -80 ) placeholder 64 176 0 0.2 0.2
|
||||
( -112 -576 -80 ) ( -64 -576 -80 ) ( -64 -576 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -112 -576 -80 ) ( -64 -528 -48 ) ( -64 -576 -80 ) placeholder 64 176 0 0.2 0.2
|
||||
( -64 -576 -112 ) ( -64 -528 -112 ) ( -112 -528 -112 ) placeholder 64 176 0 0.2 0.2
|
||||
( -64 -528 -112 ) ( -64 -528 -48 ) ( -112 -528 -80 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -576 -80 ) ( -64 -528 -48 ) ( -64 -528 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 16
|
||||
{
|
||||
( -64 -384 -112 ) ( -64 -383 -112 ) ( -64 -384 -111 ) placeholder -192 -64 0 0.2 0.2
|
||||
( -64 -624 -112 ) ( -64 -624 -111 ) ( -63 -624 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -64 -384 -112 ) ( -63 -384 -112 ) ( -64 -383 -112 ) placeholder 80 192 0 0.2 0.2
|
||||
( 64 -256 -80 ) ( 64 -255 -80 ) ( 65 -256 -80 ) placeholder 80 192 0 0.2 0.2
|
||||
( 64 -576 -80 ) ( 65 -576 -80 ) ( 64 -576 -79 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -256 -80 ) ( -16 -256 -79 ) ( -16 -255 -80 ) placeholder -192 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 17
|
||||
{
|
||||
( -16 -624 -80 ) ( -16 -672 -80 ) ( -16 -672 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
( -16 -624 -80 ) ( 32 -672 -48 ) ( -16 -672 -80 ) placeholder -160 208 0 0.2 0.2
|
||||
( -16 -672 -80 ) ( 32 -672 -48 ) ( 32 -672 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -672 -112 ) ( 32 -624 -112 ) ( -16 -624 -112 ) placeholder -160 208 0 0.2 0.2
|
||||
( -16 -624 -80 ) ( 32 -624 -80 ) ( 32 -672 -48 ) placeholder -160 208 0 0.2 0.2
|
||||
( 32 -624 -112 ) ( 32 -624 -80 ) ( -16 -624 -80 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 32 -624 -80 ) ( 32 -624 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 18
|
||||
{
|
||||
( -112 -480 -80 ) ( -112 -528 -80 ) ( -112 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -112 -480 -80 ) ( -64 -528 -48 ) ( -112 -528 -80 ) placeholder 64 160 0 0.2 0.2
|
||||
( -112 -528 -80 ) ( -64 -528 -48 ) ( -64 -528 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -528 -112 ) ( -64 -480 -112 ) ( -112 -480 -112 ) placeholder 64 160 0 0.2 0.2
|
||||
( -112 -480 -80 ) ( -64 -480 -80 ) ( -64 -528 -48 ) placeholder 64 160 0 0.2 0.2
|
||||
( -64 -480 -112 ) ( -64 -480 -80 ) ( -112 -480 -80 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -64 -480 -80 ) ( -64 -480 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 19
|
||||
{
|
||||
( -64 -528 -48 ) ( -64 -576 -80 ) ( -64 -576 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
( -64 -576 -80 ) ( -16 -576 -80 ) ( -16 -576 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -16 -576 -80 ) ( -64 -576 -80 ) placeholder 80 176 0 0.2 0.2
|
||||
( -16 -576 -112 ) ( -16 -528 -112 ) ( -64 -528 -112 ) placeholder 80 176 0 0.2 0.2
|
||||
( -16 -528 -112 ) ( -16 -528 -80 ) ( -64 -528 -48 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -16 -528 -80 ) ( -16 -576 -80 ) placeholder 80 176 0 0.2 0.2
|
||||
( -16 -576 -80 ) ( -16 -528 -80 ) ( -16 -528 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 20
|
||||
{
|
||||
( -16 -384 -112 ) ( -16 -383 -112 ) ( -16 -384 -111 ) placeholder -192 -64 0 0.2 0.2
|
||||
( -16 -624 -112 ) ( -16 -624 -111 ) ( -15 -624 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -384 -112 ) ( -15 -384 -112 ) ( -16 -383 -112 ) placeholder -160 192 0 0.2 0.2
|
||||
( 112 -256 -80 ) ( 112 -255 -80 ) ( 113 -256 -80 ) placeholder -160 192 0 0.2 0.2
|
||||
( 112 -576 -80 ) ( 113 -576 -80 ) ( 112 -576 -79 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -256 -80 ) ( 32 -256 -79 ) ( 32 -255 -80 ) placeholder -192 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 21
|
||||
{
|
||||
( 32 -624 -80 ) ( 32 -672 -48 ) ( 32 -672 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 80 -672 -80 ) ( 80 -672 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -672 -112 ) ( 80 -624 -112 ) ( 32 -624 -112 ) placeholder -144 208 0 0.2 0.2
|
||||
( 32 -624 -80 ) ( 80 -624 -80 ) ( 32 -672 -48 ) placeholder -144 208 0 0.2 0.2
|
||||
( 80 -624 -112 ) ( 80 -624 -80 ) ( 32 -624 -80 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 80 -624 -80 ) ( 80 -672 -80 ) placeholder -144 208 0 0.2 0.2
|
||||
( 80 -672 -80 ) ( 80 -624 -80 ) ( 80 -624 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 22
|
||||
{
|
||||
( -64 -480 -80 ) ( -64 -528 -48 ) ( -64 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -16 -528 -80 ) ( -16 -528 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -528 -112 ) ( -16 -480 -112 ) ( -64 -480 -112 ) placeholder 80 160 0 0.2 0.2
|
||||
( -64 -480 -80 ) ( -16 -480 -80 ) ( -64 -528 -48 ) placeholder 80 160 0 0.2 0.2
|
||||
( -16 -480 -112 ) ( -16 -480 -80 ) ( -64 -480 -80 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -16 -480 -80 ) ( -16 -528 -80 ) placeholder 80 160 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( -16 -480 -80 ) ( -16 -480 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 23
|
||||
{
|
||||
( -16 -528 -80 ) ( -16 -576 -80 ) ( -16 -576 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
( -16 -576 -80 ) ( 32 -576 -80 ) ( 32 -576 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -576 -112 ) ( 32 -528 -112 ) ( -16 -528 -112 ) placeholder -160 176 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( 32 -576 -80 ) ( -16 -576 -80 ) placeholder -160 176 0 0.2 0.2
|
||||
( 32 -528 -112 ) ( 32 -528 -96 ) ( -16 -528 -80 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( 32 -528 -96 ) ( 32 -576 -80 ) placeholder -160 176 0 0.2 0.2
|
||||
( 32 -576 -80 ) ( 32 -528 -96 ) ( 32 -528 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 24
|
||||
{
|
||||
( 32 -384 -112 ) ( 32 -383 -112 ) ( 32 -384 -111 ) placeholder -192 -64 0 0.2 0.2
|
||||
( 32 -624 -112 ) ( 32 -624 -111 ) ( 33 -624 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 32 -384 -112 ) ( 33 -384 -112 ) ( 32 -383 -112 ) placeholder -144 192 0 0.2 0.2
|
||||
( 160 -256 -80 ) ( 160 -255 -80 ) ( 161 -256 -80 ) placeholder -144 192 0 0.2 0.2
|
||||
( 160 -576 -80 ) ( 161 -576 -80 ) ( 160 -576 -79 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -256 -80 ) ( 80 -256 -79 ) ( 80 -255 -80 ) placeholder -192 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 25
|
||||
{
|
||||
( -16 -480 -80 ) ( -16 -528 -80 ) ( -16 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( 32 -528 -96 ) ( 32 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -528 -112 ) ( 32 -480 -112 ) ( -16 -480 -112 ) placeholder -160 160 0 0.2 0.2
|
||||
( -16 -480 -80 ) ( 32 -480 -80 ) ( -16 -528 -80 ) placeholder -160 160 0 0.2 0.2
|
||||
( 32 -480 -112 ) ( 32 -480 -80 ) ( -16 -480 -80 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( 32 -480 -80 ) ( 32 -528 -96 ) placeholder -160 160 0 0.2 0.2
|
||||
( 32 -528 -96 ) ( 32 -480 -80 ) ( 32 -480 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 26
|
||||
{
|
||||
( 32 -528 -96 ) ( 32 -576 -80 ) ( 32 -576 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
( 32 -528 -96 ) ( 80 -528 -80 ) ( 32 -576 -80 ) placeholder -144 176 0 0.2 0.2
|
||||
( 32 -576 -80 ) ( 80 -576 -80 ) ( 80 -576 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -576 -112 ) ( 80 -528 -112 ) ( 32 -528 -112 ) placeholder -144 176 0 0.2 0.2
|
||||
( 32 -576 -80 ) ( 80 -528 -80 ) ( 80 -576 -80 ) placeholder -144 176 0 0.2 0.2
|
||||
( 80 -528 -112 ) ( 80 -528 -80 ) ( 32 -528 -96 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -576 -80 ) ( 80 -528 -80 ) ( 80 -528 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 27
|
||||
{
|
||||
( 32 -480 -80 ) ( 32 -528 -96 ) ( 32 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -480 -80 ) ( 80 -528 -80 ) ( 32 -528 -96 ) placeholder -144 160 0 0.2 0.2
|
||||
( 32 -528 -96 ) ( 80 -528 -80 ) ( 80 -528 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -528 -112 ) ( 80 -480 -112 ) ( 32 -480 -112 ) placeholder -144 160 0 0.2 0.2
|
||||
( 32 -480 -80 ) ( 80 -480 -80 ) ( 80 -528 -80 ) placeholder -144 160 0 0.2 0.2
|
||||
( 80 -480 -112 ) ( 80 -480 -80 ) ( 32 -480 -80 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -528 -80 ) ( 80 -480 -80 ) ( 80 -480 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
}
|
||||
}
|
||||
// entity 1
|
||||
{
|
||||
"classname" "info_player_start"
|
||||
"origin" "112 -48 56"
|
||||
}
|
||||
@@ -1,293 +0,0 @@
|
||||
// Game: Generic
|
||||
// Format: Standard
|
||||
// entity 0
|
||||
{
|
||||
"classname" "worldspawn"
|
||||
"wad" ""
|
||||
// brush 0
|
||||
{
|
||||
( -112 -672 -80 ) ( -112 -720 -80 ) ( -112 -720 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
( -112 -720 -80 ) ( -64 -720 -80 ) ( -64 -720 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -720 -112 ) ( -64 -672 -112 ) ( -112 -672 -112 ) placeholder 64 224 0 0.2 0.2
|
||||
( -112 -672 -80 ) ( -64 -720 -80 ) ( -112 -720 -80 ) placeholder 64 224 0 0.2 0.2
|
||||
( -64 -672 -112 ) ( -64 -672 -96 ) ( -112 -672 -80 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -112 -672 -80 ) ( -64 -672 -96 ) ( -64 -720 -80 ) placeholder 64 224 0 0.2 0.2
|
||||
( -64 -720 -80 ) ( -64 -672 -96 ) ( -64 -672 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 1
|
||||
{
|
||||
( 0 -128 -16 ) ( 0 -127 -16 ) ( 0 -128 -15 ) placeholder 0 0 0 1 1
|
||||
( 0 -128 -16 ) ( 0 -128 -15 ) ( 1 -128 -16 ) placeholder -32 0 0 1 1
|
||||
( 0 -128 -16 ) ( 1 -128 -16 ) ( 0 -127 -16 ) placeholder -32 0 0 1 1
|
||||
( 64 -96 0 ) ( 64 -95 0 ) ( 65 -96 0 ) placeholder -32 0 0 1 1
|
||||
( 64 -96 0 ) ( 65 -96 0 ) ( 64 -96 1 ) placeholder -32 0 0 1 1
|
||||
( 64 -96 0 ) ( 64 -96 1 ) ( 64 -95 0 ) placeholder 0 0 0 1 1
|
||||
}
|
||||
// brush 2
|
||||
{
|
||||
( 64 -144 -32 ) ( 64 -143 -32 ) ( 64 -144 -31 ) placeholder -16 -16 0 1 1
|
||||
( 64 -144 -32 ) ( 64 -144 -31 ) ( 65 -144 -32 ) placeholder -32 -16 0 1 1
|
||||
( 64 -144 -32 ) ( 65 -144 -32 ) ( 64 -143 -32 ) placeholder -32 16 0 1 1
|
||||
( 192 -80 -16 ) ( 192 -79 -16 ) ( 193 -80 -16 ) placeholder -32 16 0 1 1
|
||||
( 192 -80 -16 ) ( 193 -80 -16 ) ( 192 -80 -15 ) placeholder -32 -16 0 1 1
|
||||
( 192 -80 -16 ) ( 192 -80 -15 ) ( 192 -79 -16 ) placeholder -16 -16 0 1 1
|
||||
}
|
||||
// brush 3
|
||||
{
|
||||
( 80 16 32 ) ( 80 15 32 ) ( 80 16 31 ) placeholder 0 -16 180 1 1
|
||||
( 144 -96 16 ) ( 145 -96 16 ) ( 144 -96 15 ) placeholder 16 -16 0 1 -1
|
||||
( 144 -96 16 ) ( 144 -97 16 ) ( 145 -96 16 ) placeholder 16 0 0 1 -1
|
||||
( 80 16 32 ) ( 81 16 32 ) ( 80 15 32 ) placeholder 16 0 0 1 -1
|
||||
( 80 16 32 ) ( 80 16 31 ) ( 81 16 32 ) placeholder 16 -16 0 1 -1
|
||||
( 144 -96 16 ) ( 144 -96 15 ) ( 144 -97 16 ) placeholder 0 -16 180 1 1
|
||||
}
|
||||
// brush 4
|
||||
{
|
||||
( 224 -48 -80 ) ( 224 16 -80 ) ( 224 -96 -56 ) placeholder -128 -60 0 1 2
|
||||
( 224 -96 -56 ) ( 288 -96 -80 ) ( 224 -48 -80 ) placeholder -32 8 0 1 -2
|
||||
( 224 16 -80 ) ( 272 -32 -56 ) ( 224 -96 -56 ) placeholder -134.26993 -44.949593 0 1 2
|
||||
( 272 -32 -56 ) ( 288 -96 -40 ) ( 224 -96 -56 ) placeholder -32 112 0 1 1
|
||||
( 224 -96 -56 ) ( 288 -96 -40 ) ( 288 -96 -80 ) placeholder -32 -16.941177 0 1 -2
|
||||
( 288 -96 -80 ) ( 288 16 -80 ) ( 224 16 -80 ) placeholder -32 144 0 1 1
|
||||
( 272 -32 -56 ) ( 304 -32 -56 ) ( 288 -96 -40 ) placeholder -32 112 0 1 1
|
||||
( 288 16 -80 ) ( 304 -32 -56 ) ( 272 -32 -56 ) placeholder -32 -24 0 1 -2
|
||||
( 288 -96 -80 ) ( 304 -32 -56 ) ( 288 16 -80 ) placeholder 144 -52 0 1 2
|
||||
( 288 -96 -40 ) ( 304 -32 -56 ) ( 288 -96 -80 ) placeholder 118.95169 -69.728745 0 1 2
|
||||
}
|
||||
// brush 5
|
||||
{
|
||||
( -144 -560 -80 ) ( -144 -559 -80 ) ( -144 -560 -79 ) placeholder -80 96 0 0.2 0.2
|
||||
( -144 -320 -80 ) ( -144 -320 -79 ) ( -143 -320 -80 ) placeholder -32 96 0 0.2 0.2
|
||||
( -144 -560 -80 ) ( -143 -560 -80 ) ( -144 -559 -80 ) placeholder -32 80 0 0.2 0.2
|
||||
( -16 -432 16 ) ( -16 -431 16 ) ( -15 -432 16 ) placeholder -32 80 0 0.2 0.2
|
||||
( -16 -304 -48 ) ( -15 -304 -48 ) ( -16 -304 -47 ) placeholder -32 96 0 0.2 0.2
|
||||
( 304 -432 -48 ) ( 304 -432 -47 ) ( 304 -431 -48 ) placeholder -80 96 0 0.2 0.2
|
||||
}
|
||||
// brush 6
|
||||
{
|
||||
( -160 -240 -16 ) ( -160 -241 -16 ) ( -160 -240 -17 ) placeholder -240 96 180 1 1
|
||||
( -64 -304 -32 ) ( -63 -304 -32 ) ( -64 -304 -33 ) placeholder 208 96 0 1 -1
|
||||
( -64 -352 -80 ) ( -64 -353 -80 ) ( -63 -352 -80 ) placeholder 208 240 0 1 -1
|
||||
( -160 -240 16 ) ( -159 -240 16 ) ( -160 -241 16 ) placeholder 208 240 0 1 -1
|
||||
( -160 192 -16 ) ( -160 192 -17 ) ( -159 192 -16 ) placeholder 208 96 0 1 -1
|
||||
( -144 -352 -32 ) ( -144 -352 -33 ) ( -144 -353 -32 ) placeholder -240 96 180 1 1
|
||||
}
|
||||
// brush 7
|
||||
{
|
||||
( 162.74516600406096 -112 -80 ) ( 163.4522727852475 -111.29289321881345 -80 ) ( 162.74516600406096 -112 -79 ) placeholder 190.39192 0 0 0.70710677 1
|
||||
( 162.74516600406096 -112 -80 ) ( 162.74516600406096 -112 -79 ) ( 163.45227278524752 -112.70710678118652 -80 ) placeholder -38.156433 0 0 0.70710677 1
|
||||
( 162.74516600406096 -112 -80 ) ( 163.45227278524752 -112.70710678118652 -80 ) ( 163.4522727852475 -111.29289321881345 -80 ) placeholder -2.27417 3.882248 315 1 1
|
||||
( 253.25483399593907 -112 -48 ) ( 253.96194077712562 -111.29289321881353 -48 ) ( 253.9619407771256 -112.70710678118664 -48 ) placeholder -2.27417 3.882248 315 1 1
|
||||
( 253.25483399593907 -112 -64 ) ( 253.25483399593907 -112 -63 ) ( 253.96194077712562 -111.29289321881353 -64 ) placeholder -6.156433 0 0 0.70710677 1
|
||||
( 253.25483399593907 -112 -64 ) ( 253.9619407771256 -112.70710678118664 -64 ) ( 253.25483399593907 -112 -63 ) placeholder 97.60808 0 180 0.70710677 -1
|
||||
}
|
||||
// brush 8
|
||||
{
|
||||
( -32 96 -80 ) ( -32 97 -80 ) ( -32 96 -79 ) placeholder 0 0 0 1 1
|
||||
( 96 272 -64 ) ( 97 272.625 -64 ) ( 96 272 -63 ) placeholder 0 0 0 1 1
|
||||
( -32 96 -80 ) ( -31 96.625 -80 ) ( -32 97 -80 ) placeholder -73.70788 15.668304 32.00539 1.1792476 0.87100387
|
||||
( 96 272 -32 ) ( 96 273 -32 ) ( 97 272.625 -32 ) placeholder -73.70788 15.668304 32.00539 1.1792476 0.87100387
|
||||
( -32 96 -80 ) ( -32 96 -79 ) ( -31 96.625 -80 ) placeholder 0 0 0 1 1
|
||||
( 96 272 -64 ) ( 96 272 -63 ) ( 96 273 -64 ) placeholder -80 0 0 1 1
|
||||
}
|
||||
// brush 9
|
||||
{
|
||||
( -64 -672 -96 ) ( -64 -720 -80 ) ( -64 -720 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
( -64 -672 -96 ) ( -16 -672 -80 ) ( -64 -720 -80 ) placeholder 80 224 0 0.2 0.2
|
||||
( -64 -720 -80 ) ( -16 -720 -80 ) ( -16 -720 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -720 -112 ) ( -16 -672 -112 ) ( -64 -672 -112 ) placeholder 80 224 0 0.2 0.2
|
||||
( -64 -720 -80 ) ( -16 -672 -80 ) ( -16 -720 -80 ) placeholder 80 224 0 0.2 0.2
|
||||
( -16 -672 -112 ) ( -16 -672 -80 ) ( -64 -672 -96 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -720 -80 ) ( -16 -672 -80 ) ( -16 -672 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 10
|
||||
{
|
||||
( -16 -672 -80 ) ( -16 -720 -80 ) ( -16 -720 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
( -16 -672 -80 ) ( 32 -672 -48 ) ( -16 -720 -80 ) placeholder -160 224 0 0.2 0.2
|
||||
( -16 -720 -80 ) ( 32 -720 -80 ) ( 32 -720 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -720 -80 ) ( 32 -672 -48 ) ( 32 -720 -80 ) placeholder -160 224 0 0.2 0.2
|
||||
( 32 -720 -112 ) ( 32 -672 -112 ) ( -16 -672 -112 ) placeholder -160 224 0 0.2 0.2
|
||||
( 32 -672 -112 ) ( 32 -672 -48 ) ( -16 -672 -80 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -720 -80 ) ( 32 -672 -48 ) ( 32 -672 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 11
|
||||
{
|
||||
( 32 -672 -48 ) ( 32 -720 -80 ) ( 32 -720 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
( 32 -720 -80 ) ( 80 -720 -80 ) ( 80 -720 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 80 -720 -80 ) ( 32 -720 -80 ) placeholder -144 224 0 0.2 0.2
|
||||
( 80 -720 -112 ) ( 80 -672 -112 ) ( 32 -672 -112 ) placeholder -144 224 0 0.2 0.2
|
||||
( 80 -672 -112 ) ( 80 -672 -80 ) ( 32 -672 -48 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 80 -672 -80 ) ( 80 -720 -80 ) placeholder -144 224 0 0.2 0.2
|
||||
( 80 -720 -80 ) ( 80 -672 -80 ) ( 80 -672 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 12
|
||||
{
|
||||
( -112 -624 -80 ) ( -112 -672 -80 ) ( -112 -672 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
( -112 -672 -80 ) ( -64 -672 -96 ) ( -64 -672 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -672 -112 ) ( -64 -624 -112 ) ( -112 -624 -112 ) placeholder 64 208 0 0.2 0.2
|
||||
( -112 -624 -80 ) ( -64 -624 -80 ) ( -112 -672 -80 ) placeholder 64 208 0 0.2 0.2
|
||||
( -64 -624 -112 ) ( -64 -624 -80 ) ( -112 -624 -80 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -112 -672 -80 ) ( -64 -624 -80 ) ( -64 -672 -96 ) placeholder 64 208 0 0.2 0.2
|
||||
( -64 -672 -96 ) ( -64 -624 -80 ) ( -64 -624 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 13
|
||||
{
|
||||
( -112 -384 -112 ) ( -112 -383 -112 ) ( -112 -384 -111 ) placeholder -192 -64 0 0.2 0.2
|
||||
( -112 -624 -112 ) ( -112 -624 -111 ) ( -111 -624 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -112 -384 -112 ) ( -111 -384 -112 ) ( -112 -383 -112 ) placeholder 64 192 0 0.2 0.2
|
||||
( 16 -256 -80 ) ( 16 -255 -80 ) ( 17 -256 -80 ) placeholder 64 192 0 0.2 0.2
|
||||
( 16 -576 -80 ) ( 17 -576 -80 ) ( 16 -576 -79 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -256 -80 ) ( -64 -256 -79 ) ( -64 -255 -80 ) placeholder -192 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 14
|
||||
{
|
||||
( -64 -624 -80 ) ( -64 -672 -96 ) ( -64 -672 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
( -64 -624 -80 ) ( -16 -672 -80 ) ( -64 -672 -96 ) placeholder 80 208 0 0.2 0.2
|
||||
( -64 -672 -96 ) ( -16 -672 -80 ) ( -16 -672 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -672 -112 ) ( -16 -624 -112 ) ( -64 -624 -112 ) placeholder 80 208 0 0.2 0.2
|
||||
( -64 -624 -80 ) ( -16 -624 -80 ) ( -16 -672 -80 ) placeholder 80 208 0 0.2 0.2
|
||||
( -16 -624 -112 ) ( -16 -624 -80 ) ( -64 -624 -80 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -672 -80 ) ( -16 -624 -80 ) ( -16 -624 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 15
|
||||
{
|
||||
( -112 -528 -80 ) ( -112 -576 -80 ) ( -112 -576 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
( -112 -528 -80 ) ( -64 -528 -48 ) ( -112 -576 -80 ) placeholder 64 176 0 0.2 0.2
|
||||
( -112 -576 -80 ) ( -64 -576 -80 ) ( -64 -576 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -112 -576 -80 ) ( -64 -528 -48 ) ( -64 -576 -80 ) placeholder 64 176 0 0.2 0.2
|
||||
( -64 -576 -112 ) ( -64 -528 -112 ) ( -112 -528 -112 ) placeholder 64 176 0 0.2 0.2
|
||||
( -64 -528 -112 ) ( -64 -528 -48 ) ( -112 -528 -80 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -576 -80 ) ( -64 -528 -48 ) ( -64 -528 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 16
|
||||
{
|
||||
( -64 -384 -112 ) ( -64 -383 -112 ) ( -64 -384 -111 ) placeholder -192 -64 0 0.2 0.2
|
||||
( -64 -624 -112 ) ( -64 -624 -111 ) ( -63 -624 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -64 -384 -112 ) ( -63 -384 -112 ) ( -64 -383 -112 ) placeholder 80 192 0 0.2 0.2
|
||||
( 64 -256 -80 ) ( 64 -255 -80 ) ( 65 -256 -80 ) placeholder 80 192 0 0.2 0.2
|
||||
( 64 -576 -80 ) ( 65 -576 -80 ) ( 64 -576 -79 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -256 -80 ) ( -16 -256 -79 ) ( -16 -255 -80 ) placeholder -192 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 17
|
||||
{
|
||||
( -16 -624 -80 ) ( -16 -672 -80 ) ( -16 -672 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
( -16 -624 -80 ) ( 32 -672 -48 ) ( -16 -672 -80 ) placeholder -160 208 0 0.2 0.2
|
||||
( -16 -672 -80 ) ( 32 -672 -48 ) ( 32 -672 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -672 -112 ) ( 32 -624 -112 ) ( -16 -624 -112 ) placeholder -160 208 0 0.2 0.2
|
||||
( -16 -624 -80 ) ( 32 -624 -80 ) ( 32 -672 -48 ) placeholder -160 208 0 0.2 0.2
|
||||
( 32 -624 -112 ) ( 32 -624 -80 ) ( -16 -624 -80 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 32 -624 -80 ) ( 32 -624 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 18
|
||||
{
|
||||
( -112 -480 -80 ) ( -112 -528 -80 ) ( -112 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -112 -480 -80 ) ( -64 -528 -48 ) ( -112 -528 -80 ) placeholder 64 160 0 0.2 0.2
|
||||
( -112 -528 -80 ) ( -64 -528 -48 ) ( -64 -528 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -528 -112 ) ( -64 -480 -112 ) ( -112 -480 -112 ) placeholder 64 160 0 0.2 0.2
|
||||
( -112 -480 -80 ) ( -64 -480 -80 ) ( -64 -528 -48 ) placeholder 64 160 0 0.2 0.2
|
||||
( -64 -480 -112 ) ( -64 -480 -80 ) ( -112 -480 -80 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -64 -480 -80 ) ( -64 -480 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 19
|
||||
{
|
||||
( -64 -528 -48 ) ( -64 -576 -80 ) ( -64 -576 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
( -64 -576 -80 ) ( -16 -576 -80 ) ( -16 -576 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -16 -576 -80 ) ( -64 -576 -80 ) placeholder 80 176 0 0.2 0.2
|
||||
( -16 -576 -112 ) ( -16 -528 -112 ) ( -64 -528 -112 ) placeholder 80 176 0 0.2 0.2
|
||||
( -16 -528 -112 ) ( -16 -528 -80 ) ( -64 -528 -48 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -16 -528 -80 ) ( -16 -576 -80 ) placeholder 80 176 0 0.2 0.2
|
||||
( -16 -576 -80 ) ( -16 -528 -80 ) ( -16 -528 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 20
|
||||
{
|
||||
( -16 -384 -112 ) ( -16 -383 -112 ) ( -16 -384 -111 ) placeholder -192 -64 0 0.2 0.2
|
||||
( -16 -624 -112 ) ( -16 -624 -111 ) ( -15 -624 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -384 -112 ) ( -15 -384 -112 ) ( -16 -383 -112 ) placeholder -160 192 0 0.2 0.2
|
||||
( 112 -256 -80 ) ( 112 -255 -80 ) ( 113 -256 -80 ) placeholder -160 192 0 0.2 0.2
|
||||
( 112 -576 -80 ) ( 113 -576 -80 ) ( 112 -576 -79 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -256 -80 ) ( 32 -256 -79 ) ( 32 -255 -80 ) placeholder -192 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 21
|
||||
{
|
||||
( 32 -624 -80 ) ( 32 -672 -48 ) ( 32 -672 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 80 -672 -80 ) ( 80 -672 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -672 -112 ) ( 80 -624 -112 ) ( 32 -624 -112 ) placeholder -144 208 0 0.2 0.2
|
||||
( 32 -624 -80 ) ( 80 -624 -80 ) ( 32 -672 -48 ) placeholder -144 208 0 0.2 0.2
|
||||
( 80 -624 -112 ) ( 80 -624 -80 ) ( 32 -624 -80 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 80 -624 -80 ) ( 80 -672 -80 ) placeholder -144 208 0 0.2 0.2
|
||||
( 80 -672 -80 ) ( 80 -624 -80 ) ( 80 -624 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 22
|
||||
{
|
||||
( -64 -480 -80 ) ( -64 -528 -48 ) ( -64 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -16 -528 -80 ) ( -16 -528 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -528 -112 ) ( -16 -480 -112 ) ( -64 -480 -112 ) placeholder 80 160 0 0.2 0.2
|
||||
( -64 -480 -80 ) ( -16 -480 -80 ) ( -64 -528 -48 ) placeholder 80 160 0 0.2 0.2
|
||||
( -16 -480 -112 ) ( -16 -480 -80 ) ( -64 -480 -80 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -16 -480 -80 ) ( -16 -528 -80 ) placeholder 80 160 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( -16 -480 -80 ) ( -16 -480 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 23
|
||||
{
|
||||
( -16 -528 -80 ) ( -16 -576 -80 ) ( -16 -576 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
( -16 -576 -80 ) ( 32 -576 -80 ) ( 32 -576 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -576 -112 ) ( 32 -528 -112 ) ( -16 -528 -112 ) placeholder -160 176 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( 32 -576 -80 ) ( -16 -576 -80 ) placeholder -160 176 0 0.2 0.2
|
||||
( 32 -528 -112 ) ( 32 -528 -96 ) ( -16 -528 -80 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( 32 -528 -96 ) ( 32 -576 -80 ) placeholder -160 176 0 0.2 0.2
|
||||
( 32 -576 -80 ) ( 32 -528 -96 ) ( 32 -528 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 24
|
||||
{
|
||||
( 32 -384 -112 ) ( 32 -383 -112 ) ( 32 -384 -111 ) placeholder -192 -64 0 0.2 0.2
|
||||
( 32 -624 -112 ) ( 32 -624 -111 ) ( 33 -624 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 32 -384 -112 ) ( 33 -384 -112 ) ( 32 -383 -112 ) placeholder -144 192 0 0.2 0.2
|
||||
( 160 -256 -80 ) ( 160 -255 -80 ) ( 161 -256 -80 ) placeholder -144 192 0 0.2 0.2
|
||||
( 160 -576 -80 ) ( 161 -576 -80 ) ( 160 -576 -79 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -256 -80 ) ( 80 -256 -79 ) ( 80 -255 -80 ) placeholder -192 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 25
|
||||
{
|
||||
( -16 -480 -80 ) ( -16 -528 -80 ) ( -16 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( 32 -528 -96 ) ( 32 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -528 -112 ) ( 32 -480 -112 ) ( -16 -480 -112 ) placeholder -160 160 0 0.2 0.2
|
||||
( -16 -480 -80 ) ( 32 -480 -80 ) ( -16 -528 -80 ) placeholder -160 160 0 0.2 0.2
|
||||
( 32 -480 -112 ) ( 32 -480 -80 ) ( -16 -480 -80 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( 32 -480 -80 ) ( 32 -528 -96 ) placeholder -160 160 0 0.2 0.2
|
||||
( 32 -528 -96 ) ( 32 -480 -80 ) ( 32 -480 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 26
|
||||
{
|
||||
( 32 -528 -96 ) ( 32 -576 -80 ) ( 32 -576 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
( 32 -528 -96 ) ( 80 -528 -80 ) ( 32 -576 -80 ) placeholder -144 176 0 0.2 0.2
|
||||
( 32 -576 -80 ) ( 80 -576 -80 ) ( 80 -576 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -576 -112 ) ( 80 -528 -112 ) ( 32 -528 -112 ) placeholder -144 176 0 0.2 0.2
|
||||
( 32 -576 -80 ) ( 80 -528 -80 ) ( 80 -576 -80 ) placeholder -144 176 0 0.2 0.2
|
||||
( 80 -528 -112 ) ( 80 -528 -80 ) ( 32 -528 -96 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -576 -80 ) ( 80 -528 -80 ) ( 80 -528 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 27
|
||||
{
|
||||
( 32 -480 -80 ) ( 32 -528 -96 ) ( 32 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -480 -80 ) ( 80 -528 -80 ) ( 32 -528 -96 ) placeholder -144 160 0 0.2 0.2
|
||||
( 32 -528 -96 ) ( 80 -528 -80 ) ( 80 -528 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -528 -112 ) ( 80 -480 -112 ) ( 32 -480 -112 ) placeholder -144 160 0 0.2 0.2
|
||||
( 32 -480 -80 ) ( 80 -480 -80 ) ( 80 -528 -80 ) placeholder -144 160 0 0.2 0.2
|
||||
( 80 -480 -112 ) ( 80 -480 -80 ) ( 32 -480 -80 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -528 -80 ) ( 80 -480 -80 ) ( 80 -480 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 28
|
||||
{
|
||||
( 224 256 112 ) ( 224 257 112 ) ( 224 256 113 ) placeholder 170.66669 8 0 -0.375 0.4
|
||||
( 224 256 112 ) ( 224 256 113 ) ( 225 256 112 ) placeholder 224 -256 0 0.4 0.4
|
||||
( 224 256 112 ) ( 225 256 112 ) ( 224 257 112 ) placeholder 47.999992 138.99998 0 -0.4 0.4
|
||||
( 320 336 208 ) ( 320 337 208 ) ( 321 336 208 ) placeholder 208 112 0 0.4 0.4
|
||||
( 320 352 128 ) ( 321 352 128 ) ( 320 352 129 ) placeholder 48 -256 0 -0.4 0.4
|
||||
( 320 336 128 ) ( 320 336 129 ) ( 320 337 128 ) placeholder 128 -256 0 0.4 0.4
|
||||
}
|
||||
}
|
||||
// entity 1
|
||||
{
|
||||
"classname" "info_player_start"
|
||||
"origin" "112 -48 56"
|
||||
}
|
||||
@@ -1,303 +0,0 @@
|
||||
// Game: Generic
|
||||
// Format: Standard
|
||||
// entity 0
|
||||
{
|
||||
"classname" "worldspawn"
|
||||
"wad" ""
|
||||
// brush 0
|
||||
{
|
||||
( -112 -672 -80 ) ( -112 -720 -80 ) ( -112 -720 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
( -112 -720 -80 ) ( -64 -720 -80 ) ( -64 -720 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -720 -112 ) ( -64 -672 -112 ) ( -112 -672 -112 ) placeholder 64 224 0 0.2 0.2
|
||||
( -112 -672 -80 ) ( -64 -720 -80 ) ( -112 -720 -80 ) placeholder 64 224 0 0.2 0.2
|
||||
( -64 -672 -112 ) ( -64 -672 -96 ) ( -112 -672 -80 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -112 -672 -80 ) ( -64 -672 -96 ) ( -64 -720 -80 ) placeholder 64 224 0 0.2 0.2
|
||||
( -64 -720 -80 ) ( -64 -672 -96 ) ( -64 -672 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 1
|
||||
{
|
||||
( 0 -128 -16 ) ( 0 -127 -16 ) ( 0 -128 -15 ) placeholder 0 0 0 1 1
|
||||
( 0 -128 -16 ) ( 0 -128 -15 ) ( 1 -128 -16 ) placeholder -32 0 0 1 1
|
||||
( 0 -128 -16 ) ( 1 -128 -16 ) ( 0 -127 -16 ) placeholder -32 0 0 1 1
|
||||
( 64 -96 0 ) ( 64 -95 0 ) ( 65 -96 0 ) placeholder -32 0 0 1 1
|
||||
( 64 -96 0 ) ( 65 -96 0 ) ( 64 -96 1 ) placeholder -32 0 0 1 1
|
||||
( 64 -96 0 ) ( 64 -96 1 ) ( 64 -95 0 ) placeholder 0 0 0 1 1
|
||||
}
|
||||
// brush 2
|
||||
{
|
||||
( 64 -144 -32 ) ( 64 -143 -32 ) ( 64 -144 -31 ) placeholder -16 -16 0 1 1
|
||||
( 64 -144 -32 ) ( 64 -144 -31 ) ( 65 -144 -32 ) placeholder -32 -16 0 1 1
|
||||
( 64 -144 -32 ) ( 65 -144 -32 ) ( 64 -143 -32 ) placeholder -32 16 0 1 1
|
||||
( 192 -80 -16 ) ( 192 -79 -16 ) ( 193 -80 -16 ) placeholder -32 16 0 1 1
|
||||
( 192 -80 -16 ) ( 193 -80 -16 ) ( 192 -80 -15 ) placeholder -32 -16 0 1 1
|
||||
( 192 -80 -16 ) ( 192 -80 -15 ) ( 192 -79 -16 ) placeholder -16 -16 0 1 1
|
||||
}
|
||||
// brush 3
|
||||
{
|
||||
( 80 16 32 ) ( 80 15 32 ) ( 80 16 31 ) placeholder 0 -16 180 1 1
|
||||
( 144 -96 16 ) ( 145 -96 16 ) ( 144 -96 15 ) placeholder 16 -16 0 1 -1
|
||||
( 144 -96 16 ) ( 144 -97 16 ) ( 145 -96 16 ) placeholder 16 0 0 1 -1
|
||||
( 80 16 32 ) ( 81 16 32 ) ( 80 15 32 ) placeholder 16 0 0 1 -1
|
||||
( 80 16 32 ) ( 80 16 31 ) ( 81 16 32 ) placeholder 16 -16 0 1 -1
|
||||
( 144 -96 16 ) ( 144 -96 15 ) ( 144 -97 16 ) placeholder 0 -16 180 1 1
|
||||
}
|
||||
// brush 4
|
||||
{
|
||||
( 240 -64 -80 ) ( 240 0 -80 ) ( 240 -112 -56 ) __TB_empty -128 -60 0 1 2
|
||||
( 240 -112 -56 ) ( 304 -112 -80 ) ( 240 -64 -80 ) __TB_empty -32 8 0 1 -2
|
||||
( 240 0 -80 ) ( 288 -48 -56 ) ( 240 -112 -56 ) __TB_empty -80.41865 55.557785 323.1301 1.1743635 1.1509081
|
||||
( 288 -48 -56 ) ( 304 -112 -40 ) ( 240 -112 -56 ) __TB_empty -32 112 0 1 1
|
||||
( 240 -112 -56 ) ( 304 -112 -40 ) ( 304 -112 -80 ) __TB_empty -32 -16.941177 0 1 -2
|
||||
( 304 -112 -80 ) ( 304 0 -80 ) ( 240 0 -80 ) __TB_empty -32 144 0 1 1
|
||||
( 288 -48 -56 ) ( 320 -48 -56 ) ( 304 -112 -40 ) __TB_empty -32 112 0 1 1
|
||||
( 304 0 -80 ) ( 320 -48 -56 ) ( 288 -48 -56 ) __TB_empty -32 -32 0 1 -1
|
||||
( 304 -112 -80 ) ( 320 -48 -56 ) ( 304 0 -80 ) __TB_empty 144 -52 0 1 2
|
||||
( 304 -112 -40 ) ( 320 -48 -56 ) ( 304 -112 -80 ) __TB_empty 118.95169 -69.728745 0 1 1.1
|
||||
}
|
||||
// brush 5
|
||||
{
|
||||
( -144 -560 -80 ) ( -144 -559 -80 ) ( -144 -560 -79 ) placeholder -80 96 0 0.2 0.2
|
||||
( -144 -320 -80 ) ( -144 -320 -79 ) ( -143 -320 -80 ) placeholder -32 96 0 0.2 0.2
|
||||
( -144 -560 -80 ) ( -143 -560 -80 ) ( -144 -559 -80 ) placeholder -32 80 0 0.2 0.2
|
||||
( -16 -432 16 ) ( -16 -431 16 ) ( -15 -432 16 ) placeholder -32 80 0 0.2 0.2
|
||||
( -16 -304 -48 ) ( -15 -304 -48 ) ( -16 -304 -47 ) placeholder -32 96 0 0.2 0.2
|
||||
( 304 -432 -48 ) ( 304 -432 -47 ) ( 304 -431 -48 ) placeholder -80 96 0 0.2 0.2
|
||||
}
|
||||
// brush 6
|
||||
{
|
||||
( -160 -240 -16 ) ( -160 -241 -16 ) ( -160 -240 -17 ) placeholder -240 96 180 1 1
|
||||
( -64 -304 -32 ) ( -63 -304 -32 ) ( -64 -304 -33 ) placeholder 208 96 0 1 -1
|
||||
( -64 -352 -80 ) ( -64 -353 -80 ) ( -63 -352 -80 ) placeholder 208 240 0 1 -1
|
||||
( -160 -240 16 ) ( -159 -240 16 ) ( -160 -241 16 ) placeholder 208 240 0 1 -1
|
||||
( -160 192 -16 ) ( -160 192 -17 ) ( -159 192 -16 ) placeholder 208 96 0 1 -1
|
||||
( -144 -352 -32 ) ( -144 -352 -33 ) ( -144 -353 -32 ) placeholder -240 96 180 1 1
|
||||
}
|
||||
// brush 7
|
||||
{
|
||||
( 162.74516600406096 -112 -80 ) ( 163.4522727852475 -111.29289321881345 -80 ) ( 162.74516600406096 -112 -79 ) placeholder 190.39192 0 0 0.70710677 1
|
||||
( 162.74516600406096 -112 -80 ) ( 162.74516600406096 -112 -79 ) ( 163.45227278524752 -112.70710678118652 -80 ) placeholder -38.156433 0 0 0.70710677 1
|
||||
( 162.74516600406096 -112 -80 ) ( 163.45227278524752 -112.70710678118652 -80 ) ( 163.4522727852475 -111.29289321881345 -80 ) placeholder -2.27417 3.882248 315 1 1
|
||||
( 253.25483399593907 -112 -48 ) ( 253.96194077712562 -111.29289321881353 -48 ) ( 253.9619407771256 -112.70710678118664 -48 ) placeholder 163.08612 199.7645 315 0.3 0.3
|
||||
( 253.25483399593907 -112 -64 ) ( 253.25483399593907 -112 -63 ) ( 253.96194077712562 -111.29289321881353 -64 ) placeholder -6.156433 0 0 0.70710677 1
|
||||
( 253.25483399593907 -112 -64 ) ( 253.9619407771256 -112.70710678118664 -64 ) ( 253.25483399593907 -112 -63 ) placeholder 97.60808 0 180 0.70710677 -1
|
||||
}
|
||||
// brush 8
|
||||
{
|
||||
( -32 96 -80 ) ( -32 97 -80 ) ( -32 96 -79 ) placeholder 0 0 0 1 1
|
||||
( 96 272 -64 ) ( 97 272.625 -64 ) ( 96 272 -63 ) placeholder 0 0 0 1 1
|
||||
( -32 96 -80 ) ( -31 96.625 -80 ) ( -32 97 -80 ) placeholder -73.70788 15.668304 32.00539 1.1792476 0.87100387
|
||||
( 96 272 -32 ) ( 96 273 -32 ) ( 97 272.625 -32 ) placeholder -73.70788 15.668304 32.00539 1.1792476 0.87100387
|
||||
( -32 96 -80 ) ( -32 96 -79 ) ( -31 96.625 -80 ) placeholder 0 0 0 1 1
|
||||
( 96 272 -64 ) ( 96 272 -63 ) ( 96 273 -64 ) placeholder -80 0 0 1 1
|
||||
}
|
||||
// brush 9
|
||||
{
|
||||
( -64 -672 -96 ) ( -64 -720 -80 ) ( -64 -720 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
( -64 -672 -96 ) ( -16 -672 -80 ) ( -64 -720 -80 ) placeholder 80 224 0 0.2 0.2
|
||||
( -64 -720 -80 ) ( -16 -720 -80 ) ( -16 -720 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -720 -112 ) ( -16 -672 -112 ) ( -64 -672 -112 ) placeholder 80 224 0 0.2 0.2
|
||||
( -64 -720 -80 ) ( -16 -672 -80 ) ( -16 -720 -80 ) placeholder 80 224 0 0.2 0.2
|
||||
( -16 -672 -112 ) ( -16 -672 -80 ) ( -64 -672 -96 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -720 -80 ) ( -16 -672 -80 ) ( -16 -672 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 10
|
||||
{
|
||||
( -16 -672 -80 ) ( -16 -720 -80 ) ( -16 -720 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
( -16 -672 -80 ) ( 32 -672 -48 ) ( -16 -720 -80 ) placeholder -160 224 0 0.2 0.2
|
||||
( -16 -720 -80 ) ( 32 -720 -80 ) ( 32 -720 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -720 -80 ) ( 32 -672 -48 ) ( 32 -720 -80 ) placeholder -160 224 0 0.2 0.2
|
||||
( 32 -720 -112 ) ( 32 -672 -112 ) ( -16 -672 -112 ) placeholder -160 224 0 0.2 0.2
|
||||
( 32 -672 -112 ) ( 32 -672 -48 ) ( -16 -672 -80 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -720 -80 ) ( 32 -672 -48 ) ( 32 -672 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 11
|
||||
{
|
||||
( 32 -672 -48 ) ( 32 -720 -80 ) ( 32 -720 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
( 32 -720 -80 ) ( 80 -720 -80 ) ( 80 -720 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 80 -720 -80 ) ( 32 -720 -80 ) placeholder -144 224 0 0.2 0.2
|
||||
( 80 -720 -112 ) ( 80 -672 -112 ) ( 32 -672 -112 ) placeholder -144 224 0 0.2 0.2
|
||||
( 80 -672 -112 ) ( 80 -672 -80 ) ( 32 -672 -48 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 80 -672 -80 ) ( 80 -720 -80 ) placeholder -144 224 0 0.2 0.2
|
||||
( 80 -720 -80 ) ( 80 -672 -80 ) ( 80 -672 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 12
|
||||
{
|
||||
( -112 -624 -80 ) ( -112 -672 -80 ) ( -112 -672 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
( -112 -672 -80 ) ( -64 -672 -96 ) ( -64 -672 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -672 -112 ) ( -64 -624 -112 ) ( -112 -624 -112 ) placeholder 64 208 0 0.2 0.2
|
||||
( -112 -624 -80 ) ( -64 -624 -80 ) ( -112 -672 -80 ) placeholder 64 208 0 0.2 0.2
|
||||
( -64 -624 -112 ) ( -64 -624 -80 ) ( -112 -624 -80 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -112 -672 -80 ) ( -64 -624 -80 ) ( -64 -672 -96 ) placeholder 64 208 0 0.2 0.2
|
||||
( -64 -672 -96 ) ( -64 -624 -80 ) ( -64 -624 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 13
|
||||
{
|
||||
( -112 -384 -112 ) ( -112 -383 -112 ) ( -112 -384 -111 ) placeholder -192 -64 0 0.2 0.2
|
||||
( -112 -624 -112 ) ( -112 -624 -111 ) ( -111 -624 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -112 -384 -112 ) ( -111 -384 -112 ) ( -112 -383 -112 ) placeholder 64 192 0 0.2 0.2
|
||||
( 16 -256 -80 ) ( 16 -255 -80 ) ( 17 -256 -80 ) placeholder 64 192 0 0.2 0.2
|
||||
( 16 -576 -80 ) ( 17 -576 -80 ) ( 16 -576 -79 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -256 -80 ) ( -64 -256 -79 ) ( -64 -255 -80 ) placeholder -192 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 14
|
||||
{
|
||||
( -64 -624 -80 ) ( -64 -672 -96 ) ( -64 -672 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
( -64 -624 -80 ) ( -16 -672 -80 ) ( -64 -672 -96 ) placeholder 80 208 0 0.2 0.2
|
||||
( -64 -672 -96 ) ( -16 -672 -80 ) ( -16 -672 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -672 -112 ) ( -16 -624 -112 ) ( -64 -624 -112 ) placeholder 80 208 0 0.2 0.2
|
||||
( -64 -624 -80 ) ( -16 -624 -80 ) ( -16 -672 -80 ) placeholder 80 208 0 0.2 0.2
|
||||
( -16 -624 -112 ) ( -16 -624 -80 ) ( -64 -624 -80 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -672 -80 ) ( -16 -624 -80 ) ( -16 -624 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 15
|
||||
{
|
||||
( -112 -528 -80 ) ( -112 -576 -80 ) ( -112 -576 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
( -112 -528 -80 ) ( -64 -528 -48 ) ( -112 -576 -80 ) placeholder 64 176 0 0.2 0.2
|
||||
( -112 -576 -80 ) ( -64 -576 -80 ) ( -64 -576 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -112 -576 -80 ) ( -64 -528 -48 ) ( -64 -576 -80 ) placeholder 64 176 0 0.2 0.2
|
||||
( -64 -576 -112 ) ( -64 -528 -112 ) ( -112 -528 -112 ) placeholder 64 176 0 0.2 0.2
|
||||
( -64 -528 -112 ) ( -64 -528 -48 ) ( -112 -528 -80 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -576 -80 ) ( -64 -528 -48 ) ( -64 -528 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 16
|
||||
{
|
||||
( -64 -384 -112 ) ( -64 -383 -112 ) ( -64 -384 -111 ) placeholder -192 -64 0 0.2 0.2
|
||||
( -64 -624 -112 ) ( -64 -624 -111 ) ( -63 -624 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -64 -384 -112 ) ( -63 -384 -112 ) ( -64 -383 -112 ) placeholder 80 192 0 0.2 0.2
|
||||
( 64 -256 -80 ) ( 64 -255 -80 ) ( 65 -256 -80 ) placeholder 80 192 0 0.2 0.2
|
||||
( 64 -576 -80 ) ( 65 -576 -80 ) ( 64 -576 -79 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -256 -80 ) ( -16 -256 -79 ) ( -16 -255 -80 ) placeholder -192 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 17
|
||||
{
|
||||
( -16 -624 -80 ) ( -16 -672 -80 ) ( -16 -672 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
( -16 -624 -80 ) ( 32 -672 -48 ) ( -16 -672 -80 ) placeholder -160 208 0 0.2 0.2
|
||||
( -16 -672 -80 ) ( 32 -672 -48 ) ( 32 -672 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -672 -112 ) ( 32 -624 -112 ) ( -16 -624 -112 ) placeholder -160 208 0 0.2 0.2
|
||||
( -16 -624 -80 ) ( 32 -624 -80 ) ( 32 -672 -48 ) placeholder -160 208 0 0.2 0.2
|
||||
( 32 -624 -112 ) ( 32 -624 -80 ) ( -16 -624 -80 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 32 -624 -80 ) ( 32 -624 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 18
|
||||
{
|
||||
( -112 -480 -80 ) ( -112 -528 -80 ) ( -112 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -112 -480 -80 ) ( -64 -528 -48 ) ( -112 -528 -80 ) placeholder 64 160 0 0.2 0.2
|
||||
( -112 -528 -80 ) ( -64 -528 -48 ) ( -64 -528 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -528 -112 ) ( -64 -480 -112 ) ( -112 -480 -112 ) placeholder 64 160 0 0.2 0.2
|
||||
( -112 -480 -80 ) ( -64 -480 -80 ) ( -64 -528 -48 ) placeholder 64 160 0 0.2 0.2
|
||||
( -64 -480 -112 ) ( -64 -480 -80 ) ( -112 -480 -80 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -64 -480 -80 ) ( -64 -480 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 19
|
||||
{
|
||||
( -64 -528 -48 ) ( -64 -576 -80 ) ( -64 -576 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
( -64 -576 -80 ) ( -16 -576 -80 ) ( -16 -576 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -16 -576 -80 ) ( -64 -576 -80 ) placeholder 80 176 0 0.2 0.2
|
||||
( -16 -576 -112 ) ( -16 -528 -112 ) ( -64 -528 -112 ) placeholder 80 176 0 0.2 0.2
|
||||
( -16 -528 -112 ) ( -16 -528 -80 ) ( -64 -528 -48 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -16 -528 -80 ) ( -16 -576 -80 ) placeholder 80 176 0 0.2 0.2
|
||||
( -16 -576 -80 ) ( -16 -528 -80 ) ( -16 -528 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 20
|
||||
{
|
||||
( -16 -384 -112 ) ( -16 -383 -112 ) ( -16 -384 -111 ) placeholder -192 -64 0 0.2 0.2
|
||||
( -16 -624 -112 ) ( -16 -624 -111 ) ( -15 -624 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -384 -112 ) ( -15 -384 -112 ) ( -16 -383 -112 ) placeholder -160 192 0 0.2 0.2
|
||||
( 112 -256 -80 ) ( 112 -255 -80 ) ( 113 -256 -80 ) placeholder -160 192 0 0.2 0.2
|
||||
( 112 -576 -80 ) ( 113 -576 -80 ) ( 112 -576 -79 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -256 -80 ) ( 32 -256 -79 ) ( 32 -255 -80 ) placeholder -192 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 21
|
||||
{
|
||||
( 32 -624 -80 ) ( 32 -672 -48 ) ( 32 -672 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 80 -672 -80 ) ( 80 -672 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -672 -112 ) ( 80 -624 -112 ) ( 32 -624 -112 ) placeholder -144 208 0 0.2 0.2
|
||||
( 32 -624 -80 ) ( 80 -624 -80 ) ( 32 -672 -48 ) placeholder -144 208 0 0.2 0.2
|
||||
( 80 -624 -112 ) ( 80 -624 -80 ) ( 32 -624 -80 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 80 -624 -80 ) ( 80 -672 -80 ) placeholder -144 208 0 0.2 0.2
|
||||
( 80 -672 -80 ) ( 80 -624 -80 ) ( 80 -624 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 22
|
||||
{
|
||||
( -64 -480 -80 ) ( -64 -528 -48 ) ( -64 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -16 -528 -80 ) ( -16 -528 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -528 -112 ) ( -16 -480 -112 ) ( -64 -480 -112 ) placeholder 80 160 0 0.2 0.2
|
||||
( -64 -480 -80 ) ( -16 -480 -80 ) ( -64 -528 -48 ) placeholder 80 160 0 0.2 0.2
|
||||
( -16 -480 -112 ) ( -16 -480 -80 ) ( -64 -480 -80 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -16 -480 -80 ) ( -16 -528 -80 ) placeholder 80 160 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( -16 -480 -80 ) ( -16 -480 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 23
|
||||
{
|
||||
( -16 -528 -80 ) ( -16 -576 -80 ) ( -16 -576 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
( -16 -576 -80 ) ( 32 -576 -80 ) ( 32 -576 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -576 -112 ) ( 32 -528 -112 ) ( -16 -528 -112 ) placeholder -160 176 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( 32 -576 -80 ) ( -16 -576 -80 ) placeholder -160 176 0 0.2 0.2
|
||||
( 32 -528 -112 ) ( 32 -528 -96 ) ( -16 -528 -80 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( 32 -528 -96 ) ( 32 -576 -80 ) placeholder -160 176 0 0.2 0.2
|
||||
( 32 -576 -80 ) ( 32 -528 -96 ) ( 32 -528 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 24
|
||||
{
|
||||
( 32 -384 -112 ) ( 32 -383 -112 ) ( 32 -384 -111 ) placeholder -192 -64 0 0.2 0.2
|
||||
( 32 -624 -112 ) ( 32 -624 -111 ) ( 33 -624 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 32 -384 -112 ) ( 33 -384 -112 ) ( 32 -383 -112 ) placeholder -144 192 0 0.2 0.2
|
||||
( 160 -256 -80 ) ( 160 -255 -80 ) ( 161 -256 -80 ) placeholder -144 192 0 0.2 0.2
|
||||
( 160 -576 -80 ) ( 161 -576 -80 ) ( 160 -576 -79 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -256 -80 ) ( 80 -256 -79 ) ( 80 -255 -80 ) placeholder -192 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 25
|
||||
{
|
||||
( -16 -480 -80 ) ( -16 -528 -80 ) ( -16 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( 32 -528 -96 ) ( 32 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -528 -112 ) ( 32 -480 -112 ) ( -16 -480 -112 ) placeholder -160 160 0 0.2 0.2
|
||||
( -16 -480 -80 ) ( 32 -480 -80 ) ( -16 -528 -80 ) placeholder -160 160 0 0.2 0.2
|
||||
( 32 -480 -112 ) ( 32 -480 -80 ) ( -16 -480 -80 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( 32 -480 -80 ) ( 32 -528 -96 ) placeholder -160 160 0 0.2 0.2
|
||||
( 32 -528 -96 ) ( 32 -480 -80 ) ( 32 -480 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 26
|
||||
{
|
||||
( 32 -528 -96 ) ( 32 -576 -80 ) ( 32 -576 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
( 32 -528 -96 ) ( 80 -528 -80 ) ( 32 -576 -80 ) placeholder -144 176 0 0.2 0.2
|
||||
( 32 -576 -80 ) ( 80 -576 -80 ) ( 80 -576 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -576 -112 ) ( 80 -528 -112 ) ( 32 -528 -112 ) placeholder -144 176 0 0.2 0.2
|
||||
( 32 -576 -80 ) ( 80 -528 -80 ) ( 80 -576 -80 ) placeholder -144 176 0 0.2 0.2
|
||||
( 80 -528 -112 ) ( 80 -528 -80 ) ( 32 -528 -96 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -576 -80 ) ( 80 -528 -80 ) ( 80 -528 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 27
|
||||
{
|
||||
( 32 -480 -80 ) ( 32 -528 -96 ) ( 32 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -480 -80 ) ( 80 -528 -80 ) ( 32 -528 -96 ) placeholder -144 160 0 0.2 0.2
|
||||
( 32 -528 -96 ) ( 80 -528 -80 ) ( 80 -528 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -528 -112 ) ( 80 -480 -112 ) ( 32 -480 -112 ) placeholder -144 160 0 0.2 0.2
|
||||
( 32 -480 -80 ) ( 80 -480 -80 ) ( 80 -528 -80 ) placeholder -144 160 0 0.2 0.2
|
||||
( 80 -480 -112 ) ( 80 -480 -80 ) ( 32 -480 -80 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -528 -80 ) ( 80 -480 -80 ) ( 80 -480 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 28
|
||||
{
|
||||
( 224 256 112 ) ( 224 257 112 ) ( 224 256 113 ) placeholder 170.66669 8 0 -0.375 0.4
|
||||
( 224 256 112 ) ( 224 256 113 ) ( 225 256 112 ) placeholder 224 -256 0 0.4 0.4
|
||||
( 224 256 112 ) ( 225 256 112 ) ( 224 257 112 ) placeholder 47.999992 138.99998 0 -0.4 0.4
|
||||
( 320 336 208 ) ( 320 337 208 ) ( 321 336 208 ) placeholder 208 112 0 0.4 0.4
|
||||
( 320 352 128 ) ( 321 352 128 ) ( 320 352 129 ) placeholder 48 -256 0 -0.4 0.4
|
||||
( 320 336 128 ) ( 320 336 129 ) ( 320 337 128 ) placeholder 128 -256 0 0.4 0.4
|
||||
}
|
||||
// brush 29
|
||||
{
|
||||
( 0 -144 -32 ) ( 16 -304 -64 ) ( 16 -144 -64 ) placeholder 0 0 0 1 1
|
||||
( 32 -144 -16 ) ( 0 -304 -32 ) ( 0 -144 -32 ) placeholder 0 0 0 1 1
|
||||
( 64 -304 -32 ) ( 0 -304 -32 ) ( 32 -304 -16 ) placeholder 0 0 0 1 1
|
||||
( 64 -144 -64 ) ( 16 -304 -64 ) ( 64 -304 -64 ) placeholder 0 0 0 1 1
|
||||
( 64 -144 -32 ) ( 16 -144 -64 ) ( 64 -144 -64 ) placeholder 0 0 0 1 1
|
||||
( 64 -144 -32 ) ( 32 -304 -16 ) ( 32 -144 -16 ) placeholder 0 0 0 1 1
|
||||
( 64 -144 -32 ) ( 64 -304 -64 ) ( 64 -304 -32 ) placeholder 0 0 0 1 1
|
||||
}
|
||||
}
|
||||
// entity 1
|
||||
{
|
||||
"classname" "info_player_start"
|
||||
"origin" "112 -48 56"
|
||||
}
|
||||
@@ -1,293 +0,0 @@
|
||||
// Game: Generic
|
||||
// Format: Standard
|
||||
// entity 0
|
||||
{
|
||||
"classname" "worldspawn"
|
||||
"wad" ""
|
||||
// brush 0
|
||||
{
|
||||
( -112 -672 -80 ) ( -112 -720 -80 ) ( -112 -720 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
( -112 -720 -80 ) ( -64 -720 -80 ) ( -64 -720 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -720 -112 ) ( -64 -672 -112 ) ( -112 -672 -112 ) placeholder 64 224 0 0.2 0.2
|
||||
( -112 -672 -80 ) ( -64 -720 -80 ) ( -112 -720 -80 ) placeholder 64 224 0 0.2 0.2
|
||||
( -64 -672 -112 ) ( -64 -672 -96 ) ( -112 -672 -80 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -112 -672 -80 ) ( -64 -672 -96 ) ( -64 -720 -80 ) placeholder 64 224 0 0.2 0.2
|
||||
( -64 -720 -80 ) ( -64 -672 -96 ) ( -64 -672 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 1
|
||||
{
|
||||
( 0 -128 -16 ) ( 0 -127 -16 ) ( 0 -128 -15 ) placeholder 0 0 0 1 1
|
||||
( 0 -128 -16 ) ( 0 -128 -15 ) ( 1 -128 -16 ) placeholder -32 0 0 1 1
|
||||
( 0 -128 -16 ) ( 1 -128 -16 ) ( 0 -127 -16 ) placeholder -32 0 0 1 1
|
||||
( 64 -96 0 ) ( 64 -95 0 ) ( 65 -96 0 ) placeholder -32 0 0 1 1
|
||||
( 64 -96 0 ) ( 65 -96 0 ) ( 64 -96 1 ) placeholder -32 0 0 1 1
|
||||
( 64 -96 0 ) ( 64 -96 1 ) ( 64 -95 0 ) placeholder 0 0 0 1 1
|
||||
}
|
||||
// brush 2
|
||||
{
|
||||
( 64 -144 -32 ) ( 64 -143 -32 ) ( 64 -144 -31 ) placeholder -16 -16 0 1 1
|
||||
( 64 -144 -32 ) ( 64 -144 -31 ) ( 65 -144 -32 ) placeholder -32 -16 0 1 1
|
||||
( 64 -144 -32 ) ( 65 -144 -32 ) ( 64 -143 -32 ) placeholder -32 16 0 1 1
|
||||
( 192 -80 -16 ) ( 192 -79 -16 ) ( 193 -80 -16 ) placeholder -32 16 0 1 1
|
||||
( 192 -80 -16 ) ( 193 -80 -16 ) ( 192 -80 -15 ) placeholder -32 -16 0 1 1
|
||||
( 192 -80 -16 ) ( 192 -80 -15 ) ( 192 -79 -16 ) placeholder -16 -16 0 1 1
|
||||
}
|
||||
// brush 3
|
||||
{
|
||||
( 80 16 32 ) ( 80 15 32 ) ( 80 16 31 ) placeholder 0 -16 180 1 1
|
||||
( 144 -96 16 ) ( 145 -96 16 ) ( 144 -96 15 ) placeholder 16 -16 0 1 -1
|
||||
( 144 -96 16 ) ( 144 -97 16 ) ( 145 -96 16 ) placeholder 16 0 0 1 -1
|
||||
( 80 16 32 ) ( 81 16 32 ) ( 80 15 32 ) placeholder 16 0 0 1 -1
|
||||
( 80 16 32 ) ( 80 16 31 ) ( 81 16 32 ) placeholder 16 -16 0 1 -1
|
||||
( 144 -96 16 ) ( 144 -96 15 ) ( 144 -97 16 ) placeholder 0 -16 180 1 1
|
||||
}
|
||||
// brush 4
|
||||
{
|
||||
( 224 -48 -80 ) ( 224 16 -80 ) ( 224 -96 -56 ) __TB_empty -128 -60 0 1 2
|
||||
( 224 -96 -56 ) ( 288 -96 -80 ) ( 224 -48 -80 ) __TB_empty -32 8 0 1 -2
|
||||
( 224 16 -80 ) ( 272 -32 -56 ) ( 224 -96 -56 ) __TB_empty -134.26993 -44.949593 0 1 2
|
||||
( 272 -32 -56 ) ( 288 -96 -40 ) ( 224 -96 -56 ) __TB_empty -32 112 0 1 1
|
||||
( 224 -96 -56 ) ( 288 -96 -40 ) ( 288 -96 -80 ) __TB_empty -32 -16.941177 0 1 -2
|
||||
( 288 -96 -80 ) ( 288 16 -80 ) ( 224 16 -80 ) __TB_empty -32 144 0 1 1
|
||||
( 272 -32 -56 ) ( 304 -32 -56 ) ( 288 -96 -40 ) __TB_empty -32 112 0 1 1
|
||||
( 288 16 -80 ) ( 304 -32 -56 ) ( 272 -32 -56 ) __TB_empty -32 -24 0 1 -2
|
||||
( 288 -96 -80 ) ( 304 -32 -56 ) ( 288 16 -80 ) __TB_empty 144 -52 0 1 2
|
||||
( 288 -96 -40 ) ( 304 -32 -56 ) ( 288 -96 -80 ) __TB_empty 118.95169 -69.728745 0 1 2
|
||||
}
|
||||
// brush 5
|
||||
{
|
||||
( -144 -560 -80 ) ( -144 -559 -80 ) ( -144 -560 -79 ) placeholder -80 96 0 0.2 0.2
|
||||
( -144 -320 -80 ) ( -144 -320 -79 ) ( -143 -320 -80 ) placeholder -32 96 0 0.2 0.2
|
||||
( -144 -560 -80 ) ( -143 -560 -80 ) ( -144 -559 -80 ) placeholder -32 80 0 0.2 0.2
|
||||
( -16 -432 16 ) ( -16 -431 16 ) ( -15 -432 16 ) placeholder -32 80 0 0.2 0.2
|
||||
( -16 -304 -48 ) ( -15 -304 -48 ) ( -16 -304 -47 ) placeholder -32 96 0 0.2 0.2
|
||||
( 304 -432 -48 ) ( 304 -432 -47 ) ( 304 -431 -48 ) placeholder -80 96 0 0.2 0.2
|
||||
}
|
||||
// brush 6
|
||||
{
|
||||
( -160 -240 -16 ) ( -160 -241 -16 ) ( -160 -240 -17 ) placeholder -240 96 180 1 1
|
||||
( -64 -304 -32 ) ( -63 -304 -32 ) ( -64 -304 -33 ) placeholder 208 96 0 1 -1
|
||||
( -64 -352 -80 ) ( -64 -353 -80 ) ( -63 -352 -80 ) placeholder 208 240 0 1 -1
|
||||
( -160 -240 16 ) ( -159 -240 16 ) ( -160 -241 16 ) placeholder 208 240 0 1 -1
|
||||
( -160 192 -16 ) ( -160 192 -17 ) ( -159 192 -16 ) placeholder 208 96 0 1 -1
|
||||
( -144 -352 -32 ) ( -144 -352 -33 ) ( -144 -353 -32 ) placeholder -240 96 180 1 1
|
||||
}
|
||||
// brush 7
|
||||
{
|
||||
( 162.74516600406096 -112 -80 ) ( 163.4522727852475 -111.29289321881345 -80 ) ( 162.74516600406096 -112 -79 ) placeholder 190.39192 0 0 0.70710677 1
|
||||
( 162.74516600406096 -112 -80 ) ( 162.74516600406096 -112 -79 ) ( 163.45227278524752 -112.70710678118652 -80 ) placeholder -38.156433 0 0 0.70710677 1
|
||||
( 162.74516600406096 -112 -80 ) ( 163.45227278524752 -112.70710678118652 -80 ) ( 163.4522727852475 -111.29289321881345 -80 ) placeholder -2.27417 3.882248 315 1 1
|
||||
( 253.25483399593907 -112 -48 ) ( 253.96194077712562 -111.29289321881353 -48 ) ( 253.9619407771256 -112.70710678118664 -48 ) placeholder -2.27417 3.882248 315 1 1
|
||||
( 253.25483399593907 -112 -64 ) ( 253.25483399593907 -112 -63 ) ( 253.96194077712562 -111.29289321881353 -64 ) placeholder -6.156433 0 0 0.70710677 1
|
||||
( 253.25483399593907 -112 -64 ) ( 253.9619407771256 -112.70710678118664 -64 ) ( 253.25483399593907 -112 -63 ) placeholder 97.60808 0 180 0.70710677 -1
|
||||
}
|
||||
// brush 8
|
||||
{
|
||||
( -32 96 -80 ) ( -32 97 -80 ) ( -32 96 -79 ) placeholder 0 0 0 1 1
|
||||
( 96 272 -64 ) ( 97 272.625 -64 ) ( 96 272 -63 ) placeholder 0 0 0 1 1
|
||||
( -32 96 -80 ) ( -31 96.625 -80 ) ( -32 97 -80 ) placeholder -73.70788 15.668304 32.00539 1.1792476 0.87100387
|
||||
( 96 272 -32 ) ( 96 273 -32 ) ( 97 272.625 -32 ) placeholder -73.70788 15.668304 32.00539 1.1792476 0.87100387
|
||||
( -32 96 -80 ) ( -32 96 -79 ) ( -31 96.625 -80 ) placeholder 0 0 0 1 1
|
||||
( 96 272 -64 ) ( 96 272 -63 ) ( 96 273 -64 ) placeholder -80 0 0 1 1
|
||||
}
|
||||
// brush 9
|
||||
{
|
||||
( -64 -672 -96 ) ( -64 -720 -80 ) ( -64 -720 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
( -64 -672 -96 ) ( -16 -672 -80 ) ( -64 -720 -80 ) placeholder 80 224 0 0.2 0.2
|
||||
( -64 -720 -80 ) ( -16 -720 -80 ) ( -16 -720 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -720 -112 ) ( -16 -672 -112 ) ( -64 -672 -112 ) placeholder 80 224 0 0.2 0.2
|
||||
( -64 -720 -80 ) ( -16 -672 -80 ) ( -16 -720 -80 ) placeholder 80 224 0 0.2 0.2
|
||||
( -16 -672 -112 ) ( -16 -672 -80 ) ( -64 -672 -96 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -720 -80 ) ( -16 -672 -80 ) ( -16 -672 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 10
|
||||
{
|
||||
( -16 -672 -80 ) ( -16 -720 -80 ) ( -16 -720 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
( -16 -672 -80 ) ( 32 -672 -48 ) ( -16 -720 -80 ) placeholder -160 224 0 0.2 0.2
|
||||
( -16 -720 -80 ) ( 32 -720 -80 ) ( 32 -720 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -720 -80 ) ( 32 -672 -48 ) ( 32 -720 -80 ) placeholder -160 224 0 0.2 0.2
|
||||
( 32 -720 -112 ) ( 32 -672 -112 ) ( -16 -672 -112 ) placeholder -160 224 0 0.2 0.2
|
||||
( 32 -672 -112 ) ( 32 -672 -48 ) ( -16 -672 -80 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -720 -80 ) ( 32 -672 -48 ) ( 32 -672 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 11
|
||||
{
|
||||
( 32 -672 -48 ) ( 32 -720 -80 ) ( 32 -720 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
( 32 -720 -80 ) ( 80 -720 -80 ) ( 80 -720 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 80 -720 -80 ) ( 32 -720 -80 ) placeholder -144 224 0 0.2 0.2
|
||||
( 80 -720 -112 ) ( 80 -672 -112 ) ( 32 -672 -112 ) placeholder -144 224 0 0.2 0.2
|
||||
( 80 -672 -112 ) ( 80 -672 -80 ) ( 32 -672 -48 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 80 -672 -80 ) ( 80 -720 -80 ) placeholder -144 224 0 0.2 0.2
|
||||
( 80 -720 -80 ) ( 80 -672 -80 ) ( 80 -672 -112 ) placeholder -224 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 12
|
||||
{
|
||||
( -112 -624 -80 ) ( -112 -672 -80 ) ( -112 -672 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
( -112 -672 -80 ) ( -64 -672 -96 ) ( -64 -672 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -672 -112 ) ( -64 -624 -112 ) ( -112 -624 -112 ) placeholder 64 208 0 0.2 0.2
|
||||
( -112 -624 -80 ) ( -64 -624 -80 ) ( -112 -672 -80 ) placeholder 64 208 0 0.2 0.2
|
||||
( -64 -624 -112 ) ( -64 -624 -80 ) ( -112 -624 -80 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -112 -672 -80 ) ( -64 -624 -80 ) ( -64 -672 -96 ) placeholder 64 208 0 0.2 0.2
|
||||
( -64 -672 -96 ) ( -64 -624 -80 ) ( -64 -624 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 13
|
||||
{
|
||||
( -112 -384 -112 ) ( -112 -383 -112 ) ( -112 -384 -111 ) placeholder -192 -64 0 0.2 0.2
|
||||
( -112 -624 -112 ) ( -112 -624 -111 ) ( -111 -624 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -112 -384 -112 ) ( -111 -384 -112 ) ( -112 -383 -112 ) placeholder 64 192 0 0.2 0.2
|
||||
( 16 -256 -80 ) ( 16 -255 -80 ) ( 17 -256 -80 ) placeholder 64 192 0 0.2 0.2
|
||||
( 16 -576 -80 ) ( 17 -576 -80 ) ( 16 -576 -79 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -256 -80 ) ( -64 -256 -79 ) ( -64 -255 -80 ) placeholder -192 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 14
|
||||
{
|
||||
( -64 -624 -80 ) ( -64 -672 -96 ) ( -64 -672 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
( -64 -624 -80 ) ( -16 -672 -80 ) ( -64 -672 -96 ) placeholder 80 208 0 0.2 0.2
|
||||
( -64 -672 -96 ) ( -16 -672 -80 ) ( -16 -672 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -672 -112 ) ( -16 -624 -112 ) ( -64 -624 -112 ) placeholder 80 208 0 0.2 0.2
|
||||
( -64 -624 -80 ) ( -16 -624 -80 ) ( -16 -672 -80 ) placeholder 80 208 0 0.2 0.2
|
||||
( -16 -624 -112 ) ( -16 -624 -80 ) ( -64 -624 -80 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -672 -80 ) ( -16 -624 -80 ) ( -16 -624 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 15
|
||||
{
|
||||
( -112 -528 -80 ) ( -112 -576 -80 ) ( -112 -576 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
( -112 -528 -80 ) ( -64 -528 -48 ) ( -112 -576 -80 ) placeholder 64 176 0 0.2 0.2
|
||||
( -112 -576 -80 ) ( -64 -576 -80 ) ( -64 -576 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -112 -576 -80 ) ( -64 -528 -48 ) ( -64 -576 -80 ) placeholder 64 176 0 0.2 0.2
|
||||
( -64 -576 -112 ) ( -64 -528 -112 ) ( -112 -528 -112 ) placeholder 64 176 0 0.2 0.2
|
||||
( -64 -528 -112 ) ( -64 -528 -48 ) ( -112 -528 -80 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -576 -80 ) ( -64 -528 -48 ) ( -64 -528 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 16
|
||||
{
|
||||
( -64 -384 -112 ) ( -64 -383 -112 ) ( -64 -384 -111 ) placeholder -192 -64 0 0.2 0.2
|
||||
( -64 -624 -112 ) ( -64 -624 -111 ) ( -63 -624 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -64 -384 -112 ) ( -63 -384 -112 ) ( -64 -383 -112 ) placeholder 80 192 0 0.2 0.2
|
||||
( 64 -256 -80 ) ( 64 -255 -80 ) ( 65 -256 -80 ) placeholder 80 192 0 0.2 0.2
|
||||
( 64 -576 -80 ) ( 65 -576 -80 ) ( 64 -576 -79 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -256 -80 ) ( -16 -256 -79 ) ( -16 -255 -80 ) placeholder -192 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 17
|
||||
{
|
||||
( -16 -624 -80 ) ( -16 -672 -80 ) ( -16 -672 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
( -16 -624 -80 ) ( 32 -672 -48 ) ( -16 -672 -80 ) placeholder -160 208 0 0.2 0.2
|
||||
( -16 -672 -80 ) ( 32 -672 -48 ) ( 32 -672 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -672 -112 ) ( 32 -624 -112 ) ( -16 -624 -112 ) placeholder -160 208 0 0.2 0.2
|
||||
( -16 -624 -80 ) ( 32 -624 -80 ) ( 32 -672 -48 ) placeholder -160 208 0 0.2 0.2
|
||||
( 32 -624 -112 ) ( 32 -624 -80 ) ( -16 -624 -80 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 32 -624 -80 ) ( 32 -624 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 18
|
||||
{
|
||||
( -112 -480 -80 ) ( -112 -528 -80 ) ( -112 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -112 -480 -80 ) ( -64 -528 -48 ) ( -112 -528 -80 ) placeholder 64 160 0 0.2 0.2
|
||||
( -112 -528 -80 ) ( -64 -528 -48 ) ( -64 -528 -112 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -528 -112 ) ( -64 -480 -112 ) ( -112 -480 -112 ) placeholder 64 160 0 0.2 0.2
|
||||
( -112 -480 -80 ) ( -64 -480 -80 ) ( -64 -528 -48 ) placeholder 64 160 0 0.2 0.2
|
||||
( -64 -480 -112 ) ( -64 -480 -80 ) ( -112 -480 -80 ) placeholder 64 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -64 -480 -80 ) ( -64 -480 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 19
|
||||
{
|
||||
( -64 -528 -48 ) ( -64 -576 -80 ) ( -64 -576 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
( -64 -576 -80 ) ( -16 -576 -80 ) ( -16 -576 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -16 -576 -80 ) ( -64 -576 -80 ) placeholder 80 176 0 0.2 0.2
|
||||
( -16 -576 -112 ) ( -16 -528 -112 ) ( -64 -528 -112 ) placeholder 80 176 0 0.2 0.2
|
||||
( -16 -528 -112 ) ( -16 -528 -80 ) ( -64 -528 -48 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -16 -528 -80 ) ( -16 -576 -80 ) placeholder 80 176 0 0.2 0.2
|
||||
( -16 -576 -80 ) ( -16 -528 -80 ) ( -16 -528 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 20
|
||||
{
|
||||
( -16 -384 -112 ) ( -16 -383 -112 ) ( -16 -384 -111 ) placeholder -192 -64 0 0.2 0.2
|
||||
( -16 -624 -112 ) ( -16 -624 -111 ) ( -15 -624 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -384 -112 ) ( -15 -384 -112 ) ( -16 -383 -112 ) placeholder -160 192 0 0.2 0.2
|
||||
( 112 -256 -80 ) ( 112 -255 -80 ) ( 113 -256 -80 ) placeholder -160 192 0 0.2 0.2
|
||||
( 112 -576 -80 ) ( 113 -576 -80 ) ( 112 -576 -79 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -256 -80 ) ( 32 -256 -79 ) ( 32 -255 -80 ) placeholder -192 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 21
|
||||
{
|
||||
( 32 -624 -80 ) ( 32 -672 -48 ) ( 32 -672 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 80 -672 -80 ) ( 80 -672 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -672 -112 ) ( 80 -624 -112 ) ( 32 -624 -112 ) placeholder -144 208 0 0.2 0.2
|
||||
( 32 -624 -80 ) ( 80 -624 -80 ) ( 32 -672 -48 ) placeholder -144 208 0 0.2 0.2
|
||||
( 80 -624 -112 ) ( 80 -624 -80 ) ( 32 -624 -80 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 32 -672 -48 ) ( 80 -624 -80 ) ( 80 -672 -80 ) placeholder -144 208 0 0.2 0.2
|
||||
( 80 -672 -80 ) ( 80 -624 -80 ) ( 80 -624 -112 ) placeholder -208 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 22
|
||||
{
|
||||
( -64 -480 -80 ) ( -64 -528 -48 ) ( -64 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -16 -528 -80 ) ( -16 -528 -112 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -16 -528 -112 ) ( -16 -480 -112 ) ( -64 -480 -112 ) placeholder 80 160 0 0.2 0.2
|
||||
( -64 -480 -80 ) ( -16 -480 -80 ) ( -64 -528 -48 ) placeholder 80 160 0 0.2 0.2
|
||||
( -16 -480 -112 ) ( -16 -480 -80 ) ( -64 -480 -80 ) placeholder 80 -64 0 0.2 0.2
|
||||
( -64 -528 -48 ) ( -16 -480 -80 ) ( -16 -528 -80 ) placeholder 80 160 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( -16 -480 -80 ) ( -16 -480 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 23
|
||||
{
|
||||
( -16 -528 -80 ) ( -16 -576 -80 ) ( -16 -576 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
( -16 -576 -80 ) ( 32 -576 -80 ) ( 32 -576 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -576 -112 ) ( 32 -528 -112 ) ( -16 -528 -112 ) placeholder -160 176 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( 32 -576 -80 ) ( -16 -576 -80 ) placeholder -160 176 0 0.2 0.2
|
||||
( 32 -528 -112 ) ( 32 -528 -96 ) ( -16 -528 -80 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( 32 -528 -96 ) ( 32 -576 -80 ) placeholder -160 176 0 0.2 0.2
|
||||
( 32 -576 -80 ) ( 32 -528 -96 ) ( 32 -528 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 24
|
||||
{
|
||||
( 32 -384 -112 ) ( 32 -383 -112 ) ( 32 -384 -111 ) placeholder -192 -64 0 0.2 0.2
|
||||
( 32 -624 -112 ) ( 32 -624 -111 ) ( 33 -624 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 32 -384 -112 ) ( 33 -384 -112 ) ( 32 -383 -112 ) placeholder -144 192 0 0.2 0.2
|
||||
( 160 -256 -80 ) ( 160 -255 -80 ) ( 161 -256 -80 ) placeholder -144 192 0 0.2 0.2
|
||||
( 160 -576 -80 ) ( 161 -576 -80 ) ( 160 -576 -79 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -256 -80 ) ( 80 -256 -79 ) ( 80 -255 -80 ) placeholder -192 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 25
|
||||
{
|
||||
( -16 -480 -80 ) ( -16 -528 -80 ) ( -16 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( 32 -528 -96 ) ( 32 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -528 -112 ) ( 32 -480 -112 ) ( -16 -480 -112 ) placeholder -160 160 0 0.2 0.2
|
||||
( -16 -480 -80 ) ( 32 -480 -80 ) ( -16 -528 -80 ) placeholder -160 160 0 0.2 0.2
|
||||
( 32 -480 -112 ) ( 32 -480 -80 ) ( -16 -480 -80 ) placeholder -160 -64 0 0.2 0.2
|
||||
( -16 -528 -80 ) ( 32 -480 -80 ) ( 32 -528 -96 ) placeholder -160 160 0 0.2 0.2
|
||||
( 32 -528 -96 ) ( 32 -480 -80 ) ( 32 -480 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 26
|
||||
{
|
||||
( 32 -528 -96 ) ( 32 -576 -80 ) ( 32 -576 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
( 32 -528 -96 ) ( 80 -528 -80 ) ( 32 -576 -80 ) placeholder -144 176 0 0.2 0.2
|
||||
( 32 -576 -80 ) ( 80 -576 -80 ) ( 80 -576 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -576 -112 ) ( 80 -528 -112 ) ( 32 -528 -112 ) placeholder -144 176 0 0.2 0.2
|
||||
( 32 -576 -80 ) ( 80 -528 -80 ) ( 80 -576 -80 ) placeholder -144 176 0 0.2 0.2
|
||||
( 80 -528 -112 ) ( 80 -528 -80 ) ( 32 -528 -96 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -576 -80 ) ( 80 -528 -80 ) ( 80 -528 -112 ) placeholder -176 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 27
|
||||
{
|
||||
( 32 -480 -80 ) ( 32 -528 -96 ) ( 32 -528 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
( 32 -480 -80 ) ( 80 -528 -80 ) ( 32 -528 -96 ) placeholder -144 160 0 0.2 0.2
|
||||
( 32 -528 -96 ) ( 80 -528 -80 ) ( 80 -528 -112 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -528 -112 ) ( 80 -480 -112 ) ( 32 -480 -112 ) placeholder -144 160 0 0.2 0.2
|
||||
( 32 -480 -80 ) ( 80 -480 -80 ) ( 80 -528 -80 ) placeholder -144 160 0 0.2 0.2
|
||||
( 80 -480 -112 ) ( 80 -480 -80 ) ( 32 -480 -80 ) placeholder -144 -64 0 0.2 0.2
|
||||
( 80 -528 -80 ) ( 80 -480 -80 ) ( 80 -480 -112 ) placeholder -160 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 28
|
||||
{
|
||||
( 224 256 112 ) ( 224 257 112 ) ( 224 256 113 ) placeholder 170.66669 8 0 -0.375 0.4
|
||||
( 224 256 112 ) ( 224 256 113 ) ( 225 256 112 ) placeholder 224 -256 0 0.4 0.4
|
||||
( 224 256 112 ) ( 225 256 112 ) ( 224 257 112 ) placeholder 47.999992 138.99998 0 -0.4 0.4
|
||||
( 320 336 208 ) ( 320 337 208 ) ( 321 336 208 ) placeholder 208 112 0 0.4 0.4
|
||||
( 320 352 128 ) ( 321 352 128 ) ( 320 352 129 ) placeholder 48 -256 0 -0.4 0.4
|
||||
( 320 336 128 ) ( 320 336 129 ) ( 320 337 128 ) placeholder 128 -256 0 0.4 0.4
|
||||
}
|
||||
}
|
||||
// entity 1
|
||||
{
|
||||
"classname" "info_player_start"
|
||||
"origin" "112 -48 56"
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
// Game: Generic
|
||||
// Format: Standard
|
||||
// entity 0
|
||||
{
|
||||
"classname" "worldspawn"
|
||||
"wad" ""
|
||||
// brush 0
|
||||
{
|
||||
( -144 -64 -112 ) ( -144 -63 -112 ) ( -144 -64 -111 ) placeholder 0 -64 0 0.2 0.2
|
||||
( -144 -304 -112 ) ( -144 -304 -111 ) ( -143 -304 -112 ) placeholder 224 -64 0 0.2 0.2
|
||||
( -144 -64 -112 ) ( -143 -64 -112 ) ( -144 -63 -112 ) placeholder 224 0 0 0.2 0.2
|
||||
( -16 64 -80 ) ( -16 65 -80 ) ( -15 64 -80 ) placeholder 224 0 0 0.2 0.2
|
||||
( -16 192 -80 ) ( -15 192 -80 ) ( -16 192 -79 ) placeholder 224 -64 0 0.2 0.2
|
||||
( 304 64 -80 ) ( 304 64 -79 ) ( 304 65 -80 ) placeholder 0 -64 0 0.2 0.2
|
||||
}
|
||||
// brush 1
|
||||
{
|
||||
( 0 -128 -16 ) ( 0 -127 -16 ) ( 0 -128 -15 ) placeholder 0 0 0 1 1
|
||||
( 0 -128 -16 ) ( 0 -128 -15 ) ( 1 -128 -16 ) placeholder -32 0 0 1 1
|
||||
( 0 -128 -16 ) ( 1 -128 -16 ) ( 0 -127 -16 ) placeholder -32 0 0 1 1
|
||||
( 64 -96 0 ) ( 64 -95 0 ) ( 65 -96 0 ) placeholder -32 0 0 1 1
|
||||
( 64 -96 0 ) ( 65 -96 0 ) ( 64 -96 1 ) placeholder -32 0 0 1 1
|
||||
( 64 -96 0 ) ( 64 -96 1 ) ( 64 -95 0 ) placeholder 0 0 0 1 1
|
||||
}
|
||||
// brush 2
|
||||
{
|
||||
( 64 -144 -32 ) ( 64 -143 -32 ) ( 64 -144 -31 ) placeholder -16 -16 0 1 1
|
||||
( 64 -144 -32 ) ( 64 -144 -31 ) ( 65 -144 -32 ) placeholder -32 -16 0 1 1
|
||||
( 64 -144 -32 ) ( 65 -144 -32 ) ( 64 -143 -32 ) placeholder -32 16 0 1 1
|
||||
( 192 -80 -16 ) ( 192 -79 -16 ) ( 193 -80 -16 ) placeholder -32 16 0 1 1
|
||||
( 192 -80 -16 ) ( 193 -80 -16 ) ( 192 -80 -15 ) placeholder -32 -16 0 1 1
|
||||
( 192 -80 -16 ) ( 192 -80 -15 ) ( 192 -79 -16 ) placeholder -16 -16 0 1 1
|
||||
}
|
||||
// brush 3
|
||||
{
|
||||
( 80 16 32 ) ( 80 15 32 ) ( 80 16 31 ) placeholder 0 -16 180 1 1
|
||||
( 144 -96 16 ) ( 145 -96 16 ) ( 144 -96 15 ) placeholder 16 -16 0 1 -1
|
||||
( 144 -96 16 ) ( 144 -97 16 ) ( 145 -96 16 ) placeholder 16 0 0 1 -1
|
||||
( 80 16 32 ) ( 81 16 32 ) ( 80 15 32 ) placeholder 16 0 0 1 -1
|
||||
( 80 16 32 ) ( 80 16 31 ) ( 81 16 32 ) placeholder 16 -16 0 1 -1
|
||||
( 144 -96 16 ) ( 144 -96 15 ) ( 144 -97 16 ) placeholder 0 -16 180 1 1
|
||||
}
|
||||
// brush 4
|
||||
{
|
||||
( 224 -48 -80 ) ( 224 -47 -80 ) ( 224 -48 -79 ) placeholder -144 -96 0 1 1
|
||||
( 224 -48 -80 ) ( 224 -48 -79 ) ( 225 -48 -80 ) placeholder -32 -96 0 1 1
|
||||
( 224 -48 -80 ) ( 225 -48 -80 ) ( 224 -47 -80 ) placeholder -32 144 0 1 1
|
||||
( 288 16 -64 ) ( 288 17 -64 ) ( 289 16 -64 ) placeholder -32 144 0 1 1
|
||||
( 288 16 -64 ) ( 289 16 -64 ) ( 288 16 -63 ) placeholder -32 -96 0 1 1
|
||||
( 288 16 -64 ) ( 288 16 -63 ) ( 288 17 -64 ) placeholder -144 -96 0 1 1
|
||||
}
|
||||
// brush 5
|
||||
{
|
||||
( -144 -560 -80 ) ( -144 -559 -80 ) ( -144 -560 -79 ) placeholder -80 96 0 0.2 0.2
|
||||
( -144 -320 -80 ) ( -144 -320 -79 ) ( -143 -320 -80 ) placeholder -32 96 0 0.2 0.2
|
||||
( -144 -560 -80 ) ( -143 -560 -80 ) ( -144 -559 -80 ) placeholder -32 80 0 0.2 0.2
|
||||
( -16 -432 16 ) ( -16 -431 16 ) ( -15 -432 16 ) placeholder -32 80 0 0.2 0.2
|
||||
( -16 -304 -48 ) ( -15 -304 -48 ) ( -16 -304 -47 ) placeholder -32 96 0 0.2 0.2
|
||||
( 304 -432 -48 ) ( 304 -432 -47 ) ( 304 -431 -48 ) placeholder -80 96 0 0.2 0.2
|
||||
}
|
||||
// brush 6
|
||||
{
|
||||
( -160 -240 -16 ) ( -160 -241 -16 ) ( -160 -240 -17 ) placeholder -240 96 180 1 1
|
||||
( -64 -304 -32 ) ( -63 -304 -32 ) ( -64 -304 -33 ) placeholder 208 96 0 1 -1
|
||||
( -64 -352 -80 ) ( -64 -353 -80 ) ( -63 -352 -80 ) placeholder 208 240 0 1 -1
|
||||
( -160 -240 16 ) ( -159 -240 16 ) ( -160 -241 16 ) placeholder 208 240 0 1 -1
|
||||
( -160 192 -16 ) ( -160 192 -17 ) ( -159 192 -16 ) placeholder 208 96 0 1 -1
|
||||
( -144 -352 -32 ) ( -144 -352 -33 ) ( -144 -353 -32 ) placeholder -240 96 180 1 1
|
||||
}
|
||||
// brush 7
|
||||
{
|
||||
( 176 -144 -80 ) ( 176 -143 -80 ) ( 176 -144 -79 ) placeholder 176 0 0 1 1
|
||||
( 176 -144 -80 ) ( 176 -144 -79 ) ( 177 -144 -80 ) placeholder 16 0 0 1 1
|
||||
( 176 -144 -80 ) ( 177 -144 -80 ) ( 176 -143 -80 ) placeholder 16 -176 0 1 1
|
||||
( 240 -80 -48 ) ( 240 -79 -48 ) ( 241 -80 -48 ) placeholder 16 -176 0 1 1
|
||||
( 240 -80 -64 ) ( 241 -80 -64 ) ( 240 -80 -63 ) placeholder 16 0 0 1 1
|
||||
( 240 -80 -64 ) ( 240 -80 -63 ) ( 240 -79 -64 ) placeholder 176 0 0 1 1
|
||||
}
|
||||
}
|
||||
// entity 1
|
||||
{
|
||||
"classname" "info_player_start"
|
||||
"origin" "112 -48 56"
|
||||
}
|
||||
@@ -8,45 +8,22 @@
|
||||
# set <name> <value> KV setzen (true/false/i32/f32/string)
|
||||
# inc <name> [<delta>] KV-Integer +Delta (Default +1)
|
||||
# clear <name> KV-Eintrag entfernen
|
||||
# hide_object <name> deferred (Frontend): Instance ausblenden
|
||||
# play_sound <file> deferred (Frontend): SFX abspielen
|
||||
# play_sound <name> deferred (Frontend): SFX aus assets/sounds/{name}.wav
|
||||
# mode <play|free|menu> deferred (Frontend): Anzeige-/Eingabemodus
|
||||
# post <name> <on|off> deferred (Frontend): Renderer-Post-Effekt schalten
|
||||
# scene <name> [<spawn>] in die Szene assets/maps/<name>/ wechseln,
|
||||
# optional an den Spawn-Empty <spawn>
|
||||
#
|
||||
# Reserviertes Signal `[init]` feuert einmal vor der Game-Loop —
|
||||
# idealer Ort für KV-Defaults.
|
||||
# Reserviertes Signal `[init]` feuert bei „Neues Spiel" (nach dem Leeren des
|
||||
# KV) — Ort für KV-Defaults und die Startszene. Das Hauptmenü selbst ist die
|
||||
# Szene assets/maps/title/.
|
||||
|
||||
[init]
|
||||
actions = [
|
||||
"set cube_clicks 0",
|
||||
"set mushrooms_collected 0",
|
||||
"set quest_mushroom_active false",
|
||||
"set quest_mushroom_done false",
|
||||
"scene props",
|
||||
]
|
||||
|
||||
[Mushroom]
|
||||
[tiffany]
|
||||
actions = [
|
||||
"inc mushrooms_collected",
|
||||
"play_sound pickup.wav",
|
||||
"hide_object $self",
|
||||
]
|
||||
|
||||
[Person]
|
||||
actions = [
|
||||
"play_sound greet.wav",
|
||||
"start_ink person.ink.json",
|
||||
]
|
||||
|
||||
[Suzanne]
|
||||
actions = [
|
||||
"start_ink suzanne.ink.json",
|
||||
]
|
||||
|
||||
[Cube]
|
||||
actions = [
|
||||
"inc cube_clicks",
|
||||
"start_ink cube.ink.json",
|
||||
]
|
||||
|
||||
[person_farewell]
|
||||
actions = [
|
||||
"debug_log Person hat sich verabschiedet",
|
||||
"start_ink cinema.ink.json",
|
||||
]
|
||||
|
||||
|
After Width: | Height: | Size: 192 KiB |
|
After Width: | Height: | Size: 256 KiB |
|
After Width: | Height: | Size: 256 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 112 KiB |
|
After Width: | Height: | Size: 100 KiB |
|
Before Width: | Height: | Size: 256 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 347 B |
|
Before Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 427 B |
|
Before Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,78 @@
|
||||
Alles Inhaltliche kommt aus vier Quellen:
|
||||
**Blender** (Welt),
|
||||
**Ink** (Dialoge/Story),
|
||||
**signals.toml** (Verdrahtung),
|
||||
**Assets-Ordner** (Texturen/Sounds). Fehler in Inhalten stürzen nie ab — sie werden beim
|
||||
|
||||
Start in der Konsole gemeldet (`[model]`, `[audio]`, `[tex]`, …).
|
||||
|
||||
## 3D / Blender
|
||||
|
||||
- **Format:** glTF Binary (`.glb`) nach `assets/maps/props/` — alle Dateien
|
||||
dort werden beim Start geladen.
|
||||
- **Beim Export anhaken:** „Include → Custom Properties" (sonst fehlen die
|
||||
Properties unten) **und** „Include → Textures" (sonst fehlen die Texturen).
|
||||
- **Maßstab:** 1 Blender-Meter = 1 Engine-Meter. Augenhöhe 1,6 m,
|
||||
Türen/Durchgänge ≥ 2 m hoch und ≥ 0,8 m breit denken.
|
||||
- **Texturen:** Bild im Material als Base Color zuweisen — wird beim Export
|
||||
in die `.glb` eingebettet (PNG), kein `assets/textures/` mehr. Fehlt das
|
||||
Bild, erscheint die Platzhalter-Textur. Kacheln/Skalieren über einen
|
||||
Mapping-Node (`KHR_texture_transform` wird beim Laden in die UVs gebacken).
|
||||
|
||||
### Custom Properties auf Mesh-Objekten
|
||||
|
||||
| Property | Wirkung |
|
||||
|---|---|
|
||||
| *(keine)* | nur sichtbar, kein Anfassen |
|
||||
| `collide = 1` | sichtbar **und** solide (Spieler kollidiert mit der konvexen Hülle des Meshes — Dellen/Löcher werden überspannt) |
|
||||
| `collide = proxy` | unsichtbares Kollisionsvolumen (für Fein-Collider neben Sichtgeometrie) |
|
||||
| `signal = <name>` **mit** collide | Klick-Ziel: Anklicken feuert das Signal `<name>` |
|
||||
| `signal = <name>` **ohne** collide | unsichtbare Trigger-Zone: Betreten feuert `<name>` einmal (erneut erst nach Verlassen; „nur einmal überhaupt" selbst per KV-Flag bauen) |
|
||||
|
||||
- `collide = 0` schaltet ab, ohne die Property zu löschen.
|
||||
- Objektname ist der Interact-Key: Blender-Suffixe (`Ding.001`) werden beim
|
||||
Signal-Lookup automatisch gestrippt — `[Ding]` in signals.toml trifft alle.
|
||||
|
||||
### Custom Properties auf Empties
|
||||
|
||||
| Property | Wirkung |
|
||||
|---|---|
|
||||
| `role = spawn` | Spieler-Startpunkt (Fußpunkt = Empty-Position) |
|
||||
| `sound = <name>` | Ambient-Loop `assets/sounds/<name>.wav` an dieser Position |
|
||||
| `radius = <m>` | Hörradius des Sounds (linear leiser bis Stille; Default 8) |
|
||||
|
||||
## Audio
|
||||
|
||||
- **Format:** WAV, **mono, 16 bit, 44100 Hz** — nichts anderes. Ablage in
|
||||
`assets/sounds/`, angesprochen ohne Endung (`pickup` → `pickup.wav`).
|
||||
- **Ambient:** per Empty (siehe oben), loopt immer — Loop-Punkt sauber schneiden.
|
||||
- **Einmal-SFX:** per Action `play_sound <name>` (aus signals.toml oder Ink-Tag).
|
||||
|
||||
## Dialoge / Ink
|
||||
|
||||
- `.ink` nach `assets/interactions/` — wird beim Build automatisch
|
||||
kompiliert (bei Bedarf von Hand: `./tools/build-dialogues.sh`).
|
||||
- Gestartet per Action `start_ink <datei>.ink.json`.
|
||||
- **Variablen:** alle Ink-`VAR` landen automatisch im Spiel-KV und synchen
|
||||
in beide Richtungen — `_`-Prefix (`VAR _tmp = 0`) bleibt Ink-lokal.
|
||||
- **Tags feuern Actions:** `# set has_key true`, `# play_sound klick`,
|
||||
`# mode play` … (gleiche Verben wie signals.toml). Unbekannte Tags sind
|
||||
erlaubt (reine Metadaten).
|
||||
|
||||
## signals.toml (`assets/signals.toml`)
|
||||
|
||||
- Verdrahtet Signal → Aktionen. Signal-Namen: Objektname (Klick), Wert der
|
||||
`signal`-Property (Zonen/Klick-Ziele), oder frei (aus Ink).
|
||||
- Verben: `start_ink`, `set`, `inc`, `clear`, `debug_log`, `play_sound`,
|
||||
`mode play|free|menu`.
|
||||
- `$self` = auslösender Objektname (für generische Einträge wie
|
||||
`set $self true`).
|
||||
- `[init]` feuert einmal beim Start — Ort für KV-Defaults.
|
||||
|
||||
## Testen
|
||||
|
||||
- `cargo run` — Konsole zeigt beim Start, was ankam: Objekte, Dreiecke,
|
||||
Empties und **jede Custom Property**. Fehlt eine → Export-Haken prüfen.
|
||||
- Im Spiel (Konsole = das Terminal, aus dem gestartet wurde): `noclip` zum
|
||||
freien Fliegen, `kv` zeigt alle Variablen, `signal <name>` feuert jedes
|
||||
Signal von Hand, `reload` lädt signals.toml neu.
|
||||
|
After Width: | Height: | Size: 57 KiB |
|
After Width: | Height: | Size: 58 KiB |
@@ -0,0 +1,18 @@
|
||||
# Assets
|
||||
|
||||
## Texturen
|
||||
https://www.manytextures.com/
|
||||
https://opengameart.org/content/arcade-carpet-textures
|
||||
|
||||
|
||||
# Tutorials
|
||||
|
||||
## Blender
|
||||
|
||||
Blender UI Base Setup + Tips
|
||||
https://www.youtube.com/watch?v=sZeGW0otiJI
|
||||
|
||||
Rigging in PS1 Look:
|
||||
https://www.youtube.com/watch?v=puwu9hZmQYI
|
||||
|
||||
|
||||
@@ -8,15 +8,14 @@ use std::io::{self, Write};
|
||||
|
||||
use crate::session::{Mode, Session};
|
||||
|
||||
pub fn run(mut session: Session, signals_path: &str) {
|
||||
pub fn run(mut session: Session, signals_path: &str, boot: &str) {
|
||||
println!("wds-Konsole — {} Signale aus {}. `help` für Befehle.",
|
||||
session.game.signals.len(), signals_path);
|
||||
|
||||
// Reserviertes `[init]`-Signal: KV-Defaults setzen, bevor Stories laufen.
|
||||
for line in session.start() { println!("{line}"); }
|
||||
// Startbefehl (Hauptmenü bzw. `newgame <szene>`, siehe main).
|
||||
for line in session.exec(boot).output { println!("{line}"); }
|
||||
|
||||
loop {
|
||||
let Some(input) = read_line(prompt_for(&session.mode)) else { break };
|
||||
while let Some(input) = read_line(prompt_for(&session.mode)) {
|
||||
let r = session.exec(input.trim());
|
||||
for line in r.output { println!("{line}"); }
|
||||
if r.quit { break; }
|
||||
@@ -28,6 +27,9 @@ fn prompt_for(mode: &Mode) -> &'static str {
|
||||
match mode {
|
||||
Mode::Dialog(d) if !d.choices.is_empty() => " wahl> ",
|
||||
Mode::Dialog(_) => " [Enter] ",
|
||||
Mode::Title => "titel> ",
|
||||
Mode::Menu => "menü> ",
|
||||
Mode::FirstPerson => "spiel> ",
|
||||
Mode::Free => "> ",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,13 +8,11 @@ static BASE: OnceLock<PathBuf> = OnceLock::new();
|
||||
|
||||
fn base() -> &'static PathBuf {
|
||||
BASE.get_or_init(|| {
|
||||
if let Ok(exe) = std::env::current_exe() {
|
||||
if let Some(dir) = exe.parent() {
|
||||
if dir.join("assets").exists() {
|
||||
if let Ok(exe) = std::env::current_exe()
|
||||
&& let Some(dir) = exe.parent()
|
||||
&& dir.join("assets").exists() {
|
||||
return dir.to_path_buf();
|
||||
}
|
||||
}
|
||||
}
|
||||
std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
//! Ambient-Emitter aus Blender-Modellen: Empties mit `sound`-Custom-Property
|
||||
//! sind positionale Dauerschleifen — `sound = <name>` löst zu
|
||||
//! `assets/sounds/{name}.wav` auf (macht der Frontend-Treiber), `radius`
|
||||
//! (Meter, optional) bestimmt die Distance ramp.
|
||||
//!
|
||||
//! Headless wie `trigger`: hier lebt nur die *Logik* — wer sendet wo, und
|
||||
//! wie laut ist das gerade für den Hörer ([`Emitters::gains`], lineare
|
||||
//! Rampe [`distance_gain`]). Gerätezugriff und Mixing sind Sache des
|
||||
//! Frontend-Treibers (render::audio), der die Gains jeden Frame zieht und
|
||||
//! auf seine Voices legt — die Engine ruft nie ins Frontend.
|
||||
//!
|
||||
//! Einmal-SFX laufen nicht hier, sondern über den Signal-Dispatcher
|
||||
//! (`play_sound <name>` → `Action::PlaySound` → `Session::take_sounds`).
|
||||
|
||||
use crate::engine::model::Model;
|
||||
|
||||
/// Custom-Property-Schlüssel, der ein Empty zum Ambient-Emitter macht
|
||||
/// (Wert = Sound-Name). Emitter loopen immer; „an/aus" macht die Autorin
|
||||
/// über Distanz/Radius oder (später) per Signal.
|
||||
pub const SOUND_PROP: &str = "sound";
|
||||
/// Optionaler Hörradius in Metern (Custom Property am selben Empty).
|
||||
pub const RADIUS_PROP: &str = "radius";
|
||||
const DEFAULT_RADIUS: f32 = 8.0;
|
||||
|
||||
pub struct Emitter {
|
||||
pub sound: String,
|
||||
pos: [f32; 3],
|
||||
radius: f32,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Emitters {
|
||||
list: Vec<Emitter>,
|
||||
}
|
||||
|
||||
impl Emitters {
|
||||
pub fn new() -> Self { Self::default() }
|
||||
|
||||
/// Emitter eines Modells übernehmen: alle Empties mit `sound`-Property.
|
||||
pub fn add_model(&mut self, model: &Model) {
|
||||
for e in &model.empties {
|
||||
let Some(sound) = e.props.get(SOUND_PROP) else { continue; };
|
||||
let radius = e.props.get(RADIUS_PROP)
|
||||
.and_then(|r| r.parse::<f32>().ok())
|
||||
.filter(|r| *r > 0.0)
|
||||
.unwrap_or(DEFAULT_RADIUS);
|
||||
self.list.push(Emitter { sound: sound.clone(), pos: e.pos, radius });
|
||||
}
|
||||
}
|
||||
|
||||
/// Die Emitter in fester Reihenfolge (Voice-Zuordnung des Treibers).
|
||||
pub fn list(&self) -> &[Emitter] { &self.list }
|
||||
|
||||
/// Aktueller Gain je Emitter (parallel zu [`Emitters::list`]) für einen
|
||||
/// Hörer bei `listener` — jeden Frame ziehen, auf die Voices legen.
|
||||
pub fn gains(&self, listener: [f32; 3]) -> Vec<f32> {
|
||||
self.list.iter().map(|e| {
|
||||
let d = [
|
||||
e.pos[0] - listener[0],
|
||||
e.pos[1] - listener[1],
|
||||
e.pos[2] - listener[2],
|
||||
];
|
||||
let dist = (d[0] * d[0] + d[1] * d[1] + d[2] * d[2]).sqrt();
|
||||
distance_gain(dist, e.radius)
|
||||
}).collect()
|
||||
}
|
||||
}
|
||||
|
||||
/// Lineare Distance ramp: volle Lautstärke am Emitter, Stille ab `radius`.
|
||||
/// Bewusst linear statt 1/d² — bei Zimmer-Skalen klingt die gerade Rampe
|
||||
/// kontrollierbarer, und die Autorin kann per `radius` direkt denken.
|
||||
pub fn distance_gain(dist: f32, radius: f32) -> f32 {
|
||||
(1.0 - dist / radius).clamp(0.0, 1.0)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::engine::model::{Empty, Props};
|
||||
|
||||
fn model(empties: Vec<Empty>) -> Model {
|
||||
Model { objects: Vec::new(), empties, textures: Vec::new() }
|
||||
}
|
||||
|
||||
fn empty(name: &str, pos: [f32; 3], props: &[(&str, &str)]) -> Empty {
|
||||
let mut p = Props::new();
|
||||
for (k, v) in props { p.insert((*k).into(), (*v).into()); }
|
||||
Empty { name: name.into(), pos, dir: [0.0, 0.0, -1.0], props: p }
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn collects_sound_empties_with_radius() {
|
||||
let mut em = Emitters::new();
|
||||
em.add_model(&model(vec![
|
||||
empty("Radio", [5.0, 0.0, 0.0], &[("sound", "hum"), ("radius", "4")]),
|
||||
empty("spawn", [0.0, 0.0, 0.0], &[("role", "spawn")]),
|
||||
empty("Bach", [9.0, 0.0, 0.0], &[("sound", "wasser")]),
|
||||
]));
|
||||
assert_eq!(em.list().len(), 2, "nur Empties mit sound-Property");
|
||||
assert_eq!(em.list()[0].sound, "hum");
|
||||
assert_eq!(em.list()[1].radius, DEFAULT_RADIUS);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gains_ramp_linearly_to_radius() {
|
||||
let mut em = Emitters::new();
|
||||
em.add_model(&model(vec![
|
||||
empty("Radio", [0.0, 0.0, 0.0], &[("sound", "hum"), ("radius", "4")]),
|
||||
]));
|
||||
assert_eq!(em.gains([0.0, 0.0, 0.0]), vec![1.0]);
|
||||
assert_eq!(em.gains([2.0, 0.0, 0.0]), vec![0.5]);
|
||||
assert_eq!(em.gains([4.0, 0.0, 0.0]), vec![0.0]);
|
||||
assert_eq!(em.gains([9.0, 0.0, 0.0]), vec![0.0], "hinter dem Radius still");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn broken_radius_falls_back_to_default() {
|
||||
let mut em = Emitters::new();
|
||||
em.add_model(&model(vec![
|
||||
empty("A", [0.0; 3], &[("sound", "x"), ("radius", "kaputt")]),
|
||||
empty("B", [0.0; 3], &[("sound", "y"), ("radius", "-2")]),
|
||||
]));
|
||||
assert!(em.list().iter().all(|e| e.radius == DEFAULT_RADIUS));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,452 @@
|
||||
//! Collision: Swept-AABB-Trace gegen konvexe Volumen (Quake-Hull-Idee —
|
||||
//! „Brush" heißt hier: der Schnitt seiner Halbräume `{ n·x ≤ d }`,
|
||||
//! n nach außen).
|
||||
//!
|
||||
//! Die Box wird nicht selbst getract, sondern per Minkowski-Aufblasung in den
|
||||
//! Ebenen versenkt: jede Ebene rückt um die auf ihre Normale projizierte
|
||||
//! Box-Halbgröße nach außen (`d' = d + |n|·half`). Damit wird Box-vs-Brush zur
|
||||
//! Punkt-vs-aufgeblasener-Brush-Frage, und die Trace ist ein simpler
|
||||
//! Halbraum-Clip des Segments (Eintritts-/Austritts-Bruch). Ein `SKIN` hält
|
||||
//! den Mittelpunkt eine Haaresbreite vor der Fläche, damit der Folgeframe nicht
|
||||
//! sofort wieder im Kontakt steckt.
|
||||
//!
|
||||
//! Gefüllt wird die Welt aus Blender-Modellen ([`CollisionWorld::add_model`]):
|
||||
//! jedes Objekt mit `collide`-Property wird zur **konvexen Hülle** seiner
|
||||
//! Vertices ([`hull_planes`], inkrementeller Quickhull) — das Mesh selbst darf
|
||||
//! also konkav sein, kollidiert wird gegen seine Hülle. Ergänzt um die sechs
|
||||
//! achsparallelen AABB-Ebenen (Quake-„Bevel planes"): die `|n|·half`-
|
||||
//! Aufblasung ist nur eine konservative Näherung der Minkowski-Summe; die
|
||||
//! Axial-Ebenen ziehen sie an Kanten schräger Hüllen wieder stramm.
|
||||
|
||||
use crate::engine::model::{Model, Object};
|
||||
|
||||
/// Mindestabstand (units), den der Box-Mittelpunkt vor einer Fläche hält —
|
||||
/// verhindert Re-Kollision/Jitter im Folgeframe. ~1 cm, unsichtbar.
|
||||
const SKIN: f32 = 0.01;
|
||||
|
||||
/// Eine nach außen orientierte Ebene `n·x ≤ d` (innen = Halbraum).
|
||||
pub(crate) struct Plane {
|
||||
pub(crate) n: [f32; 3],
|
||||
pub(crate) d: f32,
|
||||
}
|
||||
|
||||
/// Ein konvexer Brush = Schnitt seiner Halbräume.
|
||||
struct ConvexBrush {
|
||||
planes: Vec<Plane>,
|
||||
}
|
||||
|
||||
/// Die statische Kollisionswelt: alle soliden Volumen der geladenen Modelle.
|
||||
pub struct CollisionWorld {
|
||||
brushes: Vec<ConvexBrush>,
|
||||
}
|
||||
|
||||
/// Ergebnis einer Trace: Bruchteil entlang des Segments bis zum Kontakt und
|
||||
/// die nach außen zeigende Trefferebenen-Normale (zum Gleiten/Boden-Erkennen).
|
||||
pub struct Hit {
|
||||
pub frac: f32,
|
||||
pub normal: [f32; 3],
|
||||
}
|
||||
|
||||
impl CollisionWorld {
|
||||
/// Leere Welt — Ausgangszustand, bis Modelle geladen sind.
|
||||
pub fn empty() -> Self {
|
||||
Self { brushes: Vec::new() }
|
||||
}
|
||||
|
||||
/// Collider eines Blender-Modells hinzufügen: jedes Objekt mit
|
||||
/// `collider = true` (aus der `collide`-Property) wird als konvexer
|
||||
/// Brush übernommen (siehe [`object_planes`]).
|
||||
pub fn add_model(&mut self, model: &Model) {
|
||||
for o in &model.objects {
|
||||
if !o.collider { continue; }
|
||||
match object_planes(o) {
|
||||
Some(planes) => self.brushes.push(ConvexBrush { planes }),
|
||||
None => eprintln!("[collision] {}: kein Volumen — ignoriert", o.name),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Eine AABB (Halbmaße `half`) von `start` nach `end` (Box-Mittelpunkte)
|
||||
/// sweepen. Liefert den frühesten Kontakt über alle Brushes, sonst `None`.
|
||||
pub fn trace(&self, start: [f32; 3], end: [f32; 3], half: [f32; 3]) -> Option<Hit> {
|
||||
let mut nearest: Option<Hit> = None;
|
||||
for b in &self.brushes {
|
||||
if let Some(h) = trace_planes(&b.planes, start, end, half)
|
||||
&& nearest.as_ref().is_none_or(|n| h.frac < n.frac) {
|
||||
nearest = Some(h);
|
||||
}
|
||||
}
|
||||
nearest
|
||||
}
|
||||
}
|
||||
|
||||
/// Das konvexe Ebenen-Set eines Modell-Objekts: die **konvexe Hülle** seiner
|
||||
/// Vertices ([`hull_planes`]) plus die sechs achsparallelen AABB-Ebenen
|
||||
/// (Bevel-Ebenen, siehe Modul-Doc) — das Mesh darf also konkav sein. Flache
|
||||
/// Objekte (kein Hüll-Volumen) fallen auf ihre Face-Ebenen zurück, mit den
|
||||
/// Bevel-Ebenen ergibt das die dünne AABB-Platte (brauchbar für flächige
|
||||
/// Trigger-Zonen). `None`, wenn gar kein geschlossenes Volumen entsteht.
|
||||
pub(crate) fn object_planes(o: &Object) -> Option<Vec<Plane>> {
|
||||
if o.verts.is_empty() { return None; }
|
||||
let mut planes = hull_planes(&o.verts).unwrap_or_else(|| face_planes(o));
|
||||
|
||||
// Axiale Bevel-Ebenen aus der AABB (push_plane dedupt achsparallele
|
||||
// Duplikate weg).
|
||||
let (mut bb_min, mut bb_max) = (o.verts[0], o.verts[0]);
|
||||
for v in &o.verts {
|
||||
for k in 0..3 {
|
||||
bb_min[k] = bb_min[k].min(v[k]);
|
||||
bb_max[k] = bb_max[k].max(v[k]);
|
||||
}
|
||||
}
|
||||
for k in 0..3 {
|
||||
let mut n = [0.0f32; 3];
|
||||
n[k] = 1.0;
|
||||
push_plane(&mut planes, n, bb_max[k]);
|
||||
n[k] = -1.0;
|
||||
push_plane(&mut planes, n, -bb_min[k]);
|
||||
}
|
||||
(planes.len() >= 4).then_some(planes) // sonst kein geschlossenes Volumen
|
||||
}
|
||||
|
||||
/// Ebene anfügen, wenn keine (nahezu) gleiche schon da ist — Koplanar-Dedupe
|
||||
/// für Hüll-Dreiecke und Bevel-Ebenen.
|
||||
fn push_plane(planes: &mut Vec<Plane>, n: [f32; 3], d: f32) {
|
||||
if !planes.iter().any(|p| dot(p.n, n) > 0.999 && (p.d - d).abs() < 1e-4) {
|
||||
planes.push(Plane { n, d });
|
||||
}
|
||||
}
|
||||
|
||||
/// Fallback für degenerierte (flache) Objekte: Ebenen direkt aus den
|
||||
/// Dreiecks-Flächen (koplanare dedupliziert). OBJ-/glTF-Winding ist CCW von
|
||||
/// außen → cross(b−a, c−a) zeigt nach außen.
|
||||
fn face_planes(o: &Object) -> Vec<Plane> {
|
||||
let mut planes: Vec<Plane> = Vec::new();
|
||||
for t in &o.tris {
|
||||
let (a, b, c) = (o.verts[t[0]], o.verts[t[1]], o.verts[t[2]]);
|
||||
let n = cross(sub(b, a), sub(c, a));
|
||||
if dot(n, n) < 1e-12 { continue; } // degeneriert (Länge ~0)
|
||||
let n = normalize(n);
|
||||
push_plane(&mut planes, n, dot(n, a));
|
||||
}
|
||||
planes
|
||||
}
|
||||
|
||||
/// Toleranz der Hüllen-Konstruktion (units): Punkte näher als das an einer
|
||||
/// Ebene gelten als koplanar. Absolut statt relativ — Maßstab ist fix
|
||||
/// (1 unit = 1 Blender-Meter), und die Trace arbeitet mit ~SKIN-Auflösung.
|
||||
const HULL_EPS: f32 = 1e-4;
|
||||
|
||||
/// Ein Hüll-Dreieck während der Konstruktion; `alive = false` = durch einen
|
||||
/// später eingefügten Punkt ersetzt (Tombstone statt teurem Entfernen).
|
||||
struct HullFace {
|
||||
v: [usize; 3],
|
||||
n: [f32; 3],
|
||||
d: f32,
|
||||
alive: bool,
|
||||
}
|
||||
|
||||
/// Hüll-Dreieck `(x, y, z)`, so orientiert, dass der Referenzpunkt `w`
|
||||
/// (ein Punkt im Inneren des Start-Simplex) hinter der Ebene liegt.
|
||||
fn hull_face(pts: &[[f32; 3]], x: usize, y: usize, z: usize, w: usize) -> HullFace {
|
||||
let n = normalize(cross(sub(pts[y], pts[x]), sub(pts[z], pts[x])));
|
||||
let d = dot(n, pts[x]);
|
||||
if dot(n, pts[w]) > d {
|
||||
HullFace { v: [x, z, y], n: [-n[0], -n[1], -n[2]], d: -d, alive: true }
|
||||
} else {
|
||||
HullFace { v: [x, y, z], n, d, alive: true }
|
||||
}
|
||||
}
|
||||
|
||||
/// Konvexe Hülle einer Punktwolke als nach außen orientierte Ebenen
|
||||
/// (inkrementeller Quickhull: Start-Tetraeder aus Extrempunkten, dann jeden
|
||||
/// Außenpunkt einfügen — sichtbare Faces sterben, der Horizont wird mit
|
||||
/// neuen Dreiecken zum Punkt geschlossen). `None` bei degenerierter Eingabe
|
||||
/// (alle Punkte ~kollinear/koplanar) — kein Volumen zum Aufspannen.
|
||||
fn hull_planes(pts: &[[f32; 3]]) -> Option<Vec<Plane>> {
|
||||
if pts.len() < 4 { return None; }
|
||||
|
||||
// Start-Simplex: das fernste Paar unter den sechs Achsen-Extrema, dazu
|
||||
// der fernste Punkt zur Kante und der fernste zur aufgespannten Ebene.
|
||||
let mut ext = [0usize; 6];
|
||||
for (i, p) in pts.iter().enumerate() {
|
||||
for k in 0..3 {
|
||||
if p[k] < pts[ext[k]][k] { ext[k] = i; }
|
||||
if p[k] > pts[ext[3 + k]][k] { ext[3 + k] = i; }
|
||||
}
|
||||
}
|
||||
let (mut a, mut b, mut best) = (0, 0, -1.0);
|
||||
for &i in &ext {
|
||||
for &j in &ext {
|
||||
let d = sub(pts[i], pts[j]);
|
||||
let d = dot(d, d);
|
||||
if d > best { best = d; (a, b) = (i, j); }
|
||||
}
|
||||
}
|
||||
if best < HULL_EPS * HULL_EPS { return None; } // alle Punkte ~identisch
|
||||
|
||||
let ab = sub(pts[b], pts[a]);
|
||||
let (mut c, mut best) = (0, -1.0);
|
||||
for (i, p) in pts.iter().enumerate() {
|
||||
let x = cross(ab, sub(*p, pts[a]));
|
||||
let x = dot(x, x);
|
||||
if x > best { best = x; c = i; }
|
||||
}
|
||||
// |cross|² = Abstand² · |ab|² → Vergleich gegen EPS²·|ab|².
|
||||
if best < HULL_EPS * HULL_EPS * dot(ab, ab) { return None; } // kollinear
|
||||
|
||||
let n = normalize(cross(ab, sub(pts[c], pts[a])));
|
||||
let (mut e, mut best) = (0, -1.0);
|
||||
for (i, p) in pts.iter().enumerate() {
|
||||
let x = (dot(n, *p) - dot(n, pts[a])).abs();
|
||||
if x > best { best = x; e = i; }
|
||||
}
|
||||
if best < HULL_EPS { return None; } // koplanar
|
||||
|
||||
// Tetraeder-Faces; als Innen-Referenz dient je der vierte Eckpunkt.
|
||||
let mut faces = vec![
|
||||
hull_face(pts, a, b, c, e),
|
||||
hull_face(pts, a, b, e, c),
|
||||
hull_face(pts, a, c, e, b),
|
||||
hull_face(pts, b, c, e, a),
|
||||
];
|
||||
|
||||
for p in 0..pts.len() {
|
||||
// Faces, die den Punkt sehen (Punkt liegt vor ihrer Ebene).
|
||||
let visible: Vec<usize> = faces.iter().enumerate()
|
||||
.filter(|(_, f)| f.alive && dot(f.n, pts[p]) > f.d + HULL_EPS)
|
||||
.map(|(i, _)| i)
|
||||
.collect();
|
||||
if visible.is_empty() { continue; } // schon in der Hülle
|
||||
|
||||
// Horizont: gerichtete Kanten sichtbarer Faces, deren Gegenkante
|
||||
// nicht selbst zu einem sichtbaren Face gehört. Weil die Windings
|
||||
// konsistent sind, taucht jede innere Kante genau einmal je Richtung
|
||||
// auf — der Horizont ist der Rest.
|
||||
let mut edges: Vec<(usize, usize)> = Vec::new();
|
||||
for &fi in &visible {
|
||||
let [x, y, z] = faces[fi].v;
|
||||
edges.extend([(x, y), (y, z), (z, x)]);
|
||||
faces[fi].alive = false;
|
||||
}
|
||||
for &(x, y) in &edges {
|
||||
if edges.contains(&(y, x)) { continue; } // innere Kante
|
||||
// Horizont-Kante behält ihre Richtung → (x, y, p) zeigt nach
|
||||
// außen. Degenerierte Dreiecke (p ~auf der Kante) überspringen.
|
||||
let nn = cross(sub(pts[y], pts[x]), sub(pts[p], pts[x]));
|
||||
if dot(nn, nn) < 1e-12 { continue; }
|
||||
let n = normalize(nn);
|
||||
faces.push(HullFace { v: [x, y, p], n, d: dot(n, pts[x]), alive: true });
|
||||
}
|
||||
}
|
||||
|
||||
let mut planes: Vec<Plane> = Vec::new();
|
||||
for f in faces.iter().filter(|f| f.alive) {
|
||||
push_plane(&mut planes, f.n, f.d); // koplanare Hüll-Dreiecke dedupen
|
||||
}
|
||||
Some(planes)
|
||||
}
|
||||
|
||||
/// Überlappt eine AABB (Mittelpunkt/Halbmaße) das konvexe Volumen? Gleiche
|
||||
/// Minkowski-Aufblasung wie die Trace — „berühren" zählt als drin.
|
||||
pub(crate) fn box_touches(planes: &[Plane], center: [f32; 3], half: [f32; 3]) -> bool {
|
||||
planes.iter().all(|p| {
|
||||
let d = p.d + p.n[0].abs() * half[0] + p.n[1].abs() * half[1] + p.n[2].abs() * half[2];
|
||||
dot(p.n, center) <= d
|
||||
})
|
||||
}
|
||||
|
||||
/// Segment `start→end` gegen ein aufgeblasenes konvexes Ebenen-Set clippen.
|
||||
/// `None`, wenn das Segment das Volumen verfehlt oder der Start schon drin
|
||||
/// steckt (dann nicht blocken — sonst bliebe der Player hängen).
|
||||
pub(crate) fn trace_planes(planes: &[Plane], start: [f32; 3], end: [f32; 3], half: [f32; 3]) -> Option<Hit> {
|
||||
let mut enter = f32::NEG_INFINITY; // größter Eintritts-Bruch
|
||||
let mut leave = 1.0f32; // kleinster Austritts-Bruch
|
||||
let mut normal = [0.0f32; 3];
|
||||
let mut entered = false; // überhaupt eine Eintrittsebene gefunden?
|
||||
let mut started_outside = false;
|
||||
|
||||
for p in planes {
|
||||
// Ebene um die Box-Halbgröße nach außen aufblasen (Minkowski).
|
||||
let d = p.d + p.n[0].abs() * half[0] + p.n[1].abs() * half[1] + p.n[2].abs() * half[2];
|
||||
let ds = dot(p.n, start) - d;
|
||||
let de = dot(p.n, end) - d;
|
||||
|
||||
if ds > 0.0 { started_outside = true; }
|
||||
if ds > 0.0 && de > 0.0 { return None; } // ganz außerhalb dieser Ebene
|
||||
if ds <= 0.0 && de <= 0.0 { continue; } // ganz innerhalb dieser Ebene
|
||||
|
||||
if ds > de {
|
||||
// Eintritt (außen → innen): SKIN-Rückzug, damit der Mittelpunkt
|
||||
// knapp vor der Fläche stoppt. `enter` darf dabei leicht negativ
|
||||
// werden (Kontakt liegt im SKIN-Band) — das wird unten auf 0
|
||||
// geklemmt, nicht verworfen, sonst rutschte ein ruhender Körper
|
||||
// im Folgeframe durch die Fläche.
|
||||
let f = (ds - SKIN) / (ds - de);
|
||||
if f > enter { enter = f; normal = p.n; entered = true; }
|
||||
} else {
|
||||
// Austritt (innen → außen).
|
||||
let f = ds / (ds - de);
|
||||
if f < leave { leave = f; }
|
||||
}
|
||||
}
|
||||
|
||||
// Treffer nur, wenn der Start außerhalb lag (sonst säße man fest), eine
|
||||
// Eintrittsebene existiert und das Eintrittsintervall vor dem Segmentende
|
||||
// beginnt.
|
||||
if started_outside && entered && enter < leave && enter < 1.0 {
|
||||
Some(Hit { frac: enter.max(0.0), normal })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
// --- kleine Vektor-Helfer (privat; ein gemeinsames engine::vec3 lohnt
|
||||
// erst, falls ein dritter Nutzer auftaucht) ----------------------------------
|
||||
|
||||
fn sub(a: [f32; 3], b: [f32; 3]) -> [f32; 3] { [a[0] - b[0], a[1] - b[1], a[2] - b[2]] }
|
||||
fn dot(a: [f32; 3], b: [f32; 3]) -> f32 { a[0] * b[0] + a[1] * b[1] + a[2] * b[2] }
|
||||
|
||||
fn cross(a: [f32; 3], b: [f32; 3]) -> [f32; 3] {
|
||||
[a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]
|
||||
}
|
||||
|
||||
fn normalize(a: [f32; 3]) -> [f32; 3] {
|
||||
let len = dot(a, a).sqrt();
|
||||
if len > 0.0 { [a[0] / len, a[1] / len, a[2] / len] } else { a }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn aabb_brush(min: [f32; 3], max: [f32; 3]) -> Vec<Plane> {
|
||||
vec![
|
||||
Plane { n: [ 1.0, 0.0, 0.0], d: max[0] }, Plane { n: [-1.0, 0.0, 0.0], d: -min[0] },
|
||||
Plane { n: [0.0, 1.0, 0.0], d: max[1] }, Plane { n: [0.0, -1.0, 0.0], d: -min[1] },
|
||||
Plane { n: [0.0, 0.0, 1.0], d: max[2] }, Plane { n: [0.0, 0.0, -1.0], d: -min[2] },
|
||||
]
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn from_brushes(brushes: Vec<Vec<Plane>>) -> CollisionWorld {
|
||||
CollisionWorld {
|
||||
brushes: brushes.into_iter().map(|planes| ConvexBrush { planes }).collect(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
// Punktförmige Box (half=0) → reine Strahl-vs-Brush-Trace.
|
||||
const PT: [f32; 3] = [0.0, 0.0, 0.0];
|
||||
|
||||
#[test]
|
||||
fn trace_hits_near_face_with_normal() {
|
||||
let w = from_brushes(vec![aabb_brush([0.0, 0.0, 0.0], [2.0, 2.0, 2.0])]);
|
||||
// Von x=-1 nach x=3 (Gesamtweg 4), trifft die −X-Fläche bei x≈0.
|
||||
let h = w.trace([-1.0, 1.0, 1.0], [3.0, 1.0, 1.0], PT).unwrap();
|
||||
assert!((h.frac - 0.25).abs() < 0.02, "frac={}", h.frac);
|
||||
assert!(h.normal[0] < -0.5, "normal sollte -X sein: {:?}", h.normal);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trace_misses_returns_none() {
|
||||
let w = from_brushes(vec![aabb_brush([0.0, 0.0, 0.0], [2.0, 2.0, 2.0])]);
|
||||
// Läuft oberhalb der Box vorbei.
|
||||
assert!(w.trace([-1.0, 5.0, 1.0], [3.0, 5.0, 1.0], PT).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trace_starting_inside_does_not_block() {
|
||||
let w = from_brushes(vec![aabb_brush([0.0, 0.0, 0.0], [2.0, 2.0, 2.0])]);
|
||||
// Start mitten im Brush → kein Hit (sonst säße man fest).
|
||||
assert!(w.trace([1.0, 1.0, 1.0], [5.0, 1.0, 1.0], PT).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn aabb_expands_by_half_extents() {
|
||||
let w = from_brushes(vec![aabb_brush([0.0, 0.0, 0.0], [2.0, 2.0, 2.0])]);
|
||||
// Box mit halber Breite 0.5: Kontakt schon bei x≈-0.5 statt 0.
|
||||
let h = w.trace([-2.0, 1.0, 1.0], [2.0, 1.0, 1.0], [0.5, 0.5, 0.5]).unwrap();
|
||||
// Weg 4, Kontakt bei x≈-0.5 → frac≈(−0.5−(−2))/4 = 0.375.
|
||||
assert!((h.frac - 0.375).abs() < 0.02, "frac={}", h.frac);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn collider_object_becomes_convex_brush() {
|
||||
use crate::engine::model::{test_cube, Model};
|
||||
let model = Model {
|
||||
objects: vec![
|
||||
test_cube("Box", [0.0, 0.0, 0.0], Some("proxy"), None),
|
||||
test_cube("Deko", [5.0, 5.0, 5.0], None, None),
|
||||
],
|
||||
empties: Vec::new(),
|
||||
textures: Vec::new(),
|
||||
};
|
||||
let mut w = CollisionWorld::empty();
|
||||
w.add_model(&model);
|
||||
|
||||
// Nur Box (Deko hat kein collide); die Hülle des Würfels dedupt auf
|
||||
// 6 Ebenen, die axialen Bevel-Ebenen sind mit ihnen identisch.
|
||||
assert_eq!(w.brushes.len(), 1);
|
||||
assert_eq!(w.brushes[0].planes.len(), 6);
|
||||
|
||||
// Strahl von −X hindurch: Kontakt an x≈0 mit −X-Normale.
|
||||
let h = w.trace([-1.0, 0.5, 0.5], [3.0, 0.5, 0.5], PT).unwrap();
|
||||
assert!((h.frac - 0.25).abs() < 0.02, "frac={}", h.frac);
|
||||
assert!(h.normal[0] < -0.5, "normal sollte -X sein: {:?}", h.normal);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hull_of_concave_mesh_spans_the_notch() {
|
||||
// Konkaves „L": zwei Würfel-Objekte liefern die Punktwolke eines
|
||||
// L-Prismas — [0,2]×[0,1]×[0,1] plus [0,1]×[1,2]×[0,1]. Die Hülle
|
||||
// muss die Kerbe (x>1, y>1) mit der Schräge x+y=3 überspannen.
|
||||
let mut verts = Vec::new();
|
||||
for (min, max) in [([0.0f32, 0.0, 0.0], [2.0f32, 1.0, 1.0]),
|
||||
([0.0, 1.0, 0.0], [1.0, 2.0, 1.0])] {
|
||||
for &x in &[min[0], max[0]] {
|
||||
for &y in &[min[1], max[1]] {
|
||||
for &z in &[min[2], max[2]] { verts.push([x, y, z]); }
|
||||
}
|
||||
}
|
||||
}
|
||||
let planes = hull_planes(&verts).unwrap();
|
||||
// 6 AABB-Seiten der Gesamtbox + 1 Schräge über der Kerbe.
|
||||
assert_eq!(planes.len(), 7);
|
||||
let diag = planes.iter()
|
||||
.find(|p| p.n[0] > 0.5 && p.n[1] > 0.5)
|
||||
.expect("Schräge über der Kerbe fehlt");
|
||||
assert!((dot(diag.n, [2.0, 1.0, 0.5]) - diag.d).abs() < 1e-3,
|
||||
"Schräge sollte durch (2,1,·) laufen");
|
||||
|
||||
// Ein Punkt in der Kerbe, unter der Schräge, liegt in der Hülle.
|
||||
assert!(box_touches(&planes, [1.2, 1.2, 0.5], PT));
|
||||
// Die Ecke der Kerbe (über der Schräge) liegt außerhalb.
|
||||
assert!(!box_touches(&planes, [1.9, 1.9, 0.5], PT));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn degenerate_objects_fall_back_or_are_rejected() {
|
||||
use crate::engine::model::{Object, Props};
|
||||
// Flaches Quad in der XY-Ebene: keine Hülle, aber der Face-Ebenen-
|
||||
// Fallback + Bevels ergeben die dünne Platte.
|
||||
let flat = Object {
|
||||
name: "Zone".into(),
|
||||
verts: vec![[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [1.0, 1.0, 0.0], [0.0, 1.0, 0.0]],
|
||||
uvs: vec![[0.0, 0.0]; 4],
|
||||
normals: vec![[0.0, 0.0, 1.0]; 4],
|
||||
tris: vec![[0, 1, 2], [0, 2, 3]],
|
||||
tri_mats: vec![0; 2],
|
||||
visible: true, collider: false, props: Props::new(),
|
||||
};
|
||||
let planes = object_planes(&flat).unwrap();
|
||||
assert!(box_touches(&planes, [0.5, 0.5, 0.0], PT));
|
||||
assert!(!box_touches(&planes, [0.5, 0.5, 1.0], PT));
|
||||
|
||||
// Ohne Vertices gibt es nichts.
|
||||
let empty = Object { verts: Vec::new(), uvs: Vec::new(), tris: Vec::new(),
|
||||
tri_mats: Vec::new(), ..flat };
|
||||
assert!(object_planes(&empty).is_none());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,11 +5,9 @@
|
||||
//! `ActionCtx` ist der schmale `&mut`-View; er wird über `Game::action_ctx()`
|
||||
//! konstruiert und durch die Dispatch-Pipeline gereicht.
|
||||
//!
|
||||
//! Verben, deren Ziel-Subsystem (Szene, Audio, Renderer) noch nicht
|
||||
//! existiert oder den Kern nichts angeht, produzieren [`Action`]-Werte
|
||||
//! statt direkt zu wirken. Frontends konsumieren die Queue: die CLI druckt
|
||||
//! sie, die Engine führt sie später aus. So bleibt der Kern headless
|
||||
//! testbar und kennt keines der Subsysteme.
|
||||
//! Verben, deren Ziel-Subsystem (Szene, Audio, Renderer) den Kern nichts
|
||||
//! angeht, produzieren [`Action`]-Werte statt direkt zu wirken. Frontends
|
||||
//! konsumieren die Queue: die CLI druckt sie, das Fenster führt sie aus.
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -26,10 +24,52 @@ pub type Signals = HashMap<String, Vec<String>>;
|
||||
/// geleert (konsumiert).
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Action {
|
||||
/// Instance unsichtbar + kollisionslos + nicht mehr interagierbar machen.
|
||||
HideObject(String),
|
||||
/// WAV unter `assets/audio/<name>` als SFX abspielen.
|
||||
/// `assets/sounds/{name}.wav` als Einmal-SFX abspielen.
|
||||
PlaySound(String),
|
||||
/// Anzeige-/Eingabemodus wechseln (Spiel, Noclip, Menü). Der Dialog-Modus
|
||||
/// ist bewusst nicht wählbar — er entsteht nur aus dem Story-Ablauf.
|
||||
SetMode(ModeTarget),
|
||||
/// Renderer-Post-Effekt schalten. Der Kern kennt weder die Kette noch die
|
||||
/// Effektnamen — das Fenster löst `name` gegen seine Kette auf (unbekannt
|
||||
/// → Meldung), die CLI reicht nur die `[action]`-Zeile.
|
||||
SetPost { name: String, on: bool },
|
||||
/// In die Szene `assets/maps/{name}/` wechseln, optional an den
|
||||
/// Spawn-Empty `spawn`. Die Session führt sie aus (lädt die Modelle und
|
||||
/// baut die Sim-Welt neu); mehrere in einem Schritt → die letzte gilt.
|
||||
LoadScene { name: String, spawn: Option<String> },
|
||||
}
|
||||
|
||||
/// Frontend-neutrales Ziel eines Moduswechsels: die nicht-Dialog-Varianten von
|
||||
/// `session::Mode`, ohne dass der Kern dessen Dialog-Daten kennen muss.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ModeTarget {
|
||||
/// First-Person-Spiel.
|
||||
Play,
|
||||
/// Noclip: freies Fliegen ohne Kollision.
|
||||
Free,
|
||||
/// Menü (pausiert die Welt, gibt die Maus frei).
|
||||
Menu,
|
||||
}
|
||||
|
||||
impl ModeTarget {
|
||||
/// `play`/`free`/`menu` (case-insensitiv) → Ziel; sonst `None`.
|
||||
pub fn parse(s: &str) -> Option<Self> {
|
||||
match s.trim().to_ascii_lowercase().as_str() {
|
||||
"play" => Some(Self::Play),
|
||||
"free" => Some(Self::Free),
|
||||
"menu" => Some(Self::Menu),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Kanonischer Name fürs Echo/Logging.
|
||||
pub fn label(self) -> &'static str {
|
||||
match self {
|
||||
Self::Play => "play",
|
||||
Self::Free => "free",
|
||||
Self::Menu => "menu",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Game {
|
||||
|
||||
@@ -0,0 +1,675 @@
|
||||
//! glTF-Binary-Loader (.glb, Blender-Export) → geparstes [`Model`].
|
||||
//!
|
||||
//! Die tragenden Kanäle: **Custom Properties** (in Blender beim Export
|
||||
//! „Include → Custom Properties" anhaken → landen in `node.extras`) und
|
||||
//! **Empties** (Nodes ohne Mesh) als Entity-Marker. Beide kommen als
|
||||
//! `props`/`empties` im Modell an; Bedeutung geben die Konsumenten.
|
||||
//!
|
||||
//! Subset: GLB-Container (JSON- + BIN-Chunk; reine `.gltf` mit externen
|
||||
//! Buffern sind außerhalb — in Blender „glTF Binary (.glb)" exportieren),
|
||||
//! Dreiecks-Primitives (Mode 4, Default) mit `POSITION`/`TEXCOORD_0`
|
||||
//! (float) und optionalen Indizes (u8/u16/u32). Node-Transforms (Matrix
|
||||
//! oder T·R·S, samt Hierarchie) werden in die Vertices eingebacken.
|
||||
//!
|
||||
//! Texturen: die `baseColorTexture` jedes Materials wird aus dem BIN-Chunk
|
||||
//! geholt und dekodiert (PNG, wie Blender es einbettet) → `model::Texture`.
|
||||
//! `KHR_texture_transform` (Blenders Mapping-Node) wird beim Laden in die UVs
|
||||
//! eingebacken. Der Rest von glTFs PBR-Modell bleibt ungenutzt.
|
||||
//!
|
||||
//! Achsen: glTF ist per Spezifikation Y-up/−Z-forward — unser System,
|
||||
//! Blenders Exporter konvertiert selbst. Maßstab 1:1.
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::engine::image::{self, Image};
|
||||
use crate::engine::model::{apply_props, fill_missing_normals, norm, Empty, Model, Object, Props, Texture};
|
||||
|
||||
pub fn load(path: &str) -> Result<Model, String> {
|
||||
let bytes = std::fs::read(path).map_err(|e| format!("gltf load {path}: {e}"))?;
|
||||
parse_glb(&bytes).map_err(|e| format!("gltf {path}: {e}"))
|
||||
}
|
||||
|
||||
/// GLB-Container: 12-Byte-Header (`glTF`, Version 2, Gesamtlänge), dann
|
||||
/// Chunks aus Länge/Typ/Daten. Wir brauchen JSON (`JSON`) und BIN (`BIN\0`).
|
||||
pub fn parse_glb(bytes: &[u8]) -> Result<Model, String> {
|
||||
if bytes.len() < 12 || &bytes[0..4] != b"glTF" {
|
||||
return Err("kein GLB (Magic fehlt) — in Blender als „glTF Binary (.glb)“ exportieren".into());
|
||||
}
|
||||
let version = u32_at(bytes, 4)?;
|
||||
if version != 2 { return Err(format!("glTF-Version {version}, unterstützt ist 2")); }
|
||||
|
||||
let (mut json, mut bin): (Option<&[u8]>, &[u8]) = (None, &[]);
|
||||
let mut off = 12;
|
||||
while off + 8 <= bytes.len() {
|
||||
let len = u32_at(bytes, off)? as usize;
|
||||
let ty = &bytes[off + 4..off + 8];
|
||||
let data = bytes.get(off + 8..off + 8 + len).ok_or("Chunk länger als Datei")?;
|
||||
match ty {
|
||||
b"JSON" => json = Some(data),
|
||||
b"BIN\0" => bin = data,
|
||||
_ => {} // unbekannte Chunks per Spec ignorieren
|
||||
}
|
||||
off += 8 + len.next_multiple_of(4); // Chunks sind 4-Byte-aligned
|
||||
}
|
||||
let json = json.ok_or("kein JSON-Chunk")?;
|
||||
let doc: Value = serde_json::from_slice(json).map_err(|e| format!("JSON: {e}"))?;
|
||||
build(&doc, bin)
|
||||
}
|
||||
|
||||
fn build(doc: &Value, bin: &[u8]) -> Result<Model, String> {
|
||||
let mut model = Model { objects: Vec::new(), empties: Vec::new(), textures: Vec::new() };
|
||||
|
||||
// Szenen-Wurzeln (Default-Szene, sonst 0) rekursiv ablaufen; die
|
||||
// Welt-Transform wächst dabei Parent → Kind.
|
||||
let scene = doc["scene"].as_u64().unwrap_or(0) as usize;
|
||||
let roots = doc["scenes"][scene]["nodes"].as_array().cloned().unwrap_or_default();
|
||||
for r in roots {
|
||||
let Some(i) = r.as_u64() else { continue; };
|
||||
walk_node(doc, bin, i as usize, IDENTITY, &mut model)?;
|
||||
}
|
||||
resolve_textures(doc, bin, &mut model);
|
||||
Ok(model)
|
||||
}
|
||||
|
||||
/// Nach dem Walk tragen die `tri_mats` rohe glTF-Material-Indizes
|
||||
/// (`usize::MAX` = kein Material). Daraus die deduplizierte Texturliste bauen
|
||||
/// (erste-Sicht-Reihenfolge) und die `tri_mats` auf ihre Indizes umschreiben.
|
||||
fn resolve_textures(doc: &Value, bin: &[u8], model: &mut Model) {
|
||||
let mut order: Vec<usize> = Vec::new();
|
||||
let mut local: HashMap<usize, usize> = HashMap::new();
|
||||
for o in &model.objects {
|
||||
for &m in &o.tri_mats {
|
||||
local.entry(m).or_insert_with(|| { order.push(m); order.len() - 1 });
|
||||
}
|
||||
}
|
||||
model.textures = order.iter().map(|&raw| build_texture(doc, bin, raw)).collect();
|
||||
for o in &mut model.objects {
|
||||
for m in &mut o.tri_mats { *m = local[m]; }
|
||||
}
|
||||
}
|
||||
|
||||
/// Das `model::Texture` für einen rohen glTF-Material-Index:
|
||||
/// `material → pbrMetallicRoughness.baseColorTexture → texture → image`, Bild
|
||||
/// aus dem BIN-Chunk dekodiert. Fehlt ein Glied, bleibt `image: None` (der
|
||||
/// Konsument nimmt seinen Platzhalter), der Schlüssel wird trotzdem gesetzt.
|
||||
fn build_texture(doc: &Value, bin: &[u8], raw_mat: usize) -> Texture {
|
||||
if raw_mat == usize::MAX {
|
||||
return Texture { key: String::new(), image: None };
|
||||
}
|
||||
let mat = &doc["materials"][raw_mat];
|
||||
let mat_name = mat["name"].as_str().unwrap_or("");
|
||||
let tex_ref = &mat["pbrMetallicRoughness"]["baseColorTexture"];
|
||||
let img_node = tex_ref["index"].as_u64()
|
||||
.and_then(|t| doc["textures"][t as usize]["source"].as_u64())
|
||||
.map(|s| &doc["images"][s as usize]);
|
||||
let Some(img_node) = img_node else {
|
||||
return Texture { key: mat_name.to_string(), image: None };
|
||||
};
|
||||
let key = img_node["name"].as_str()
|
||||
.filter(|s| !s.is_empty())
|
||||
.unwrap_or(mat_name)
|
||||
.to_string();
|
||||
let image = decode_embedded_image(doc, bin, img_node, &key);
|
||||
Texture { key, image }
|
||||
}
|
||||
|
||||
/// Ein `images[]`-Node aus dem BIN-Chunk dekodieren. Externe Dateien und
|
||||
/// Daten-URIs unterstützt der GLB-Pfad nicht — sie werden gemeldet.
|
||||
fn decode_embedded_image(doc: &Value, bin: &[u8], node: &Value, key: &str) -> Option<Image> {
|
||||
let Some(view) = node["bufferView"].as_u64() else {
|
||||
eprintln!("[tex] {key}: Bild ohne bufferView (externe Datei/Daten-URI wird nicht gelesen)");
|
||||
return None;
|
||||
};
|
||||
let bytes = match buffer_view_bytes(doc, bin, view as usize) {
|
||||
Ok(b) => b,
|
||||
Err(e) => { eprintln!("[tex] {key}: {e}"); return None; }
|
||||
};
|
||||
match image::decode(bytes, node["mimeType"].as_str().unwrap_or("")) {
|
||||
Ok(img) => Some(img),
|
||||
Err(e) => { eprintln!("[tex] {key}: {e}"); None }
|
||||
}
|
||||
}
|
||||
|
||||
/// Rohe Bytes eines bufferViews (ohne Accessor-Stride) aus dem BIN-Chunk.
|
||||
fn buffer_view_bytes<'a>(doc: &Value, bin: &'a [u8], view: usize) -> Result<&'a [u8], String> {
|
||||
let v = &doc["bufferViews"][view];
|
||||
if v.is_null() { return Err(format!("bufferView {view} fehlt")); }
|
||||
let off = v["byteOffset"].as_u64().unwrap_or(0) as usize;
|
||||
let len = v["byteLength"].as_u64().ok_or("bufferView ohne byteLength")? as usize;
|
||||
bin.get(off..off + len).ok_or_else(|| "bufferView ragt aus dem BIN-Chunk".into())
|
||||
}
|
||||
|
||||
/// KHR_texture_transform einer Textur-Referenz — hier landet Blenders
|
||||
/// Mapping-Node. Fehlt die Extension: `None`.
|
||||
struct UvTransform {
|
||||
offset: [f32; 2],
|
||||
scale: [f32; 2],
|
||||
rotation: f32,
|
||||
}
|
||||
|
||||
fn uv_transform(tex_ref: &Value) -> Option<UvTransform> {
|
||||
let x = &tex_ref["extensions"]["KHR_texture_transform"];
|
||||
if x.is_null() { return None; }
|
||||
Some(UvTransform {
|
||||
offset: vecn::<2>(&x["offset"], [0.0, 0.0]),
|
||||
scale: vecn::<2>(&x["scale"], [1.0, 1.0]),
|
||||
rotation: x["rotation"].as_f64().unwrap_or(0.0) as f32,
|
||||
})
|
||||
}
|
||||
|
||||
impl UvTransform {
|
||||
/// `uv' = translation · rotation · scale · uv` (KHR-Referenz: die
|
||||
/// Rotationsmatrix dreht mit negativem Winkel).
|
||||
fn apply(&self, uv: [f32; 2]) -> [f32; 2] {
|
||||
let (a, b) = (uv[0] * self.scale[0], uv[1] * self.scale[1]);
|
||||
let (s, c) = self.rotation.sin_cos();
|
||||
[
|
||||
c * a + s * b + self.offset[0],
|
||||
-s * a + c * b + self.offset[1],
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
fn walk_node(doc: &Value, bin: &[u8], idx: usize, parent: M4, model: &mut Model) -> Result<(), String> {
|
||||
let node = &doc["nodes"][idx];
|
||||
if node.is_null() { return Err(format!("Node {idx} fehlt")); }
|
||||
let world = mul(parent, node_local(node));
|
||||
let name = node["name"].as_str().map_or_else(|| format!("node{idx}"), str::to_string);
|
||||
let props = extras_props(&node["extras"]);
|
||||
|
||||
match node["mesh"].as_u64() {
|
||||
Some(mesh) => {
|
||||
let mut o = Object {
|
||||
name, props,
|
||||
visible: true, collider: false, // bis apply_props entscheidet
|
||||
verts: Vec::new(), uvs: Vec::new(), normals: Vec::new(),
|
||||
tris: Vec::new(), tri_mats: Vec::new(),
|
||||
};
|
||||
append_mesh(doc, bin, mesh as usize, world, &mut o)?;
|
||||
fill_missing_normals(&mut o); // Primitives ohne NORMAL
|
||||
apply_props(&mut o); // collide-/signal-Regeln (siehe engine::model)
|
||||
if !o.tris.is_empty() { model.objects.push(o); }
|
||||
}
|
||||
// Node ohne Mesh = Empty (Entity-Marker); Position aus der
|
||||
// Welt-Transform (Translationsspalte), Blickrichtung aus ihrer
|
||||
// negierten Z-Spalte (siehe model::Empty::dir).
|
||||
None => model.empties.push(Empty {
|
||||
name, props,
|
||||
pos: [world[12], world[13], world[14]],
|
||||
dir: norm([-world[8], -world[9], -world[10]]),
|
||||
}),
|
||||
}
|
||||
|
||||
for c in node["children"].as_array().into_iter().flatten() {
|
||||
if let Some(ci) = c.as_u64() {
|
||||
walk_node(doc, bin, ci as usize, world, model)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Alle Dreiecks-Primitives eines glTF-Meshes (Welt-transformiert) an ein
|
||||
/// Objekt anhängen. Nicht-Dreiecks-Modes werden gemeldet und übersprungen.
|
||||
fn append_mesh(
|
||||
doc: &Value, bin: &[u8], mesh: usize, world: M4, o: &mut Object,
|
||||
) -> Result<(), String> {
|
||||
for prim in doc["meshes"][mesh]["primitives"].as_array().into_iter().flatten() {
|
||||
if prim["mode"].as_u64().unwrap_or(4) != 4 {
|
||||
eprintln!("[gltf] {}: Primitive-Mode ≠ Dreiecke — übersprungen", o.name);
|
||||
continue;
|
||||
}
|
||||
let Some(pos_acc) = prim["attributes"]["POSITION"].as_u64() else { continue; };
|
||||
let positions = read_floats::<3>(doc, bin, pos_acc as usize)?;
|
||||
let uvs = match prim["attributes"]["TEXCOORD_0"].as_u64() {
|
||||
Some(a) => read_floats::<2>(doc, bin, a as usize)?,
|
||||
None => vec![[0.0, 0.0]; positions.len()],
|
||||
};
|
||||
// Ohne NORMAL bleibt der Nullvektor stehen; fill_missing_normals
|
||||
// rechnet ihn später aus den Flächen.
|
||||
let normals = match prim["attributes"]["NORMAL"].as_u64() {
|
||||
Some(a) => read_floats::<3>(doc, bin, a as usize)?,
|
||||
None => vec![[0.0, 0.0, 0.0]; positions.len()],
|
||||
};
|
||||
|
||||
// Rohen glTF-Material-Index behalten; resolve_textures baut daraus
|
||||
// nach dem Walk die deduplizierte Texturliste und schreibt die
|
||||
// tri_mats auf deren Indizes um. usize::MAX = kein Material.
|
||||
let raw_mat = prim["material"].as_u64().map_or(usize::MAX, |m| m as usize);
|
||||
|
||||
let base = o.verts.len();
|
||||
let nm = normal_matrix(world);
|
||||
for ((p, uv), n) in positions.iter().zip(&uvs).zip(&normals) {
|
||||
o.verts.push(transform(world, *p));
|
||||
o.uvs.push(*uv);
|
||||
o.normals.push(norm(transform3(nm, *n)));
|
||||
}
|
||||
// KHR_texture_transform (Blenders Mapping-Node) in die UVs dieses
|
||||
// Primitives einbacken — der Shader bleibt UV-agnostisch.
|
||||
if raw_mat != usize::MAX {
|
||||
let tex_ref = &doc["materials"][raw_mat]["pbrMetallicRoughness"]["baseColorTexture"];
|
||||
if let Some(xf) = uv_transform(tex_ref) {
|
||||
for uv in &mut o.uvs[base..] { *uv = xf.apply(*uv); }
|
||||
}
|
||||
}
|
||||
|
||||
let idxs: Vec<usize> = match prim["indices"].as_u64() {
|
||||
Some(a) => read_indices(doc, bin, a as usize)?,
|
||||
None => (0..positions.len()).collect(), // non-indexed: sequenziell
|
||||
};
|
||||
for t in idxs.chunks_exact(3) {
|
||||
if t.iter().any(|&i| i >= positions.len()) {
|
||||
return Err(format!("{}: Index außerhalb der Positionen", o.name));
|
||||
}
|
||||
o.tris.push([base + t[0], base + t[1], base + t[2]]);
|
||||
o.tri_mats.push(raw_mat);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// `node.extras` (Objekt) → Props; Skalare werden zu Strings vereinheitlicht,
|
||||
/// verschachtelte Werte als kompaktes JSON durchgereicht.
|
||||
fn extras_props(extras: &Value) -> Props {
|
||||
let mut props = Props::new();
|
||||
if let Some(map) = extras.as_object() {
|
||||
for (k, v) in map {
|
||||
let s = match v {
|
||||
Value::String(s) => s.clone(),
|
||||
other => other.to_string(),
|
||||
};
|
||||
props.insert(k.clone(), s);
|
||||
}
|
||||
}
|
||||
props
|
||||
}
|
||||
|
||||
// --- Accessor-Dekodierung ----------------------------------------------------
|
||||
|
||||
/// Bytes eines Accessors samt Element-Stride auflösen (BufferView-Offset,
|
||||
/// Accessor-Offset, optionaler byteStride — sonst dicht gepackt).
|
||||
fn accessor_bytes<'a>(doc: &Value, bin: &'a [u8], acc: usize, elem_size: usize)
|
||||
-> Result<(&'a [u8], usize, usize), String>
|
||||
{
|
||||
let a = &doc["accessors"][acc];
|
||||
let count = a["count"].as_u64().ok_or("Accessor ohne count")? as usize;
|
||||
let view = a["bufferView"].as_u64().ok_or("Accessor ohne bufferView")? as usize;
|
||||
let v = &doc["bufferViews"][view];
|
||||
let v_off = v["byteOffset"].as_u64().unwrap_or(0) as usize;
|
||||
let a_off = a["byteOffset"].as_u64().unwrap_or(0) as usize;
|
||||
let stride = v["byteStride"].as_u64().map_or(elem_size, |s| s as usize);
|
||||
let start = v_off + a_off;
|
||||
let need = start + stride * count.saturating_sub(1) + elem_size;
|
||||
if need > bin.len() { return Err("Accessor ragt aus dem BIN-Chunk".into()); }
|
||||
Ok((&bin[start..], stride, count))
|
||||
}
|
||||
|
||||
/// N-Komponenten-float-Accessor (POSITION: N=3, TEXCOORD: N=2) lesen.
|
||||
fn read_floats<const N: usize>(doc: &Value, bin: &[u8], acc: usize) -> Result<Vec<[f32; N]>, String> {
|
||||
let ctype = doc["accessors"][acc]["componentType"].as_u64().unwrap_or(0);
|
||||
if ctype != 5126 {
|
||||
return Err(format!("Accessor {acc}: componentType {ctype}, erwartet float (5126)"));
|
||||
}
|
||||
let (bytes, stride, count) = accessor_bytes(doc, bin, acc, N * 4)?;
|
||||
let mut out = Vec::with_capacity(count);
|
||||
for i in 0..count {
|
||||
let mut e = [0.0f32; N];
|
||||
for (k, v) in e.iter_mut().enumerate() {
|
||||
let o = i * stride + k * 4;
|
||||
*v = f32::from_le_bytes(bytes[o..o + 4].try_into().unwrap());
|
||||
}
|
||||
out.push(e);
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// Index-Accessor lesen (u8/u16/u32 → usize).
|
||||
fn read_indices(doc: &Value, bin: &[u8], acc: usize) -> Result<Vec<usize>, String> {
|
||||
let ctype = doc["accessors"][acc]["componentType"].as_u64().unwrap_or(0);
|
||||
let size = match ctype {
|
||||
5121 => 1, // u8
|
||||
5123 => 2, // u16
|
||||
5125 => 4, // u32
|
||||
_ => return Err(format!("Index-Accessor {acc}: componentType {ctype}")),
|
||||
};
|
||||
let (bytes, stride, count) = accessor_bytes(doc, bin, acc, size)?;
|
||||
let mut out = Vec::with_capacity(count);
|
||||
for i in 0..count {
|
||||
let o = i * stride;
|
||||
out.push(match size {
|
||||
1 => bytes[o] as usize,
|
||||
2 => u16::from_le_bytes(bytes[o..o + 2].try_into().unwrap()) as usize,
|
||||
_ => u32::from_le_bytes(bytes[o..o + 4].try_into().unwrap()) as usize,
|
||||
});
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
// --- Transform-Helfer (4×4 column-major, wie glTFs `matrix`) -----------------
|
||||
|
||||
type M4 = [f32; 16];
|
||||
|
||||
const IDENTITY: M4 = [
|
||||
1.0, 0.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0,
|
||||
];
|
||||
|
||||
/// Lokale Transform eines Nodes: explizite `matrix` oder T·R·S
|
||||
/// (glTF-Reihenfolge; fehlende Anteile sind Identität).
|
||||
fn node_local(node: &Value) -> M4 {
|
||||
if let Some(m) = node["matrix"].as_array() {
|
||||
let mut out = IDENTITY;
|
||||
for (i, v) in m.iter().take(16).enumerate() {
|
||||
out[i] = v.as_f64().unwrap_or(0.0) as f32;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
let t = vecn::<3>(&node["translation"], [0.0, 0.0, 0.0]);
|
||||
let q = vecn::<4>(&node["rotation"], [0.0, 0.0, 0.0, 1.0]);
|
||||
let s = vecn::<3>(&node["scale"], [1.0, 1.0, 1.0]);
|
||||
|
||||
// Rotationsmatrix aus dem Quaternion (x, y, z, w), Spalten skaliert,
|
||||
// Translation in die vierte Spalte — direkt komponiertes T·R·S.
|
||||
let (x, y, z, w) = (q[0], q[1], q[2], q[3]);
|
||||
let r = [
|
||||
[1.0 - 2.0 * (y * y + z * z), 2.0 * (x * y + z * w), 2.0 * (x * z - y * w)],
|
||||
[2.0 * (x * y - z * w), 1.0 - 2.0 * (x * x + z * z), 2.0 * (y * z + x * w)],
|
||||
[2.0 * (x * z + y * w), 2.0 * (y * z - x * w), 1.0 - 2.0 * (x * x + y * y)],
|
||||
]; // r[spalte][zeile]
|
||||
let mut out = IDENTITY;
|
||||
for c in 0..3 {
|
||||
for row in 0..3 {
|
||||
out[c * 4 + row] = r[c][row] * s[c];
|
||||
}
|
||||
}
|
||||
out[12] = t[0]; out[13] = t[1]; out[14] = t[2];
|
||||
out
|
||||
}
|
||||
|
||||
fn vecn<const N: usize>(v: &Value, default: [f32; N]) -> [f32; N] {
|
||||
let Some(arr) = v.as_array() else { return default; };
|
||||
let mut out = default;
|
||||
for (o, x) in out.iter_mut().zip(arr) {
|
||||
if let Some(f) = x.as_f64() { *o = f as f32; }
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
fn mul(a: M4, b: M4) -> M4 {
|
||||
let mut out = [0.0; 16];
|
||||
for c in 0..4 {
|
||||
for r in 0..4 {
|
||||
out[c * 4 + r] = (0..4).map(|k| a[k * 4 + r] * b[c * 4 + k]).sum();
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Normalen-Transform zur Welt-Matrix: die Kofaktormatrix ihres 3×3-Teils
|
||||
/// (zeilenweise). Das ist die inverse Transponierte bis auf den Faktor
|
||||
/// `det` — den frisst das anschließende Normieren, und im Gegensatz zur
|
||||
/// Matrix selbst hält sie Normalen auch bei ungleichmäßiger Skalierung
|
||||
/// senkrecht auf der Fläche. Bei Spiegelungen (det < 0) dreht sie die
|
||||
/// Normale korrekt mit.
|
||||
fn normal_matrix(m: M4) -> [f32; 9] {
|
||||
let a = |r: usize, c: usize| m[c * 4 + r];
|
||||
let cof = |r: usize, c: usize| {
|
||||
let (r0, r1) = ((r + 1) % 3, (r + 2) % 3);
|
||||
let (c0, c1) = ((c + 1) % 3, (c + 2) % 3);
|
||||
a(r0, c0) * a(r1, c1) - a(r0, c1) * a(r1, c0)
|
||||
};
|
||||
let mut out = [0.0; 9];
|
||||
for r in 0..3 {
|
||||
for c in 0..3 { out[r * 3 + c] = cof(r, c); }
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Richtungsvektor mit einer 3×3-Matrix (zeilenweise) drehen — ohne
|
||||
/// Translation, anders als [`transform`].
|
||||
fn transform3(m: [f32; 9], v: [f32; 3]) -> [f32; 3] {
|
||||
let mut out = [0.0; 3];
|
||||
for (r, o) in out.iter_mut().enumerate() {
|
||||
*o = m[r * 3] * v[0] + m[r * 3 + 1] * v[1] + m[r * 3 + 2] * v[2];
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
fn transform(m: M4, p: [f32; 3]) -> [f32; 3] {
|
||||
let mut out = [0.0; 3];
|
||||
for (r, o) in out.iter_mut().enumerate() {
|
||||
*o = m[r] * p[0] + m[4 + r] * p[1] + m[8 + r] * p[2] + m[12 + r];
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
fn u32_at(bytes: &[u8], off: usize) -> Result<u32, String> {
|
||||
bytes.get(off..off + 4)
|
||||
.map(|b| u32::from_le_bytes(b.try_into().unwrap()))
|
||||
.ok_or_else(|| "Datei zu kurz".into())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// GLB aus JSON-Text und BIN-Daten zusammensetzen (mit 4-Byte-Padding),
|
||||
/// wie es ein Exporter täte.
|
||||
fn glb(json: &str, bin: &[u8]) -> Vec<u8> {
|
||||
let mut j = json.as_bytes().to_vec();
|
||||
while !j.len().is_multiple_of(4) { j.push(b' '); }
|
||||
let mut b = bin.to_vec();
|
||||
while !b.len().is_multiple_of(4) { b.push(0); }
|
||||
let total = 12 + 8 + j.len() + 8 + b.len();
|
||||
let mut out = Vec::new();
|
||||
out.extend(b"glTF");
|
||||
out.extend(2u32.to_le_bytes());
|
||||
out.extend((total as u32).to_le_bytes());
|
||||
out.extend((j.len() as u32).to_le_bytes());
|
||||
out.extend(b"JSON");
|
||||
out.extend(j);
|
||||
out.extend((b.len() as u32).to_le_bytes());
|
||||
out.extend(b"BIN\0");
|
||||
out.extend(b);
|
||||
out
|
||||
}
|
||||
|
||||
/// Diagonale Normale — unter ungleichmäßiger Skalierung unterscheidet
|
||||
/// sie die korrekte Kofaktor-Transform von der (falschen) Matrix.
|
||||
const DIAG: f32 = std::f32::consts::FRAC_1_SQRT_2;
|
||||
|
||||
/// Ein Dreieck (Positionen + UVs + Normalen + u16-Indizes) im BIN-Chunk.
|
||||
fn sample_bin() -> Vec<u8> {
|
||||
let mut bin: Vec<u8> = Vec::new();
|
||||
for f in [0.0f32, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0] { bin.extend(f.to_le_bytes()); }
|
||||
for f in [0.0f32, 0.0, 1.0, 0.0, 1.0, 1.0] { bin.extend(f.to_le_bytes()); }
|
||||
for _ in 0..3 { for f in [DIAG, DIAG, 0.0] { bin.extend(f.to_le_bytes()); } }
|
||||
for i in [0u16, 1, 2] { bin.extend(i.to_le_bytes()); }
|
||||
bin
|
||||
}
|
||||
|
||||
/// Mesh-Node mit Translation und extras, ein skaliertes Kind, ein Empty.
|
||||
const SAMPLE_JSON: &str = r#"{
|
||||
"asset": {"version": "2.0"},
|
||||
"scene": 0,
|
||||
"scenes": [{"nodes": [0, 2]}],
|
||||
"nodes": [
|
||||
{"name": "Ding", "mesh": 0, "translation": [10, 0, 0],
|
||||
"extras": {"signal": "tiffany", "hp": 3},
|
||||
"children": [1]},
|
||||
{"name": "Kind", "mesh": 0, "scale": [2, 1, 1],
|
||||
"extras": {"collide": "proxy"}},
|
||||
{"name": "spawn", "translation": [1, 2, 3],
|
||||
"rotation": [0, 0.7071068, 0, 0.7071068]}
|
||||
],
|
||||
"meshes": [{"primitives": [{
|
||||
"attributes": {"POSITION": 0, "TEXCOORD_0": 1, "NORMAL": 2},
|
||||
"indices": 3, "material": 0
|
||||
}]}],
|
||||
"materials": [{"name": "carpet"}],
|
||||
"accessors": [
|
||||
{"bufferView": 0, "componentType": 5126, "count": 3, "type": "VEC3"},
|
||||
{"bufferView": 1, "componentType": 5126, "count": 3, "type": "VEC2"},
|
||||
{"bufferView": 2, "componentType": 5126, "count": 3, "type": "VEC3"},
|
||||
{"bufferView": 3, "componentType": 5123, "count": 3, "type": "SCALAR"}
|
||||
],
|
||||
"bufferViews": [
|
||||
{"buffer": 0, "byteOffset": 0, "byteLength": 36},
|
||||
{"buffer": 0, "byteOffset": 36, "byteLength": 24},
|
||||
{"buffer": 0, "byteOffset": 60, "byteLength": 36},
|
||||
{"buffer": 0, "byteOffset": 96, "byteLength": 6}
|
||||
],
|
||||
"buffers": [{"byteLength": 102}]
|
||||
}"#;
|
||||
|
||||
fn sample_glb() -> Vec<u8> { glb(SAMPLE_JSON, &sample_bin()) }
|
||||
|
||||
/// Dasselbe Modell ohne `NORMAL` — glTF erlaubt das, der Loader muss die
|
||||
/// Normalen dann selbst rechnen.
|
||||
fn sample_glb_without_normals() -> Vec<u8> {
|
||||
glb(&SAMPLE_JSON.replace(r#", "NORMAL": 2"#, ""), &sample_bin())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_geometry_with_baked_transforms() {
|
||||
let m = parse_glb(&sample_glb()).unwrap();
|
||||
assert_eq!(m.objects.len(), 2);
|
||||
|
||||
let d = &m.objects[0];
|
||||
assert_eq!(d.name, "Ding");
|
||||
assert_eq!(d.tris, vec![[0, 1, 2]]);
|
||||
assert_eq!(d.verts[1], [11.0, 0.0, 0.0]); // Translation eingebacken
|
||||
// signal-Property ohne Collider → Betretens-Zone, wird nie gerendert.
|
||||
assert!(!d.visible && !d.collider);
|
||||
// Material "carpet" ohne baseColorTexture → Schlüssel gesetzt, kein Bild.
|
||||
assert_eq!(m.textures.len(), 1);
|
||||
assert_eq!(m.textures[0].key, "carpet");
|
||||
assert!(m.textures[0].image.is_none());
|
||||
|
||||
// Kind erbt die Parent-Transform (10, 0, 0);
|
||||
// collide="proxy" → unsichtbarer Collider.
|
||||
let k = &m.objects[1];
|
||||
assert_eq!(k.name, "Kind");
|
||||
assert!(!k.visible && k.collider);
|
||||
assert_eq!(k.verts[0], [10.0, 0.0, 0.0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extras_become_props_and_empties_are_captured() {
|
||||
let m = parse_glb(&sample_glb()).unwrap();
|
||||
let d = &m.objects[0];
|
||||
assert_eq!(d.props.get("signal").map(String::as_str), Some("tiffany"));
|
||||
assert_eq!(d.props.get("hp").map(String::as_str), Some("3")); // Zahl → String
|
||||
|
||||
assert_eq!(m.empties.len(), 1);
|
||||
let e = &m.empties[0];
|
||||
assert_eq!(e.name, "spawn");
|
||||
assert_eq!(e.pos, [1.0, 2.0, 3.0]);
|
||||
// 90° um +Y gedreht: der Blick (lokal −Z) zeigt nach −X.
|
||||
assert!((e.dir[0] + 1.0).abs() < 1e-5 && e.dir[1].abs() < 1e-5 && e.dir[2].abs() < 1e-5,
|
||||
"{:?}", e.dir);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn normals_survive_nonuniform_scale() {
|
||||
let m = parse_glb(&sample_glb()).unwrap();
|
||||
// „Ding": nur Translation → Normale unverändert.
|
||||
let n = m.objects[0].normals[0];
|
||||
assert!((n[0] - DIAG).abs() < 1e-5 && (n[1] - DIAG).abs() < 1e-5, "{n:?}");
|
||||
|
||||
// „Kind": Skalierung [2,1,1]. Richtig ist die inverse Transponierte
|
||||
// (x wird gestaucht → [0.447, 0.894, 0]); die Matrix selbst ergäbe
|
||||
// fälschlich [0.894, 0.447, 0], die Normale stünde schief zur Fläche.
|
||||
let n = m.objects[1].normals[0];
|
||||
assert!((n[0] - 0.4472).abs() < 1e-3, "x sollte gestaucht sein: {n:?}");
|
||||
assert!((n[1] - 0.8944).abs() < 1e-3, "y sollte überwiegen: {n:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_normals_are_computed_from_faces() {
|
||||
let m = parse_glb(&sample_glb_without_normals()).unwrap();
|
||||
// Dreieck liegt in der XY-Ebene, CCW → Normale +Z.
|
||||
assert_eq!(m.objects[0].normals[0], [0.0, 0.0, 1.0]);
|
||||
assert!(m.objects[0].normals.iter().all(|n| *n != [0.0; 3]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn uvs_pass_through_unchanged() {
|
||||
// glTF-UVs (Ursprung oben links) sind die Modell-Konvention — kein Flip.
|
||||
let m = parse_glb(&sample_glb()).unwrap();
|
||||
assert_eq!(m.objects[0].uvs[2], [1.0, 1.0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_non_glb_and_wrong_version() {
|
||||
assert!(parse_glb(b"PNG...whatever").is_err());
|
||||
let mut v1 = sample_glb();
|
||||
v1[4] = 1; // Version patchen
|
||||
assert!(parse_glb(&v1).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn embedded_png_is_decoded_and_uv_transform_baked_in() {
|
||||
// 2×2-RGB-PNG (schwarz, rot, grün, blau) in den BIN-Chunk legen.
|
||||
let mut png_bytes = Vec::new();
|
||||
{
|
||||
let mut enc = png::Encoder::new(&mut png_bytes, 2, 2);
|
||||
enc.set_color(png::ColorType::Rgb);
|
||||
enc.set_depth(png::BitDepth::Eight);
|
||||
enc.write_header().unwrap()
|
||||
.write_image_data(&[0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255])
|
||||
.unwrap();
|
||||
}
|
||||
let mut bin = sample_bin();
|
||||
while !bin.len().is_multiple_of(4) { bin.push(0); }
|
||||
let img_off = bin.len();
|
||||
bin.extend_from_slice(&png_bytes);
|
||||
|
||||
let json = format!(r#"{{
|
||||
"asset": {{"version": "2.0"}},
|
||||
"scene": 0,
|
||||
"scenes": [{{"nodes": [0]}}],
|
||||
"nodes": [{{"name": "Boden", "mesh": 0}}],
|
||||
"meshes": [{{"primitives": [{{
|
||||
"attributes": {{"POSITION": 0, "TEXCOORD_0": 1, "NORMAL": 2}},
|
||||
"indices": 3, "material": 0
|
||||
}}]}}],
|
||||
"materials": [{{"name": "Bodenmat", "pbrMetallicRoughness": {{"baseColorTexture": {{
|
||||
"index": 0,
|
||||
"extensions": {{"KHR_texture_transform": {{"scale": [2.0, 4.0], "offset": [0.5, 0.0]}}}}
|
||||
}}}}}}],
|
||||
"textures": [{{"source": 0}}],
|
||||
"images": [{{"name": "boden_tex", "mimeType": "image/png", "bufferView": 4}}],
|
||||
"accessors": [
|
||||
{{"bufferView": 0, "componentType": 5126, "count": 3, "type": "VEC3"}},
|
||||
{{"bufferView": 1, "componentType": 5126, "count": 3, "type": "VEC2"}},
|
||||
{{"bufferView": 2, "componentType": 5126, "count": 3, "type": "VEC3"}},
|
||||
{{"bufferView": 3, "componentType": 5123, "count": 3, "type": "SCALAR"}}
|
||||
],
|
||||
"bufferViews": [
|
||||
{{"buffer": 0, "byteOffset": 0, "byteLength": 36}},
|
||||
{{"buffer": 0, "byteOffset": 36, "byteLength": 24}},
|
||||
{{"buffer": 0, "byteOffset": 60, "byteLength": 36}},
|
||||
{{"buffer": 0, "byteOffset": 96, "byteLength": 6}},
|
||||
{{"buffer": 0, "byteOffset": {img_off}, "byteLength": {png_len}}}
|
||||
],
|
||||
"buffers": [{{"byteLength": {bin_len}}}]
|
||||
}}"#, img_off = img_off, png_len = png_bytes.len(), bin_len = bin.len());
|
||||
|
||||
let m = parse_glb(&glb(&json, &bin)).unwrap();
|
||||
|
||||
assert_eq!(m.textures.len(), 1);
|
||||
let t = &m.textures[0];
|
||||
assert_eq!(t.key, "boden_tex"); // glTF-Bildname, nicht Materialname
|
||||
let img = t.image.as_ref().expect("PNG dekodiert");
|
||||
assert_eq!((img.width, img.height), (2, 2));
|
||||
assert_eq!(&img.rgba[0..8], &[0, 0, 0, 255, 255, 0, 0, 255]);
|
||||
|
||||
// KHR_texture_transform eingebacken: UV (1,1) → (1·2 + 0.5, 1·4) = (2.5, 4.0).
|
||||
let uv = m.objects[0].uvs[2];
|
||||
assert!((uv[0] - 2.5).abs() < 1e-5 && (uv[1] - 4.0).abs() < 1e-5, "{uv:?}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
//! RGBA8-`Image` — der geteilte Pixel-Container der Engine, dazu der Decoder
|
||||
//! für eingebettete glTF-Bilder. Immer 32 bit, Ursprung oben-links, fertig
|
||||
//! konvertiert; der Aufrufer macht nur noch das Sampling (und damit die
|
||||
//! UV-Konvention) selbst.
|
||||
//!
|
||||
//! [`decode`] liest die Bilder, die Blender beim glTF-Export in die `.glb`
|
||||
//! packt; [`load`] dieselbe Sorte Bild von der Platte (UI, Fonts,
|
||||
//! Platzhalter). Beides PNG — ein Decoder für alles.
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Image {
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
/// `width * height * 4`, Ursprung oben-links.
|
||||
pub rgba: Vec<u8>,
|
||||
}
|
||||
|
||||
/// Eine PNG-Datei von der Platte laden.
|
||||
pub fn load(path: &str) -> Result<Image, String> {
|
||||
let bytes = std::fs::read(path).map_err(|e| format!("image load {path}: {e}"))?;
|
||||
decode(&bytes, "").map_err(|e| format!("image {path}: {e}"))
|
||||
}
|
||||
|
||||
/// Ein eingebettetes glTF-Bild dekodieren. `mime` ist der glTF-`mimeType`
|
||||
/// (darf leer sein — dann entscheidet die Datei-Signatur). Unterstützt wird
|
||||
/// nur PNG; JPEG/WebP werden gemeldet, nicht dekodiert.
|
||||
pub fn decode(bytes: &[u8], mime: &str) -> Result<Image, String> {
|
||||
const PNG_MAGIC: &[u8] = b"\x89PNG\r\n\x1a\n";
|
||||
let is_png = mime == "image/png" || (mime.is_empty() && bytes.starts_with(PNG_MAGIC));
|
||||
if !is_png {
|
||||
let what = if mime.is_empty() { "unbekanntes Format" } else { mime };
|
||||
return Err(format!("{what} — nur PNG (in Blender „Images: PNG“ beim glTF-Export)"));
|
||||
}
|
||||
decode_png(bytes)
|
||||
}
|
||||
|
||||
fn decode_png(bytes: &[u8]) -> Result<Image, String> {
|
||||
let mut decoder = png::Decoder::new(std::io::Cursor::new(bytes));
|
||||
// EXPAND hebt Palette/Low-Bit-Grau auf 8 bit, ALPHA erzwingt einen
|
||||
// Alpha-Kanal, STRIP_16 wirft die zweite Byte-Hälfte weg. Damit bleiben
|
||||
// als Ausgabe nur noch RGBA8 und Grau+Alpha8.
|
||||
decoder.set_transformations(
|
||||
png::Transformations::EXPAND | png::Transformations::ALPHA | png::Transformations::STRIP_16,
|
||||
);
|
||||
let mut reader = decoder.read_info().map_err(|e| format!("PNG: {e}"))?;
|
||||
let mut buf = vec![0u8; reader.output_buffer_size().ok_or("PNG: Bild zu groß")?];
|
||||
let info = reader.next_frame(&mut buf).map_err(|e| format!("PNG: {e}"))?;
|
||||
let (width, height) = (info.width, info.height);
|
||||
let src = &buf[..info.buffer_size()];
|
||||
let n = (width as usize) * (height as usize);
|
||||
|
||||
let rgba = match info.color_type {
|
||||
png::ColorType::Rgba => src.to_vec(),
|
||||
png::ColorType::GrayscaleAlpha => {
|
||||
let mut out = vec![0u8; n * 4];
|
||||
for i in 0..n {
|
||||
let (v, a) = (src[2 * i], src[2 * i + 1]);
|
||||
let o = i * 4;
|
||||
out[o] = v; out[o + 1] = v; out[o + 2] = v; out[o + 3] = a;
|
||||
}
|
||||
out
|
||||
}
|
||||
other => return Err(format!("PNG: unerwarteter Ausgabetyp {other:?}")),
|
||||
};
|
||||
Ok(Image { width, height, rgba })
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// Ein `w`×`h`-PNG mit gegebenem Farbtyp im Speicher erzeugen.
|
||||
fn png(w: u32, h: u32, color: png::ColorType, data: &[u8]) -> Vec<u8> {
|
||||
let mut out = Vec::new();
|
||||
let mut enc = png::Encoder::new(&mut out, w, h);
|
||||
enc.set_color(color);
|
||||
enc.set_depth(png::BitDepth::Eight);
|
||||
enc.write_header().unwrap().write_image_data(data).unwrap();
|
||||
out
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rgb_png_gets_opaque_alpha() {
|
||||
// 2×1, zwei RGB-Pixel.
|
||||
let bytes = png(2, 1, png::ColorType::Rgb, &[10, 20, 30, 40, 50, 60]);
|
||||
let img = decode(&bytes, "image/png").unwrap();
|
||||
assert_eq!((img.width, img.height), (2, 1));
|
||||
assert_eq!(img.rgba, vec![10, 20, 30, 255, 40, 50, 60, 255]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn grayscale_png_expands_to_rgba() {
|
||||
let bytes = png(2, 1, png::ColorType::Grayscale, &[128, 255]);
|
||||
let img = decode(&bytes, "").unwrap(); // mime leer → Signatur greift
|
||||
assert_eq!(img.rgba, vec![128, 128, 128, 255, 255, 255, 255, 255]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn non_png_is_reported_not_decoded() {
|
||||
assert!(decode(b"\xff\xd8\xff\xe0junk", "image/jpeg").is_err());
|
||||
assert!(decode(b"whatever", "").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn loads_the_real_project_assets() {
|
||||
for (path, w, h) in [
|
||||
("assets/textures/placeholder.png", 256, 256),
|
||||
("assets/textures/fonts/oldschool-ega-8x14.png", 256, 112),
|
||||
("assets/textures/fonts/oldschool-cga-8x8.png", 256, 64),
|
||||
("assets/textures/ui/cursors.png", 32, 32),
|
||||
("assets/textures/ui/panel_ornaments.png", 32, 32),
|
||||
] {
|
||||
let img = load(path).unwrap_or_else(|e| panic!("{path}: {e}"));
|
||||
assert_eq!((img.width, img.height), (w, h), "{path}");
|
||||
assert_eq!(img.rgba.len(), (w * h * 4) as usize, "{path}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,30 @@
|
||||
//! Dünner Adapter um die `bladeink`-Crate, gekoppelt an unseren `kv::Store`.
|
||||
//! Dünner Adapter um die `bladeink`-Crate — und die einzige Stelle im Kern,
|
||||
//! die sie kennt. `to_ink`/`from_ink` rechnen zwischen `kv::Value` und Inks
|
||||
//! `ValueType` um; alles andere spricht nur den neutralen KV-Typ.
|
||||
//!
|
||||
//! Bei jedem `cont()` läuft ein bidirektionaler Sync:
|
||||
//! - vor `continue`: KV-Werte ins `variables_state` der Story spiegeln
|
||||
//! (Skript sieht aktuelle Spielvariablen)
|
||||
//! - nach `continue`: alle KV-Keys, die das Skript kennt, zurücklesen
|
||||
//! (Ink-`~ var = …`-Writes landen im KV)
|
||||
//! - nach `continue`: **alle** im Skript deklarierten `VAR`s zurücklesen
|
||||
//! (Auto-Import). So wandern Werte wie `snaks` oder `favor_nails` ohne
|
||||
//! Registrierung automatisch ins nächste per `start_ink` verkettete
|
||||
//! Skript — die Autorin legt einfach `VAR`s an, die Engine trägt sie.
|
||||
//!
|
||||
//! Variablen die der KV kennt, das Skript aber nicht als `VAR` deklariert,
|
||||
//! lehnt bladeink beim `set_variable` ab — wir ignorieren das still.
|
||||
//! Variablen die nur im Skript existieren, werden beim Read-Back ignoriert
|
||||
//! (KV bleibt minimal: nur was Rust kennt).
|
||||
//! Ausnahme: `VAR`s mit `_`-Prefix sind skript-lokal und werden in keine
|
||||
//! Richtung synchronisiert. KV-Variablen, die das Skript nicht als `VAR`
|
||||
//! deklariert, lehnt bladeink beim `set_variable` ab — wir ignorieren das
|
||||
//! still.
|
||||
//!
|
||||
//! bladeink bietet keine öffentliche Enumeration der Globals; die
|
||||
//! Deklarationsliste wird deshalb beim Laden per Quelltext-Scan aus dem
|
||||
//! kompilierten JSON gezogen (siehe [`global_var_names`]).
|
||||
|
||||
use std::fs::read_to_string;
|
||||
|
||||
use bladeink::story::Story as BladeStory;
|
||||
use bladeink::value_type::ValueType;
|
||||
|
||||
use crate::engine::kv::Store;
|
||||
use crate::engine::kv::{Store, Value};
|
||||
|
||||
pub enum StoryState {
|
||||
Text(String),
|
||||
@@ -26,17 +35,59 @@ pub enum StoryState {
|
||||
pub struct Story {
|
||||
inner: BladeStory,
|
||||
tags: Vec<String>,
|
||||
/// Im Skript deklarierte globale `VAR`s (ohne `_`-lokale) — die Menge,
|
||||
/// die `sync_to_kv` in den KV exportiert.
|
||||
vars: Vec<String>,
|
||||
/// Skript-Pfad, nur für Fehlermeldungen.
|
||||
path: String,
|
||||
}
|
||||
|
||||
/// Alle globalen `VAR`-Namen aus kompiliertem Ink-JSON ziehen. Inklecate
|
||||
/// kodiert jede Global-Zuweisung — die Deklaration in `"global decl"` ebenso
|
||||
/// wie jedes `~ var = …` — als `{"VAR=":"name"}`; ein simpler Scan über den
|
||||
/// Quelltext findet also genau die Globals (temp-Variablen kodieren als
|
||||
/// `"temp="` und Reads als `"VAR?"`). `_`-Prefix = skript-lokal → aussortiert.
|
||||
fn global_var_names(src: &str) -> Vec<String> {
|
||||
const PAT: &str = "\"VAR=\":\"";
|
||||
let mut names: Vec<String> = Vec::new();
|
||||
let mut rest = src;
|
||||
while let Some(i) = rest.find(PAT) {
|
||||
rest = &rest[i + PAT.len()..];
|
||||
if let Some(end) = rest.find('"') {
|
||||
let name = &rest[..end];
|
||||
if !name.starts_with('_') && !names.iter().any(|n| n == name) {
|
||||
names.push(name.to_string());
|
||||
}
|
||||
rest = &rest[end..];
|
||||
}
|
||||
}
|
||||
names
|
||||
}
|
||||
|
||||
impl Story {
|
||||
pub fn load(path: &str, kv: &Store) -> Self {
|
||||
/// Lädt und parst ein Ink-Skript. Fehlende oder kaputte Datei liefert
|
||||
/// `Err(msg)` statt zu panicken — ein Tippfehler in einem `start_ink`-Tag
|
||||
/// darf das laufende Spiel nicht crashen; der Aufrufer meldet den Fehler.
|
||||
pub fn load(path: &str, kv: &Store) -> Result<Self, String> {
|
||||
let src = read_to_string(path)
|
||||
.unwrap_or_else(|e| panic!("ink load {}: {}", path, e));
|
||||
let inner = BladeStory::new(&src)
|
||||
.unwrap_or_else(|e| panic!("ink parse {}: {:?}", path, e));
|
||||
let mut s = Self { inner, tags: Vec::new() };
|
||||
.map_err(|e| format!("ink load {path}: {e}"))?;
|
||||
Self::from_src(&src, path, kv)
|
||||
}
|
||||
|
||||
/// Wie [`load`], nur direkt aus dem JSON-Quelltext — `path` dient
|
||||
/// ausschließlich Fehlermeldungen. Eigener Schritt, damit Tests ohne
|
||||
/// Dateisystem arbeiten können.
|
||||
fn from_src(src: &str, path: &str, kv: &Store) -> Result<Self, String> {
|
||||
let inner = BladeStory::new(src)
|
||||
.map_err(|e| format!("ink parse {path}: {e:?}"))?;
|
||||
let mut s = Self {
|
||||
inner,
|
||||
tags: Vec::new(),
|
||||
vars: global_var_names(src),
|
||||
path: path.to_string(),
|
||||
};
|
||||
s.sync_from_kv(kv);
|
||||
s
|
||||
Ok(s)
|
||||
}
|
||||
|
||||
pub fn take_tags(&mut self) -> Vec<String> { std::mem::take(&mut self.tags) }
|
||||
@@ -51,8 +102,16 @@ impl Story {
|
||||
// Text verloren.
|
||||
let mut text = String::new();
|
||||
while self.inner.can_continue() {
|
||||
let chunk = self.inner.cont()
|
||||
.unwrap_or_else(|e| panic!("ink cont: {:?}", e));
|
||||
// Runtime-Fehler (z.B. „ran out of content" bei einem Skript-Pfad
|
||||
// ohne Divert) beenden den Dialog und melden nach stderr — ein
|
||||
// Autoren-Fehler im Ink darf das laufende Spiel nicht crashen.
|
||||
let chunk = match self.inner.cont() {
|
||||
Ok(c) => c,
|
||||
Err(e) => {
|
||||
eprintln!("[ink] {}: {e:?}", self.path);
|
||||
return StoryState::End;
|
||||
}
|
||||
};
|
||||
text.push_str(&chunk);
|
||||
if let Ok(t) = self.inner.get_current_tags() {
|
||||
self.tags.extend(t);
|
||||
@@ -72,24 +131,114 @@ impl Story {
|
||||
}
|
||||
|
||||
pub fn choose(&mut self, i: usize) {
|
||||
self.inner.choose_choice_index(i)
|
||||
.unwrap_or_else(|e| panic!("ink choose {}: {:?}", i, e));
|
||||
// Fehler (z.B. Index außerhalb der Choices) nur melden — der nächste
|
||||
// `cont()` präsentiert dann denselben Zustand erneut.
|
||||
if let Err(e) = self.inner.choose_choice_index(i) {
|
||||
eprintln!("[ink] {}: choose {i}: {e:?}", self.path);
|
||||
}
|
||||
}
|
||||
|
||||
fn sync_from_kv(&mut self, kv: &Store) {
|
||||
for (name, value) in kv {
|
||||
if name.starts_with('_') { continue; } // skript-lokal
|
||||
// set_variable schlägt fehl wenn der Name kein deklariertes
|
||||
// VAR im Skript ist — still ignorieren.
|
||||
let _ = self.inner.set_variable(name, value);
|
||||
let _ = self.inner.set_variable(name, &to_ink(value));
|
||||
}
|
||||
}
|
||||
|
||||
/// Auto-Import: alle deklarierten `VAR`s des Skripts in den KV übernehmen
|
||||
/// (siehe Modul-Doc). Der KV wächst damit um jede neue Skript-Variable —
|
||||
/// genau so wandern Werte in per `start_ink` verkettete Folgeskripte.
|
||||
fn sync_to_kv(&self, kv: &mut Store) {
|
||||
let keys: Vec<String> = kv.keys().cloned().collect();
|
||||
for name in keys {
|
||||
if let Some(v) = self.inner.get_variable(&name) {
|
||||
kv.insert(name, v);
|
||||
for name in &self.vars {
|
||||
if let Some(v) = self.inner.get_variable(name).as_ref().and_then(from_ink) {
|
||||
kv.insert(name.clone(), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// [`Value`] → Inks `ValueType`. Zusammen mit [`from_ink`] die einzige Stelle,
|
||||
/// an der der Kern-KV die Story-Crate berührt.
|
||||
fn to_ink(v: &Value) -> ValueType {
|
||||
match v {
|
||||
Value::Bool(b) => ValueType::Bool(*b),
|
||||
Value::Int(i) => ValueType::Int(*i),
|
||||
Value::Float(f) => ValueType::Float(*f),
|
||||
Value::Str(s) => ValueType::new(s.as_str()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Inks `ValueType` → [`Value`]. `None` für Ink-eigene Typen (Listen, Divert-
|
||||
/// und Variablen-Referenzen), die im KV nichts verloren haben.
|
||||
fn from_ink(v: &ValueType) -> Option<Value> {
|
||||
Some(match v {
|
||||
ValueType::Bool(b) => Value::Bool(*b),
|
||||
ValueType::Int(i) => Value::Int(*i),
|
||||
ValueType::Float(f) => Value::Float(*f),
|
||||
ValueType::String(s) => Value::Str(s.string.clone()),
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
// Handkompiliertes Minimal-Ink (inklecate-Format wie cube.ink.json):
|
||||
// VAR snaks = 0
|
||||
// VAR _local = 0
|
||||
// S={snaks} → gibt den (ggf. aus dem KV gesyncten) Wert aus
|
||||
// ~ snaks = 1
|
||||
// ~ _local = 5
|
||||
// -> END
|
||||
const MINIMAL: &str = r##"{"inkVersion":21,"root":[["^S=","ev",{"VAR?":"snaks"},"out","/ev","\n","ev",1,{"VAR=":"snaks","re":true},"/ev","ev",5,{"VAR=":"_local","re":true},"/ev","end",["done",{"#n":"g-0"}],null],"done",{"global decl":["ev",0,{"VAR=":"snaks"},0,{"VAR=":"_local"},"/ev","end",null]}],"listDefs":{}}"##;
|
||||
|
||||
#[test]
|
||||
fn global_var_names_scans_dedupes_and_filters_locals() {
|
||||
let names = global_var_names(MINIMAL);
|
||||
assert_eq!(names, vec!["snaks"]); // dedupliziert, `_local` gefiltert
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn declared_vars_auto_import_into_kv() {
|
||||
// KV kennt `snaks` vorher nicht — nach dem Lauf steht es trotzdem
|
||||
// drin (Auto-Import), `_local` bleibt draußen.
|
||||
let mut kv = Store::new();
|
||||
let mut s = Story::from_src(MINIMAL, "test", &kv).unwrap();
|
||||
assert!(matches!(s.cont(&mut kv), StoryState::Text(_)));
|
||||
assert!(matches!(kv["snaks"], Value::Int(1)));
|
||||
assert!(!kv.contains_key("_local"), "_-Prefix ist skript-lokal");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kv_values_flow_into_the_script() {
|
||||
// Vorbelegter KV-Wert ist im Skript sichtbar (Sync vor `continue`).
|
||||
let mut kv = Store::new();
|
||||
kv.insert("snaks".into(), Value::Int(7));
|
||||
let mut s = Story::from_src(MINIMAL, "test", &kv).unwrap();
|
||||
match s.cont(&mut kv) {
|
||||
StoryState::Text(t) => assert_eq!(t, "S=7"),
|
||||
_ => panic!("erwartete Textzeile"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_error_ends_story_instead_of_panicking() {
|
||||
// Flow läuft ohne `done`/`end` aus (wie ein Skript-Pfad ohne Divert)
|
||||
// → bladeink meldet „ran out of content". Erwartung: End, kein Panic.
|
||||
let src = r#"{"inkVersion":21,"root":[["^Hi","\n",null],null],"listDefs":{}}"#;
|
||||
let mut kv = Store::new();
|
||||
let mut s = Story::from_src(src, "test", &kv).unwrap();
|
||||
assert!(matches!(s.cont(&mut kv), StoryState::End));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_choice_is_reported_not_fatal() {
|
||||
let mut kv = Store::new();
|
||||
let mut s = Story::from_src(MINIMAL, "test", &kv).unwrap();
|
||||
s.choose(3); // keine Choices vorhanden → Meldung, kein Panic
|
||||
assert!(matches!(s.cont(&mut kv), StoryState::Text(_)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,41 +3,68 @@
|
||||
//! Single Source of Truth für alle Spielvariablen (Quest-Flags, Inventar-
|
||||
//! Counter, Story-Beats). Ink-Skripte haben eigene `variables_state`-Stores;
|
||||
//! die werden bei jedem `cont()` mit diesem KV synchronisiert (siehe
|
||||
//! [`crate::engine::ink`]). Damit der KV authoritativ bleibt: externe Actions
|
||||
//! [`crate::engine::ink`]). Damit der KV autoritativ bleibt: externe Actions
|
||||
//! (`set`, `inc`, `clear`) ändern *immer* den KV, niemals direkt die Story.
|
||||
//!
|
||||
//! Wir nutzen `bladeink::ValueType` als Value, damit die Sync-Konvertierung
|
||||
//! gratis ist (kein Mapping zwischen Rust- und Ink-Typen nötig).
|
||||
//! [`Value`] ist ein eigener, Ink- und frontend-neutraler Typ. Die Umrechnung
|
||||
//! auf `bladeink::ValueType` passiert allein an der Ink-Grenze in
|
||||
//! [`crate::engine::ink`] — so hängt der Kern-KV nicht an der Story-Crate.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
|
||||
use bladeink::value_type::ValueType;
|
||||
pub type Store = HashMap<String, Value>;
|
||||
|
||||
pub type Store = HashMap<String, ValueType>;
|
||||
/// Ein KV-Wert. Deckt die Skalare ab, die signals.toml-Actions und Ink-`VAR`s
|
||||
/// austauschen; Ink-eigene Typen (Listen, Divert-Referenzen) haben hier
|
||||
/// bewusst keinen Platz.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum Value {
|
||||
Bool(bool),
|
||||
Int(i32),
|
||||
Float(f32),
|
||||
Str(String),
|
||||
}
|
||||
|
||||
/// Parst einen Action-Arg-String zu einem `ValueType`. Reihenfolge:
|
||||
/// `true`/`false` → Bool, dann i32, dann f32, sonst String.
|
||||
pub fn parse_value(s: &str) -> ValueType {
|
||||
let s = s.trim();
|
||||
match s {
|
||||
"true" => return ValueType::Bool(true),
|
||||
"false" => return ValueType::Bool(false),
|
||||
_ => {}
|
||||
impl Value {
|
||||
/// Als Ganzzahl lesen (für `inc`): `Bool` zählt als 0/1, `Float` schneidet
|
||||
/// ab, `Str` hat keinen Zahlwert. Spiegelt die Coercion, die vorher
|
||||
/// bladeink lieferte.
|
||||
pub fn as_int(&self) -> Option<i32> {
|
||||
match self {
|
||||
Value::Bool(b) => Some(*b as i32),
|
||||
Value::Int(i) => Some(*i),
|
||||
Value::Float(f) => Some(*f as i32),
|
||||
Value::Str(_) => None,
|
||||
}
|
||||
}
|
||||
if let Ok(i) = s.parse::<i32>() { return ValueType::Int(i); }
|
||||
if let Ok(f) = s.parse::<f32>() { return ValueType::Float(f); }
|
||||
ValueType::new(s)
|
||||
}
|
||||
|
||||
/// Menschenlesbare Darstellung für REPL-Dumps und Debug-Logs.
|
||||
pub fn format_value(v: &ValueType) -> String {
|
||||
match v {
|
||||
ValueType::Bool(b) => b.to_string(),
|
||||
ValueType::Int(i) => i.to_string(),
|
||||
ValueType::Float(f) => f.to_string(),
|
||||
other => other.coerce_to_string().unwrap_or_else(|_| "<?>".into()),
|
||||
impl fmt::Display for Value {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Value::Bool(b) => write!(f, "{b}"),
|
||||
Value::Int(i) => write!(f, "{i}"),
|
||||
Value::Float(x) => write!(f, "{x}"),
|
||||
Value::Str(s) => write!(f, "{s}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Parst einen Action-Arg-String zu einem [`Value`]. Reihenfolge:
|
||||
/// `true`/`false` → Bool, dann i32, dann f32, sonst String.
|
||||
pub fn parse_value(s: &str) -> Value {
|
||||
let s = s.trim();
|
||||
match s {
|
||||
"true" => return Value::Bool(true),
|
||||
"false" => return Value::Bool(false),
|
||||
_ => {}
|
||||
}
|
||||
if let Ok(i) = s.parse::<i32>() { return Value::Int(i); }
|
||||
if let Ok(x) = s.parse::<f32>() { return Value::Float(x); }
|
||||
Value::Str(s.to_string())
|
||||
}
|
||||
|
||||
pub fn apply_set(args: &str, store: &mut Store) {
|
||||
let Some((name, value)) = args.split_once(char::is_whitespace) else {
|
||||
@@ -51,8 +78,8 @@ pub fn apply_inc(args: &str, store: &mut Store) {
|
||||
let (name, delta) = args.split_once(char::is_whitespace).unwrap_or((args, "1"));
|
||||
let name = name.trim();
|
||||
let delta = delta.trim().parse::<i32>().unwrap_or(1);
|
||||
let cur = store.get(name).and_then(|v| v.coerce_to_int().ok()).unwrap_or(0);
|
||||
store.insert(name.to_string(), ValueType::Int(cur + delta));
|
||||
let cur = store.get(name).and_then(Value::as_int).unwrap_or(0);
|
||||
store.insert(name.to_string(), Value::Int(cur + delta));
|
||||
}
|
||||
|
||||
pub fn apply_clear(args: &str, store: &mut Store) {
|
||||
@@ -65,29 +92,37 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn parse_value_types() {
|
||||
assert!(matches!(parse_value("true"), ValueType::Bool(true)));
|
||||
assert!(matches!(parse_value("false"), ValueType::Bool(false)));
|
||||
assert!(matches!(parse_value("42"), ValueType::Int(42)));
|
||||
assert!(matches!(parse_value("-7"), ValueType::Int(-7)));
|
||||
assert!(matches!(parse_value("1.5"), ValueType::Float(f) if f == 1.5));
|
||||
assert!(matches!(parse_value("hallo"), ValueType::String(_)));
|
||||
assert!(matches!(parse_value("true"), Value::Bool(true)));
|
||||
assert!(matches!(parse_value("false"), Value::Bool(false)));
|
||||
assert!(matches!(parse_value("42"), Value::Int(42)));
|
||||
assert!(matches!(parse_value("-7"), Value::Int(-7)));
|
||||
assert!(matches!(parse_value("1.5"), Value::Float(f) if f == 1.5));
|
||||
assert!(matches!(parse_value("hallo"), Value::Str(_)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn as_int_coerces_like_ink_did() {
|
||||
assert_eq!(Value::Bool(true).as_int(), Some(1));
|
||||
assert_eq!(Value::Int(-7).as_int(), Some(-7));
|
||||
assert_eq!(Value::Float(2.9).as_int(), Some(2));
|
||||
assert_eq!(Value::Str("x".into()).as_int(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_inc_clear_roundtrip() {
|
||||
let mut s = Store::new();
|
||||
apply_set("clicks 3", &mut s);
|
||||
assert_eq!(s["clicks"].coerce_to_int().unwrap(), 3);
|
||||
assert_eq!(s["clicks"].as_int().unwrap(), 3);
|
||||
|
||||
apply_inc("clicks", &mut s);
|
||||
assert_eq!(s["clicks"].coerce_to_int().unwrap(), 4);
|
||||
assert_eq!(s["clicks"].as_int().unwrap(), 4);
|
||||
|
||||
apply_inc("clicks -2", &mut s);
|
||||
assert_eq!(s["clicks"].coerce_to_int().unwrap(), 2);
|
||||
assert_eq!(s["clicks"].as_int().unwrap(), 2);
|
||||
|
||||
// inc auf unbekannten Key startet bei 0
|
||||
apply_inc("fresh 5", &mut s);
|
||||
assert_eq!(s["fresh"].coerce_to_int().unwrap(), 5);
|
||||
assert_eq!(s["fresh"].as_int().unwrap(), 5);
|
||||
|
||||
apply_clear("clicks", &mut s);
|
||||
assert!(!s.contains_key("clicks"));
|
||||
@@ -99,4 +134,11 @@ mod tests {
|
||||
apply_set("only_name", &mut s);
|
||||
assert!(s.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn display_is_plain_scalar() {
|
||||
assert_eq!(Value::Bool(true).to_string(), "true");
|
||||
assert_eq!(Value::Int(-3).to_string(), "-3");
|
||||
assert_eq!(Value::Str("hi".into()).to_string(), "hi");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
//! Quake-`.map`-Parser (Standard-Format, wie TrenchBroom es mit dem
|
||||
//! Generic-Game exportiert).
|
||||
//!
|
||||
//! Struktur: eine Datei ist eine Liste von Entities `{...}`. Eine Entity
|
||||
//! hält Key/Value-Properties (`"key" "value"`) und null oder mehr Brushes
|
||||
//! `{...}`. Ein Brush ist eine Liste von Faces; jede Face ist eine Ebene
|
||||
//! aus drei Punkten plus Textur-Ausrichtung:
|
||||
//!
|
||||
//! ( x y z ) ( x y z ) ( x y z ) TEXTUR offX offY rot scaleX scaleY
|
||||
//!
|
||||
//! Hier wird nur geparst — Geometrie bleibt im Quake-Koordinatensystem
|
||||
//! (Z-up, Brush = Schnitt der Halbräume); die Umrechnung ins Engine-System
|
||||
//! und der Halbraum-Schnitt sind Sache des Konsumenten (render::brush).
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::fs::read_to_string;
|
||||
|
||||
pub struct Map {
|
||||
pub entities: Vec<Entity>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Entity {
|
||||
pub props: HashMap<String, String>,
|
||||
pub brushes: Vec<Brush>,
|
||||
}
|
||||
|
||||
impl Entity {
|
||||
// Wird beim Entity-/Metadaten-Schritt gebraucht (worldspawn vs. Props,
|
||||
// Signal-Bindung); bis dahin nur in Tests verwendet.
|
||||
#[allow(dead_code)]
|
||||
pub fn classname(&self) -> Option<&str> {
|
||||
self.props.get("classname").map(String::as_str)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Brush {
|
||||
pub faces: Vec<Face>,
|
||||
}
|
||||
|
||||
/// Eine Brush-Face: Ebene aus drei Punkten (Quake-Reihenfolge, im
|
||||
/// Uhrzeigersinn von vorn gesehen) plus Textur-Ausrichtung. Die
|
||||
/// Ausrichtungsfelder werden erst vom Textur-Schritt gebraucht.
|
||||
pub struct Face {
|
||||
pub plane: [[f32; 3]; 3],
|
||||
pub texture: String,
|
||||
#[allow(dead_code)]
|
||||
pub offset: [f32; 2],
|
||||
#[allow(dead_code)]
|
||||
pub rotation: f32,
|
||||
#[allow(dead_code)]
|
||||
pub scale: [f32; 2],
|
||||
}
|
||||
|
||||
pub fn load(path: &str) -> Map {
|
||||
let src = read_to_string(path).unwrap_or_else(|e| panic!("map load {path}: {e}"));
|
||||
parse(&src)
|
||||
}
|
||||
|
||||
pub fn parse(src: &str) -> Map {
|
||||
let mut entities = Vec::new();
|
||||
let mut cur_entity: Option<Entity> = None;
|
||||
let mut cur_brush: Option<Brush> = None;
|
||||
|
||||
for raw in src.lines() {
|
||||
// Kommentar (`// …`) abschneiden, dann trimmen.
|
||||
let line = match raw.split_once("//") {
|
||||
Some((code, _)) => code.trim(),
|
||||
None => raw.trim(),
|
||||
};
|
||||
if line.is_empty() { continue; }
|
||||
|
||||
match line {
|
||||
"{" => {
|
||||
// Erstes `{` öffnet eine Entity, ein weiteres einen Brush.
|
||||
if cur_entity.is_none() {
|
||||
cur_entity = Some(Entity::default());
|
||||
} else {
|
||||
cur_brush = Some(Brush { faces: Vec::new() });
|
||||
}
|
||||
}
|
||||
"}" => {
|
||||
if let Some(brush) = cur_brush.take() {
|
||||
cur_entity.as_mut().unwrap().brushes.push(brush);
|
||||
} else if let Some(entity) = cur_entity.take() {
|
||||
entities.push(entity);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
if let Some(brush) = cur_brush.as_mut() {
|
||||
if let Some(face) = parse_face(line) {
|
||||
brush.faces.push(face);
|
||||
}
|
||||
} else if let Some(entity) = cur_entity.as_mut() {
|
||||
if let Some((k, v)) = parse_property(line) {
|
||||
entity.props.insert(k, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Map { entities }
|
||||
}
|
||||
|
||||
/// `"key" "value"` — Wert darf leer sein.
|
||||
fn parse_property(line: &str) -> Option<(String, String)> {
|
||||
let mut it = line.split('"');
|
||||
it.next()?; // vor dem ersten "
|
||||
let key = it.next()?; // key
|
||||
it.next()?; // zwischen den Paaren
|
||||
let val = it.next()?; // value
|
||||
Some((key.to_string(), val.to_string()))
|
||||
}
|
||||
|
||||
/// `( x y z ) ( x y z ) ( x y z ) TEX offX offY rot sx sy`
|
||||
fn parse_face(line: &str) -> Option<Face> {
|
||||
let t: Vec<&str> = line.split_whitespace().collect();
|
||||
let mut i = 0;
|
||||
let mut plane = [[0.0f32; 3]; 3];
|
||||
for p in 0..3 {
|
||||
if *t.get(i)? != "(" { return None; }
|
||||
for k in 0..3 {
|
||||
plane[p][k] = t.get(i + 1 + k)?.parse().ok()?;
|
||||
}
|
||||
if *t.get(i + 4)? != ")" { return None; }
|
||||
i += 5;
|
||||
}
|
||||
let texture = (*t.get(i)?).to_string();
|
||||
let nums: Option<Vec<f32>> = t[i + 1..i + 6].iter().map(|s| s.parse().ok()).collect();
|
||||
let n = nums?;
|
||||
Some(Face {
|
||||
plane,
|
||||
texture,
|
||||
offset: [n[0], n[1]],
|
||||
rotation: n[2],
|
||||
scale: [n[3], n[4]],
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
const SAMPLE: &str = r#"
|
||||
// entity 0
|
||||
{
|
||||
"classname" "worldspawn"
|
||||
"wad" ""
|
||||
// brush 0
|
||||
{
|
||||
( -48 -64 -48 ) ( -48 -63 -48 ) ( -48 -64 -47 ) placeholder 32 -32 0 1 1
|
||||
( -48 -64 -48 ) ( -48 -64 -47 ) ( -47 -64 -48 ) placeholder -16 -32 0 1 1
|
||||
( -48 -64 -48 ) ( -47 -64 -48 ) ( -48 -63 -48 ) placeholder -16 -32 0 1 1
|
||||
( 80 64 -16 ) ( 80 65 -16 ) ( 81 64 -16 ) placeholder -16 -32 0 1 1
|
||||
( 80 64 -16 ) ( 81 64 -16 ) ( 80 64 -15 ) placeholder -16 -32 0 1 1
|
||||
( 80 64 -16 ) ( 80 64 -15 ) ( 80 65 -16 ) placeholder 32 -32 0 1 1
|
||||
}
|
||||
}
|
||||
"#;
|
||||
|
||||
#[test]
|
||||
fn parses_entity_brush_and_face() {
|
||||
let m = parse(SAMPLE);
|
||||
assert_eq!(m.entities.len(), 1);
|
||||
let e = &m.entities[0];
|
||||
assert_eq!(e.classname(), Some("worldspawn"));
|
||||
assert_eq!(e.props.get("wad").map(String::as_str), Some(""));
|
||||
assert_eq!(e.brushes.len(), 1);
|
||||
let b = &e.brushes[0];
|
||||
assert_eq!(b.faces.len(), 6);
|
||||
|
||||
let f = &b.faces[0];
|
||||
assert_eq!(f.texture, "placeholder");
|
||||
assert_eq!(f.plane[0], [-48.0, -64.0, -48.0]);
|
||||
assert_eq!(f.plane[2], [-48.0, -64.0, -47.0]);
|
||||
assert_eq!(f.offset, [32.0, -32.0]);
|
||||
assert_eq!(f.scale, [1.0, 1.0]);
|
||||
}
|
||||
}
|
||||
@@ -3,29 +3,41 @@
|
||||
//! Schicht-Regel: `engine` kennt keine Frontends. Nach außen kommuniziert
|
||||
//! der Kern nur über Rückgabewerte (`StoryState`, Tags) und die
|
||||
//! [`game::Action`]-Queue — niemals über Aufrufe in Frontend-Module.
|
||||
//! Frontends (CLI-REPL jetzt, Renderer später) sind Geschwister-Module,
|
||||
//! die `engine` konsumieren; die Richtung kehrt sich nie um.
|
||||
//!
|
||||
//! Interner Abhängigkeitsgraph (azyklisch, Pfeil = „benutzt"):
|
||||
//! Interner Abhängigkeitsgraph (azyklisch halten, Pfeil = „benutzt"):
|
||||
//!
|
||||
//! kv ← ink ← game ← story_ctrl ← signals
|
||||
//! ↑ ↑
|
||||
//! kv assets
|
||||
//!
|
||||
//! Bitte azyklisch halten: neue Querverbindungen lieber über Rückgabewerte
|
||||
//! an den Aufrufer lösen (so wie story_ctrl Tags zurückgibt, statt selbst
|
||||
//! signals::dispatch zu rufen).
|
||||
//! Neue Querverbindungen lieber über Rückgabewerte an den Aufrufer lösen —
|
||||
//! so wie story_ctrl Tags zurückgibt, statt selbst `signals::dispatch` zu
|
||||
//! rufen.
|
||||
//!
|
||||
//! `map` und `tga` sind reine Decoder (Bytes → owned Daten, hängen an
|
||||
//! nichts) — die geteilte Heimat für Format-Dekodierung, die jedes Frontend
|
||||
//! per Pull konsumiert. `map` ist zugleich der Anfang des headless
|
||||
//! Datenmodells (Phase 2 des Renderer-Plans).
|
||||
//! `gltf`, `image` und `wav` sind reine Decoder (Bytes → owned Daten);
|
||||
//! `gltf` ist DER 3D-Pfad und produziert das `model::Model`, den Vertrag
|
||||
//! zwischen Loader und seinen Konsumenten (collision, trigger, audio,
|
||||
//! render::props) — samt der Welt-Texturen, die als PNG in der `.glb` liegen.
|
||||
//! `image` dekodiert PNG (eingebettet wie von der Platte) und stellt den
|
||||
//! RGBA8-`Image`-Typ für alle.
|
||||
//! `scene` lädt einen Szenenordner (`assets/maps/<name>/`) zu Modellen und
|
||||
//! wählt den Spawn; was daraus Sim-Welt wird, entscheidet `session`.
|
||||
//! `audio` ist die Emitter-Logik zum Frontend-Treiber render::audio, `player`
|
||||
//! die First-Person-Physik auf der Welt aus `collision`. Post-Effekte kennt
|
||||
//! der Kern nur als `game::Action::SetPost` — die Kette lebt in render::post.
|
||||
|
||||
pub mod assets;
|
||||
pub mod audio;
|
||||
pub mod collision;
|
||||
pub mod game;
|
||||
pub mod gltf;
|
||||
pub mod image;
|
||||
pub mod ink;
|
||||
pub mod kv;
|
||||
pub mod map;
|
||||
pub mod model;
|
||||
pub mod player;
|
||||
pub mod scene;
|
||||
pub mod signals;
|
||||
pub mod story_ctrl;
|
||||
pub mod tga;
|
||||
pub mod trigger;
|
||||
pub mod wav;
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
//! Das geparste Blender-Modell: Ergebnis des Loaders (engine::gltf) und der
|
||||
//! Vertrag, auf den sich seine Konsumenten stützen — collision, trigger,
|
||||
//! audio, render::props und session::enter_scene arbeiten alle auf dieser
|
||||
//! einen Struktur, statt selbst glTF zu lesen. Eine Entkopplungsgrenze
|
||||
//! zwischen dem einen Loader und seinen Konsumenten, keine Format-Abstraktion:
|
||||
//! glTF ist der einzige 3D-Pfad (die OBJ- und Map-Loader-Pfade sind
|
||||
//! Geschichte), `gltf` der einzige Produzent.
|
||||
//!
|
||||
//! Texturen kommen als Pixel mit — der Loader zieht sie aus der `.glb`
|
||||
//! (baseColorTexture, PNG-Chunk im BIN), siehe [`Texture`]. Keine externe
|
||||
//! Namenskonvention mehr.
|
||||
//!
|
||||
//! Was ein Objekt *ist*, steuern seine Blender-Custom-Properties (keine
|
||||
//! Namens-Präfixe — Namen bleiben frei für die Autorin), siehe
|
||||
//! [`apply_props`]:
|
||||
//! `collide = true` → sichtbar **und** Collider (konvexe Hülle des
|
||||
//! Meshes, siehe collision::object_planes)
|
||||
//! `collide = "proxy"` → unsichtbarer Collider (reines Kollisionsvolumen)
|
||||
//! `signal = <name>` → Trigger; mit Collider Klick-Ziel, ohne Collider
|
||||
//! unsichtbare Betretens-Zone (engine::trigger)
|
||||
//! nichts davon → nur sichtbar
|
||||
//!
|
||||
//! Objektnamen sind zugleich die Interact-Keys: Blender-Suffixe
|
||||
//! (`Thing.001`) strippt `signals::signal_key` beim Dispatch, nicht hier —
|
||||
//! der Loader bleibt frei von Signal-Wissen.
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::engine::image::Image;
|
||||
|
||||
/// Blender-Custom-Properties eines Objekts/Empties (glTF-`extras`),
|
||||
/// Werte zu Strings vereinheitlicht.
|
||||
pub type Props = HashMap<String, String>;
|
||||
|
||||
pub struct Model {
|
||||
pub objects: Vec<Object>,
|
||||
/// Nodes ohne Mesh (Blender-Empties) — der Entity-Kanal: Marker für
|
||||
/// Spawn-Punkte, Trigger o.Ä., Bedeutung geben künftige Konsumenten.
|
||||
pub empties: Vec<Empty>,
|
||||
/// Distinkte Texturen in Auftrittsreihenfolge; `Object::tri_mats`
|
||||
/// indiziert hierhin.
|
||||
pub textures: Vec<Texture>,
|
||||
}
|
||||
|
||||
/// Eine baseColorTexture aus der `.glb` (bzw. ein Material ohne Bild).
|
||||
pub struct Texture {
|
||||
/// Dedup-/Log-Schlüssel: der glTF-Bildname (Blender: Name des
|
||||
/// Bild-Datablocks), sonst der Materialname, sonst `""`. Texturen mit
|
||||
/// gleichem Schlüssel — auch über mehrere `.glb` — teilen sich auf der
|
||||
/// GPU eine Textur.
|
||||
pub key: String,
|
||||
/// Dekodierte Pixel (RGBA8, Ursprung oben links). `None`: Material ohne
|
||||
/// baseColorTexture oder unlesbares Bild → der Konsument nimmt seine
|
||||
/// Platzhalter-Textur.
|
||||
pub image: Option<Image>,
|
||||
}
|
||||
|
||||
pub struct Object {
|
||||
pub name: String,
|
||||
/// Positionen in Engine-Koords (Y-up, Blick −Z), Welt-Raum (Transforms
|
||||
/// vom Loader eingebacken), Maßstab 1:1 (Blender-Meter = Engine-Unit).
|
||||
pub verts: Vec<[f32; 3]>,
|
||||
/// UVs parallel zu `verts`, V-Ursprung oben links — glTF- und zugleich
|
||||
/// `image::Image`-Konvention, direkt sampelbar ohne Flip.
|
||||
pub uvs: Vec<[f32; 2]>,
|
||||
/// Normalen parallel zu `verts`, normiert, Welt-Raum. Fehlen sie im
|
||||
/// Modell, rechnet der Loader sie aus den Flächen.
|
||||
pub normals: Vec<[f32; 3]>,
|
||||
pub tris: Vec<[usize; 3]>,
|
||||
/// Textur-Index je Dreieck, parallel zu `tris` (→ `Model::textures`).
|
||||
pub tri_mats: Vec<usize>,
|
||||
pub visible: bool,
|
||||
pub collider: bool,
|
||||
pub props: Props,
|
||||
}
|
||||
|
||||
pub struct Empty {
|
||||
pub name: String,
|
||||
/// Welt-Position (Engine-Koords).
|
||||
pub pos: [f32; 3],
|
||||
/// Blickrichtung (normiert, Welt-Raum): die lokale −Z-Achse des Nodes,
|
||||
/// in Blender also die grüne +Y-Achse des Empties. Unrotiert = −Z, der
|
||||
/// Engine-Blick bei Yaw 0 — alte Spawns schauen weiter wie bisher.
|
||||
pub dir: [f32; 3],
|
||||
pub props: Props,
|
||||
}
|
||||
|
||||
/// Custom-Property-Schlüssel, der ein Objekt zum Collider macht (siehe
|
||||
/// Modul-Doc): truthy (`true`, `1`, …) = sichtbar + Collider, `"proxy"` =
|
||||
/// unsichtbarer Collider. `0`/`false`/`no`/leer zählen als aus, damit die
|
||||
/// Autorin die Property abschalten kann, ohne sie zu löschen.
|
||||
pub const COLLIDE_PROP: &str = "collide";
|
||||
|
||||
/// Custom-Property-Schlüssel, der ein Objekt zum Trigger macht (Wert =
|
||||
/// Signal-Name für `signals::dispatch`). Die Collider-Frage entscheidet die
|
||||
/// Semantik — anfassbar = klickbar, durchlaufbar = Betretens-Zone:
|
||||
/// `collide` + `signal` → solide **und** klickbar (Point-and-Click)
|
||||
/// nur `signal` → unsichtbare Trigger-Zone, feuert beim Betreten
|
||||
/// (einmal je Eintritt; erneut erst nach Verlassen)
|
||||
pub const SIGNAL_PROP: &str = "signal";
|
||||
|
||||
/// Custom-Property-Schlüssel für Empty-Rollen (der Entity-Kanal):
|
||||
/// `role = "spawn"` markiert den Spieler-Startpunkt (Fußpunkt =
|
||||
/// Empty-Position). Weitere Rollen geben künftige Konsumenten.
|
||||
pub const ROLE_PROP: &str = "role";
|
||||
pub const ROLE_SPAWN: &str = "spawn";
|
||||
|
||||
/// Auf Länge 1 bringen; der Nullvektor bleibt der Nullvektor (Sentinel für
|
||||
/// „noch keine Normale" in [`fill_missing_normals`]).
|
||||
pub fn norm(v: [f32; 3]) -> [f32; 3] {
|
||||
let l = (v[0] * v[0] + v[1] * v[1] + v[2] * v[2]).sqrt();
|
||||
if l > 0.0 { [v[0] / l, v[1] / l, v[2] / l] } else { v }
|
||||
}
|
||||
|
||||
/// Fehlende Normalen (Nullvektoren) aus den angrenzenden Flächen füllen —
|
||||
/// glTF erlaubt Meshes ohne `NORMAL`. Die Flächennormalen werden je Vertex
|
||||
/// aufsummiert, was an Kanten weich mittelt; Alternative wäre, die Vertices
|
||||
/// je Fläche aufzuspalten (hartes Flat-Shading) — dafür ist der Look hier
|
||||
/// nicht empfindlich genug.
|
||||
pub fn fill_missing_normals(o: &mut Object) {
|
||||
if !o.normals.contains(&[0.0; 3]) { return; }
|
||||
let mut acc = vec![[0.0f32; 3]; o.verts.len()];
|
||||
for t in &o.tris {
|
||||
let (a, b, c) = (o.verts[t[0]], o.verts[t[1]], o.verts[t[2]]);
|
||||
let u = [b[0] - a[0], b[1] - a[1], b[2] - a[2]];
|
||||
let v = [c[0] - a[0], c[1] - a[1], c[2] - a[2]];
|
||||
let n = [
|
||||
u[1] * v[2] - u[2] * v[1],
|
||||
u[2] * v[0] - u[0] * v[2],
|
||||
u[0] * v[1] - u[1] * v[0],
|
||||
];
|
||||
for &i in t {
|
||||
for k in 0..3 { acc[i][k] += n[k]; }
|
||||
}
|
||||
}
|
||||
for (i, n) in o.normals.iter_mut().enumerate() {
|
||||
if *n == [0.0; 3] { *n = norm(acc[i]); }
|
||||
}
|
||||
}
|
||||
|
||||
/// Die Property-Regeln anwenden, sobald `props` gelesen sind (Objekte
|
||||
/// starten sichtbar und ohne Collider): `collide` schaltet den Collider,
|
||||
/// `"proxy"` und Betretens-Zonen sind reine Volumen und werden nie gerendert.
|
||||
pub fn apply_props(o: &mut Object) {
|
||||
if let Some(v) = o.props.get(COLLIDE_PROP) {
|
||||
let v = v.to_ascii_lowercase();
|
||||
if !matches!(v.as_str(), "" | "0" | "false" | "no") {
|
||||
o.collider = true;
|
||||
if v == "proxy" { o.visible = false; }
|
||||
}
|
||||
}
|
||||
if !o.collider && o.props.contains_key(SIGNAL_PROP) {
|
||||
o.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// Test-Helfer: Einheitswürfel-Objekt bei `min..min+1` (Quads CCW von außen,
|
||||
/// Fan-trianguliert wie der Loader) mit optionalen `collide`-/`signal`-
|
||||
/// Properties — geteilt von trigger-/session-/collision-Tests.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn test_cube(name: &str, min: [f32; 3], collide: Option<&str>, signal: Option<&str>) -> Object {
|
||||
let v = |dx: f32, dy: f32, dz: f32| [min[0] + dx, min[1] + dy, min[2] + dz];
|
||||
let verts = vec![
|
||||
v(0.0, 0.0, 0.0), v(1.0, 0.0, 0.0), v(1.0, 1.0, 0.0), v(0.0, 1.0, 0.0),
|
||||
v(0.0, 0.0, 1.0), v(1.0, 0.0, 1.0), v(1.0, 1.0, 1.0), v(0.0, 1.0, 1.0),
|
||||
];
|
||||
let quads = [
|
||||
[4, 5, 6, 7], [0, 3, 2, 1], [1, 2, 6, 5],
|
||||
[0, 4, 7, 3], [3, 7, 6, 2], [0, 1, 5, 4],
|
||||
];
|
||||
let mut tris = Vec::new();
|
||||
for q in quads {
|
||||
tris.push([q[0], q[1], q[2]]);
|
||||
tris.push([q[0], q[2], q[3]]);
|
||||
}
|
||||
let n = tris.len();
|
||||
let mut props = Props::new();
|
||||
if let Some(c) = collide { props.insert(COLLIDE_PROP.into(), c.into()); }
|
||||
if let Some(s) = signal { props.insert(SIGNAL_PROP.into(), s.into()); }
|
||||
let mut o = Object {
|
||||
name: name.into(),
|
||||
uvs: vec![[0.0, 0.0]; verts.len()],
|
||||
// Vom Mittelpunkt nach außen — die Collider-Tests rendern nie, aber
|
||||
// so ist die Richtung wenigstens plausibel.
|
||||
normals: verts.iter()
|
||||
.map(|v| norm([v[0] - min[0] - 0.5, v[1] - min[1] - 0.5, v[2] - min[2] - 0.5]))
|
||||
.collect(),
|
||||
verts, tris,
|
||||
tri_mats: vec![0; n],
|
||||
visible: true, collider: false, props,
|
||||
};
|
||||
apply_props(&mut o);
|
||||
o
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn collide_prop_rules() {
|
||||
// truthy → sichtbar + Collider; "proxy" → unsichtbarer Collider.
|
||||
let o = test_cube("Kiste", [0.0; 3], Some("true"), None);
|
||||
assert!(o.visible && o.collider);
|
||||
let o = test_cube("Wand", [0.0; 3], Some("proxy"), None);
|
||||
assert!(!o.visible && o.collider);
|
||||
// Abschaltwerte zählen als aus; ohne Property nur sichtbar.
|
||||
let o = test_cube("Aus", [0.0; 3], Some("0"), None);
|
||||
assert!(o.visible && !o.collider);
|
||||
let o = test_cube("Deko", [0.0; 3], None, None);
|
||||
assert!(o.visible && !o.collider);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signal_without_collider_is_invisible_zone() {
|
||||
let o = test_cube("Zone", [0.0; 3], None, Some("betreten"));
|
||||
assert!(!o.visible && !o.collider);
|
||||
// Mit Collider bleibt das Objekt sichtbar (Klick-Ziel).
|
||||
let o = test_cube("Kiste", [0.0; 3], Some("1"), Some("kiste"));
|
||||
assert!(o.visible && o.collider);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,618 @@
|
||||
//! First-Person-Player: headless Bewegungsphysik.
|
||||
//!
|
||||
//! `step` sweept die Spieler-AABB gegen die [`CollisionWorld`] und gleitet an
|
||||
//! Treffern entlang (move-and-slide). Getract wird der Box-Mittelpunkt
|
||||
//! (Fußpunkt + halbe Höhe), danach geht es zurück auf den Fußpunkt.
|
||||
//! Bodenkontakt fällt aus nach oben zeigenden Trefferflächen ab. `fly` ist der
|
||||
//! Noclip-Gegenpart ohne Welt.
|
||||
//!
|
||||
//! Der Renderer leitet seine View hier ab (`Mat4::view(eye, yaw, pitch)`), der
|
||||
//! Player kennt ihn nie. Konvention: yaw=0 blickt −Z, positiver Yaw dreht nach
|
||||
//! links, positiver Pitch hebt den Blick. Gelaufen wird horizontal aus dem Yaw
|
||||
//! — Hochschauen hebt nicht ab, Fliegen dagegen folgt dem vollen Blick.
|
||||
|
||||
use crate::engine::collision::CollisionWorld;
|
||||
|
||||
/// Augenhöhe über dem Fußpunkt (units). Der Renderer setzt die Kamera auf
|
||||
/// `pos + [0, EYE_HEIGHT, 0]`. 1 Engine-Unit = 1 m (= 1 Blender-Meter).
|
||||
pub const EYE_HEIGHT: f32 = 1.6;
|
||||
|
||||
/// Fallbeschleunigung (units/s²). Über realem g für knackiges Spielgefühl.
|
||||
const GRAVITY: f32 = 20.0;
|
||||
/// Laufgeschwindigkeit (units/s). 1 Engine-Unit = 1 m (= 1 Blender-Meter).
|
||||
const WALK_SPEED: f32 = 5.0;
|
||||
/// Absprunggeschwindigkeit (units/s) — bestimmt die Sprunghöhe.
|
||||
const JUMP_SPEED: f32 = 7.0;
|
||||
/// Flug-Geschwindigkeit im Noclip (units/s).
|
||||
const FLY_SPEED: f32 = 4.0;
|
||||
/// Knapp unter 90°: hält den Blick aus der Senkrechten (wie `camera.rs`).
|
||||
const PITCH_LIMIT: f32 = 1.55;
|
||||
/// Halbmaße der Spieler-AABB (units): 0.6 m breit/tief, 1.8 m hoch.
|
||||
/// Öffentlich, weil die Session dieselbe Box gegen Trigger-Zonen prüft.
|
||||
pub const HALF_EXTENTS: [f32; 3] = [0.3, 0.9, 0.3];
|
||||
/// Grenzwinkel für begehbaren Boden, als Kosinus (= Y-Komponente der
|
||||
/// Trefferormale einer Fläche mit diesem Neigungswinkel). 0.7 ≈ **45°**:
|
||||
/// flacher wird gelaufen, steiler wird gerutscht. Das ist *der* Regler fürs
|
||||
/// Hangverhalten — Wunschwinkel als Kosinus eintragen (30° → 0.866,
|
||||
/// 50° → 0.643, 60° → 0.5).
|
||||
const GROUND_NORMAL_Y: f32 = 0.7;
|
||||
/// Slide-Iterationen pro Schritt (Wände, Ecken, Boden zugleich).
|
||||
const MAX_SLIDES: u32 = 4;
|
||||
/// Wie weit der Ground-Snap nach unten sucht (units). Überbrückt Stufen,
|
||||
/// abwärts-Slopes und Brush-Nähte, ohne echte Abgründe zu „verschlucken".
|
||||
const SNAP_DIST: f32 = 0.5;
|
||||
/// Maximale Stufenhöhe, die der Spieler ohne Sprung übersteigt (units).
|
||||
const STEP_HEIGHT: f32 = 0.5;
|
||||
|
||||
pub struct Player {
|
||||
/// Fußpunkt in Engine-Koords (Y-up).
|
||||
pub pos: [f32; 3],
|
||||
/// Geschwindigkeit in units/s (Y trägt Gravitation/Sprung).
|
||||
pub vel: [f32; 3],
|
||||
pub yaw: f32,
|
||||
pub pitch: f32,
|
||||
/// Steht auf Boden? Setzt der Boden-/Collision-Schritt; Gattung für Sprung.
|
||||
pub grounded: bool,
|
||||
}
|
||||
|
||||
impl Player {
|
||||
pub fn new(pos: [f32; 3]) -> Self {
|
||||
Self { pos, vel: [0.0; 3], yaw: 0.0, pitch: 0.0, grounded: false }
|
||||
}
|
||||
|
||||
/// Roh-Maus-Delta (Pixel) → Yaw/Pitch, identisch zu `camera::apply_mouse`,
|
||||
/// damit Bewegung und Bild dieselbe Konvention teilen.
|
||||
pub fn look(&mut self, dx: f32, dy: f32, sens: f32) {
|
||||
self.yaw -= dx * sens;
|
||||
self.pitch = (self.pitch - dy * sens).clamp(-PITCH_LIMIT, PITCH_LIMIT);
|
||||
}
|
||||
|
||||
/// Blick auf eine Richtung ausrichten (Umkehrung von [`Player::look_dir`]),
|
||||
/// Pitch wie beim Maus-Look begrenzt — für Spawn-Empties.
|
||||
pub fn face(&mut self, dir: [f32; 3]) {
|
||||
self.yaw = (-dir[0]).atan2(-dir[2]);
|
||||
self.pitch = dir[1].clamp(-1.0, 1.0).asin().clamp(-PITCH_LIMIT, PITCH_LIMIT);
|
||||
}
|
||||
|
||||
/// Augenpunkt (Fußpunkt + [`EYE_HEIGHT`]) — Kamera- und Hörposition,
|
||||
/// Startpunkt des Point-and-Click-Strahls.
|
||||
pub fn eye(&self) -> [f32; 3] {
|
||||
[self.pos[0], self.pos[1] + EYE_HEIGHT, self.pos[2]]
|
||||
}
|
||||
|
||||
/// Blickrichtung inkl. Pitch — dieselbe Formel wie `math::view`. Trägt den
|
||||
/// Point-and-Click-Strahl aus der Bildmitte und das Vorwärts im Noclip.
|
||||
pub fn look_dir(&self) -> [f32; 3] {
|
||||
let (sy, cy) = self.yaw.sin_cos();
|
||||
let (sp, cp) = self.pitch.sin_cos();
|
||||
[-sy * cp, sp, -cy * cp]
|
||||
}
|
||||
|
||||
/// Horizontales Rechts (ohne Pitch) — Strafen kippt nie mit dem Blick.
|
||||
pub fn right_dir(&self) -> [f32; 3] {
|
||||
let (sy, cy) = self.yaw.sin_cos();
|
||||
[cy, 0.0, -sy]
|
||||
}
|
||||
|
||||
/// Noclip: frei durch die Welt, ohne Kollision und ohne Gravitation.
|
||||
/// Vorwärts folgt dem vollen Blick, `up` ist Welt-Y (Auf-/Absteigen bleibt
|
||||
/// unabhängig vom Blickwinkel).
|
||||
pub fn fly(&mut self, fwd: f32, right: f32, up: f32, dt: f32) {
|
||||
let (f, r) = (self.look_dir(), self.right_dir());
|
||||
for i in 0..3 {
|
||||
self.pos[i] += (f[i] * fwd + r[i] * right) * FLY_SPEED * dt;
|
||||
}
|
||||
self.pos[1] += up * FLY_SPEED * dt;
|
||||
self.vel = [0.0; 3];
|
||||
self.grounded = false;
|
||||
}
|
||||
|
||||
/// Einen Physikschritt integrieren. `world` ist die Brush-Kollisionswelt,
|
||||
/// `fwd`/`right` Tastenachsen in [-1, 1], `jump` ein Flankensignal (true =
|
||||
/// Sprungtaste diesen Frame), `dt` die Frame-Zeit in Sekunden.
|
||||
pub fn step(&mut self, world: &CollisionWorld, fwd: f32, right: f32, jump: bool, dt: f32) {
|
||||
let was_grounded = self.grounded;
|
||||
|
||||
// Wunschgeschwindigkeit sofort setzen — ohne Beschleunigung/Reibung,
|
||||
// mit voller Luftkontrolle. Vorwärts ist der flache Blick, damit
|
||||
// Hochschauen nicht abhebt.
|
||||
let (sy, cy) = self.yaw.sin_cos();
|
||||
let r = self.right_dir();
|
||||
self.vel[0] = (-sy * fwd + r[0] * right) * WALK_SPEED;
|
||||
self.vel[2] = (-cy * fwd + r[2] * right) * WALK_SPEED;
|
||||
|
||||
// Sprung nur vom Boden — kein Doppelsprung. Gravitation wirkt nur in
|
||||
// der Luft: am Boden bliebe sonst nach der Slide-Projektion ein
|
||||
// hangparalleler Rest stehen, der sich über die Frames zum Hangabtrieb
|
||||
// aufschaukelt. Steiler als [`GROUND_NORMAL_Y`] ist `grounded` ohnehin
|
||||
// nicht gesetzt — dort greift der Luft-Zweig und man rutscht ab.
|
||||
let jumped = jump && was_grounded;
|
||||
if jumped {
|
||||
self.vel[1] = JUMP_SPEED;
|
||||
self.grounded = false;
|
||||
} else if was_grounded {
|
||||
self.vel[1] = 0.0;
|
||||
} else {
|
||||
self.vel[1] -= GRAVITY * dt;
|
||||
}
|
||||
|
||||
self.move_and_slide(world, dt);
|
||||
|
||||
// Ground-Snap: stand er eben noch am Boden und schwebt nach dem Zug
|
||||
// knapp darüber (abwärts-Slope, Stufe runter, Brush-Naht), ziehen wir
|
||||
// ihn hinunter. Nicht beim Aufsteigen — sonst gäbe es keine
|
||||
// Rampen-Absprünge mehr.
|
||||
if was_grounded && !jumped && !self.grounded && self.vel[1] <= 0.0 {
|
||||
self.snap_to_ground(world);
|
||||
}
|
||||
}
|
||||
|
||||
/// Die Box senkrecht bis zu [`SNAP_DIST`] nach unten tracen; trifft sie
|
||||
/// dabei echten Boden, den Spieler dorthin heften und `grounded` setzen.
|
||||
fn snap_to_ground(&mut self, world: &CollisionWorld) {
|
||||
let half = HALF_EXTENTS;
|
||||
let center = [self.pos[0], self.pos[1] + half[1], self.pos[2]];
|
||||
let down = [center[0], center[1] - SNAP_DIST, center[2]];
|
||||
let Some(hit) = world.trace(center, down, half) else { return; };
|
||||
if hit.normal[1] <= GROUND_NORMAL_Y { return; } // nur Boden, keine Wand
|
||||
self.pos[1] = (center[1] - SNAP_DIST * hit.frac) - half[1];
|
||||
self.grounded = true;
|
||||
if self.vel[1] < 0.0 { self.vel[1] = 0.0; }
|
||||
}
|
||||
|
||||
/// Den Box-Mittelpunkt gegen die Welt bewegen, mit Step-up. Aktualisiert
|
||||
/// `pos`, `vel` und `grounded`.
|
||||
///
|
||||
/// Zuerst ein flacher Slide. Steht der Spieler am Boden, wird zusätzlich
|
||||
/// der Step-up probiert: hoch um [`STEP_HEIGHT`], horizontal sliden, wieder
|
||||
/// runter auf Boden. Kommt das horizontal weiter und endet auf begehbarem
|
||||
/// Boden, gewinnt es. Das hebt die flache Box-Unterkante über Brush-Nähte
|
||||
/// (Slope-Kanten, Stufen), an denen sie sonst als „Wand" verkantet.
|
||||
fn move_and_slide(&mut self, world: &CollisionWorld, dt: f32) {
|
||||
let half = HALF_EXTENTS;
|
||||
let was_grounded = self.grounded; // in step() vor dem Sprung gesetzt
|
||||
let start = [self.pos[0], self.pos[1] + half[1], self.pos[2]];
|
||||
|
||||
let (flat_c, flat_v, flat_g) = slide(world, start, self.vel, dt);
|
||||
let (mut best_c, mut best_v, mut best_g) = (flat_c, flat_v, flat_g);
|
||||
|
||||
if was_grounded {
|
||||
let (up, _) = trace_step(world, start, [0.0, STEP_HEIGHT, 0.0]);
|
||||
let (stepped, step_v, _) = slide(world, up, self.vel, dt);
|
||||
let down_dist = (up[1] - start[1]) + STEP_HEIGHT;
|
||||
let (landed, normal) = trace_step(world, stepped, [0.0, -down_dist, 0.0]);
|
||||
let on_ground = normal.is_some_and(|n| n[1] > GROUND_NORMAL_Y);
|
||||
if on_ground && horiz_dist2(landed, start) > horiz_dist2(flat_c, start) + 1e-6 {
|
||||
best_c = landed;
|
||||
best_v = step_v;
|
||||
best_g = true;
|
||||
}
|
||||
}
|
||||
|
||||
self.pos = [best_c[0], best_c[1] - half[1], best_c[2]];
|
||||
self.vel = best_v;
|
||||
self.grounded = best_g;
|
||||
}
|
||||
}
|
||||
|
||||
/// Reine Slide-Bewegung des Box-Mittelpunkts entlang `vel·dt` (keine Stufen):
|
||||
/// bis zu [`MAX_SLIDES`] Iterationen, an Treffern entlanggleitend. Gibt
|
||||
/// Endpunkt, Restgeschwindigkeit und Bodenkontakt zurück.
|
||||
#[allow(clippy::needless_range_loop)] // Komponenten-Index läuft parallel über center/disp bzw. vel/normal
|
||||
fn slide(world: &CollisionWorld, mut center: [f32; 3], mut vel: [f32; 3], dt: f32) -> ([f32; 3], [f32; 3], bool) {
|
||||
let half = HALF_EXTENTS;
|
||||
let mut grounded = false;
|
||||
let mut remaining = dt;
|
||||
for _ in 0..MAX_SLIDES {
|
||||
if remaining <= 0.0 { break; }
|
||||
let disp = [vel[0] * remaining, vel[1] * remaining, vel[2] * remaining];
|
||||
let end = [center[0] + disp[0], center[1] + disp[1], center[2] + disp[2]];
|
||||
let Some(hit) = world.trace(center, end, half) else {
|
||||
center = end; // freie Bahn — Rest des Schritts ausführen
|
||||
break;
|
||||
};
|
||||
for i in 0..3 { center[i] += disp[i] * hit.frac; }
|
||||
remaining *= 1.0 - hit.frac;
|
||||
if hit.normal[1] > GROUND_NORMAL_Y { grounded = true; }
|
||||
let into = vel[0] * hit.normal[0] + vel[1] * hit.normal[1] + vel[2] * hit.normal[2];
|
||||
for i in 0..3 { vel[i] -= hit.normal[i] * into; }
|
||||
}
|
||||
(center, vel, grounded)
|
||||
}
|
||||
|
||||
/// Den Mittelpunkt um `delta` (ein Achsen-Versatz) bewegen, an Geometrie
|
||||
/// gestoppt. Gibt den erreichten Punkt und — falls gestoppt — die Treffer-
|
||||
/// Normale zurück.
|
||||
fn trace_step(world: &CollisionWorld, from: [f32; 3], delta: [f32; 3]) -> ([f32; 3], Option<[f32; 3]>) {
|
||||
let to = [from[0] + delta[0], from[1] + delta[1], from[2] + delta[2]];
|
||||
match world.trace(from, to, HALF_EXTENTS) {
|
||||
None => (to, None),
|
||||
Some(hit) => (
|
||||
[from[0] + delta[0] * hit.frac, from[1] + delta[1] * hit.frac, from[2] + delta[2] * hit.frac],
|
||||
Some(hit.normal),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
/// Quadrierte horizontale Distanz (X/Z) — fürs „weiter gekommen?"-Vergleichen.
|
||||
fn horiz_dist2(a: [f32; 3], b: [f32; 3]) -> f32 {
|
||||
(a[0] - b[0]).powi(2) + (a[2] - b[2]).powi(2)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::engine::collision::{self, CollisionWorld};
|
||||
|
||||
/// Leere Welt (kein Boden) → freier Fall, gut für Luft-Tests.
|
||||
fn void() -> CollisionWorld {
|
||||
collision::from_brushes(vec![])
|
||||
}
|
||||
|
||||
/// Großer Boden-Brush mit Oberkante bei y=0.
|
||||
fn floor() -> CollisionWorld {
|
||||
collision::from_brushes(vec![
|
||||
collision::aabb_brush([-50.0, -1.0, -50.0], [50.0, 0.0, 50.0]),
|
||||
])
|
||||
}
|
||||
|
||||
/// Brush-Naht mit kleinem Höhensprung: obere Fläche (Oberkante y=0.3, x≤0)
|
||||
/// trifft auf untere (Oberkante y=0, x≥0). Sprung 0.3 < SNAP_DIST.
|
||||
fn step_down() -> CollisionWorld {
|
||||
collision::from_brushes(vec![
|
||||
collision::aabb_brush([-50.0, -1.0, -50.0], [0.0, 0.3, 50.0]),
|
||||
collision::aabb_brush([0.0, -1.0, -50.0], [50.0, 0.0, 50.0]),
|
||||
])
|
||||
}
|
||||
|
||||
/// Wie `step_down`, aber der Absatz ist 2.0 tief — größer als SNAP_DIST,
|
||||
/// also ein echter Abgrund.
|
||||
fn tall_ledge() -> CollisionWorld {
|
||||
collision::from_brushes(vec![
|
||||
collision::aabb_brush([-50.0, -1.0, -50.0], [0.0, 0.0, 50.0]),
|
||||
collision::aabb_brush([0.0, -3.0, -50.0], [50.0, -2.0, 50.0]),
|
||||
])
|
||||
}
|
||||
|
||||
/// Solides Dreiecksprisma (Slope steigt von (x=0,y=0) auf (x=2,y=1)) plus
|
||||
/// untere Fläche (Oberkante y=0, x≤0), die am Slope-Fuß bündig anschließt.
|
||||
fn ramp() -> CollisionWorld {
|
||||
let s = 5.0f32.sqrt();
|
||||
collision::from_brushes(vec![
|
||||
vec![
|
||||
collision::Plane { n: [-1.0 / s, 2.0 / s, 0.0], d: 0.0 }, // Slope-Oberfläche
|
||||
collision::Plane { n: [0.0, -1.0, 0.0], d: 0.0 }, // Unterseite (y≥0)
|
||||
collision::Plane { n: [1.0, 0.0, 0.0], d: 2.0 }, // x≤2
|
||||
collision::Plane { n: [-1.0, 0.0, 0.0], d: 0.0 }, // x≥0 (Slope-Fuß)
|
||||
collision::Plane { n: [0.0, 0.0, 1.0], d: 50.0 },
|
||||
collision::Plane { n: [0.0, 0.0, -1.0], d: 50.0 },
|
||||
],
|
||||
collision::aabb_brush([-50.0, -1.0, -50.0], [0.0, 0.0, 50.0]),
|
||||
])
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn falls_under_gravity() {
|
||||
let mut p = Player::new([0.0, 5.0, 0.0]);
|
||||
p.step(&void(), 0.0, 0.0, false, 0.1);
|
||||
assert!(p.pos[1] < 5.0, "sollte fallen: y={}", p.pos[1]);
|
||||
assert!(p.vel[1] < 0.0, "vel.y sollte negativ sein: {}", p.vel[1]);
|
||||
assert!(!p.grounded);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lands_and_rests_on_ground() {
|
||||
let w = floor();
|
||||
let mut p = Player::new([0.0, 0.5, 0.0]);
|
||||
p.vel[1] = -10.0;
|
||||
// Mehrere Schritte fallen + setzen lassen.
|
||||
for _ in 0..5 { p.step(&w, 0.0, 0.0, false, 0.1); }
|
||||
assert!(p.grounded, "sollte auf dem Boden stehen");
|
||||
assert!(p.pos[1] >= 0.0 && p.pos[1] < 0.05, "Füße ~ auf y=0: {}", p.pos[1]);
|
||||
assert!(p.vel[1].abs() < 1e-3, "vertikal in Ruhe: {}", p.vel[1]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn jump_only_when_grounded() {
|
||||
// Am Boden: Sprung hebt ab.
|
||||
let mut p = Player::new([0.0, 0.0, 0.0]);
|
||||
p.grounded = true;
|
||||
p.step(&void(), 0.0, 0.0, true, 0.016);
|
||||
assert!(p.vel[1] > 0.0, "Sprung sollte vel.y heben: {}", p.vel[1]);
|
||||
assert!(!p.grounded);
|
||||
|
||||
// In der Luft: kein zweiter Sprung — vel.y bleibt von Gravitation
|
||||
// bestimmt (negativ), nicht auf JUMP_SPEED gesetzt.
|
||||
let mut a = Player::new([0.0, 5.0, 0.0]);
|
||||
a.grounded = false;
|
||||
a.step(&void(), 0.0, 0.0, true, 0.016);
|
||||
assert!(a.vel[1] < 0.0, "kein Doppelsprung: {}", a.vel[1]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn walks_horizontally_along_yaw() {
|
||||
// yaw=0: vorwärts → -Z, strafe → +X; y bleibt am Boden (kein Drift).
|
||||
let w = floor();
|
||||
let mut p = Player::new([0.0, 0.0, 0.0]);
|
||||
p.grounded = true;
|
||||
p.step(&w, 1.0, 0.0, false, 0.1);
|
||||
assert!(p.pos[2] < 0.0, "vorwärts sollte -Z sein: {}", p.pos[2]);
|
||||
assert!(p.pos[0].abs() < 1e-6, "kein Seitversatz: {}", p.pos[0]);
|
||||
assert!(p.pos[1] < 0.05, "kein Y-Drift: {}", p.pos[1]);
|
||||
|
||||
let mut q = Player::new([0.0, 0.0, 0.0]);
|
||||
q.grounded = true;
|
||||
q.step(&w, 0.0, 1.0, false, 0.1);
|
||||
assert!(q.pos[0] > 0.0, "strafe rechts sollte +X sein: {}", q.pos[0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn looking_up_does_not_lift_movement() {
|
||||
// Pitch nach oben darf die Horizontalbewegung nicht kippen.
|
||||
let mut p = Player::new([0.0, 0.0, 0.0]);
|
||||
p.grounded = true;
|
||||
p.pitch = 1.0;
|
||||
p.step(&floor(), 1.0, 0.0, false, 0.1);
|
||||
assert!(p.pos[1] < 0.05, "Hochschauen darf nicht abheben: y={}", p.pos[1]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn yaw_quarter_turn_walks_minus_x() {
|
||||
// yaw=90° blickt -X (wie math::view) → vorwärts bewegt nach -X.
|
||||
let mut p = Player::new([0.0, 0.0, 0.0]);
|
||||
p.grounded = true;
|
||||
p.yaw = std::f32::consts::FRAC_PI_2;
|
||||
p.step(&floor(), 1.0, 0.0, false, 0.1);
|
||||
assert!(p.pos[0] < 0.0, "yaw=90° vorwärts sollte -X sein: {}", p.pos[0]);
|
||||
assert!(p.pos[2].abs() < 1e-6, "kein Z-Anteil: {}", p.pos[2]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fly_ignores_gravity_and_geometry() {
|
||||
// Noclip kennt die Welt gar nicht: nach unten durch jeden Boden, und
|
||||
// vorwärts dem vollen Blick nach — ohne Gravitation.
|
||||
let mut p = Player::new([0.0, 2.0, 0.0]);
|
||||
p.fly(0.0, 0.0, -1.0, 1.0);
|
||||
assert!(p.pos[1] < -1.0, "sollte durch den Boden sinken: {}", p.pos[1]);
|
||||
assert_eq!(p.vel, [0.0; 3], "Flug trägt keine Geschwindigkeit");
|
||||
|
||||
p.pitch = std::f32::consts::FRAC_PI_2; // gerade nach oben schauen
|
||||
let y0 = p.pos[1];
|
||||
p.fly(1.0, 0.0, 0.0, 1.0);
|
||||
assert!(p.pos[1] > y0 + 1.0, "vorwärts folgt dem Blick: {y0} -> {}", p.pos[1]);
|
||||
assert!(!p.grounded);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wall_blocks_horizontal_movement() {
|
||||
// Wand bei x=1 (Brush x∈[1,3]); Player läuft nach +X (yaw=-90°) dagegen.
|
||||
let w = collision::from_brushes(vec![
|
||||
collision::aabb_brush([1.0, -1.0, -50.0], [3.0, 5.0, 50.0]),
|
||||
]);
|
||||
let mut p = Player::new([0.0, 0.0, 0.0]);
|
||||
p.grounded = true;
|
||||
p.yaw = -std::f32::consts::FRAC_PI_2; // vorwärts → +X
|
||||
for _ in 0..10 { p.step(&w, 1.0, 0.0, false, 0.05); }
|
||||
// AABB-Halbbreite 0.3 → Füße stoppen vor x = 1 - 0.3 = 0.7.
|
||||
assert!(p.pos[0] < 0.72, "sollte an der Wand stoppen: x={}", p.pos[0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ground_snap_keeps_grounded_over_step_down() {
|
||||
let w = step_down();
|
||||
let mut p = Player::new([-1.0, 0.6, 0.0]);
|
||||
for _ in 0..6 { p.step(&w, 0.0, 0.0, false, 0.1); } // auf obere Fläche fallen
|
||||
assert!(p.grounded && (p.pos[1] - 0.3).abs() < 0.05, "auf oberer Fläche: y={}", p.pos[1]);
|
||||
|
||||
p.yaw = -std::f32::consts::FRAC_PI_2; // vorwärts → +X über die Naht
|
||||
for _ in 0..8 {
|
||||
p.step(&w, 1.0, 0.0, false, 0.1);
|
||||
assert!(p.grounded, "Snap soll über die Stufe am Boden halten: y={}", p.pos[1]);
|
||||
}
|
||||
assert!(p.pos[0] > 0.3, "sollte die Naht überquert haben: x={}", p.pos[0]);
|
||||
assert!(p.pos[1] < 0.05, "auf der unteren Fläche angekommen: y={}", p.pos[1]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ground_snap_follows_downhill_slope() {
|
||||
let w = ramp();
|
||||
let mut p = Player::new([1.7, 1.3, 0.0]);
|
||||
for _ in 0..8 { p.step(&w, 0.0, 0.0, false, 0.1); } // auf die Slope setzen
|
||||
assert!(p.grounded, "auf der Slope gelandet: y={}", p.pos[1]);
|
||||
|
||||
p.yaw = std::f32::consts::FRAC_PI_2; // vorwärts → -X (abwärts)
|
||||
let y0 = p.pos[1];
|
||||
for _ in 0..3 {
|
||||
p.step(&w, 1.0, 0.0, false, 0.1);
|
||||
assert!(p.grounded, "Snap soll auf der Slope am Boden halten: y={}", p.pos[1]);
|
||||
}
|
||||
assert!(p.pos[1] < y0 - 0.1, "sollte die Slope hinab (y sinkt): {y0} -> {}", p.pos[1]);
|
||||
assert!(p.pos[0] < 1.7, "bewegt sich abwärts (-X): x={}", p.pos[0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_snap_off_tall_ledge() {
|
||||
let w = tall_ledge();
|
||||
let mut p = Player::new([-1.0, 0.3, 0.0]);
|
||||
for _ in 0..5 { p.step(&w, 0.0, 0.0, false, 0.1); } // auf obere Fläche setzen
|
||||
p.yaw = -std::f32::consts::FRAC_PI_2; // über die hohe Kante nach +X
|
||||
for _ in 0..6 { p.step(&w, 1.0, 0.0, false, 0.1); }
|
||||
assert!(!p.grounded, "über die hohe Kante (> SNAP_DIST) soll er fallen");
|
||||
assert!(p.pos[1] < 0.0, "fällt ins Tiefere: y={}", p.pos[1]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn jump_overrides_snap() {
|
||||
let w = floor();
|
||||
let mut p = Player::new([0.0, 0.5, 0.0]); // von oben einpendeln (ds>0)
|
||||
for _ in 0..5 { p.step(&w, 0.0, 0.0, false, 0.1); } // am Boden setzen
|
||||
assert!(p.grounded);
|
||||
p.step(&w, 0.0, 0.0, true, 0.1); // springen
|
||||
assert!(!p.grounded, "Sprung darf nicht vom Snap annulliert werden");
|
||||
assert!(p.vel[1] > 0.0, "steigt nach dem Sprung: {}", p.vel[1]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn step_up_over_curb() {
|
||||
// 0.4 hohe Kante (< STEP_HEIGHT) vor einer Fläche: muss erstiegen werden.
|
||||
let w = collision::from_brushes(vec![
|
||||
collision::aabb_brush([-50.0, -1.0, -50.0], [0.0, 0.0, 50.0]), // Boden y=0, x≤0
|
||||
collision::aabb_brush([0.0, -1.0, -50.0], [50.0, 0.4, 50.0]), // Stufe y=0.4, x≥0
|
||||
]);
|
||||
let mut p = Player::new([-1.0, 0.3, 0.0]);
|
||||
for _ in 0..30 { p.step(&w, 0.0, 0.0, false, 1.0 / 60.0); }
|
||||
p.yaw = -std::f32::consts::FRAC_PI_2; // vorwärts → +X gegen die Stufe
|
||||
for _ in 0..120 { p.step(&w, 1.0, 0.0, false, 1.0 / 60.0); }
|
||||
assert!(p.pos[0] > 0.3, "sollte die Stufe erstiegen haben: x={}", p.pos[0]);
|
||||
assert!((p.pos[1] - 0.4).abs() < 0.05, "steht auf der Stufe: y={}", p.pos[1]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tall_step_blocks() {
|
||||
// 1.0 hohe Wand (> STEP_HEIGHT): kein Erklimmen.
|
||||
let w = collision::from_brushes(vec![
|
||||
collision::aabb_brush([-50.0, -1.0, -50.0], [0.0, 0.0, 50.0]),
|
||||
collision::aabb_brush([0.0, -1.0, -50.0], [50.0, 1.0, 50.0]),
|
||||
]);
|
||||
let mut p = Player::new([-1.0, 0.3, 0.0]);
|
||||
for _ in 0..30 { p.step(&w, 0.0, 0.0, false, 1.0 / 60.0); }
|
||||
p.yaw = -std::f32::consts::FRAC_PI_2;
|
||||
for _ in 0..120 { p.step(&w, 1.0, 0.0, false, 1.0 / 60.0); }
|
||||
assert!(p.pos[0] < -0.25, "hohe Wand muss blocken: x={}", p.pos[0]);
|
||||
}
|
||||
|
||||
/// Slope (von (0,1) hinab auf (2,0)) zwischen oberer Fläche (y=1, x≤0) und
|
||||
/// unterer (y=0, x≥2). Genau der reale Naht-Fall — bei 60 fps getestet.
|
||||
fn slope_between_floors() -> CollisionWorld {
|
||||
let s = 5.0f32.sqrt();
|
||||
collision::from_brushes(vec![
|
||||
collision::aabb_brush([-50.0, -1.0, -50.0], [0.0, 1.0, 50.0]),
|
||||
vec![
|
||||
collision::Plane { n: [1.0 / s, 2.0 / s, 0.0], d: 2.0 / s }, // Slope-Oberfläche
|
||||
collision::Plane { n: [0.0, -1.0, 0.0], d: 0.0 },
|
||||
collision::Plane { n: [-1.0, 0.0, 0.0], d: 0.0 },
|
||||
collision::Plane { n: [1.0, 0.0, 0.0], d: 2.0 },
|
||||
collision::Plane { n: [0.0, 0.0, 1.0], d: 50.0 },
|
||||
collision::Plane { n: [0.0, 0.0, -1.0], d: 50.0 },
|
||||
],
|
||||
collision::aabb_brush([2.0, -1.0, -50.0], [50.0, 0.0, 50.0]),
|
||||
])
|
||||
}
|
||||
|
||||
/// Keilförmige Rampe, die in +X mit `deg` Grad ansteigt (Fuß bei x=0,
|
||||
/// Länge 10). Bergab ist damit -X.
|
||||
fn slope_world(deg: f32) -> CollisionWorld {
|
||||
let (s, c) = deg.to_radians().sin_cos();
|
||||
collision::from_brushes(vec![vec![
|
||||
collision::Plane { n: [-s, c, 0.0], d: 0.0 }, // Rampenoberfläche
|
||||
collision::Plane { n: [0.0, -1.0, 0.0], d: 0.0 }, // Unterseite (y≥0)
|
||||
collision::Plane { n: [1.0, 0.0, 0.0], d: 10.0 }, // x≤10
|
||||
collision::Plane { n: [-1.0, 0.0, 0.0], d: 0.0 }, // x≥0
|
||||
collision::Plane { n: [0.0, 0.0, 1.0], d: 50.0 },
|
||||
collision::Plane { n: [0.0, 0.0, -1.0], d: 50.0 },
|
||||
]])
|
||||
}
|
||||
|
||||
/// Auf eine Rampe fallen lassen und setzen — gibt den Ruhepunkt zurück.
|
||||
fn settle(w: &CollisionWorld, x: f32, deg: f32) -> Player {
|
||||
// Über der Fläche starten — mit Abstand, sonst steckt die aufgeblasene
|
||||
// Box schon in der Rampe und die Trace lässt sie durchfallen.
|
||||
let y = x * deg.to_radians().tan() + 1.0;
|
||||
let mut p = Player::new([x, y, 0.0]);
|
||||
for _ in 0..60 { p.step(w, 0.0, 0.0, false, 1.0 / 60.0); }
|
||||
p
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stands_still_on_walkable_slope() {
|
||||
// 30° < Grenzwinkel: ohne Eingabe darf der Spieler nicht abwärts
|
||||
// kriechen — sonst ist der Hangabtrieb zurück.
|
||||
let w = slope_world(30.0);
|
||||
let mut p = settle(&w, 5.0, 30.0);
|
||||
assert!(p.grounded, "sollte auf der 30°-Rampe stehen: {:?}", p.pos);
|
||||
let (x0, y0) = (p.pos[0], p.pos[1]);
|
||||
for _ in 0..300 { p.step(&w, 0.0, 0.0, false, 1.0 / 60.0); } // 5 Sekunden
|
||||
assert!((p.pos[0] - x0).abs() < 0.01, "kein Hangabtrieb: x {x0} -> {}", p.pos[0]);
|
||||
assert!((p.pos[1] - y0).abs() < 0.01, "keine Höhendrift: y {y0} -> {}", p.pos[1]);
|
||||
assert!(p.grounded, "bleibt am Boden");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn slides_down_steep_slope() {
|
||||
// 60° > Grenzwinkel: hier soll er abrutschen (bergab = -X).
|
||||
let w = slope_world(60.0);
|
||||
let mut p = settle(&w, 5.0, 60.0);
|
||||
assert!(!p.grounded, "zu steil zum Stehen: {:?}", p.pos);
|
||||
let (x0, y0) = (p.pos[0], p.pos[1]);
|
||||
for _ in 0..60 { p.step(&w, 0.0, 0.0, false, 1.0 / 60.0); }
|
||||
assert!(p.pos[0] < x0 - 0.5, "sollte hangabwärts rutschen: x {x0} -> {}", p.pos[0]);
|
||||
assert!(p.pos[1] < y0 - 0.5, "und dabei sinken: y {y0} -> {}", p.pos[1]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn walks_up_and_down_walkable_slope() {
|
||||
// Der stehenbleibende Spieler muss trotzdem beide Richtungen laufen.
|
||||
let w = slope_world(30.0);
|
||||
let mut up = settle(&w, 5.0, 30.0);
|
||||
up.yaw = -std::f32::consts::FRAC_PI_2; // vorwärts → +X, bergauf
|
||||
let y0 = up.pos[1];
|
||||
for _ in 0..60 { up.step(&w, 1.0, 0.0, false, 1.0 / 60.0); }
|
||||
assert!(up.pos[1] > y0 + 0.5, "bergauf steigt y: {y0} -> {}", up.pos[1]);
|
||||
assert!(up.grounded, "bleibt bergauf am Boden");
|
||||
|
||||
let mut down = settle(&w, 5.0, 30.0);
|
||||
down.yaw = std::f32::consts::FRAC_PI_2; // vorwärts → -X, bergab
|
||||
let y0 = down.pos[1];
|
||||
for i in 0..60 {
|
||||
down.step(&w, 1.0, 0.0, false, 1.0 / 60.0);
|
||||
assert!(down.grounded, "bergab am Boden kleben (i={i}, {:?})", down.pos);
|
||||
}
|
||||
assert!(down.pos[1] < y0 - 0.5, "bergab sinkt y: {y0} -> {}", down.pos[1]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn walks_down_slope_across_seams_at_60fps() {
|
||||
let w = slope_between_floors();
|
||||
let mut p = Player::new([-1.0, 1.3, 0.0]);
|
||||
for _ in 0..60 { p.step(&w, 0.0, 0.0, false, 1.0 / 60.0); } // obere Fläche
|
||||
assert!(p.grounded && (p.pos[1] - 1.0).abs() < 0.05, "auf oberer Fläche: y={}", p.pos[1]);
|
||||
|
||||
p.yaw = -std::f32::consts::FRAC_PI_2; // +X, abwärts über beide Nähte
|
||||
for i in 0..180 {
|
||||
p.step(&w, 1.0, 0.0, false, 1.0 / 60.0);
|
||||
assert!(p.grounded, "darf an der Naht nicht hängenbleiben (i={i}, x={}, y={})", p.pos[0], p.pos[1]);
|
||||
}
|
||||
assert!(p.pos[0] > 2.0, "sollte auf die untere Fläche gelangt sein: x={}", p.pos[0]);
|
||||
assert!((p.pos[1]).abs() < 0.05, "auf der unteren Fläche: y={}", p.pos[1]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn walks_up_slope_across_seams_at_60fps() {
|
||||
let w = slope_between_floors();
|
||||
let mut p = Player::new([4.0, 0.3, 0.0]);
|
||||
for _ in 0..60 { p.step(&w, 0.0, 0.0, false, 1.0 / 60.0); } // untere Fläche
|
||||
assert!(p.grounded && p.pos[1].abs() < 0.05, "auf unterer Fläche: y={}", p.pos[1]);
|
||||
|
||||
p.yaw = std::f32::consts::FRAC_PI_2; // -X, aufwärts über beide Nähte
|
||||
for i in 0..180 {
|
||||
p.step(&w, 1.0, 0.0, false, 1.0 / 60.0);
|
||||
assert!(p.grounded, "darf an der Naht nicht hängenbleiben (i={i}, x={}, y={})", p.pos[0], p.pos[1]);
|
||||
}
|
||||
assert!(p.pos[0] < 0.0, "sollte auf die obere Fläche gelangt sein: x={}", p.pos[0]);
|
||||
assert!((p.pos[1] - 1.0).abs() < 0.05, "auf der oberen Fläche: y={}", p.pos[1]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn face_inverts_look_dir() {
|
||||
// Beliebige Richtung (normiert) → face → look_dir liefert sie zurück.
|
||||
let d = crate::engine::model::norm([0.3, -0.2, 0.8]);
|
||||
let mut p = Player::new([0.0; 3]);
|
||||
p.face(d);
|
||||
let l = p.look_dir();
|
||||
for k in 0..3 { assert!((l[k] - d[k]).abs() < 1e-5, "{l:?} vs {d:?}"); }
|
||||
|
||||
// Unrotiertes Empty (−Z) = Ausgangsblick.
|
||||
p.face([0.0, 0.0, -1.0]);
|
||||
assert!(p.yaw.abs() < 1e-6 && p.pitch.abs() < 1e-6);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
//! Szenen: eine Szene ist ein Unterordner von `assets/maps/` — alle `.glb`
|
||||
//! darin zusammen sind ihre Welt. Gewechselt wird über das `scene`-Verb
|
||||
//! (`game::Action::LoadScene`), das die Session ausführt; das Hauptmenü ist
|
||||
//! selbst nur die Szene [`TITLE`].
|
||||
//!
|
||||
//! Hier wird nur geladen und ausgewählt (Bytes → [`Scene`]); die Sim-Welt
|
||||
//! daraus baut `session`, die Sichtgeometrie render::props. Fehler sind
|
||||
//! Autorinnen-Content: kaputte `.glb` werden gemeldet und übersprungen, ein
|
||||
//! fehlender Ordner ist ein `Err` — nie ein Absturz.
|
||||
|
||||
use crate::engine::model::{self, Empty, Model};
|
||||
use crate::engine::{assets, gltf};
|
||||
|
||||
/// Wurzel aller Szenenordner (relativ zum Asset-Basisverzeichnis).
|
||||
pub const MAPS_DIR: &str = "assets/maps";
|
||||
/// Die Szene hinter dem Hauptmenü.
|
||||
pub const TITLE: &str = "title";
|
||||
|
||||
pub struct Scene {
|
||||
pub name: String,
|
||||
/// Die `.glb` des Ordners in Dateinamen-Reihenfolge: (Dateistamm, Modell).
|
||||
pub models: Vec<(String, Model)>,
|
||||
}
|
||||
|
||||
impl Scene {
|
||||
/// Spawn-Empty (`role = spawn`) wählen: mit `name` das gleichnamige,
|
||||
/// sonst das erste in Dateireihenfolge. `Err` nur, wenn `name` gesetzt
|
||||
/// ist und nicht passt — der Aufrufer meldet das und fällt auf
|
||||
/// `spawn(None)` zurück.
|
||||
pub fn spawn(&self, name: Option<&str>) -> Result<Option<&Empty>, String> {
|
||||
let mut spawns = self.models.iter()
|
||||
.flat_map(|(_, m)| &m.empties)
|
||||
.filter(|e| e.props.get(model::ROLE_PROP).map(String::as_str) == Some(model::ROLE_SPAWN));
|
||||
match name {
|
||||
None => Ok(spawns.next()),
|
||||
Some(n) => spawns.find(|e| e.name == n).map(Some)
|
||||
.ok_or_else(|| format!("Szene {:?}: kein Spawn-Empty {n:?} (role = spawn)", self.name)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Szene `name` laden: alle `.glb` in `assets/maps/<name>/` (sortiert →
|
||||
/// deterministische Reihenfolge). Leerer Ordner = leere Welt; fehlender =
|
||||
/// `Err`. Rückgabe: die Szene plus Log-Zeilen (Modelle, Properties,
|
||||
/// übersprungene Dateien) für die Konsole — so sieht die Autorin, ob ihr
|
||||
/// Export `collide`, `signal` und `role` mitgenommen hat.
|
||||
pub fn load(name: &str) -> Result<(Scene, Vec<String>), String> {
|
||||
// Ein Name, kein Pfad: sonst landete `scene ../x` außerhalb der Maps.
|
||||
if name.is_empty() || name.contains(['/', '\\']) || name.starts_with('.') {
|
||||
return Err(format!("ungültiger Szenenname {name:?}"));
|
||||
}
|
||||
let dir = assets::path(&format!("{MAPS_DIR}/{name}"));
|
||||
let entries = std::fs::read_dir(&dir).map_err(|e| format!("{dir}: {e}"))?;
|
||||
let mut paths: Vec<std::path::PathBuf> = entries.flatten()
|
||||
.map(|e| e.path())
|
||||
.filter(|p| p.extension().and_then(|s| s.to_str()) == Some("glb"))
|
||||
.collect();
|
||||
paths.sort();
|
||||
|
||||
let mut models = Vec::new();
|
||||
let mut log = Vec::new();
|
||||
for p in paths {
|
||||
let m = match gltf::load(&p.to_string_lossy()) {
|
||||
Ok(m) => m,
|
||||
Err(e) => { log.push(format!("[model] {e}")); continue; }
|
||||
};
|
||||
let stem = p.file_stem().map_or_else(String::new, |s| s.to_string_lossy().into_owned());
|
||||
let tris: usize = m.objects.iter().map(|o| o.tris.len()).sum();
|
||||
log.push(format!("[model] {stem}: {} Objekte, {tris} Dreiecke, {} Empties",
|
||||
m.objects.len(), m.empties.len()));
|
||||
for o in &m.objects {
|
||||
for (k, v) in &o.props { log.push(format!("[model] {} · {k} = {v}", o.name)); }
|
||||
}
|
||||
for e in &m.empties {
|
||||
log.push(format!("[model] Empty {} @ {:?}", e.name, e.pos));
|
||||
for (k, v) in &e.props { log.push(format!("[model] {} · {k} = {v}", e.name)); }
|
||||
}
|
||||
models.push((stem, m));
|
||||
}
|
||||
Ok((Scene { name: name.to_string(), models }, log))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn test_empty(name: &str, pos: [f32; 3], role: Option<&str>) -> Empty {
|
||||
let mut props = model::Props::new();
|
||||
if let Some(r) = role { props.insert(model::ROLE_PROP.into(), r.into()); }
|
||||
Empty { name: name.into(), pos, dir: [0.0, 0.0, -1.0], props }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn scene_with(empties: Vec<Empty>) -> Scene {
|
||||
Scene {
|
||||
name: "test".into(),
|
||||
models: vec![("a".into(), Model { objects: Vec::new(), empties, textures: Vec::new() })],
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn spawn_picks_first_or_named() {
|
||||
let s = scene_with(vec![
|
||||
test_empty("deko", [9.0; 3], None),
|
||||
test_empty("tuer", [1.0; 3], Some("spawn")),
|
||||
test_empty("fenster", [2.0; 3], Some("spawn")),
|
||||
]);
|
||||
assert_eq!(s.spawn(None).unwrap().unwrap().name, "tuer", "ohne Namen: erster Spawn");
|
||||
assert_eq!(s.spawn(Some("fenster")).unwrap().unwrap().name, "fenster");
|
||||
// Nur role=spawn zählt, auch wenn der Name passt.
|
||||
assert!(s.spawn(Some("deko")).is_err());
|
||||
assert!(scene_with(Vec::new()).spawn(None).unwrap().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_paths_as_names() {
|
||||
assert!(load("../signals.toml").is_err());
|
||||
assert!(load("a/b").is_err());
|
||||
assert!(load("").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_scene_is_an_error_not_a_panic() {
|
||||
assert!(load("gibt_es_nicht").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn loads_the_real_props_scene() {
|
||||
// Projekt-Asset wie in image::tests: die Testszene bringt einen Spawn mit.
|
||||
let (s, log) = load("props").expect("assets/maps/props");
|
||||
assert!(!s.models.is_empty());
|
||||
assert!(s.spawn(None).unwrap().is_some());
|
||||
assert!(log.iter().any(|l| l.starts_with("[model] testscene")));
|
||||
}
|
||||
}
|
||||
@@ -14,23 +14,36 @@
|
||||
//! `set <name> <value>` KV setzen (true/false/i32/f32/string)
|
||||
//! `inc <name> [<delta>]` KV-Integer inkrementieren (Default +1)
|
||||
//! `clear <name>` KV-Eintrag entfernen
|
||||
//! `hide_object <name>` → Action::HideObject (deferred)
|
||||
//! `play_sound <file>` → Action::PlaySound (deferred)
|
||||
//! `play_sound <name>` → Action::PlaySound (deferred): SFX aus
|
||||
//! `assets/sounds/{name}.wav`
|
||||
//! `mode <play|free|menu>` → Action::SetMode (deferred): Anzeige-/
|
||||
//! Eingabemodus wechseln
|
||||
//! `post <name> <on|off>` → Action::SetPost (deferred): Renderer-
|
||||
//! Post-Effekt schalten (Name = Kettenglied
|
||||
//! im Fenster-Frontend)
|
||||
//! `scene <name> [<spawn>]` → Action::LoadScene (deferred): in
|
||||
//! `assets/maps/{name}/` wechseln, optional
|
||||
//! an den Spawn-Empty `spawn`
|
||||
//!
|
||||
//! Parameter-Substitution: vor dem Parsen ersetzt `execute` `$self` in den
|
||||
//! Action-Args durch `ctx.instance_name`. Damit kann eine generische Action
|
||||
//! wie `hide_object $self` für viele duplizierte Instances wirken, ohne pro
|
||||
//! (z.B. `set $self true`) für viele duplizierte Instances wirken, ohne pro
|
||||
//! Instance einen Eintrag in signals.toml zu brauchen.
|
||||
//!
|
||||
//! Dispatch-Reihenfolge: erst Signal-Lookup; steht der Name in der Table,
|
||||
//! laufen alle gemappten Actions. Sonst wird der String direkt als
|
||||
//! Builtin-Aufruf probiert — so wirken Ink-Tags wie `# set has_key true`
|
||||
//! ohne Umweg über signals.toml. Unbekannte Verben werden still ignoriert.
|
||||
//! ohne Umweg über signals.toml.
|
||||
//!
|
||||
//! Unbekannte Verben: aus einer signals.toml-*Action* sind sie immer ein
|
||||
//! Tippfehler und werden nach stderr gemeldet. Im Ink-Tag-Fall-Through bleiben
|
||||
//! sie hingegen still — Tags dürfen bewusst reine Metadaten sein, die (noch)
|
||||
//! kein Verb konsumiert (z.B. ein späteres `# speaker …`).
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::fs::read_to_string;
|
||||
|
||||
use crate::engine::game::{Action, ActionCtx, Signals};
|
||||
use crate::engine::game::{Action, ActionCtx, ModeTarget, Signals};
|
||||
use crate::engine::kv;
|
||||
use crate::engine::story_ctrl;
|
||||
|
||||
@@ -49,19 +62,29 @@ pub fn signal_key(name: &str) -> &str {
|
||||
}
|
||||
|
||||
pub fn dispatch(signal: &str, ctx: &mut ActionCtx) {
|
||||
// Signal-Name in der Table? Dann alle gemappten Actions ausführen.
|
||||
// Signal-Name in der Table? Dann alle gemappten Actions ausführen. Ein
|
||||
// unbekanntes Verb in einer Action ist hier immer ein Tippfehler → melden.
|
||||
if let Some(actions) = ctx.signals.get(signal) {
|
||||
let actions = actions.clone(); // entkoppelt vom ctx.signals-Borrow
|
||||
for a in &actions { execute(a, ctx); }
|
||||
for a in &actions {
|
||||
if !execute(a, ctx) {
|
||||
eprintln!("[signal] {signal:?}: unbekanntes Verb in Action {a:?} \
|
||||
— Tippfehler in signals.toml?");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Sonst direkt als Builtin probieren (Ink-Tag-Pfad).
|
||||
execute(signal, ctx);
|
||||
// Sonst direkt als Builtin probieren (Ink-Tag-Pfad). Unbekanntes bleibt
|
||||
// hier still (Tags dürfen bloße Metadaten sein) — Rückgabe verworfen.
|
||||
let _ = execute(signal, ctx);
|
||||
}
|
||||
|
||||
fn execute(cmd: &str, ctx: &mut ActionCtx) {
|
||||
/// Führt einen einzelnen Befehl (`verb args`) aus. Rückgabe: `true`, wenn das
|
||||
/// Verb bekannt war und lief; `false` bei unbekanntem Verb (der Aufrufer
|
||||
/// entscheidet, ob das eine Meldung wert ist — siehe `dispatch`).
|
||||
fn execute(cmd: &str, ctx: &mut ActionCtx) -> bool {
|
||||
// $self → ctx.instance_name. Substituieren bevor wir Verb/Args splitten,
|
||||
// damit Tokens wie `hide_object $self` einheitlich funktionieren. Ohne
|
||||
// damit Tokens wie `set $self true` einheitlich funktionieren. Ohne
|
||||
// instance_name (z.B. `init`-Signal) bleibt `$self` stehen — die Action
|
||||
// zielt dann ins Leere, was für deferred Actions ein No-Op beim
|
||||
// Konsumenten ist.
|
||||
@@ -80,10 +103,43 @@ fn execute(cmd: &str, ctx: &mut ActionCtx) {
|
||||
"set" => kv::apply_set(args, ctx.kv),
|
||||
"inc" => kv::apply_inc(args, ctx.kv),
|
||||
"clear" => kv::apply_clear(args, ctx.kv),
|
||||
"hide_object" => ctx.actions.push(Action::HideObject(args.to_string())),
|
||||
"play_sound" => ctx.actions.push(Action::PlaySound(args.to_string())),
|
||||
_ => { /* Unbekannter Verb/Tag → still ignorieren */ }
|
||||
"mode" => if let Some(t) = ModeTarget::parse(args) {
|
||||
ctx.actions.push(Action::SetMode(t));
|
||||
},
|
||||
"post" => if let Some((name, on)) = parse_post_arg(args) {
|
||||
ctx.actions.push(Action::SetPost { name, on });
|
||||
},
|
||||
"scene" => if let Some(a) = parse_scene_arg(args) {
|
||||
ctx.actions.push(a);
|
||||
},
|
||||
_ => return false, // Unbekanntes Verb — der Aufrufer meldet ggf.
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
/// `"<name> on"` / `"<name> off"` → `(name, bool)`; sonst `None`. Kein
|
||||
/// nackter Toggle — eine geskriptete Schaltung soll lesbar sagen, wohin sie
|
||||
/// schaltet. Geteilt von der Dispatch-Pipeline (`post`-Verb) und dem
|
||||
/// `post`-Konsolenbefehl in `session`.
|
||||
pub fn parse_post_arg(args: &str) -> Option<(String, bool)> {
|
||||
let (name, state) = args.trim().split_once(char::is_whitespace)?;
|
||||
let on = match state.trim() {
|
||||
"on" => true,
|
||||
"off" => false,
|
||||
_ => return None,
|
||||
};
|
||||
let name = name.trim();
|
||||
(!name.is_empty()).then(|| (name.to_string(), on))
|
||||
}
|
||||
|
||||
/// `"<name> [<spawn>]"` → [`Action::LoadScene`]; leer → `None`. Geteilt von
|
||||
/// der Dispatch-Pipeline (`scene`-Verb) und dem `scene`-Konsolenbefehl.
|
||||
pub fn parse_scene_arg(args: &str) -> Option<Action> {
|
||||
let mut words = args.split_whitespace();
|
||||
let name = words.next()?.to_string();
|
||||
let spawn = words.next().map(str::to_string);
|
||||
Some(Action::LoadScene { name, spawn })
|
||||
}
|
||||
|
||||
/// Parst das signals.toml-Subset: `[signal]`-Header gefolgt von einem
|
||||
@@ -161,28 +217,87 @@ mod tests {
|
||||
let mut signals = Signals::new();
|
||||
signals.insert("pickup".into(), vec![
|
||||
"inc items".into(),
|
||||
"play_sound pickup.wav".into(),
|
||||
"hide_object $self".into(),
|
||||
"play_sound $self".into(), // $self-Substitution in deferred Action
|
||||
]);
|
||||
let mut game = Game::new(signals);
|
||||
|
||||
let mut ctx = game.action_ctx(Some("Mushroom.005".into()));
|
||||
dispatch("pickup", &mut ctx);
|
||||
|
||||
assert_eq!(game.kv["items"].coerce_to_int().unwrap(), 1);
|
||||
assert_eq!(game.kv["items"].as_int().unwrap(), 1);
|
||||
assert_eq!(game.actions, vec![
|
||||
Action::PlaySound("pickup.wav".into()),
|
||||
Action::HideObject("Mushroom.005".into()),
|
||||
Action::PlaySound("Mushroom.005".into()),
|
||||
]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mode_verb_queues_setmode_action() {
|
||||
let mut game = Game::new(Signals::new());
|
||||
let mut ctx = game.action_ctx(None);
|
||||
dispatch("mode free", &mut ctx);
|
||||
assert_eq!(game.actions, vec![Action::SetMode(ModeTarget::Free)]);
|
||||
|
||||
// Unbekanntes Ziel → kein Action (stilles No-Op).
|
||||
game.actions.clear();
|
||||
let mut ctx = game.action_ctx(None);
|
||||
dispatch("mode wat", &mut ctx);
|
||||
assert!(game.actions.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn post_verb_queues_setpost_action() {
|
||||
let mut game = Game::new(Signals::new());
|
||||
let mut ctx = game.action_ctx(None);
|
||||
dispatch("post outline off", &mut ctx);
|
||||
assert_eq!(game.actions, vec![
|
||||
Action::SetPost { name: "outline".into(), on: false },
|
||||
]);
|
||||
|
||||
// Fehlendes/ungültiges on|off → kein Action (stilles No-Op wie `mode`).
|
||||
game.actions.clear();
|
||||
let mut ctx = game.action_ctx(None);
|
||||
dispatch("post outline", &mut ctx);
|
||||
dispatch("post outline wat", &mut ctx);
|
||||
assert!(game.actions.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scene_verb_queues_loadscene_action() {
|
||||
let mut game = Game::new(Signals::new());
|
||||
let mut ctx = game.action_ctx(None);
|
||||
dispatch("scene cinema", &mut ctx);
|
||||
dispatch("scene cinema lobby", &mut ctx);
|
||||
// Ohne Namen → kein Action (stilles No-Op wie `post`).
|
||||
dispatch("scene", &mut ctx);
|
||||
assert_eq!(game.actions, vec![
|
||||
Action::LoadScene { name: "cinema".into(), spawn: None },
|
||||
Action::LoadScene { name: "cinema".into(), spawn: Some("lobby".into()) },
|
||||
]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn typo_verb_in_table_is_tolerated_and_reported() {
|
||||
// Ein Tippfehler-Verb in einer Table-Action wird gemeldet (stderr) und
|
||||
// bleibt ohne Wirkung, während die gültige Nachbar-Action weiter läuft.
|
||||
let mut signals = Signals::new();
|
||||
signals.insert("thing".into(), vec![
|
||||
"st has_key true".into(), // Tippfehler für `set` → No-Op + Meldung
|
||||
"set ok true".into(), // gültig → wirkt
|
||||
]);
|
||||
let mut game = Game::new(signals);
|
||||
let mut ctx = game.action_ctx(None);
|
||||
dispatch("thing", &mut ctx);
|
||||
assert!(!game.kv.contains_key("has_key"), "Tippfehler darf nichts setzen");
|
||||
assert!(matches!(game.kv["ok"], kv::Value::Bool(true)), "gültige Action wirkt weiter");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_signal_falls_through_to_builtin() {
|
||||
let mut game = Game::new(Signals::new());
|
||||
let mut ctx = game.action_ctx(None);
|
||||
// Ink-Tag-Pfad: kein Table-Eintrag, direkt als Verb ausführen.
|
||||
dispatch("set has_key true", &mut ctx);
|
||||
assert!(game.kv["has_key"].coerce_to_bool().unwrap());
|
||||
assert!(matches!(game.kv["has_key"], kv::Value::Bool(true)));
|
||||
|
||||
// Unbekanntes Verb ist ein stilles No-Op.
|
||||
let mut ctx = game.action_ctx(None);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
//! Story-Lifecycle: Ink-Skript in den Story-Slot laden und schrittweise
|
||||
//! treiben. Frontend-agnostisch — anders als in irl3d, wo `StoryState`
|
||||
//! direkt in UI-Panels gegossen wurde, konsumiert hier der Aufrufer
|
||||
//! (CLI-REPL jetzt, Panel-UI später) den Zustand selbst.
|
||||
//! treiben. Frontend-agnostisch — den `StoryState` gießt der Aufrufer selbst
|
||||
//! in seine Darstellung.
|
||||
//!
|
||||
//! Tags eines Schritts werden als `Vec<String>` zurückgegeben — der
|
||||
//! Aufrufer entscheidet, ob/wie er sie via `signals::dispatch` weiterreicht
|
||||
@@ -16,7 +15,12 @@ use crate::engine::ink::{Story, StoryState};
|
||||
/// dafür `advance(None, …)`.
|
||||
pub fn start(script: &str, ctx: &mut ActionCtx) {
|
||||
let path = assets::path(&format!("assets/interactions/{script}"));
|
||||
*ctx.story = Some(Story::load(&path, ctx.kv));
|
||||
match Story::load(&path, ctx.kv) {
|
||||
Ok(story) => *ctx.story = Some(story),
|
||||
// Kaputtes/fehlendes Skript darf das Spiel nicht crashen: den Slot
|
||||
// leer lassen (kein Dialog öffnet) und den Fehler nach stderr melden.
|
||||
Err(msg) => eprintln!("[start_ink] {msg}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Treibt die laufende Story einen Schritt weiter. `sel` ist die
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
//! TGA-Decoder → fertig dekodiertes RGBA8-`Image`.
|
||||
//!
|
||||
//! Neutral: kennt weder GPU noch UI noch Fonts. Liefert *immer* RGBA8,
|
||||
//! Ursprung oben-links, vollständig konvertiert — der Aufrufer macht keine
|
||||
//! Nachbearbeitung. (Anders als irl3d, wo der Loader BGR zurückgab und die
|
||||
//! RGB-Umrechnung jedem Konsumenten einzeln überließ.) Konsumenten ziehen
|
||||
//! ein `Image` und legen es ab, wie sie es brauchen: Renderer → GPU-Textur,
|
||||
//! UI/Font → eigene Interpretation. Die UV-/V-Achsen-Konvention ist damit
|
||||
//! Sache des Konsumenten beim Sampling, nicht des Loaders.
|
||||
//!
|
||||
//! Unterstützt True-Color unkomprimiert (Typ 2) und RLE (Typ 10) mit 24
|
||||
//! oder 32 bpp, sowie Graustufen (Typ 3/11, 8 bpp → zu RGBA expandiert) für
|
||||
//! Font-Maps. Paletten-TGAs gibt es nicht mehr (wds ist 15-bit True-Color).
|
||||
|
||||
pub struct Image {
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
/// `width * height * 4`, Ursprung oben-links.
|
||||
pub rgba: Vec<u8>,
|
||||
}
|
||||
|
||||
pub fn load(path: &str) -> Image {
|
||||
let bytes = std::fs::read(path).unwrap_or_else(|e| panic!("tga load {path}: {e}"));
|
||||
decode(&bytes).unwrap_or_else(|e| panic!("tga decode {path}: {e}"))
|
||||
}
|
||||
|
||||
pub fn decode(d: &[u8]) -> Result<Image, String> {
|
||||
if d.len() < 18 { return Err("Header zu kurz".into()); }
|
||||
let id_len = d[0] as usize;
|
||||
let cmap_type = d[1];
|
||||
let image_type = d[2];
|
||||
let width = u16::from_le_bytes([d[12], d[13]]) as u32;
|
||||
let height = u16::from_le_bytes([d[14], d[15]]) as u32;
|
||||
let depth = d[16];
|
||||
let descriptor = d[17];
|
||||
|
||||
if cmap_type != 0 {
|
||||
return Err("Color-Map-TGAs nicht unterstützt (True-Color only)".into());
|
||||
}
|
||||
// Pixeldaten beginnen nach Header + ID-Feld (Color-Map ist leer).
|
||||
let off = 18 + id_len;
|
||||
|
||||
let channels = match (image_type, depth) {
|
||||
(2 | 10, 24) => 3,
|
||||
(2 | 10, 32) => 4,
|
||||
(3 | 11, 8) => 1,
|
||||
(t, b) => return Err(format!("nicht unterstützt: Typ {t}, {b} bpp")),
|
||||
};
|
||||
let n = (width as usize) * (height as usize);
|
||||
if n == 0 { return Err("Nullgröße".into()); }
|
||||
|
||||
// Rohpixel (channels Bytes je Pixel), bei RLE entpackt.
|
||||
let raw_len = n * channels;
|
||||
let raw: Vec<u8> = match image_type {
|
||||
2 | 3 => d.get(off..off + raw_len).ok_or("Pixeldaten zu kurz")?.to_vec(),
|
||||
10 | 11 => decode_rle(d.get(off..).ok_or("RLE-Daten fehlen")?, raw_len, channels)?,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
// → RGBA8. True-Color liegt im TGA als BGR(A) vor; Graustufen replizieren.
|
||||
let mut rgba = vec![0u8; n * 4];
|
||||
for i in 0..n {
|
||||
let (r, g, b, a) = match channels {
|
||||
1 => { let v = raw[i]; (v, v, v, 255) }
|
||||
3 => (raw[i * 3 + 2], raw[i * 3 + 1], raw[i * 3], 255),
|
||||
4 => (raw[i * 4 + 2], raw[i * 4 + 1], raw[i * 4], raw[i * 4 + 3]),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let o = i * 4;
|
||||
rgba[o] = r; rgba[o + 1] = g; rgba[o + 2] = b; rgba[o + 3] = a;
|
||||
}
|
||||
|
||||
// Ursprung oben-links erzwingen. Descriptor-Bit 5 gesetzt = top-origin.
|
||||
if (descriptor >> 5) & 1 == 0 {
|
||||
flip_vertical(&mut rgba, width as usize, height as usize);
|
||||
}
|
||||
Ok(Image { width, height, rgba })
|
||||
}
|
||||
|
||||
/// TGA-RLE: Pakete operieren auf ganzen Pixeln (`ch` Bytes).
|
||||
fn decode_rle(src: &[u8], raw_len: usize, ch: usize) -> Result<Vec<u8>, String> {
|
||||
let mut out = Vec::with_capacity(raw_len);
|
||||
let mut si = 0;
|
||||
while out.len() < raw_len {
|
||||
let header = *src.get(si).ok_or("RLE: Quelle zu kurz")?;
|
||||
si += 1;
|
||||
let count = (header & 0x7f) as usize + 1;
|
||||
if header & 0x80 != 0 {
|
||||
// RLE-Paket: ein Pixel count-mal.
|
||||
let px = src.get(si..si + ch).ok_or("RLE: Pixel zu kurz")?;
|
||||
si += ch;
|
||||
for _ in 0..count { out.extend_from_slice(px); }
|
||||
} else {
|
||||
// Raw-Paket: count Pixel am Stück.
|
||||
let bytes = count * ch;
|
||||
let chunk = src.get(si..si + bytes).ok_or("RLE: Chunk zu kurz")?;
|
||||
si += bytes;
|
||||
out.extend_from_slice(chunk);
|
||||
}
|
||||
}
|
||||
out.truncate(raw_len);
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
fn flip_vertical(rgba: &mut [u8], w: usize, h: usize) {
|
||||
let row = w * 4;
|
||||
for y in 0..h / 2 {
|
||||
let (a, b) = (y * row, (h - 1 - y) * row);
|
||||
for x in 0..row { rgba.swap(a + x, b + x); }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn bgr_to_rgba_uncompressed() {
|
||||
// Minimal-TGA: Typ 2, 2×1, 24 bpp, bottom-origin (descriptor 0).
|
||||
// Zwei Pixel BGR (10,20,30) und (40,50,60).
|
||||
let mut d = vec![0u8; 18];
|
||||
d[2] = 2; d[12] = 2; d[14] = 1; d[16] = 24;
|
||||
d.extend_from_slice(&[10, 20, 30, 40, 50, 60]);
|
||||
let img = decode(&d).unwrap();
|
||||
assert_eq!((img.width, img.height), (2, 1));
|
||||
assert_eq!(&img.rgba[0..4], &[30, 20, 10, 255]);
|
||||
assert_eq!(&img.rgba[4..8], &[60, 50, 40, 255]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rle_truecolor_expands() {
|
||||
// Typ 10, 4×1, 24 bpp: ein RLE-Paket (4× BGR 1,2,3).
|
||||
let mut d = vec![0u8; 18];
|
||||
d[2] = 10; d[12] = 4; d[14] = 1; d[16] = 24;
|
||||
d.push(0x80 | 3); // RLE, count = 4
|
||||
d.extend_from_slice(&[1, 2, 3]); // ein Pixel
|
||||
let img = decode(&d).unwrap();
|
||||
assert_eq!(img.rgba.len(), 4 * 4);
|
||||
assert!(img.rgba.chunks(4).all(|p| p == [3, 2, 1, 255]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decodes_real_placeholder() {
|
||||
let bytes = std::fs::read("assets/textures/placeholder.tga").unwrap();
|
||||
let img = decode(&bytes).unwrap();
|
||||
assert_eq!((img.width, img.height), (256, 256));
|
||||
assert_eq!(img.rgba.len(), 256 * 256 * 4);
|
||||
assert!(img.rgba.chunks(4).all(|p| p[3] == 255)); // 24bpp → Alpha 255
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
//! Trigger aus Blender-Modellen: Objekte mit `signal`-Custom-Property
|
||||
//! (siehe [`model::SIGNAL_PROP`]), aufgeteilt nach Collider-Frage —
|
||||
//! **anfassbar = klickbar, durchlaufbar = Betretens-Zone**:
|
||||
//!
|
||||
//! - `collide` + `signal` → *Klick-Ziel*: das solide Volumen ist zugleich
|
||||
//! das Ziel des Point-and-Click-Raycasts (siehe [`Triggers::pick`]).
|
||||
//! Feuern läuft über den `use <name>`-Trichter in `Session::exec`.
|
||||
//! - nur `signal` → *Zone*: unsichtbares konvexes Volumen; Betreten
|
||||
//! feuert das Signal genau einmal je Eintritt ([`Triggers::enter_events`],
|
||||
//! Flanken-Semantik: erneut erst nach Verlassen). „Einmal für immer"
|
||||
//! baut die Autorin über KV-Flags/Ink, nicht hier.
|
||||
//!
|
||||
//! In beiden Fällen ist der Signal-Name der Property-*Wert*, `$self` der
|
||||
//! Objektname. Volumen-Mathe kommt aus `collision` (dieselben konvexen
|
||||
//! Ebenen-Sets wie die Proxies); gefeuert wird hier nichts — die Session
|
||||
//! zieht Events/Treffer und schickt sie durch ihren Dispatch, damit der
|
||||
//! Eingabe-Trichter der einzige Weg in den State bleibt.
|
||||
|
||||
use crate::engine::collision::{self, Plane};
|
||||
use crate::engine::model::{Model, SIGNAL_PROP};
|
||||
|
||||
struct Clickable {
|
||||
name: String,
|
||||
signal: String,
|
||||
planes: Vec<Plane>,
|
||||
}
|
||||
|
||||
struct Zone {
|
||||
name: String,
|
||||
signal: String,
|
||||
planes: Vec<Plane>,
|
||||
/// Flanken-Zustand: war der Spieler im letzten Check im Volumen?
|
||||
inside: bool,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Triggers {
|
||||
clickables: Vec<Clickable>,
|
||||
zones: Vec<Zone>,
|
||||
}
|
||||
|
||||
impl Triggers {
|
||||
pub fn new() -> Self { Self::default() }
|
||||
|
||||
/// Trigger eines Modells übernehmen: alle Objekte mit `signal`-Property.
|
||||
pub fn add_model(&mut self, model: &Model) {
|
||||
for o in &model.objects {
|
||||
let Some(signal) = o.props.get(SIGNAL_PROP) else { continue; };
|
||||
let Some(planes) = collision::object_planes(o) else {
|
||||
eprintln!("[trigger] {}: kein geschlossenes konvexes Volumen — ignoriert", o.name);
|
||||
continue;
|
||||
};
|
||||
let (name, signal) = (o.name.clone(), signal.clone());
|
||||
if o.collider {
|
||||
self.clickables.push(Clickable { name, signal, planes });
|
||||
} else {
|
||||
self.zones.push(Zone { name, signal, planes, inside: false });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Signal eines Klick-Ziels (für die `use <name>`-Auflösung der Session).
|
||||
pub fn signal_for(&self, name: &str) -> Option<&str> {
|
||||
self.clickables.iter()
|
||||
.find(|c| c.name == name)
|
||||
.map(|c| c.signal.as_str())
|
||||
}
|
||||
|
||||
/// Nächstes Klick-Ziel entlang `start→end` (Punktstrahl): Name und
|
||||
/// Trefferbruch. Ob Weltgeometrie davor liegt, prüft der Aufrufer.
|
||||
pub fn pick(&self, start: [f32; 3], end: [f32; 3]) -> Option<(&str, f32)> {
|
||||
let mut nearest: Option<(&str, f32)> = None;
|
||||
for c in &self.clickables {
|
||||
if let Some(hit) = collision::trace_planes(&c.planes, start, end, [0.0; 3])
|
||||
&& nearest.is_none_or(|(_, f)| hit.frac < f) {
|
||||
nearest = Some((&c.name, hit.frac));
|
||||
}
|
||||
}
|
||||
nearest
|
||||
}
|
||||
|
||||
/// Zonen gegen die Spieler-AABB prüfen und die Eintritts-Flanken melden:
|
||||
/// `(Objektname, Signal)` je Zone, die diesen Check betreten wurde.
|
||||
pub fn enter_events(&mut self, center: [f32; 3], half: [f32; 3]) -> Vec<(String, String)> {
|
||||
let mut events = Vec::new();
|
||||
for z in &mut self.zones {
|
||||
let inside = collision::box_touches(&z.planes, center, half);
|
||||
if inside && !z.inside {
|
||||
events.push((z.name.clone(), z.signal.clone()));
|
||||
}
|
||||
z.inside = inside;
|
||||
}
|
||||
events
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::engine::model::{test_cube as cube, Object};
|
||||
|
||||
fn model(objects: Vec<Object>) -> Model {
|
||||
Model { objects, empties: Vec::new(), textures: Vec::new() }
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn splits_by_collider_and_zone_is_invisible() {
|
||||
let m = model(vec![
|
||||
cube("Kiste", [0.0, 0.0, 0.0], Some("1"), Some("kiste")),
|
||||
cube("Zone.001", [5.0, 0.0, 0.0], None, Some("betreten")),
|
||||
cube("Deko", [9.0, 0.0, 0.0], None, None),
|
||||
]);
|
||||
assert!(!m.objects[1].visible, "Zone darf nicht gerendert werden");
|
||||
|
||||
let mut t = Triggers::new();
|
||||
t.add_model(&m);
|
||||
assert_eq!(t.clickables.len(), 1);
|
||||
assert_eq!(t.zones.len(), 1);
|
||||
assert_eq!(t.signal_for("Kiste"), Some("kiste"));
|
||||
assert_eq!(t.signal_for("Deko"), None, "ohne signal-Property kein Klick-Ziel");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pick_finds_nearest_clickable() {
|
||||
let mut t = Triggers::new();
|
||||
t.add_model(&model(vec![
|
||||
cube("Fern", [4.0, -0.5, -0.5], Some("1"), Some("f")),
|
||||
cube("Nah", [1.0, -0.5, -0.5], Some("1"), Some("n")),
|
||||
]));
|
||||
// Strahl entlang +X durch beide Würfel → der nahe gewinnt.
|
||||
let (name, frac) = t.pick([0.0, 0.0, 0.0], [10.0, 0.0, 0.0]).unwrap();
|
||||
assert_eq!(name, "Nah");
|
||||
assert!((frac - 0.1).abs() < 0.01, "frac={frac}");
|
||||
// Strahl daneben → nichts.
|
||||
assert!(t.pick([0.0, 5.0, 0.0], [10.0, 5.0, 0.0]).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zone_fires_on_entry_edge_and_rearms_after_exit() {
|
||||
let mut t = Triggers::new();
|
||||
t.add_model(&model(vec![cube("Zone", [0.0, 0.0, 0.0], None, Some("betreten"))]));
|
||||
let half = [0.3, 0.9, 0.3];
|
||||
|
||||
// Außerhalb: nichts.
|
||||
assert!(t.enter_events([5.0, 0.5, 0.5], half).is_empty());
|
||||
// Betreten: genau ein Event …
|
||||
let ev = t.enter_events([0.5, 0.5, 0.5], half);
|
||||
assert_eq!(ev, vec![("Zone".to_string(), "betreten".to_string())]);
|
||||
// … und beim Verweilen keins.
|
||||
assert!(t.enter_events([0.6, 0.5, 0.5], half).is_empty());
|
||||
// Verlassen und wieder betreten: feuert erneut.
|
||||
assert!(t.enter_events([5.0, 0.5, 0.5], half).is_empty());
|
||||
assert_eq!(t.enter_events([0.5, 0.5, 0.5], half).len(), 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
//! Minimaler WAV-Decoder (Blender-/DAW-Export) → Mono-Samples.
|
||||
//!
|
||||
//! Reiner Decoder (Bytes → owned Daten), `Result` statt Panic — Sounds sind
|
||||
//! Autorinnen-Content, ein kaputtes File wird gemeldet und bleibt still.
|
||||
//!
|
||||
//! Akzeptiert ausschließlich PCM (`format = 1`), 1 Kanal, 16 bit, 44100 Hz,
|
||||
//! little-endian — das feste Format des Mixers (render::audio). „Als WAV
|
||||
//! mono 16-bit 44,1 kHz exportieren" ist die ganze Anleitung; alles andere
|
||||
//! ist eine klare Fehlermeldung mit Pfad. Über unbekannte RIFF-Chunks
|
||||
//! (`LIST`, `INFO`, `bext`, …) wird hinweggesprungen.
|
||||
|
||||
/// Sample-Rate des gesamten Audio-Pfads (Decoder-Kontrakt und Mixer-Takt).
|
||||
pub const SAMPLE_RATE: u32 = 44100;
|
||||
|
||||
pub struct Wav {
|
||||
pub samples: Vec<i16>,
|
||||
}
|
||||
|
||||
pub fn load(path: &str) -> Result<Wav, String> {
|
||||
let bytes = std::fs::read(path).map_err(|e| format!("wav load {path}: {e}"))?;
|
||||
parse(&bytes).map_err(|e| format!("wav {path}: {e}"))
|
||||
}
|
||||
|
||||
pub fn parse(data: &[u8]) -> Result<Wav, String> {
|
||||
if data.len() < 12 || &data[0..4] != b"RIFF" || &data[8..12] != b"WAVE" {
|
||||
return Err("kein RIFF/WAVE".into());
|
||||
}
|
||||
|
||||
let mut fmt_found = false;
|
||||
let mut samples: Option<Vec<i16>> = None;
|
||||
|
||||
let mut i = 12;
|
||||
while i + 8 <= data.len() {
|
||||
let id = &data[i..i + 4];
|
||||
let size = u32::from_le_bytes(data[i + 4..i + 8].try_into().unwrap()) as usize;
|
||||
let body = i + 8;
|
||||
let end = body + size;
|
||||
if end > data.len() { return Err("Chunk länger als Datei".into()); }
|
||||
match id {
|
||||
b"fmt " => {
|
||||
if size < 16 { return Err("fmt-Chunk zu kurz".into()); }
|
||||
let format = u16::from_le_bytes(data[body..body + 2].try_into().unwrap());
|
||||
let channels = u16::from_le_bytes(data[body + 2..body + 4].try_into().unwrap());
|
||||
let rate = u32::from_le_bytes(data[body + 4..body + 8].try_into().unwrap());
|
||||
let bits = u16::from_le_bytes(data[body + 14..body + 16].try_into().unwrap());
|
||||
if format != 1 || channels != 1 || bits != 16 || rate != SAMPLE_RATE {
|
||||
return Err(format!(
|
||||
"brauche PCM mono 16-bit {SAMPLE_RATE} Hz, ist format={format} \
|
||||
channels={channels} bits={bits} rate={rate}"));
|
||||
}
|
||||
fmt_found = true;
|
||||
}
|
||||
b"data" => {
|
||||
if !fmt_found { return Err("data-Chunk vor fmt".into()); }
|
||||
samples = Some(data[body..end].chunks_exact(2)
|
||||
.map(|c| i16::from_le_bytes([c[0], c[1]]))
|
||||
.collect());
|
||||
}
|
||||
_ => {} // LIST, INFO, bext, … überspringen
|
||||
}
|
||||
// Chunks sind word-aligned (Padding-Byte bei ungerader Größe).
|
||||
i = end + (size & 1);
|
||||
}
|
||||
|
||||
match samples {
|
||||
Some(samples) if !samples.is_empty() => Ok(Wav { samples }),
|
||||
Some(_) => Err("data-Chunk leer".into()),
|
||||
None => Err("kein data-Chunk".into()),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// Minimale WAV-Datei bauen, wie ein Exporter sie schriebe.
|
||||
fn wav_bytes(format: u16, channels: u16, rate: u32, bits: u16, samples: &[i16]) -> Vec<u8> {
|
||||
let data_len = samples.len() * 2;
|
||||
let mut out = Vec::new();
|
||||
out.extend(b"RIFF");
|
||||
out.extend(((4 + 8 + 16 + 8 + data_len) as u32).to_le_bytes());
|
||||
out.extend(b"WAVE");
|
||||
out.extend(b"fmt ");
|
||||
out.extend(16u32.to_le_bytes());
|
||||
out.extend(format.to_le_bytes());
|
||||
out.extend(channels.to_le_bytes());
|
||||
out.extend(rate.to_le_bytes());
|
||||
out.extend((rate * 2).to_le_bytes()); // byte rate
|
||||
out.extend(2u16.to_le_bytes()); // block align
|
||||
out.extend(bits.to_le_bytes());
|
||||
out.extend(b"data");
|
||||
out.extend((data_len as u32).to_le_bytes());
|
||||
for s in samples { out.extend(s.to_le_bytes()); }
|
||||
out
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_pcm_mono_16bit() {
|
||||
let w = parse(&wav_bytes(1, 1, SAMPLE_RATE, 16, &[0, 1000, -1000])).unwrap();
|
||||
assert_eq!(w.samples, vec![0, 1000, -1000]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn skips_unknown_chunks() {
|
||||
// LIST-Chunk zwischen fmt und data.
|
||||
let base = wav_bytes(1, 1, SAMPLE_RATE, 16, &[7]);
|
||||
let mut out = base[..36].to_vec(); // bis inkl. fmt
|
||||
out.extend(b"LIST");
|
||||
out.extend(4u32.to_le_bytes());
|
||||
out.extend(b"INFO");
|
||||
out.extend(&base[36..]); // data-Chunk
|
||||
let len = (out.len() - 8) as u32;
|
||||
out[4..8].copy_from_slice(&len.to_le_bytes());
|
||||
assert_eq!(parse(&out).unwrap().samples, vec![7]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_wrong_formats() {
|
||||
assert!(parse(b"OggS...nope").is_err());
|
||||
assert!(parse(&wav_bytes(1, 2, SAMPLE_RATE, 16, &[0])).is_err(), "stereo");
|
||||
assert!(parse(&wav_bytes(1, 1, 22050, 16, &[0])).is_err(), "falsche Rate");
|
||||
assert!(parse(&wav_bytes(1, 1, SAMPLE_RATE, 8, &[0])).is_err(), "8 bit");
|
||||
assert!(parse(&wav_bytes(3, 1, SAMPLE_RATE, 16, &[0])).is_err(), "float-PCM");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn load_missing_file_is_err() {
|
||||
assert!(load("/nonexistent/x.wav").is_err());
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,10 @@
|
||||
//! darüber (Game + Dialog-Modus + Befehls-Interpreter). Beide Frontends
|
||||
//! steuern dieselbe Session: das Fenster (`render`, Default) und die
|
||||
//! Konsolen-REPL (`cli`, via `--cli`).
|
||||
//!
|
||||
//! Flags: `--cli` startet die Konsolen-REPL statt des Fensters; `--scene <name>`
|
||||
//! überspringt das Hauptmenü und startet ein neues Spiel direkt in der Szene
|
||||
//! `assets/maps/<name>/`.
|
||||
|
||||
mod cli;
|
||||
mod engine;
|
||||
@@ -15,11 +19,26 @@ use engine::assets;
|
||||
use session::Session;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
let signals_path = assets::path("assets/signals.toml");
|
||||
let session = Session::new(signals_path.clone());
|
||||
if std::env::args().any(|a| a == "--cli") {
|
||||
cli::run(session, &signals_path);
|
||||
// Der Start ist ein ganz normaler Befehl durch `Session::exec`: ins
|
||||
// Hauptmenü, oder per `--scene` gleich ins Spiel.
|
||||
let boot = match arg_value(&args, "--scene") {
|
||||
Some(scene) => format!("newgame {scene}"),
|
||||
None => "title".to_string(),
|
||||
};
|
||||
if args.iter().any(|a| a == "--cli") {
|
||||
cli::run(session, &signals_path, &boot);
|
||||
} else {
|
||||
render::run(session);
|
||||
render::run(session, &boot);
|
||||
}
|
||||
}
|
||||
|
||||
/// Wert eines `--flag <wert>`-Paars aus `args`, falls das Flag vorkommt und
|
||||
/// ein Wort folgt.
|
||||
fn arg_value(args: &[String], flag: &str) -> Option<String> {
|
||||
args.iter().position(|a| a == flag)
|
||||
.and_then(|i| args.get(i + 1))
|
||||
.cloned()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
//! Audio-Treiber auf tinyaudio — Frontend-Gegenstück zur headless
|
||||
//! Emitter-Logik in engine::audio (wie `Gpu` zu `scene`: die Engine kennt
|
||||
//! dieses Modul nie).
|
||||
//!
|
||||
//! Kein Panic: kein Gerät oder fehlende/kaputte WAVs sind eine Meldung und
|
||||
//! Stille, nie fatal ([`Audio::open`] liefert `None`, alle Aufrufe darauf
|
||||
//! entfallen still beim Aufrufer).
|
||||
//!
|
||||
//! Mono, 44100 Hz (fest, siehe engine::wav). Zwei Voice-Klassen:
|
||||
//! - 8 SFX-Voices: einmal durchlaufen, dann geräumt; sind alle belegt,
|
||||
//! wird die am weitesten gespielte verdrängt (`play`).
|
||||
//! - Ambient-Voices: eine je Emitter, loopen immer; ihr Gain ist die
|
||||
//! Distance ramp, die das Frontend jeden Frame aus
|
||||
//! `Session::emitter_gains` zieht ([`Audio::set_ambient_gains`]).
|
||||
//!
|
||||
//! Gemischt wird im Callback-Thread in f32 über alle aktiven Voices
|
||||
//! (Sample × Gain), am Ende auf [-1, 1] geklemmt. Der Mixer hängt hinter
|
||||
//! einem Mutex; Frontend-Seite fasst ihn nur kurz pro Frame/SFX an.
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use tinyaudio::{run_output_device, OutputDevice, OutputDeviceParameters};
|
||||
|
||||
use crate::engine::wav;
|
||||
|
||||
const SFX_VOICES: usize = 8;
|
||||
/// Callback-Puffergröße in Samples (~6 ms bei 44,1 kHz).
|
||||
const BUFFER_LEN: usize = 256;
|
||||
|
||||
/// Dekodierte Mono-Samples, geteilt zwischen Cache und laufenden Voices.
|
||||
#[derive(Clone)]
|
||||
pub struct Sound {
|
||||
samples: Arc<Vec<i16>>,
|
||||
}
|
||||
|
||||
impl Sound {
|
||||
pub fn new(w: wav::Wav) -> Self {
|
||||
Sound { samples: Arc::new(w.samples) }
|
||||
}
|
||||
}
|
||||
|
||||
struct Voice {
|
||||
samples: Arc<Vec<i16>>,
|
||||
cursor: usize,
|
||||
gain: f32,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct Mixer {
|
||||
sfx: Vec<Option<Voice>>,
|
||||
/// Loop-Voices der Ambient-Emitter, Index = Emitter-Reihenfolge.
|
||||
ambient: Vec<Voice>,
|
||||
}
|
||||
|
||||
impl Mixer {
|
||||
fn mix(&mut self, out: &mut [f32]) {
|
||||
for s in out.iter_mut() {
|
||||
let mut acc = 0.0f32;
|
||||
for slot in self.sfx.iter_mut() {
|
||||
if let Some(v) = slot {
|
||||
acc += v.samples[v.cursor] as f32 * v.gain;
|
||||
v.cursor += 1;
|
||||
if v.cursor >= v.samples.len() { *slot = None; }
|
||||
}
|
||||
}
|
||||
for v in self.ambient.iter_mut() {
|
||||
// Auch bei Gain 0 weiterlaufen lassen: ein Emitter, in dessen
|
||||
// Radius man zurückkehrt, spielt mitten in seiner Schleife —
|
||||
// nicht jedes Mal von vorn.
|
||||
acc += v.samples[v.cursor] as f32 * v.gain;
|
||||
v.cursor = (v.cursor + 1) % v.samples.len();
|
||||
}
|
||||
*s = (acc / 32768.0).clamp(-1.0, 1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Audio {
|
||||
mixer: Arc<Mutex<Mixer>>,
|
||||
_device: OutputDevice, // lebt, solange Audio lebt
|
||||
}
|
||||
|
||||
impl Audio {
|
||||
/// Ausgabegerät öffnen. `None`, wenn keins da ist (Meldung, Spiel läuft
|
||||
/// stumm weiter).
|
||||
pub fn open() -> Option<Self> {
|
||||
// pipewire-pulse/PulseAudio respektiert diese Variable als
|
||||
// Ziel-Latenz des Streams (Default ~50–200 ms) — herabsetzen für
|
||||
// snappige SFX. Muss vor `run_output_device` gesetzt sein; auf
|
||||
// Windows/macOS ignoriert.
|
||||
// SAFETY: einmalig beim Start, bevor weitere Threads laufen (wird
|
||||
// in render::run vor dem stdin-Thread gerufen).
|
||||
unsafe { std::env::set_var("PULSE_LATENCY_MSEC", "15"); }
|
||||
|
||||
let mixer = Arc::new(Mutex::new(Mixer {
|
||||
sfx: (0..SFX_VOICES).map(|_| None).collect(),
|
||||
ambient: Vec::new(),
|
||||
}));
|
||||
let cb_mixer = Arc::clone(&mixer);
|
||||
let device = run_output_device(
|
||||
OutputDeviceParameters {
|
||||
channels_count: 1,
|
||||
sample_rate: wav::SAMPLE_RATE as usize,
|
||||
channel_sample_count: BUFFER_LEN,
|
||||
},
|
||||
move |buf: &mut [f32]| { cb_mixer.lock().unwrap().mix(buf); },
|
||||
);
|
||||
match device {
|
||||
Ok(device) => Some(Audio { mixer, _device: device }),
|
||||
Err(e) => {
|
||||
eprintln!("[audio] kein Ausgabegerät ({e}) — Spiel läuft stumm");
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Einmal-SFX starten: freier Slot, sonst wird die am weitesten
|
||||
/// gespielte Voice verdrängt.
|
||||
pub fn play(&self, s: &Sound) {
|
||||
if s.samples.is_empty() { return; }
|
||||
let mut m = self.mixer.lock().unwrap();
|
||||
let target = m.sfx.iter().enumerate()
|
||||
.max_by_key(|(_, slot)| slot.as_ref().map_or(usize::MAX, |v| v.cursor))
|
||||
.map_or(0, |(i, _)| i);
|
||||
m.sfx[target] = Some(Voice {
|
||||
samples: Arc::clone(&s.samples), cursor: 0, gain: 1.0,
|
||||
});
|
||||
}
|
||||
|
||||
/// Die Ambient-Loop-Voices anlegen — einmal beim Start, Reihenfolge =
|
||||
/// `Session::emitters` (die Gains kommen dann parallel dazu, deshalb
|
||||
/// bekommt auch ein nicht ladbarer Sound seine — stille — Voice).
|
||||
pub fn set_ambients(&self, sounds: &[Option<Sound>]) {
|
||||
let mut m = self.mixer.lock().unwrap();
|
||||
m.ambient = sounds.iter().map(|s| Voice {
|
||||
samples: s.as_ref().map_or_else(|| Arc::new(vec![0]), |s| Arc::clone(&s.samples)),
|
||||
cursor: 0,
|
||||
gain: 0.0,
|
||||
}).collect();
|
||||
}
|
||||
|
||||
/// Distance-ramp-Gains auf die Ambient-Voices legen — jeden Frame, aus
|
||||
/// `Session::emitter_gains`.
|
||||
pub fn set_ambient_gains(&self, gains: &[f32]) {
|
||||
let mut m = self.mixer.lock().unwrap();
|
||||
for (v, g) in m.ambient.iter_mut().zip(gains) {
|
||||
v.gain = *g;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Upscale-Pass: internes 320×240-Target nearest-gesampelt auf die
|
||||
// Upscale-Pass: internes 640×480-Target nearest-gesampelt auf die
|
||||
// Surface. Das 4:3-Letterbox-Rechteck setzt der Rust-Code als Viewport;
|
||||
// hier ist es ein simples Fullscreen-Dreieck mit UVs.
|
||||
|
||||
|
||||
@@ -1,417 +0,0 @@
|
||||
//! Brush → Render-Geometrie.
|
||||
//!
|
||||
//! Ein Quake-Brush ist der Schnitt der Halbräume seiner Face-Ebenen. Aus
|
||||
//! den Ebenen rekonstruieren wir das konvexe Polyeder (Standard-Verfahren:
|
||||
//! alle Ebenen-Tripel schneiden, nur Punkte behalten, die in *allen*
|
||||
//! Halbräumen liegen), bilden pro Face das Polygon und fächern es zu
|
||||
//! Dreiecken. Indizes werden nach Textur gruppiert (ein Draw-Batch je
|
||||
//! Textur).
|
||||
//!
|
||||
//! Koplanar-Elimination: stoßen zwei Brushes aneinander, teilen sie eine
|
||||
//! Fläche — beide Faces liegen auf derselben Ebene, mit entgegengesetzten
|
||||
//! Normalen, und sind nie sichtbar. Wir verwerfen jede Face, die von einer
|
||||
//! solchen gegenüberliegenden Face vollständig überdeckt wird (hinter ihr
|
||||
//! liegt dann garantiert solides Brush-Inneres). Zusammen mit dem Back-face
|
||||
//! Culling der Pipeline bleibt so nur die Außenhaut übrig — ohne BSP.
|
||||
//!
|
||||
//! UVs nach dem Standard-Map-Format: die Textur-Achsen ergeben sich aus der
|
||||
//! dominanten Flächennormale (Quake-`baseaxis`-Tabelle), dann Rotation,
|
||||
//! Skalierung und Offset der Face. Das erzeugt das klassische Quake-
|
||||
//! Verziehen auf schrägen Flächen — gewollt fürs PS1-Gefühl.
|
||||
//!
|
||||
//! Achsen: Quake ist Z-up, unsere Engine Y-up mit Blick -Z. UVs werden im
|
||||
//! Quake-System gerechnet (so sind Offsets/Scale definiert), die Position
|
||||
//! danach umgerechnet: `(qx, qy, qz) → (qx, qz, -qy)`, mal `MAP_SCALE`.
|
||||
|
||||
use crate::engine::map::{Face, Map};
|
||||
use crate::render::scene::{Batch, Mesh, Vertex};
|
||||
|
||||
/// Quake-Einheiten pro Engine-Einheit (32 ≈ klassische „1 Meter"-Annahme).
|
||||
const MAP_SCALE: f32 = 1.0 / 32.0;
|
||||
/// Punkt liegt „auf" einer Ebene / „innerhalb" eines Halbraums (Quake-Units).
|
||||
const ON_EPS: f32 = 1e-2;
|
||||
|
||||
struct Plane {
|
||||
n: [f32; 3], // nach außen, im Quake-System
|
||||
d: f32, // n · x = d
|
||||
}
|
||||
|
||||
/// Ein fertig rekonstruiertes Face-Polygon (Quake-Koords, CCW um `n`),
|
||||
/// vor der UV-/Engine-Umrechnung. Hält die Ebene für die Koplanar-Prüfung
|
||||
/// und einen Verweis auf die Quell-Face (Textur, Offsets, Skalierung).
|
||||
struct FacePoly<'a> {
|
||||
n: [f32; 3],
|
||||
d: f32,
|
||||
poly: Vec<[f32; 3]>,
|
||||
face: &'a Face,
|
||||
}
|
||||
|
||||
/// Distinkte Texturnamen in der Map (sortiert) — die Indizes hier sind die
|
||||
/// Textur-Indizes, auf die `Batch::texture` und der Bilder-Vec verweisen.
|
||||
pub fn texture_names(map: &Map) -> Vec<String> {
|
||||
let mut names: Vec<String> = map.entities.iter()
|
||||
.flat_map(|e| &e.brushes)
|
||||
.flat_map(|b| &b.faces)
|
||||
.map(|f| f.texture.clone())
|
||||
.collect();
|
||||
names.sort_unstable();
|
||||
names.dedup();
|
||||
names
|
||||
}
|
||||
|
||||
/// Alle Brushes zu einem Mesh. `tex_names` (aus [`texture_names`]) gibt die
|
||||
/// Textur-Indizes, `dims` die Pixelmaße je Textur (für UV-Normalisierung).
|
||||
pub fn build(map: &Map, tex_names: &[String], dims: &[(u32, u32)]) -> Mesh {
|
||||
// 1) Alle Face-Polygone rekonstruieren (noch in Quake-Koords).
|
||||
let mut faces: Vec<FacePoly> = Vec::new();
|
||||
for ent in &map.entities {
|
||||
for brush in &ent.brushes {
|
||||
collect_faces(&brush.faces, &mut faces);
|
||||
}
|
||||
}
|
||||
|
||||
// 2) Koplanar verdeckte Faces markieren.
|
||||
let hidden = mark_hidden(&faces);
|
||||
|
||||
// 3) Überlebende mit UV in den Vertex-Buffer ausgeben, nach Textur
|
||||
// gruppiert.
|
||||
let mut verts = Vec::new();
|
||||
let mut per_tex: Vec<Vec<u32>> = vec![Vec::new(); tex_names.len()];
|
||||
for (i, fp) in faces.iter().enumerate() {
|
||||
if hidden[i] { continue; }
|
||||
emit_face(fp, tex_names, dims, &mut verts, &mut per_tex);
|
||||
}
|
||||
|
||||
// Pro-Textur-Indexlisten zu einem Buffer + Batches verflachen.
|
||||
let mut indices = Vec::new();
|
||||
let mut batches = Vec::new();
|
||||
for (ti, list) in per_tex.into_iter().enumerate() {
|
||||
if list.is_empty() { continue; }
|
||||
batches.push(Batch { texture: ti, start: indices.len() as u32, count: list.len() as u32 });
|
||||
indices.extend_from_slice(&list);
|
||||
}
|
||||
Mesh { verts, indices, batches }
|
||||
}
|
||||
|
||||
/// Die Face-Polygone *eines* Brushes rekonstruieren und an `out` anhängen.
|
||||
fn collect_faces<'a>(faces: &'a [Face], out: &mut Vec<FacePoly<'a>>) {
|
||||
let planes: Vec<Plane> = faces.iter().map(|f| plane(&f.plane)).collect();
|
||||
let n = planes.len();
|
||||
|
||||
// Gültige Eckpunkte: Schnitt je dreier Ebenen, sofern in allen
|
||||
// Halbräumen.
|
||||
let mut corners: Vec<[f32; 3]> = Vec::new();
|
||||
for i in 0..n {
|
||||
for j in (i + 1)..n {
|
||||
for k in (j + 1)..n {
|
||||
let Some(p) = intersect(&planes[i], &planes[j], &planes[k]) else { continue; };
|
||||
if planes.iter().all(|pl| dot(pl.n, p) <= pl.d + ON_EPS)
|
||||
&& !corners.iter().any(|q| dist2(*q, p) < ON_EPS * ON_EPS)
|
||||
{
|
||||
corners.push(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Pro Face: Eckpunkte auf der Ebene sammeln, CCW um die Normale sortieren.
|
||||
for (fi, face) in faces.iter().enumerate() {
|
||||
let pl = &planes[fi];
|
||||
let mut poly: Vec<[f32; 3]> = corners.iter().copied()
|
||||
.filter(|&p| (dot(pl.n, p) - pl.d).abs() < ON_EPS)
|
||||
.collect();
|
||||
if poly.len() < 3 { continue; }
|
||||
|
||||
let center = average(&poly);
|
||||
let axis_u = any_perp(pl.n);
|
||||
let axis_v = cross(pl.n, axis_u);
|
||||
poly.sort_by(|a, b| {
|
||||
angle(*a, center, axis_u, axis_v)
|
||||
.partial_cmp(&angle(*b, center, axis_u, axis_v))
|
||||
.unwrap_or(std::cmp::Ordering::Equal)
|
||||
});
|
||||
|
||||
out.push(FacePoly { n: pl.n, d: pl.d, poly, face });
|
||||
}
|
||||
}
|
||||
|
||||
/// Markiert Faces, die von einer gegenüberliegenden, deckungsgleichen Face
|
||||
/// (anderer Brush) vollständig überdeckt werden — also nie sichtbar sind.
|
||||
fn mark_hidden(faces: &[FacePoly]) -> Vec<bool> {
|
||||
let mut hidden = vec![false; faces.len()];
|
||||
for i in 0..faces.len() {
|
||||
let a = &faces[i];
|
||||
for (j, b) in faces.iter().enumerate() {
|
||||
if i == j { continue; }
|
||||
// Gegenüberliegende, koplanare Ebene? (n_a ≈ -n_b und d_a ≈ -d_b,
|
||||
// denn n_b·x = d_b ⇒ n_a·x = -d_b muss a.d treffen.)
|
||||
if dot(a.n, b.n) > -0.999 { continue; }
|
||||
if (a.d + b.d).abs() > ON_EPS { continue; }
|
||||
if covered_by(&a.poly, &b.poly, a.n) {
|
||||
hidden[i] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
hidden
|
||||
}
|
||||
|
||||
/// Liegt jeder Eckpunkt von `inner` innerhalb des Polygons `outer`? Beide
|
||||
/// liegen (per Aufruf) auf derselben Ebene mit Normale `n`; wir projizieren
|
||||
/// in deren 2D-Basis. Testpunkte werden minimal zur Polygonmitte gezogen,
|
||||
/// damit deckungsgleiche Ränder/Ecken eindeutig als „innen" zählen.
|
||||
fn covered_by(inner: &[[f32; 3]], outer: &[[f32; 3]], n: [f32; 3]) -> bool {
|
||||
let u = any_perp(n);
|
||||
let v = cross(n, u);
|
||||
let c = average(inner);
|
||||
let proj = |p: [f32; 3]| -> [f32; 2] { let d = sub(p, c); [dot(d, u), dot(d, v)] };
|
||||
let outer2: Vec<[f32; 2]> = outer.iter().map(|&p| proj(p)).collect();
|
||||
inner.iter().all(|&p| {
|
||||
let pp = [
|
||||
p[0] + 1e-3 * (c[0] - p[0]),
|
||||
p[1] + 1e-3 * (c[1] - p[1]),
|
||||
p[2] + 1e-3 * (c[2] - p[2]),
|
||||
];
|
||||
in_poly_2d(proj(pp), &outer2)
|
||||
})
|
||||
}
|
||||
|
||||
/// Crossing-Number-Punkt-in-Polygon in 2D (orientierungsunabhängig).
|
||||
fn in_poly_2d(p: [f32; 2], poly: &[[f32; 2]]) -> bool {
|
||||
let mut inside = false;
|
||||
let mut j = poly.len() - 1;
|
||||
for i in 0..poly.len() {
|
||||
let (a, b) = (poly[i], poly[j]);
|
||||
if (a[1] > p[1]) != (b[1] > p[1]) {
|
||||
let t = (p[1] - a[1]) / (b[1] - a[1]);
|
||||
if p[0] < a[0] + t * (b[0] - a[0]) { inside = !inside; }
|
||||
}
|
||||
j = i;
|
||||
}
|
||||
inside
|
||||
}
|
||||
|
||||
/// Ein Face-Polygon mit UV in den Vertex-Buffer fächern.
|
||||
fn emit_face(
|
||||
fp: &FacePoly,
|
||||
tex_names: &[String],
|
||||
dims: &[(u32, u32)],
|
||||
verts: &mut Vec<Vertex>,
|
||||
per_tex: &mut [Vec<u32>],
|
||||
) {
|
||||
let Some(ti) = tex_names.iter().position(|nm| nm == &fp.face.texture) else { return; };
|
||||
let (tw, th) = dims[ti];
|
||||
let (su, sv) = tex_axes(fp.n, fp.face); // skalierte Textur-Achsen (Quake)
|
||||
let base = verts.len() as u32;
|
||||
for p in &fp.poly {
|
||||
// UV in Texeln, dann auf 0..1 normalisiert.
|
||||
let u = (dot(*p, su) + fp.face.offset[0]) / tw as f32;
|
||||
let v = (dot(*p, sv) + fp.face.offset[1]) / th as f32;
|
||||
verts.push(Vertex { pos: to_engine(*p), uv: [u, v] });
|
||||
}
|
||||
for t in 1..(fp.poly.len() as u32 - 1) {
|
||||
per_tex[ti].extend([base, base + t, base + t + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
/// Ebene aus drei Face-Punkten. Quake listet sie im Uhrzeigersinn von vorn,
|
||||
/// damit `cross(c-a, b-a)` nach außen zeigt.
|
||||
fn plane(p: &[[f32; 3]; 3]) -> Plane {
|
||||
let n = normalize(cross(sub(p[2], p[0]), sub(p[1], p[0])));
|
||||
Plane { n, d: dot(n, p[0]) }
|
||||
}
|
||||
|
||||
/// Schnittpunkt dreier Ebenen (Cramer); `None`, wenn sie ~parallel sind.
|
||||
fn intersect(a: &Plane, b: &Plane, c: &Plane) -> Option<[f32; 3]> {
|
||||
let denom = dot(a.n, cross(b.n, c.n));
|
||||
if denom.abs() < 1e-6 { return None; }
|
||||
let mut x = scale(cross(b.n, c.n), a.d);
|
||||
x = add(x, scale(cross(c.n, a.n), b.d));
|
||||
x = add(x, scale(cross(a.n, b.n), c.d));
|
||||
Some(scale(x, 1.0 / denom))
|
||||
}
|
||||
|
||||
/// Textur-Achsen (skaliert) im Quake-System nach dem Standard-Map-Format:
|
||||
/// dominante Achse aus der Normale, dann Rotation und Skalierung.
|
||||
fn tex_axes(n: [f32; 3], face: &Face) -> ([f32; 3], [f32; 3]) {
|
||||
let (mut u, mut v) = base_axes(n);
|
||||
|
||||
let (sinv, cosv) = face.rotation.to_radians().sin_cos();
|
||||
// Basis-Achsen sind achsen-ausgerichtet (genau eine Komponente ≠ 0);
|
||||
// wir rotieren ihre beiden in-plane-Komponenten.
|
||||
let su = nonzero_axis(u);
|
||||
let sv = nonzero_axis(v);
|
||||
for vec in [&mut u, &mut v] {
|
||||
let a = cosv * vec[su] - sinv * vec[sv];
|
||||
let b = sinv * vec[su] + cosv * vec[sv];
|
||||
vec[su] = a;
|
||||
vec[sv] = b;
|
||||
}
|
||||
|
||||
let sx = if face.scale[0] == 0.0 { 1.0 } else { face.scale[0] };
|
||||
let sy = if face.scale[1] == 0.0 { 1.0 } else { face.scale[1] };
|
||||
(scale(u, 1.0 / sx), scale(v, 1.0 / sy))
|
||||
}
|
||||
|
||||
/// Quake-`baseaxis`-Tabelle: (Normalen-Kandidat, U-Achse, V-Achse) × 6.
|
||||
/// Die U/V-Achsen der am besten passenden Normale bilden die Textur-Ebene.
|
||||
fn base_axes(n: [f32; 3]) -> ([f32; 3], [f32; 3]) {
|
||||
const BA: [[[f32; 3]; 3]; 6] = [
|
||||
[[0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, -1.0, 0.0]], // Boden (+Z)
|
||||
[[0.0, 0.0, -1.0], [1.0, 0.0, 0.0], [0.0, -1.0, 0.0]], // Decke (-Z)
|
||||
[[ 1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, -1.0]], // West (+X)
|
||||
[[-1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, -1.0]], // Ost (-X)
|
||||
[[0.0, 1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, -1.0]], // Süd (+Y)
|
||||
[[0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, -1.0]], // Nord (-Y)
|
||||
];
|
||||
let mut best = -1.0;
|
||||
let mut bi = 0;
|
||||
for (i, ax) in BA.iter().enumerate() {
|
||||
let d = dot(n, ax[0]);
|
||||
if d > best { best = d; bi = i; }
|
||||
}
|
||||
(BA[bi][1], BA[bi][2])
|
||||
}
|
||||
|
||||
fn to_engine(p: [f32; 3]) -> [f32; 3] {
|
||||
[p[0] * MAP_SCALE, p[2] * MAP_SCALE, -p[1] * MAP_SCALE]
|
||||
}
|
||||
|
||||
// --- kleine Vektor-Helfer auf [f32; 3] ---------------------------------------
|
||||
|
||||
fn sub(a: [f32; 3], b: [f32; 3]) -> [f32; 3] { [a[0] - b[0], a[1] - b[1], a[2] - b[2]] }
|
||||
fn add(a: [f32; 3], b: [f32; 3]) -> [f32; 3] { [a[0] + b[0], a[1] + b[1], a[2] + b[2]] }
|
||||
fn scale(a: [f32; 3], s: f32) -> [f32; 3] { [a[0] * s, a[1] * s, a[2] * s] }
|
||||
fn dot(a: [f32; 3], b: [f32; 3]) -> f32 { a[0] * b[0] + a[1] * b[1] + a[2] * b[2] }
|
||||
fn dist2(a: [f32; 3], b: [f32; 3]) -> f32 { let d = sub(a, b); dot(d, d) }
|
||||
|
||||
fn cross(a: [f32; 3], b: [f32; 3]) -> [f32; 3] {
|
||||
[a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]
|
||||
}
|
||||
|
||||
fn normalize(a: [f32; 3]) -> [f32; 3] {
|
||||
let len = dot(a, a).sqrt();
|
||||
if len > 0.0 { scale(a, 1.0 / len) } else { a }
|
||||
}
|
||||
|
||||
fn average(pts: &[[f32; 3]]) -> [f32; 3] {
|
||||
let mut c = [0.0; 3];
|
||||
for p in pts { c = add(c, *p); }
|
||||
scale(c, 1.0 / pts.len() as f32)
|
||||
}
|
||||
|
||||
/// Index der (einzigen) Nicht-Null-Komponente einer achsen-ausgerichteten Achse.
|
||||
fn nonzero_axis(a: [f32; 3]) -> usize {
|
||||
if a[0] != 0.0 { 0 } else if a[1] != 0.0 { 1 } else { 2 }
|
||||
}
|
||||
|
||||
/// Achse in der Ebene, möglichst weit weg von der Normale, als Sortier-Basis.
|
||||
fn any_perp(n: [f32; 3]) -> [f32; 3] {
|
||||
let a = if n[0].abs() < 0.9 { [1.0, 0.0, 0.0] } else { [0.0, 1.0, 0.0] };
|
||||
normalize(cross(n, a))
|
||||
}
|
||||
|
||||
/// Winkel von `p` um `center` in der (u, v)-Basis — für CCW-Sortierung.
|
||||
fn angle(p: [f32; 3], center: [f32; 3], u: [f32; 3], v: [f32; 3]) -> f32 {
|
||||
let d = sub(p, center);
|
||||
dot(d, v).atan2(dot(d, u))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::engine::map;
|
||||
|
||||
// Ein achsenparalleler Quader-Brush (x[-48,80], y[-64,64], z[-48,-16]).
|
||||
const BOX: &str = r#"
|
||||
{
|
||||
"classname" "worldspawn"
|
||||
{
|
||||
( -48 -64 -48 ) ( -48 -63 -48 ) ( -48 -64 -47 ) t 0 0 0 1 1
|
||||
( -48 -64 -48 ) ( -48 -64 -47 ) ( -47 -64 -48 ) t 0 0 0 1 1
|
||||
( -48 -64 -48 ) ( -47 -64 -48 ) ( -48 -63 -48 ) t 0 0 0 1 1
|
||||
( 80 64 -16 ) ( 80 65 -16 ) ( 81 64 -16 ) t 0 0 0 1 1
|
||||
( 80 64 -16 ) ( 81 64 -16 ) ( 80 64 -15 ) t 0 0 0 1 1
|
||||
( 80 64 -16 ) ( 80 64 -15 ) ( 80 65 -16 ) t 0 0 0 1 1
|
||||
}
|
||||
}
|
||||
"#;
|
||||
|
||||
#[test]
|
||||
fn box_brush_has_cuboid_geometry() {
|
||||
let m = map::parse(BOX);
|
||||
let names = texture_names(&m);
|
||||
assert_eq!(names, vec!["t".to_string()]);
|
||||
let mesh = build(&m, &names, &[(64, 64)]);
|
||||
|
||||
// Quader: 6 Faces · 4 Ecken = 24 Vertices, 6 · 2 Dreiecke · 3 = 36 Indizes.
|
||||
assert_eq!(mesh.verts.len(), 24);
|
||||
assert_eq!(mesh.indices.len(), 36);
|
||||
// Eine Textur → ein Batch über alle Indizes.
|
||||
assert_eq!(mesh.batches.len(), 1);
|
||||
assert_eq!((mesh.batches[0].texture, mesh.batches[0].start, mesh.batches[0].count), (0, 0, 36));
|
||||
|
||||
// Engine-Bounds: x[-1.5,2.5], y(=quake z)[-1.5,-0.5], z(=-quake y)[-2,2].
|
||||
let (mut mn, mut mx) = ([f32::MAX; 3], [f32::MIN; 3]);
|
||||
for v in &mesh.verts {
|
||||
for k in 0..3 {
|
||||
mn[k] = mn[k].min(v.pos[k]);
|
||||
mx[k] = mx[k].max(v.pos[k]);
|
||||
}
|
||||
}
|
||||
let approx = |a: f32, b: f32| (a - b).abs() < 1e-4;
|
||||
assert!(approx(mn[0], -1.5) && approx(mx[0], 2.5), "x: {:?}..{:?}", mn[0], mx[0]);
|
||||
assert!(approx(mn[1], -1.5) && approx(mx[1], -0.5), "y: {:?}..{:?}", mn[1], mx[1]);
|
||||
assert!(approx(mn[2], -2.0) && approx(mx[2], 2.0), "z: {:?}..{:?}", mn[2], mx[2]);
|
||||
}
|
||||
|
||||
// Zwei achsenparallele Würfel, die sich die Ebene x=64 teilen:
|
||||
// A = x[0,64], B = x[64,128], beide y[0,64] z[0,64].
|
||||
const TWO_BOXES: &str = r#"
|
||||
{
|
||||
"classname" "worldspawn"
|
||||
{
|
||||
( 0 0 0 ) ( 0 1 0 ) ( 0 0 1 ) t 0 0 0 1 1
|
||||
( 0 0 0 ) ( 0 0 1 ) ( 1 0 0 ) t 0 0 0 1 1
|
||||
( 0 0 0 ) ( 1 0 0 ) ( 0 1 0 ) t 0 0 0 1 1
|
||||
( 64 64 64 ) ( 64 65 64 ) ( 65 64 64 ) t 0 0 0 1 1
|
||||
( 64 64 64 ) ( 65 64 64 ) ( 64 64 65 ) t 0 0 0 1 1
|
||||
( 64 64 64 ) ( 64 64 65 ) ( 64 65 64 ) t 0 0 0 1 1
|
||||
}
|
||||
{
|
||||
( 64 0 0 ) ( 64 1 0 ) ( 64 0 1 ) t 0 0 0 1 1
|
||||
( 64 0 0 ) ( 64 0 1 ) ( 65 0 0 ) t 0 0 0 1 1
|
||||
( 64 0 0 ) ( 65 0 0 ) ( 64 1 0 ) t 0 0 0 1 1
|
||||
( 128 64 64 ) ( 128 65 64 ) ( 129 64 64 ) t 0 0 0 1 1
|
||||
( 128 64 64 ) ( 129 64 64 ) ( 128 64 65 ) t 0 0 0 1 1
|
||||
( 128 64 64 ) ( 128 64 65 ) ( 128 65 64 ) t 0 0 0 1 1
|
||||
}
|
||||
}
|
||||
"#;
|
||||
|
||||
#[test]
|
||||
fn shared_faces_are_eliminated() {
|
||||
let m = map::parse(TWO_BOXES);
|
||||
let names = texture_names(&m);
|
||||
let mesh = build(&m, &names, &[(64, 64)]);
|
||||
|
||||
// 2 Würfel · 6 Faces = 12, minus die 2 deckungsgleichen an x=64 → 10.
|
||||
// 10 Faces · 4 Ecken = 40 Vertices, 10 · 2 Dreiecke · 3 = 60 Indizes.
|
||||
// (Ohne Elimination wären es 48 Vertices / 72 Indizes.)
|
||||
assert_eq!(mesh.verts.len(), 40);
|
||||
assert_eq!(mesh.indices.len(), 60);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn uvs_scale_with_texture_size() {
|
||||
// Auf der +Z-Boden-Face (baseaxis U=+X, V=-Y) ist U = qx/tw, V = -qy/th
|
||||
// bei Offset 0, Scale 1. Prüft, dass UVs in Texeln/Größe gerechnet werden.
|
||||
let m = map::parse(BOX);
|
||||
let names = texture_names(&m);
|
||||
let mesh = build(&m, &names, &[(64, 64)]);
|
||||
// Alle UVs endlich und im erwarteten groben Bereich (Brush ~128 units
|
||||
// breit / 64 Texel → bis ~2).
|
||||
assert!(mesh.verts.iter().all(|v| v.uv[0].is_finite() && v.uv[1].is_finite()));
|
||||
assert!(mesh.verts.iter().any(|v| v.uv[0].abs() > 0.5));
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
//! Flycam: freie Debug-/Entwicklungskamera (Schritt 4). Position, Yaw und
|
||||
//! Pitch in f32 — Port der irl3d-Kamera-Idee, aber ohne Q16.16: an dieser
|
||||
//! Kamera hängt keine Physik, und der Renderer rechnet ohnehin f32.
|
||||
//!
|
||||
//! Konvention wie `math::Mat4::view`: yaw=0 blickt -Z, positiver Yaw dreht
|
||||
//! nach links, positiver Pitch hebt den Blick.
|
||||
|
||||
use crate::render::math::Mat4;
|
||||
|
||||
/// Knapp unter 90°: hält den Blick aus der Senkrechten, wo Yaw bedeutungslos
|
||||
/// würde (und `right`/`forward` zusammenfielen).
|
||||
const PITCH_LIMIT: f32 = 1.55;
|
||||
|
||||
pub struct Camera {
|
||||
pub pos: [f32; 3],
|
||||
pub yaw: f32,
|
||||
pub pitch: f32,
|
||||
}
|
||||
|
||||
impl Camera {
|
||||
pub fn new(pos: [f32; 3]) -> Self {
|
||||
Self { pos, yaw: 0.0, pitch: 0.0 }
|
||||
}
|
||||
|
||||
/// Roh-Maus-Delta (Pixel) → Yaw/Pitch. `sens` in Radiant pro Pixel.
|
||||
/// Maus nach rechts dreht den Blick nach rechts (Yaw sinkt), Maus nach
|
||||
/// unten senkt ihn; Pitch wird geclamped.
|
||||
pub fn apply_mouse(&mut self, dx: f32, dy: f32, sens: f32) {
|
||||
self.yaw -= dx * sens;
|
||||
self.pitch = (self.pitch - dy * sens).clamp(-PITCH_LIMIT, PITCH_LIMIT);
|
||||
}
|
||||
|
||||
/// Blickrichtung inkl. Pitch — W/S bewegen sich hier entlang.
|
||||
fn forward(&self) -> [f32; 3] {
|
||||
let (sy, cy) = self.yaw.sin_cos();
|
||||
let (sp, cp) = self.pitch.sin_cos();
|
||||
[-sy * cp, sp, -cy * cp]
|
||||
}
|
||||
|
||||
/// Horizontales Rechts (ohne Pitch) — A/D strafen hier entlang, ohne
|
||||
/// dass der Blick nach oben/unten die Bewegung kippt.
|
||||
fn right(&self) -> [f32; 3] {
|
||||
let (sy, cy) = self.yaw.sin_cos();
|
||||
[cy, 0.0, -sy]
|
||||
}
|
||||
|
||||
/// Bewegung integrieren. `fwd`/`right`/`up` je in [-1, 1] (Tastenachsen),
|
||||
/// `dist` ist die Strecke diesen Frame (Speed · dt). Hoch/runter ist
|
||||
/// Welt-Y, damit Auf-/Absteigen unabhängig vom Blickwinkel bleibt.
|
||||
pub fn translate(&mut self, fwd: f32, right: f32, up: f32, dist: f32) {
|
||||
let f = self.forward();
|
||||
let r = self.right();
|
||||
for i in 0..3 {
|
||||
self.pos[i] += (f[i] * fwd + r[i] * right) * dist;
|
||||
}
|
||||
self.pos[1] += up * dist;
|
||||
}
|
||||
|
||||
pub fn view(&self) -> Mat4 {
|
||||
Mat4::view(self.pos, self.yaw, self.pitch)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// Die Bewegungs-Basis (`forward`) muss exakt zu der Richtung passen,
|
||||
/// die `view()` als „vor der Kamera" definiert — sonst driften
|
||||
/// Steuerung und Bild auseinander. Ein Punkt `d` vor der Kamera muss
|
||||
/// in View-Space auf (0, 0, -d) landen.
|
||||
#[test]
|
||||
fn forward_matches_view() {
|
||||
for &(yaw, pitch) in &[(0.0, 0.0), (0.7, 0.0), (0.0, 0.5), (1.2, -0.4)] {
|
||||
let c = Camera { pos: [1.0, 2.0, 3.0], yaw, pitch };
|
||||
let f = c.forward();
|
||||
let ahead = [
|
||||
c.pos[0] + f[0] * 5.0,
|
||||
c.pos[1] + f[1] * 5.0,
|
||||
c.pos[2] + f[2] * 5.0,
|
||||
1.0,
|
||||
];
|
||||
let v = c.view().transform(ahead);
|
||||
assert!(
|
||||
(v[0]).abs() < 1e-4 && (v[1]).abs() < 1e-4 && (v[2] + 5.0).abs() < 1e-4,
|
||||
"yaw={yaw} pitch={pitch}: {v:?}",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// `right` muss horizontal sein und im View-Space nach +X zeigen
|
||||
/// (sonst wären A/D vertauscht oder gekippt).
|
||||
#[test]
|
||||
fn right_is_horizontal_and_points_view_right() {
|
||||
let c = Camera { pos: [0.0, 0.0, 0.0], yaw: 0.6, pitch: 0.3 };
|
||||
let r = c.right();
|
||||
assert!(r[1].abs() < 1e-6, "right darf kein Y haben: {r:?}");
|
||||
let p = [r[0] * 5.0, r[1] * 5.0, r[2] * 5.0, 1.0];
|
||||
let v = c.view().transform(p);
|
||||
assert!(v[0] > 4.0, "right sollte nach View-+X zeigen: {v:?}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// Post-Effekt „dither": RGB555-Quantisierung mit 4×4-Bayer-Ordered-Dither —
|
||||
// die PS1-Farbtiefe. Gehört ans Ende der Kette: quantisieren ist der letzte
|
||||
// Schritt vor der Ausgabe.
|
||||
//
|
||||
// Vertex-Stufe kommt aus fullscreen.wgsl. Eingang ist das Bild des
|
||||
// vorherigen Kettenglieds, 1:1 per textureLoad — kein Sampler, keine
|
||||
// Filterung, ein Ziel-Pixel liest genau ein Quell-Pixel.
|
||||
|
||||
@group(0) @binding(0) var src: texture_2d<f32>;
|
||||
|
||||
// 4×4-Bayer-Matrix (Werte 0..15).
|
||||
fn bayer4(px: vec2u) -> f32 {
|
||||
var m = array<u32, 16>(
|
||||
0u, 8u, 2u, 10u,
|
||||
12u, 4u, 14u, 6u,
|
||||
3u, 11u, 1u, 9u,
|
||||
15u, 7u, 13u, 5u,
|
||||
);
|
||||
return f32(m[(px.y % 4u) * 4u + (px.x % 4u)]);
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fs_main(@builtin(position) pos: vec4f) -> @location(0) vec4f {
|
||||
let px = vec2u(pos.xy);
|
||||
let c = clamp(textureLoad(src, vec2i(px), 0).rgb, vec3f(0.0), vec3f(1.0));
|
||||
// RGB555: 31 Stufen pro Kanal. Bayer-Schwelle vor dem Abrunden →
|
||||
// Verläufe zerfallen ins typische Dither-Muster.
|
||||
let t = (bayer4(px) + 0.5) / 16.0;
|
||||
return vec4f(floor(c * 31.0 + t) / 31.0, 1.0);
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
//! seinen GPU-Textur-Index, damit `ui::Ui::text` ohne Zusatzargumente damit
|
||||
//! zeichnen kann.
|
||||
|
||||
use crate::engine::tga::Image;
|
||||
use crate::engine::image::Image;
|
||||
|
||||
const COLS: u32 = 32;
|
||||
|
||||
@@ -41,15 +41,17 @@ pub(crate) struct Font {
|
||||
/// gereicht.
|
||||
pub(crate) struct Fonts {
|
||||
pub(crate) ega: Font,
|
||||
/// Kleinerer Font, für späteres HUD-Kleinzeug bereitgehalten.
|
||||
#[allow(dead_code)]
|
||||
pub(crate) cga: Font,
|
||||
}
|
||||
|
||||
impl Font {
|
||||
/// EGA 8×14 (`assets/textures/fonts/oldschool-ega-8x14.tga`, 256×112).
|
||||
/// EGA 8×14 (`assets/textures/fonts/oldschool-ega-8x14.png`, 256×112).
|
||||
pub(crate) fn ega(tex: usize, atlas: &Image) -> Font {
|
||||
Font::measure(8.0, 14.0, 256.0, 112.0, tex, atlas)
|
||||
}
|
||||
/// CGA 8×8 (`assets/textures/fonts/oldschool-cga-8x8.tga`, 256×64).
|
||||
/// CGA 8×8 (`assets/textures/fonts/oldschool-cga-8x8.png`, 256×64).
|
||||
pub(crate) fn cga(tex: usize, atlas: &Image) -> Font {
|
||||
Font::measure(8.0, 8.0, 256.0, 64.0, tex, atlas)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// Vertex-Stufe *aller* Post-Effekte: ein Dreieck über den ganzen Schirm.
|
||||
//
|
||||
// Bewusst ein eigenes Modul: die Pipeline nimmt die Vertex-Stufe von hier und
|
||||
// die Fragment-Stufe aus der Effekt-Datei. So besteht eine Effekt-Datei nur
|
||||
// aus ihrem `fs_main` und kennt keinen anderen Shader.
|
||||
|
||||
struct VsOut {
|
||||
@builtin(position) pos: vec4f,
|
||||
};
|
||||
|
||||
@vertex
|
||||
fn vs_main(@builtin(vertex_index) i: u32) -> VsOut {
|
||||
var xy = array<vec2f, 3>(
|
||||
vec2f(-1.0, -1.0), vec2f(3.0, -1.0), vec2f(-1.0, 3.0),
|
||||
);
|
||||
var o: VsOut;
|
||||
o.pos = vec4f(xy[i], 0.0, 1.0);
|
||||
return o;
|
||||
}
|
||||
@@ -1,42 +1,57 @@
|
||||
//! wgpu-Zustand: Surface, Device und der zweistufige Render-Pfad
|
||||
//! aus dem Renderer-Plan:
|
||||
//! wgpu-Zustand: Surface, Device und der interne Render-Pfad:
|
||||
//!
|
||||
//! Pass 1 (intern): 320×240 RGBA8 + Depth — hier entsteht das Bild
|
||||
//! ([`ScenePass`], PS1-Shader).
|
||||
//! Pass 2 (Fenster): Nearest-Upscale des internen Targets mit
|
||||
//! 4:3-Letterbox (via Viewport) auf die Surface.
|
||||
//! Szene (intern): 640×480 RGBA8 + Depth — Geometrie und Textur
|
||||
//! ([`ScenePass`]).
|
||||
//! Post (intern): die Effekt-Kette ([`Post`]), Ping-Pong zwischen zwei
|
||||
//! Targets; jeder Effekt einzeln schaltbar.
|
||||
//! Overlay (intern): das UI ([`SpritePass`]) — *nach* der Kette, damit
|
||||
//! Bild-Effekte nur die Welt treffen, nie den Text.
|
||||
//! Blit (Fenster): Nearest-Upscale mit 4:3-Letterbox (via Viewport).
|
||||
//!
|
||||
//! 640×480 (VGA) statt 320×240: das Spiel ist text-getrieben — die höhere
|
||||
//! Auflösung trägt den 80-Spalten-Textmodus-Look (EGA 8×14), der Lo-Fi-Rest
|
||||
//! (RGB555 + Bayer-Dither, affines Mapping) bleibt.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use winit::window::Window;
|
||||
|
||||
use crate::engine::tga::Image;
|
||||
use crate::engine::image::Image;
|
||||
use crate::render::math::Mat4;
|
||||
use crate::render::post::{Post, PostChain};
|
||||
use crate::render::scene::{Mesh, ScenePass};
|
||||
use crate::render::sprite::SpritePass;
|
||||
use crate::render::ui::Ui;
|
||||
|
||||
pub const INTERNAL_W: u32 = 320;
|
||||
pub const INTERNAL_H: u32 = 240;
|
||||
pub const INTERNAL_W: u32 = 640;
|
||||
pub const INTERNAL_H: u32 = 480;
|
||||
|
||||
/// D16 reicht für PS1-Geometrieskalen und ist das älteste, überall
|
||||
/// (auch GL-Fallback) unterstützte Depth-Format.
|
||||
const DEPTH_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Depth16Unorm;
|
||||
const INTERNAL_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8Unorm;
|
||||
|
||||
/// Near-/Far-Ebene der Projektion. Auch die Post-Kette bekommt sie (als
|
||||
/// Uniform), damit kein Effekt-Shader die Werte abschreiben muss, um die
|
||||
/// Tiefe zu linearisieren — sonst lügen sie, sobald die Kamera sich ändert.
|
||||
const NEAR_FAR: [f32; 2] = [0.1, 100.0];
|
||||
|
||||
pub struct Gpu {
|
||||
surface: wgpu::Surface<'static>,
|
||||
device: wgpu::Device,
|
||||
queue: wgpu::Queue,
|
||||
config: wgpu::SurfaceConfiguration,
|
||||
|
||||
internal_view: wgpu::TextureView,
|
||||
depth_view: wgpu::TextureView,
|
||||
|
||||
scene: ScenePass,
|
||||
post: Post,
|
||||
sprite: SpritePass,
|
||||
blit_pipeline: wgpu::RenderPipeline,
|
||||
blit_bind: wgpu::BindGroup,
|
||||
/// Blit-Bind-Group je Post-Target — welche gilt, sagt [`Post::run`].
|
||||
blit_binds: [wgpu::BindGroup; 2],
|
||||
/// Nullpunkt der Shader-Zeit (Post-Uniform).
|
||||
start: std::time::Instant,
|
||||
}
|
||||
|
||||
impl Gpu {
|
||||
@@ -94,19 +109,21 @@ impl Gpu {
|
||||
};
|
||||
surface.configure(&device, &config);
|
||||
|
||||
let (internal_view, depth_view) = make_internal_targets(&device);
|
||||
let depth_view = make_depth_target(&device);
|
||||
|
||||
// Pass 1: die Szene. Geometrie + Bilder kommen fertig vom Aufrufer
|
||||
// (Decode in render::run); hier wird nur hochgeladen.
|
||||
// Szene: Geometrie + Bilder kommen fertig vom Aufrufer (Decode in
|
||||
// render::run); hier wird nur hochgeladen.
|
||||
let scene = ScenePass::new(&device, &queue, INTERNAL_FORMAT, DEPTH_FORMAT, mesh, images);
|
||||
let post = Post::new(
|
||||
&device, INTERNAL_FORMAT, [INTERNAL_W, INTERNAL_H], &depth_view, NEAR_FAR);
|
||||
|
||||
// Overlay-Pass: zeichnet nach der Szene ins selbe interne Target.
|
||||
// Overlay: eigener Pass hinter der Kette, ohne Tiefe.
|
||||
let sprite = SpritePass::new(
|
||||
&device, &queue, INTERNAL_FORMAT, DEPTH_FORMAT,
|
||||
&device, &queue, INTERNAL_FORMAT,
|
||||
[INTERNAL_W as f32, INTERNAL_H as f32], ui_textures,
|
||||
);
|
||||
|
||||
// Pass 2: internes Target nearest-gesampelt auf die Surface.
|
||||
// Blit: das fertige interne Bild nearest-gesampelt auf die Surface.
|
||||
let blit_shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
||||
label: Some("blit"),
|
||||
source: wgpu::ShaderSource::Wgsl(include_str!("blit.wgsl").into()),
|
||||
@@ -138,28 +155,38 @@ impl Gpu {
|
||||
min_filter: wgpu::FilterMode::Nearest,
|
||||
..Default::default()
|
||||
});
|
||||
let blit_bind = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||
let blit_layout = blit_pipeline.get_bind_group_layout(0);
|
||||
let blit_bind = |view: &wgpu::TextureView| {
|
||||
device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||
label: Some("blit"),
|
||||
layout: &blit_pipeline.get_bind_group_layout(0),
|
||||
layout: &blit_layout,
|
||||
entries: &[
|
||||
wgpu::BindGroupEntry {
|
||||
binding: 0,
|
||||
resource: wgpu::BindingResource::TextureView(&internal_view),
|
||||
resource: wgpu::BindingResource::TextureView(view),
|
||||
},
|
||||
wgpu::BindGroupEntry {
|
||||
binding: 1,
|
||||
resource: wgpu::BindingResource::Sampler(&sampler),
|
||||
},
|
||||
],
|
||||
});
|
||||
})
|
||||
};
|
||||
let blit_binds = [blit_bind(post.view(0)), blit_bind(post.view(1))];
|
||||
|
||||
Self {
|
||||
surface, device, queue, config,
|
||||
internal_view, depth_view,
|
||||
scene, sprite, blit_pipeline, blit_bind,
|
||||
depth_view,
|
||||
scene, post, sprite, blit_pipeline, blit_binds,
|
||||
start: std::time::Instant::now(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Die Szenen-Welt austauschen (Szenenwechsel, siehe `Session::take_scene`).
|
||||
pub fn set_world(&mut self, mesh: &Mesh, images: &[Image]) {
|
||||
self.scene.set_world(&self.device, &self.queue, mesh, images);
|
||||
}
|
||||
|
||||
pub fn resize(&mut self, width: u32, height: u32) {
|
||||
self.config.width = width.max(1);
|
||||
self.config.height = height.max(1);
|
||||
@@ -175,17 +202,18 @@ impl Gpu {
|
||||
[ix.clamp(0.0, INTERNAL_W as f32), iy.clamp(0.0, INTERNAL_H as f32)]
|
||||
}
|
||||
|
||||
/// Einen Frame rendern. Die View-Matrix kommt vom Aufrufer (Flycam);
|
||||
/// Einen Frame rendern. Die View-Matrix kommt vom Aufrufer;
|
||||
/// die Projektion gehört hierher, weil sie an der internen Auflösung
|
||||
/// hängt.
|
||||
pub fn frame(&mut self, view: &Mat4, ui: &Ui) {
|
||||
pub fn frame(&mut self, view: &Mat4, ui: &Ui, post: &PostChain) {
|
||||
let proj = Mat4::perspective(
|
||||
60f32.to_radians(),
|
||||
INTERNAL_W as f32 / INTERNAL_H as f32,
|
||||
0.1, 100.0,
|
||||
NEAR_FAR[0], NEAR_FAR[1],
|
||||
);
|
||||
let half_res = [INTERNAL_W as f32 * 0.5, INTERNAL_H as f32 * 0.5];
|
||||
self.scene.prepare(&self.queue, &proj.mul(view), half_res);
|
||||
self.post.prepare(&self.queue, self.start.elapsed().as_secs_f32());
|
||||
self.sprite.prepare(&self.queue, &ui.verts);
|
||||
|
||||
use wgpu::CurrentSurfaceTexture as Cst;
|
||||
@@ -204,19 +232,22 @@ impl Gpu {
|
||||
let surface_view = frame.texture.create_view(&Default::default());
|
||||
let mut enc = self.device.create_command_encoder(&Default::default());
|
||||
|
||||
// Pass 1: intern.
|
||||
// Szene füllt den G-Buffer: Albedo ins erste Post-Target, Normale ins
|
||||
// zweite Attachment.
|
||||
{
|
||||
let mut pass = enc.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
label: Some("internal"),
|
||||
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||
view: &self.internal_view,
|
||||
let [albedo, normal] = self.post.scene_targets();
|
||||
let attach = |view| Some(wgpu::RenderPassColorAttachment {
|
||||
view,
|
||||
depth_slice: None,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
|
||||
store: wgpu::StoreOp::Store,
|
||||
},
|
||||
})],
|
||||
});
|
||||
let mut pass = enc.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
label: Some("scene"),
|
||||
color_attachments: &[attach(albedo), attach(normal)],
|
||||
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
|
||||
view: &self.depth_view,
|
||||
depth_ops: Some(wgpu::Operations {
|
||||
@@ -230,11 +261,33 @@ impl Gpu {
|
||||
multiview_mask: None,
|
||||
});
|
||||
self.scene.draw(&mut pass);
|
||||
// Overlay obenauf, im selben Pass (kein Tiefentest).
|
||||
}
|
||||
|
||||
// Effekt-Kette; sie sagt, welches Target das Bild jetzt trägt.
|
||||
let out = self.post.run(&mut enc, post);
|
||||
|
||||
// Overlay obendrauf — nach der Kette, also von keinem Effekt berührt.
|
||||
{
|
||||
let mut pass = enc.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
label: Some("overlay"),
|
||||
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||
view: self.post.view(out),
|
||||
depth_slice: None,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
load: wgpu::LoadOp::Load,
|
||||
store: wgpu::StoreOp::Store,
|
||||
},
|
||||
})],
|
||||
depth_stencil_attachment: None,
|
||||
timestamp_writes: None,
|
||||
occlusion_query_set: None,
|
||||
multiview_mask: None,
|
||||
});
|
||||
self.sprite.draw(&mut pass, &ui.batches);
|
||||
}
|
||||
|
||||
// Pass 2: Letterbox-Blit aufs Fenster.
|
||||
// Letterbox-Blit aufs Fenster.
|
||||
{
|
||||
let mut pass = enc.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
label: Some("blit"),
|
||||
@@ -256,7 +309,7 @@ impl Gpu {
|
||||
let (vx, vy, vw, vh) = letterbox(self.config.width, self.config.height);
|
||||
pass.set_viewport(vx, vy, vw, vh, 0.0, 1.0);
|
||||
pass.set_pipeline(&self.blit_pipeline);
|
||||
pass.set_bind_group(0, &self.blit_bind, &[]);
|
||||
pass.set_bind_group(0, &self.blit_binds[out], &[]);
|
||||
pass.draw(0..3, 0..1);
|
||||
}
|
||||
|
||||
@@ -265,31 +318,21 @@ impl Gpu {
|
||||
}
|
||||
}
|
||||
|
||||
fn make_internal_targets(device: &wgpu::Device) -> (wgpu::TextureView, wgpu::TextureView) {
|
||||
let size = wgpu::Extent3d {
|
||||
width: INTERNAL_W, height: INTERNAL_H, depth_or_array_layers: 1,
|
||||
};
|
||||
let color = device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: Some("internal color"),
|
||||
size,
|
||||
mip_level_count: 1,
|
||||
sample_count: 1,
|
||||
dimension: wgpu::TextureDimension::D2,
|
||||
format: INTERNAL_FORMAT,
|
||||
usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::TEXTURE_BINDING,
|
||||
view_formats: &[],
|
||||
});
|
||||
fn make_depth_target(device: &wgpu::Device) -> wgpu::TextureView {
|
||||
let depth = device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: Some("internal depth"),
|
||||
size,
|
||||
size: wgpu::Extent3d {
|
||||
width: INTERNAL_W, height: INTERNAL_H, depth_or_array_layers: 1,
|
||||
},
|
||||
mip_level_count: 1,
|
||||
sample_count: 1,
|
||||
dimension: wgpu::TextureDimension::D2,
|
||||
format: DEPTH_FORMAT,
|
||||
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
|
||||
// TEXTURE_BINDING: die Post-Kette liest die Tiefe (Outline, Nebel).
|
||||
usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::TEXTURE_BINDING,
|
||||
view_formats: &[],
|
||||
});
|
||||
(color.create_view(&Default::default()), depth.create_view(&Default::default()))
|
||||
depth.create_view(&Default::default())
|
||||
}
|
||||
|
||||
/// Größtes 4:3-Rechteck, das ins Fenster passt, zentriert.
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
//! Minimale f32-Matrix-Mathematik für den Renderer — bewusst handgerollt
|
||||
//! statt glam: PS1-Style braucht nur Multiply, View und Perspective.
|
||||
//! (Die Spiellogik bekommt später ihr eigenes Q16.16 wie irl3d; das hier
|
||||
//! ist nur der GPU-Pfad.)
|
||||
//! statt glam: nötig sind nur Multiply, View und Perspective.
|
||||
//!
|
||||
//! Konventionen:
|
||||
//! - rechtshändig, Kamera blickt -Z, +Y oben (wie Blender-OBJ-Export)
|
||||
//! - rechtshändig, Kamera blickt -Z, +Y oben (wie der Blender-Export)
|
||||
//! - Spaltenvektoren, Speicher column-major — `Mat4.0[spalte][zeile]`,
|
||||
//! bytemuck-kompatibel zu WGSL `mat4x4f`
|
||||
//! - Clip-Z in [0,1] (wgpu/WebGPU, nicht GL-[-1,1])
|
||||
@@ -21,6 +19,7 @@ impl Mat4 {
|
||||
[0.0, 0.0, 0.0, 1.0],
|
||||
]);
|
||||
|
||||
#[allow(clippy::needless_range_loop)] // Zeilen-/Spalten-Index ist bei 4×4-Mathematik klarer als Iteratoren
|
||||
pub fn mul(&self, rhs: &Mat4) -> Mat4 {
|
||||
let mut out = [[0.0f32; 4]; 4];
|
||||
for c in 0..4 {
|
||||
@@ -34,6 +33,7 @@ impl Mat4 {
|
||||
/// Punkt-Transformation auf der CPU — bisher nur von den Tests
|
||||
/// gebraucht; der Renderer transformiert auf der GPU.
|
||||
#[cfg(test)]
|
||||
#[allow(clippy::needless_range_loop)] // Zeilen-Index ist bei der Matrix-Vektor-Mathematik klarer
|
||||
pub fn transform(&self, v: [f32; 4]) -> [f32; 4] {
|
||||
let mut out = [0.0f32; 4];
|
||||
for r in 0..4 {
|
||||
@@ -65,8 +65,7 @@ impl Mat4 {
|
||||
}
|
||||
|
||||
/// FPS-View: erst Kamera-Position abziehen, dann Yaw, dann Pitch
|
||||
/// herausdrehen. Yaw/Pitch wie die irl3d-Kamera: yaw=0 blickt -Z,
|
||||
/// positiver Pitch hebt den Blick.
|
||||
/// herausdrehen. yaw=0 blickt -Z, positiver Pitch hebt den Blick.
|
||||
pub fn view(pos: [f32; 3], yaw: f32, pitch: f32) -> Mat4 {
|
||||
Mat4::rot_x(-pitch)
|
||||
.mul(&Mat4::rot_y(-yaw))
|
||||
@@ -102,8 +101,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn view_yaw_quarter_turn_looks_minus_x() {
|
||||
// yaw=90°: Blick Richtung -X (irl3d-Konvention) — ein Punkt auf
|
||||
// -X liegt dann vor der Kamera.
|
||||
// yaw=90°: Blick Richtung -X — ein Punkt auf -X liegt vor der Kamera.
|
||||
let v = Mat4::view([0.0, 0.0, 0.0], std::f32::consts::FRAC_PI_2, 0.0);
|
||||
assert!(close(v.transform([-2.0, 0.0, 0.0, 1.0]), [0.0, 0.0, -2.0, 1.0]));
|
||||
}
|
||||
@@ -114,6 +112,30 @@ mod tests {
|
||||
assert!(close(v.transform([0.0, 3.0, 0.0, 1.0]), [0.0, 0.0, -3.0, 1.0]));
|
||||
}
|
||||
|
||||
/// Die Bewegungs-Basis des Players muss exakt zu der Richtung passen, die
|
||||
/// `view` als „vor der Kamera" definiert — sonst driften Steuerung und Bild
|
||||
/// auseinander. Ein Punkt `d` voraus muss im View-Space auf (0, 0, -d)
|
||||
/// landen, `right_dir` auf +X und ohne Y-Anteil.
|
||||
#[test]
|
||||
fn view_matches_player_basis() {
|
||||
use crate::engine::player::Player;
|
||||
for &(yaw, pitch) in &[(0.0, 0.0), (0.7, 0.0), (0.0, 0.5), (1.2, -0.4)] {
|
||||
let mut p = Player::new([1.0, 2.0, 3.0]);
|
||||
(p.yaw, p.pitch) = (yaw, pitch);
|
||||
let v = Mat4::view(p.pos, p.yaw, p.pitch);
|
||||
|
||||
let f = p.look_dir();
|
||||
let ahead = [p.pos[0] + f[0] * 5.0, p.pos[1] + f[1] * 5.0, p.pos[2] + f[2] * 5.0, 1.0];
|
||||
assert!(close(v.transform(ahead), [0.0, 0.0, -5.0, 1.0]),
|
||||
"look_dir bei yaw={yaw} pitch={pitch}: {:?}", v.transform(ahead));
|
||||
|
||||
let r = p.right_dir();
|
||||
assert!(r[1].abs() < 1e-6, "right_dir darf kein Y haben: {r:?}");
|
||||
let side = v.transform([p.pos[0] + r[0] * 5.0, p.pos[1], p.pos[2] + r[2] * 5.0, 1.0]);
|
||||
assert!(side[0] > 4.0, "right_dir sollte nach View-+X zeigen: {side:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn perspective_maps_near_far_to_0_1() {
|
||||
let p = Mat4::perspective(1.0, 4.0 / 3.0, 0.1, 100.0);
|
||||
|
||||
@@ -1,28 +1,24 @@
|
||||
//! Fenster-Frontend: winit-Loop um den wgpu-Renderer.
|
||||
//!
|
||||
//! Stand: Schritt 4 des Renderer-Plans (notes/renderer-plan.md) — Flycam
|
||||
//! über dem PS1-Szenen-Pass. WASD bewegt, Maus blickt (Klick fängt den
|
||||
//! Cursor, Escape gibt ihn frei bzw. beendet), Space/Shift hoch/runter.
|
||||
//! Als Nächstes: OBJ-Szene (Schritt 5).
|
||||
//!
|
||||
//! Steuert dieselbe [`Session`] wie die CLI: das Fenster *besitzt* sie,
|
||||
//! Terminal-Befehle kommen über einen Channel von einem stdin-Thread und
|
||||
//! werden pro Loop-Durchlauf eingespielt. Im Dialog-Modus pausiert die
|
||||
//! Welt (Sim-Uhr und Kamera stehen) — so sieht das Fenster nie einen
|
||||
//! anderen Zustand als die Konsole.
|
||||
//! Welt — so sieht das Fenster nie einen anderen Zustand als die Konsole.
|
||||
//!
|
||||
//! Schicht-Regel wie `cli`: Geschwister von `engine`/`session`, konsumiert
|
||||
//! deren Schnittstellen — nie umgekehrt.
|
||||
|
||||
mod brush;
|
||||
mod camera;
|
||||
mod audio;
|
||||
mod font;
|
||||
mod gpu;
|
||||
mod math;
|
||||
mod post;
|
||||
mod props;
|
||||
mod scene;
|
||||
mod sprite;
|
||||
mod ui;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::mpsc::{self, Receiver};
|
||||
use std::sync::Arc;
|
||||
use std::time::Instant;
|
||||
@@ -33,44 +29,44 @@ use winit::event_loop::{ActiveEventLoop, ControlFlow, EventLoop};
|
||||
use winit::keyboard::{KeyCode, PhysicalKey};
|
||||
use winit::window::{CursorGrabMode, Window, WindowId};
|
||||
|
||||
use crate::engine::tga::Image;
|
||||
use crate::engine::{assets, map, tga};
|
||||
use crate::session::{Mode, Session};
|
||||
use camera::Camera;
|
||||
use crate::engine::image::{self, Image};
|
||||
use crate::engine::player;
|
||||
use crate::engine::scene::Scene;
|
||||
use crate::engine::{assets, wav};
|
||||
use crate::session::{FrameInput, Mode, Session};
|
||||
use gpu::Gpu;
|
||||
use math::Mat4;
|
||||
use scene::Mesh;
|
||||
|
||||
/// Radiant pro Maus-Pixel.
|
||||
const MOUSE_SENS: f32 = 0.0025;
|
||||
/// Welt-Einheiten pro Sekunde.
|
||||
const MOVE_SPEED: f32 = 4.0;
|
||||
/// Zeitkonstante (s) des Eye-Height-Smoothings am Boden: die Kamera gleitet
|
||||
/// vertikal sanft auf Augenhöhe nach, statt Step-up-/Slope-Sprüngen sofort zu
|
||||
/// folgen. Größer = weicher, aber träger.
|
||||
const EYE_SMOOTH_TAU: f32 = 0.06;
|
||||
/// Maximaler vertikaler Nachlauf der Kamera hinter den Füßen (units).
|
||||
const EYE_MAX_LAG: f32 = 0.6;
|
||||
pub fn run(mut session: Session, boot: &str) {
|
||||
// Startbefehl (Hauptmenü bzw. `newgame <szene>`, siehe main) durch den
|
||||
// exec-Trichter — er lädt die erste Szene, deren Sichtgeometrie
|
||||
// `App::take_scene` unten abholt. Kann bereits einen Dialog öffnen.
|
||||
for line in session.exec(boot).output { println!("{line}"); }
|
||||
|
||||
pub fn run(mut session: Session) {
|
||||
// Init-Signal feuern, bevor das Fenster steht (kann bereits einen
|
||||
// Dialog öffnen — dann startet die Welt eben pausiert).
|
||||
for line in session.start() { println!("{line}"); }
|
||||
|
||||
// CPU-Assets dekodieren (Pull über die engine-Decoder). Das Hochladen
|
||||
// auf die GPU macht später `Gpu` — Decode (CPU) und Upload (GPU) bleiben
|
||||
// getrennt.
|
||||
let world = map::load(&assets::path("assets/maps/test.map"));
|
||||
let tex_names = brush::texture_names(&world);
|
||||
let images: Vec<Image> = tex_names.iter()
|
||||
.map(|n| tga::load(&assets::path(&format!("assets/textures/{n}.tga"))))
|
||||
.collect();
|
||||
let dims: Vec<(u32, u32)> = images.iter().map(|i| (i.width, i.height)).collect();
|
||||
let mesh = brush::build(&world, &tex_names, &dims);
|
||||
report_map(&world, &tex_names, &mesh);
|
||||
// Audio-Treiber öffnen (vor dem stdin-Thread, siehe Audio::open); die
|
||||
// Ambient-Voices legt take_scene je Szene an. Ohne Gerät läuft das Spiel
|
||||
// stumm.
|
||||
let audio = audio::Audio::open();
|
||||
|
||||
// UI-Texturen, Reihenfolge = die Index-Konstanten in ui (WHITE, FONT_EGA,
|
||||
// FONT_CGA, CURSORS, ORN). Decode (CPU) bleibt in run(); Fonts, Cursor und
|
||||
// Ornament sind weiß-auf-schwarz und bekommen ihre Alpha-Maske aus der
|
||||
// Luminanz.
|
||||
let load_keyed = |p: &str| ui::key_luminance(&tga::load(&assets::path(p)));
|
||||
// FONT_CGA, CURSORS, ORN). Fonts, Cursor und Ornament sind weiß-auf-schwarz
|
||||
// und bekommen ihre Alpha-Maske aus der Luminanz. Anders als
|
||||
// Autorinnen-Content sind sie Projekt-Assets: fehlen sie, ist die
|
||||
// Installation kaputt und es darf scheitern.
|
||||
let load_keyed = |p: &str| {
|
||||
ui::key_luminance(&image::load(&assets::path(p)).expect("UI-Textur (Projekt-Asset)"))
|
||||
};
|
||||
// Font-Atlanten zuerst keyen, daraus die Glyph-Breiten messen (Font),
|
||||
// dann dieselben Bilder in die GPU-Texturliste übernehmen.
|
||||
let ega_img = load_keyed("assets/textures/fonts/oldschool-ega-8x14.tga");
|
||||
let cga_img = load_keyed("assets/textures/fonts/oldschool-cga-8x8.tga");
|
||||
let ega_img = load_keyed("assets/textures/fonts/oldschool-ega-8x14.png");
|
||||
let cga_img = load_keyed("assets/textures/fonts/oldschool-cga-8x8.png");
|
||||
let fonts = font::Fonts {
|
||||
ega: font::Font::ega(ui::FONT_EGA, &ega_img),
|
||||
cga: font::Font::cga(ui::FONT_CGA, &cga_img),
|
||||
@@ -79,8 +75,8 @@ pub fn run(mut session: Session) {
|
||||
ui::white_pixel(),
|
||||
ega_img,
|
||||
cga_img,
|
||||
load_keyed("assets/textures/ui/cursors.tga"),
|
||||
load_keyed("assets/textures/ui/panel_ornaments.tga"),
|
||||
load_keyed("assets/textures/ui/cursors.png"),
|
||||
load_keyed("assets/textures/ui/panel_ornaments.png"),
|
||||
];
|
||||
|
||||
// stdin auf einem eigenen Thread: er darf blockieren, der Main-Thread
|
||||
@@ -105,22 +101,59 @@ pub fn run(mut session: Session) {
|
||||
// Poll statt Wait: wir rendern kontinuierlich (Spiel, kein Editor) und
|
||||
// pollen nebenbei den Befehls-Channel.
|
||||
event_loop.set_control_flow(ControlFlow::Poll);
|
||||
let mut app = App::new(session, rx, mesh, images, ui_textures, fonts);
|
||||
let mut app = App::new(session, rx, ui_textures, fonts, audio);
|
||||
app.take_scene(); // die Boot-Szene, bevor `resumed` sie hochlädt
|
||||
event_loop.run_app(&mut app).expect("winit: run");
|
||||
}
|
||||
|
||||
/// Kurzer Lade-Report: Map-Inhalt und resultierende Geometriegröße.
|
||||
fn report_map(world: &map::Map, tex_names: &[String], mesh: &Mesh) {
|
||||
let brushes: usize = world.entities.iter().map(|e| e.brushes.len()).sum();
|
||||
let faces: usize = world.entities.iter()
|
||||
.flat_map(|e| &e.brushes)
|
||||
.map(|b| b.faces.len())
|
||||
.sum();
|
||||
println!(
|
||||
"[map] {} Entities, {} Brushes, {} Faces, Texturen {:?} → {} Vertices, {} Dreiecke",
|
||||
world.entities.len(), brushes, faces, tex_names,
|
||||
mesh.verts.len(), mesh.indices.len() / 3,
|
||||
);
|
||||
/// Sichtgeometrie einer Szene: alle Modelle zu einem Mesh, dazu die Texturen
|
||||
/// in Index-Reihenfolge. Decode (CPU) hier, Upload (GPU) in `Gpu` — die
|
||||
/// beiden bleiben getrennt.
|
||||
fn build_world(scene: &Scene, placeholder: &Image) -> (Mesh, Vec<Image>) {
|
||||
// Eine geteilte Textur-Schlüsselliste über alle Modelle, damit ihre
|
||||
// Meshes denselben Index-Raum benutzen und zu einem Buffer verschmelzen.
|
||||
let mut tex_names: Vec<String> = Vec::new();
|
||||
for (_, m) in &scene.models { tex_names.extend(props::texture_keys(m)); }
|
||||
tex_names.sort_unstable();
|
||||
tex_names.dedup();
|
||||
|
||||
// Die Pixel liegen in den `.glb` selbst; gleicher Schlüssel = eine Textur
|
||||
// (erstes Vorkommen gewinnt). Schlüssel ohne Bild treffen den Platzhalter.
|
||||
let mut by_key: HashMap<&str, &Image> = HashMap::new();
|
||||
for (_, m) in &scene.models {
|
||||
for t in &m.textures {
|
||||
if let Some(img) = &t.image { by_key.entry(props::texture_key(t)).or_insert(img); }
|
||||
}
|
||||
}
|
||||
let images: Vec<Image> = tex_names.iter()
|
||||
.map(|k| by_key.get(k.as_str()).map_or_else(|| placeholder.clone(), |i| (*i).clone()))
|
||||
.collect();
|
||||
|
||||
let mut mesh = Mesh::default();
|
||||
for (_, m) in &scene.models { mesh.append(props::build(m, &tex_names)); }
|
||||
println!("[scene] {}: {} Modelle, Texturen {:?} → {} Vertices, {} Dreiecke",
|
||||
scene.name, scene.models.len(), tex_names, mesh.verts.len(), mesh.indices.len() / 3);
|
||||
(mesh, images)
|
||||
}
|
||||
|
||||
/// Sound laden: `name` → `assets/sounds/{name}.wav`. Autorinnen-Content —
|
||||
/// Fehler werden gemeldet und ergeben Stille (`None`), nie einen Absturz.
|
||||
fn load_sound(name: &str) -> Option<audio::Sound> {
|
||||
match wav::load(&assets::path(&format!("assets/sounds/{name}.wav"))) {
|
||||
Ok(w) => Some(audio::Sound::new(w)),
|
||||
Err(e) => {
|
||||
eprintln!("[audio] {e}");
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Die Platzhalter-Textur für Schlüssel ohne eigenes Bild in der `.glb`.
|
||||
/// Projekt-Asset: fehlt sie, ist die Installation kaputt und es darf scheitern.
|
||||
fn placeholder() -> Image {
|
||||
let name = props::FALLBACK_TEXTURE;
|
||||
image::load(&assets::path(&format!("assets/textures/{name}.png")))
|
||||
.expect("Platzhalter-Textur (Projekt-Asset)")
|
||||
}
|
||||
|
||||
/// Aktueller Eingabezustand. Tasten als gehaltene Flags (nicht Events),
|
||||
@@ -134,6 +167,8 @@ struct Input {
|
||||
right: bool,
|
||||
up: bool,
|
||||
down: bool,
|
||||
/// Sprung-Flanke: bei Space-Druck gesetzt, nach `player::step` verbraucht.
|
||||
jump: bool,
|
||||
mouse_dx: f32,
|
||||
mouse_dy: f32,
|
||||
/// Cursor gefangen → Maus-Look aktiv.
|
||||
@@ -145,48 +180,68 @@ struct App {
|
||||
gpu: Option<Gpu>,
|
||||
session: Session,
|
||||
rx: Receiver<String>,
|
||||
camera: Camera,
|
||||
/// Geglättete Kamera-Augenhöhe (Welt-Y) — siehe Eye-Height-Smoothing.
|
||||
eye_y: f32,
|
||||
input: Input,
|
||||
last: Option<Instant>,
|
||||
/// Letzte Mausposition in Fenster-Pixeln (für den UI-Cursor).
|
||||
cursor_win: [f32; 2],
|
||||
/// CPU-seitige Welt-Geometrie + Texturen, in `resumed` einmal auf die
|
||||
/// GPU geladen.
|
||||
/// Linksklick steht aus, wird im nächsten redraw gegen das UI aufgelöst.
|
||||
pending_click: bool,
|
||||
/// CPU-seitige Welt der Boot-Szene, bis `resumed` die GPU hat und sie
|
||||
/// hochlädt (danach leer — spätere Szenen gehen direkt an `Gpu::set_world`).
|
||||
mesh: Mesh,
|
||||
images: Vec<Image>,
|
||||
/// Pixel für Texturen ohne eigenes Bild in der `.glb`.
|
||||
placeholder: Image,
|
||||
ui_textures: Vec<Image>,
|
||||
fonts: font::Fonts,
|
||||
/// Audio-Treiber (`None` = kein Gerät, Spiel läuft stumm) und der
|
||||
/// Lazy-Cache der Einmal-SFX (`None` = Laden schlug fehl, nur einmal
|
||||
/// melden, nicht jeden Klick).
|
||||
audio: Option<audio::Audio>,
|
||||
sfx_cache: HashMap<String, Option<audio::Sound>>,
|
||||
/// Post-Effekt-Kette (Renderer-Zustand, nicht im Kern). Pro Frame aus
|
||||
/// `session.take_post()` nachgeführt, dann an `gpu.frame`.
|
||||
post: post::PostChain,
|
||||
}
|
||||
|
||||
impl App {
|
||||
fn new(
|
||||
session: Session,
|
||||
rx: Receiver<String>,
|
||||
mesh: Mesh,
|
||||
images: Vec<Image>,
|
||||
ui_textures: Vec<Image>,
|
||||
fonts: font::Fonts,
|
||||
audio: Option<audio::Audio>,
|
||||
) -> Self {
|
||||
let eye_y = session.player.pos[1] + player::EYE_HEIGHT;
|
||||
Self {
|
||||
window: None,
|
||||
gpu: None,
|
||||
session,
|
||||
rx,
|
||||
// Etwas zurück und erhöht, Blick Richtung Welt-Ursprung.
|
||||
camera: Camera::new([0.0, 1.0, 4.0]),
|
||||
eye_y,
|
||||
input: Input::default(),
|
||||
last: None,
|
||||
cursor_win: [0.0, 0.0],
|
||||
mesh,
|
||||
images,
|
||||
pending_click: false,
|
||||
mesh: Mesh::default(),
|
||||
images: Vec::new(),
|
||||
placeholder: placeholder(),
|
||||
ui_textures,
|
||||
fonts,
|
||||
audio,
|
||||
sfx_cache: HashMap::new(),
|
||||
// Die Post-Kette gehört dem Renderer, nicht dem Kern: geschaltet
|
||||
// wird sie über `Action::SetPost` (Trigger/Ink/Konsole), die die
|
||||
// Session als `take_post`-Queue durchreicht.
|
||||
post: post::PostChain::defaults(),
|
||||
}
|
||||
}
|
||||
|
||||
// Der OS-Cursor bleibt immer versteckt (in `resumed` einmal gesetzt) —
|
||||
// wir zeichnen stets ein eigenes Sprite. `set_grab` schaltet nur die
|
||||
// Greif-Art: Locked (Flycam, relativer Blick) ↔ None (freie Maus, UI).
|
||||
// Greif-Art: Locked (Spiel/Noclip, relativer Blick) ↔ None (freie Maus, UI).
|
||||
fn set_grab(&mut self, grab: bool) {
|
||||
let Some(window) = &self.window else { return; };
|
||||
if grab {
|
||||
@@ -203,6 +258,27 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
impl App {
|
||||
/// Frisch geladene Szene aus der Session übernehmen: Sichtgeometrie auf
|
||||
/// die GPU (bzw. bis `resumed` zwischenlagern), je Ambient-Emitter eine
|
||||
/// Loop-Voice, Kamera-Augenhöhe auf den neuen Spawn. Kein Wechsel → nichts.
|
||||
fn take_scene(&mut self) {
|
||||
let Some(scene) = self.session.take_scene() else { return; };
|
||||
let (mesh, images) = build_world(&scene, &self.placeholder);
|
||||
if let Some(a) = &self.audio {
|
||||
let sounds: Vec<Option<audio::Sound>> = self.session.emitters().iter()
|
||||
.map(|e| load_sound(&e.sound))
|
||||
.collect();
|
||||
a.set_ambients(&sounds);
|
||||
}
|
||||
self.eye_y = self.session.player.pos[1] + player::EYE_HEIGHT;
|
||||
match &mut self.gpu {
|
||||
Some(gpu) => gpu.set_world(&mesh, &images),
|
||||
None => { self.mesh = mesh; self.images = images; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ApplicationHandler for App {
|
||||
/// winit liefert das Fenster erst hier, nicht beim Loop-Start —
|
||||
/// deshalb sind `window`/`gpu` Options statt Konstruktor-Felder.
|
||||
@@ -223,19 +299,20 @@ impl ApplicationHandler for App {
|
||||
&self.images,
|
||||
&self.ui_textures,
|
||||
));
|
||||
self.mesh = Mesh::default();
|
||||
self.images = Vec::new();
|
||||
self.window = Some(window);
|
||||
}
|
||||
|
||||
/// Rohe Maus-Bewegung (unabhängig von Cursor-Position) — nur sinnvoll,
|
||||
/// solange der Cursor gefangen ist.
|
||||
fn device_event(&mut self, _el: &ActiveEventLoop, _id: DeviceId, event: DeviceEvent) {
|
||||
if let DeviceEvent::MouseMotion { delta } = event {
|
||||
if self.input.grabbed {
|
||||
if let DeviceEvent::MouseMotion { delta } = event
|
||||
&& self.input.grabbed {
|
||||
self.input.mouse_dx += delta.0 as f32;
|
||||
self.input.mouse_dy += delta.1 as f32;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Läuft einmal pro Loop-Durchlauf, nachdem die Events abgearbeitet
|
||||
/// sind: Konsolen-Befehle einspielen und den nächsten Frame anfordern.
|
||||
@@ -255,9 +332,10 @@ impl ApplicationHandler for App {
|
||||
self.cursor_win = [position.x as f32, position.y as f32];
|
||||
}
|
||||
WindowEvent::MouseInput { state: ElementState::Pressed, button: MouseButton::Left, .. } => {
|
||||
// Nur im freien Modus greift der Klick die Maus (Flycam). Im
|
||||
// UI-/Dialog-Modus bleibt die Maus frei (für Klicks aufs UI).
|
||||
if matches!(self.session.mode, Mode::Free) { self.set_grab(true); }
|
||||
// Klick nur vormerken; der nächste redraw entscheidet (mit der
|
||||
// frisch berechneten Hover-Aktion) zwischen UI-Klick und
|
||||
// Maus-Greifen.
|
||||
self.pending_click = true;
|
||||
}
|
||||
WindowEvent::KeyboardInput { event: key, .. } => self.on_key(event_loop, key),
|
||||
WindowEvent::Resized(size) => {
|
||||
@@ -265,7 +343,7 @@ impl ApplicationHandler for App {
|
||||
gpu.resize(size.width, size.height);
|
||||
}
|
||||
}
|
||||
WindowEvent::RedrawRequested => self.redraw(),
|
||||
WindowEvent::RedrawRequested => self.redraw(event_loop),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -276,9 +354,16 @@ impl App {
|
||||
let PhysicalKey::Code(code) = key.physical_key else { return; };
|
||||
let down = key.state == ElementState::Pressed;
|
||||
|
||||
// Escape: erst den Cursor freigeben, sonst beenden.
|
||||
// Escape togglet das Menü über denselben exec-Trichter wie Konsole
|
||||
// und Klick. Der Lock-Zustand folgt danach automatisch dem Modus
|
||||
// (siehe redraw). Im Dialog tut Escape nichts (Dialog endet über
|
||||
// seine Choices).
|
||||
if code == KeyCode::Escape && down {
|
||||
if self.input.grabbed { self.set_grab(false); } else { event_loop.exit(); }
|
||||
if !matches!(self.session.mode, Mode::Dialog(_)) {
|
||||
let r = self.session.exec("menu");
|
||||
for out in r.output { println!("{out}"); }
|
||||
if r.quit { event_loop.exit(); }
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -287,47 +372,132 @@ impl App {
|
||||
KeyCode::KeyS => self.input.back = down,
|
||||
KeyCode::KeyA => self.input.left = down,
|
||||
KeyCode::KeyD => self.input.right = down,
|
||||
KeyCode::Space => self.input.up = down,
|
||||
// Space: im Noclip „hoch" (gehalten), im Spiel Sprung (Flanke,
|
||||
// nicht Auto-Repeat). Beide Deutungen aus derselben Taste.
|
||||
KeyCode::Space => {
|
||||
self.input.up = down;
|
||||
if down && !key.repeat { self.input.jump = true; }
|
||||
}
|
||||
KeyCode::ShiftLeft => self.input.down = down,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn redraw(&mut self) {
|
||||
// dt messen; im Dialog Kamera und Sim anhalten → Welt pausiert,
|
||||
// während die Konsole den Dialog treibt.
|
||||
fn redraw(&mut self, event_loop: &ActiveEventLoop) {
|
||||
let now = Instant::now();
|
||||
let dt = self.last.replace(now).map_or(0.0, |prev| (now - prev).as_secs_f32());
|
||||
|
||||
if matches!(self.session.mode, Mode::Free) {
|
||||
self.camera.apply_mouse(self.input.mouse_dx, self.input.mouse_dy, MOUSE_SENS);
|
||||
let fwd = axis(self.input.fwd, self.input.back);
|
||||
let right = axis(self.input.right, self.input.left);
|
||||
let up = axis(self.input.up, self.input.down);
|
||||
self.camera.translate(fwd, right, up, MOVE_SPEED * dt);
|
||||
} else if self.input.grabbed {
|
||||
// Nicht-Free (Dialog/Menü) → Maus freigeben, damit das UI klickbar
|
||||
// ist und der Maus-Cursor statt des HUD-Pointers erscheint.
|
||||
self.set_grab(false);
|
||||
}
|
||||
// Delta immer verwerfen, auch im Dialog — sonst springt der Blick
|
||||
// beim Fortsetzen um die aufgestaute Bewegung.
|
||||
// Lock-Zustand folgt dem Modus: Spiel und Noclip fangen die Maus
|
||||
// (relativer Blick), Menü/Dialog geben sie frei fürs UI.
|
||||
let fly = matches!(self.session.mode, Mode::Free);
|
||||
let play = matches!(self.session.mode, Mode::FirstPerson);
|
||||
let grab = fly || play;
|
||||
if grab != self.input.grabbed { self.set_grab(grab); }
|
||||
|
||||
// Eingaben einsammeln; ob daraus Physik oder Flug wird, entscheidet
|
||||
// die Session an ihrem Modus. Betretens-Zonen melden ihre
|
||||
// Signal-Ausgaben wie exec-Befehle.
|
||||
let input = FrameInput {
|
||||
fwd: axis(self.input.fwd, self.input.back),
|
||||
right: axis(self.input.right, self.input.left),
|
||||
up: axis(self.input.up, self.input.down),
|
||||
jump: self.input.jump,
|
||||
look_dx: self.input.mouse_dx,
|
||||
look_dy: self.input.mouse_dy,
|
||||
};
|
||||
for out in self.session.tick(&input, dt) { println!("{out}"); }
|
||||
// Deltas/Flanke immer verwerfen, auch im Dialog — sonst springt der
|
||||
// Blick beim Fortsetzen um die aufgestaute Bewegung.
|
||||
self.input.mouse_dx = 0.0;
|
||||
self.input.mouse_dy = 0.0;
|
||||
self.input.jump = false;
|
||||
|
||||
// Audio: Distance ramps der Ambient-Emitter nachführen und
|
||||
// aufgelaufene Einmal-SFX (play_sound-Actions) starten. Die Queue
|
||||
// immer leeren, auch ohne Gerät — sonst wüchse sie unbegrenzt.
|
||||
let sfx = self.session.take_sounds();
|
||||
if let Some(a) = &self.audio {
|
||||
a.set_ambient_gains(&self.session.emitter_gains());
|
||||
for name in sfx {
|
||||
let sound = self.sfx_cache.entry(name.clone())
|
||||
.or_insert_with(|| load_sound(&name));
|
||||
if let Some(s) = sound { a.play(s); }
|
||||
}
|
||||
}
|
||||
|
||||
// Post-Effekt-Schaltungen (SetPost-Actions von Trigger/Ink/Konsole)
|
||||
// auf die eigene Kette anwenden; unbekannter Name wird gemeldet, wie
|
||||
// ein fehlendes WAV bei play_sound.
|
||||
for (name, on) in self.session.take_post() {
|
||||
if !self.post.set(&name, on) {
|
||||
eprintln!("[post] unbekannter Effekt {name:?}");
|
||||
}
|
||||
}
|
||||
|
||||
// Fadenkreuz-Pick im Spielmodus: Blickstrahl aus Augenhöhe auf
|
||||
// Klick-Ziele (`signal`-Property). Steuert den Interakt-Cursor und
|
||||
// löst beim Klick unten das `use` aus.
|
||||
let aim: Option<String> = if play {
|
||||
let eye = self.session.player.eye();
|
||||
let dir = self.session.player.look_dir();
|
||||
self.session.pick(eye, dir, crate::session::INTERACT_REACH).map(str::to_string)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let view = self.camera.view();
|
||||
// Mausposition über die Letterbox in interne Pixel mappen.
|
||||
let cursor = ui::Cursor {
|
||||
pos: self.gpu.as_ref()
|
||||
.map(|g| g.map_cursor(self.cursor_win))
|
||||
.unwrap_or([0.0, 0.0]),
|
||||
grabbed: self.input.grabbed,
|
||||
hud_interact: aim.is_some(),
|
||||
};
|
||||
// Overlay state-driven bauen (Stage 3: Demo-Panel + Cursor).
|
||||
let overlay = ui::layout(
|
||||
[gpu::INTERNAL_W as f32, gpu::INTERNAL_H as f32], &self.fonts, &cursor,
|
||||
// Overlay state-driven bauen (verzweigt nach session.mode); die
|
||||
// Hover-Aktion kommt aus der Maus-Position.
|
||||
let screen = ui::layout(
|
||||
[gpu::INTERNAL_W as f32, gpu::INTERNAL_H as f32], &self.fonts, &self.session, &cursor,
|
||||
);
|
||||
if let Some(gpu) = &mut self.gpu { gpu.frame(&view, &overlay); }
|
||||
|
||||
// Vorgemerkten Klick auflösen — beides durch denselben exec-Trichter
|
||||
// wie die Konsole: über einem UI-Klickziel dessen Aktion, sonst im
|
||||
// Spielmodus das Fadenkreuz-Ziel als `use <name>`.
|
||||
if self.pending_click {
|
||||
self.pending_click = false;
|
||||
let action = screen.hover_action.clone()
|
||||
.or_else(|| aim.map(|name| format!("use {name}")));
|
||||
if let Some(action) = action {
|
||||
let r = self.session.exec(&action);
|
||||
for out in r.output { println!("{out}"); }
|
||||
if r.quit { event_loop.exit(); }
|
||||
}
|
||||
}
|
||||
|
||||
// Szenenwechsel dieses Frames (Konsole, Zone, Klick, Ink-Tag) erst
|
||||
// jetzt übernehmen — so zeigt das Bild nie die alte Welt aus der
|
||||
// Kamera am neuen Spawn.
|
||||
self.take_scene();
|
||||
|
||||
// Am Boden gleitet die Augenhöhe sanft nach (siehe EYE_SMOOTH_TAU); in
|
||||
// der Luft und außerhalb des Spiels folgt sie exakt.
|
||||
let target_eye = self.session.player.pos[1] + player::EYE_HEIGHT;
|
||||
if play && self.session.player.grounded {
|
||||
let a = 1.0 - (-dt / EYE_SMOOTH_TAU).exp();
|
||||
self.eye_y += (target_eye - self.eye_y) * a;
|
||||
self.eye_y = self.eye_y.clamp(target_eye - EYE_MAX_LAG, target_eye + EYE_MAX_LAG);
|
||||
} else {
|
||||
self.eye_y = target_eye;
|
||||
}
|
||||
|
||||
// Alle Modi sehen durch die Augen des Players; Menü und Dialog frieren
|
||||
// nur die Sim ein, nicht die Sicht.
|
||||
let p = self.session.player.pos;
|
||||
let view = Mat4::view(
|
||||
[p[0], self.eye_y, p[2]], self.session.player.yaw, self.session.player.pitch);
|
||||
|
||||
if let Some(gpu) = &mut self.gpu {
|
||||
gpu.frame(&view, &screen.ui, &self.post);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
// Post-Effekt „normals": zeigt den G-Buffer statt des Bildes, in drei
|
||||
// waagerechten Bändern — Normale, Objektnummer, Tiefe. Standardmäßig aus;
|
||||
// `post normals on` schaltet ihn zu.
|
||||
//
|
||||
// Kein Debug-Beiwerk, sondern die Probe aufs Exempel: Cel-Ramp und Outline
|
||||
// rechnen aus genau diesen Puffern. Sieht das Bild hier falsch aus, liegt der
|
||||
// Fehler im Loader oder im Szenen-Pass, nicht im Effekt.
|
||||
|
||||
@group(1) @binding(0) var gnormal: texture_2d<f32>;
|
||||
@group(1) @binding(1) var gdepth: texture_depth_2d;
|
||||
|
||||
struct Uniforms {
|
||||
inv_res: vec2f,
|
||||
near: f32,
|
||||
far: f32,
|
||||
time: f32,
|
||||
};
|
||||
@group(2) @binding(0) var<uniform> u: Uniforms;
|
||||
|
||||
@fragment
|
||||
fn fs_main(@builtin(position) pos: vec4f) -> @location(0) vec4f {
|
||||
let px = vec2i(pos.xy);
|
||||
let band = i32(textureDimensions(gnormal).y) / 3;
|
||||
let g = textureLoad(gnormal, px, 0);
|
||||
if px.y < band {
|
||||
// Kodierung rückgängig: [0,1] → [-1,1] → wieder in [0,1] zum Ansehen.
|
||||
let n = g.xyz * 2.0 - 1.0;
|
||||
return vec4f(n * 0.5 + 0.5, 1.0);
|
||||
}
|
||||
if px.y < 2 * band {
|
||||
// Objektnummer: benachbarte Nummern sollen *verschieden aussehen*,
|
||||
// deshalb drei teilerfremde Faktoren statt eines Grauverlaufs.
|
||||
let id = g.w * 255.0;
|
||||
return vec4f(fract(id * vec3f(0.13, 0.37, 0.71)), 1.0);
|
||||
}
|
||||
// Tiefe ist perspektivisch verteilt — linearisieren, sonst ist ab zwei
|
||||
// Metern alles weiß. Near/Far kommen aus dem Uniform, nicht aus dem
|
||||
// Shader: sie gehören zur Projektion des Renderers.
|
||||
let z = textureLoad(gdepth, px, 0);
|
||||
let lin = u.near * u.far / (u.far - z * (u.far - u.near));
|
||||
return vec4f(vec3f(1.0 - lin / u.far), 1.0);
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
// Post-Effekt „outline": Kantenlinien aus dem G-Buffer, nicht aus dem Bild.
|
||||
//
|
||||
// Auf dem fertigen Bild zu suchen wäre falsch — der Dither zerlegt Flächen in
|
||||
// Muster, und jede Texturkante wäre eine Kante. Gesucht sind Kanten der
|
||||
// *Geometrie*, also drei unabhängige Signale:
|
||||
//
|
||||
// Tiefe — Sprünge in der Entfernung (Silhouetten, Vorder-/Hintergrund)
|
||||
// Normale — Knicke in der Fläche (Zimmerecken, Kanten eines Würfels)
|
||||
// ID — Objektgrenzen, auch wenn Tiefe *und* Normale gleich sind
|
||||
// (Bild an der Wand, Teppich auf dem Boden)
|
||||
//
|
||||
// Jedes für sich reicht; genommen wird das stärkste. Tiefe und Normale laufen
|
||||
// über einen 3×3-Sobel, die ID über einen simplen Vergleich mit den vier
|
||||
// direkten Nachbarn — auf Ganzzahlen ist ein Gradient sinnlos.
|
||||
|
||||
@group(0) @binding(0) var src: texture_2d<f32>;
|
||||
|
||||
@group(1) @binding(0) var gnormal: texture_2d<f32>;
|
||||
@group(1) @binding(1) var gdepth: texture_depth_2d;
|
||||
|
||||
struct Uniforms {
|
||||
inv_res: vec2f,
|
||||
near: f32,
|
||||
far: f32,
|
||||
time: f32,
|
||||
};
|
||||
@group(2) @binding(0) var<uniform> u: Uniforms;
|
||||
|
||||
// --- Regler ------------------------------------------------------------
|
||||
// Beide Schwellen sind auf „Sobel geteilt durch 4" normiert, also grob:
|
||||
// 1.0 = maximal möglicher Unterschied zwischen zwei Nachbarn.
|
||||
|
||||
/// Tiefenstufe *relativ zur Entfernung* — relativ, damit eine Kante in 20 m
|
||||
/// genauso zählt wie dieselbe Kante in 2 m. Das schwächste der drei Signale:
|
||||
/// flach gesehene Böden ändern ihre Tiefe von Pixel zu Pixel stark, ohne dass
|
||||
/// dort eine Kante wäre. Zu niedrig → der Boden bekommt Streifen.
|
||||
const DEPTH_T: f32 = 0.10;
|
||||
|
||||
/// Knick in der Normale. Ein rechter Winkel liegt bei ~1.4, eine sanfte
|
||||
/// Wölbung weit darunter. Zu niedrig → Suzanne wird schraffiert.
|
||||
const NORMAL_T: f32 = 0.40;
|
||||
|
||||
/// Strichstärke in Pixeln: Abstand, in dem der Kernel abtastet. 1 = dünnste
|
||||
/// Linie, 2–3 wird deutlich. Die Gradienten werden durch den Abstand geteilt,
|
||||
/// damit die beiden Schwellen oben ihre Bedeutung behalten und man nicht bei
|
||||
/// jeder Breitenänderung neu justieren muss.
|
||||
///
|
||||
/// Verbreitert wird über den Abtastabstand, nicht durch Aufdicken der
|
||||
/// gefundenen Linie: das kostet keinen einzigen zusätzlichen Texturzugriff.
|
||||
/// Der Preis ist, dass Details, die schmaler als die Strichstärke sind, eine
|
||||
/// doppelte Linie bekommen können — bei 1–3 Pixeln kein Thema.
|
||||
const WIDTH: i32 = 2;
|
||||
|
||||
/// Farbe der Linie und wie stark sie deckt (1.0 = voll).
|
||||
const LINE: vec3f = vec3f(0.0);
|
||||
const STRENGTH: f32 = 1.0;
|
||||
|
||||
/// Objektgrenzen mitzeichnen. Aus wirkt es wie klassisches Cel-Shading
|
||||
/// (nur Silhouetten und Knicke), an eher wie ein Comic-Panel, in dem jedes
|
||||
/// Ding umrandet ist.
|
||||
const USE_ID: bool = true;
|
||||
|
||||
// --- G-Buffer-Zugriff --------------------------------------------------
|
||||
|
||||
/// Tiefe in Metern statt im perspektivisch verteilten [0,1] des Puffers.
|
||||
fn linear_depth(px: vec2i) -> f32 {
|
||||
let z = textureLoad(gdepth, px, 0);
|
||||
return u.near * u.far / (u.far - z * (u.far - u.near));
|
||||
}
|
||||
|
||||
fn normal_at(px: vec2i) -> vec3f {
|
||||
return textureLoad(gnormal, px, 0).xyz * 2.0 - 1.0;
|
||||
}
|
||||
|
||||
fn id_at(px: vec2i) -> f32 {
|
||||
return textureLoad(gnormal, px, 0).w;
|
||||
}
|
||||
|
||||
// --- Kantensuche -------------------------------------------------------
|
||||
|
||||
/// Sobel-Betrag über die 3×3-Nachbarschaft, auf ~0..1 normiert (geteilt
|
||||
/// durch 4, die Gewichtssumme einer Kernelhälfte).
|
||||
fn sobel_depth(px: vec2i) -> f32 {
|
||||
var gx = 0.0;
|
||||
var gy = 0.0;
|
||||
// Sobel-Gewichte, Zeile für Zeile: [-1 0 1] × [1 2 1].
|
||||
for (var dy = -1; dy <= 1; dy++) {
|
||||
for (var dx = -1; dx <= 1; dx++) {
|
||||
let v = linear_depth(px + vec2i(dx, dy) * WIDTH);
|
||||
let wx = f32(dx) * select(1.0, 2.0, dy == 0);
|
||||
let wy = f32(dy) * select(1.0, 2.0, dx == 0);
|
||||
gx += v * wx;
|
||||
gy += v * wy;
|
||||
}
|
||||
}
|
||||
return sqrt(gx * gx + gy * gy) / (4.0 * f32(WIDTH));
|
||||
}
|
||||
|
||||
/// Dasselbe für die Normale: jede Komponente einzeln gefiltert, am Ende die
|
||||
/// Länge über beide Richtungen.
|
||||
fn sobel_normal(px: vec2i) -> f32 {
|
||||
var gx = vec3f(0.0);
|
||||
var gy = vec3f(0.0);
|
||||
for (var dy = -1; dy <= 1; dy++) {
|
||||
for (var dx = -1; dx <= 1; dx++) {
|
||||
let v = normal_at(px + vec2i(dx, dy) * WIDTH);
|
||||
let wx = f32(dx) * select(1.0, 2.0, dy == 0);
|
||||
let wy = f32(dy) * select(1.0, 2.0, dx == 0);
|
||||
gx += v * wx;
|
||||
gy += v * wy;
|
||||
}
|
||||
}
|
||||
return sqrt(dot(gx, gx) + dot(gy, gy)) / (4.0 * f32(WIDTH));
|
||||
}
|
||||
|
||||
/// 1.0, sobald einer der vier direkten Nachbarn zu einem anderen Objekt
|
||||
/// gehört. Nur ganze Pixel, keine Gradienten.
|
||||
fn id_edge(px: vec2i) -> f32 {
|
||||
let c = id_at(px);
|
||||
let d = abs(id_at(px + vec2i( WIDTH, 0)) - c)
|
||||
+ abs(id_at(px + vec2i(-WIDTH, 0)) - c)
|
||||
+ abs(id_at(px + vec2i( 0, WIDTH)) - c)
|
||||
+ abs(id_at(px + vec2i( 0,-WIDTH)) - c);
|
||||
// Eine Nummer Unterschied sind 1/255 — alles darüber ist eine Grenze.
|
||||
return select(0.0, 1.0, d > 0.5 / 255.0);
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fs_main(@builtin(position) pos: vec4f) -> @location(0) vec4f {
|
||||
let px = vec2i(pos.xy);
|
||||
let color = textureLoad(src, px, 0);
|
||||
|
||||
// Auf dem Hintergrund (nichts gezeichnet) keine Linie: sonst läge die
|
||||
// Silhouette doppelt, je einmal innen und außen.
|
||||
if id_at(px) == 0.0 { return color; }
|
||||
|
||||
let depth = sobel_depth(px) / linear_depth(px);
|
||||
var edge = max(
|
||||
step(DEPTH_T, depth),
|
||||
step(NORMAL_T, sobel_normal(px)),
|
||||
);
|
||||
if USE_ID { edge = max(edge, id_edge(px)); }
|
||||
|
||||
return vec4f(mix(color.rgb, LINE, edge * STRENGTH), color.a);
|
||||
}
|
||||
@@ -0,0 +1,358 @@
|
||||
//! Post-Kette: eigenständige Fullscreen-Effekte zwischen Szene und Overlay.
|
||||
//!
|
||||
//! Jeder Effekt ist eine eigene `.wgsl` mit *nur* einem `fs_main`; die
|
||||
//! Vertex-Stufe teilen sich alle über `fullscreen.wgsl`. Der Vertrag ist
|
||||
//! immer derselbe:
|
||||
//!
|
||||
//! group 0, binding 0: Farbe des vorherigen Kettenglieds
|
||||
//! group 1, binding 0: Normale (`n*0.5+0.5`, w = Objekt-ID, reserviert)
|
||||
//! group 1, binding 1: Tiefe
|
||||
//! group 2, binding 0: [`Uniforms`] — Auflösung, Near/Far, Zeit
|
||||
//!
|
||||
//! Group 1 ist der G-Buffer aus dem Szenen-Pass, group 2 das, was jeder
|
||||
//! Effekt über den Frame wissen kann; beide darf ein Effekt ignorieren. Kein
|
||||
//! Effekt kennt einen anderen, keiner darf einen anderen voraussetzen. Ein
|
||||
//! Effekt wird hinzugefügt, indem er in [`EFFECTS`] auftaucht; geschaltet
|
||||
//! wird er über [`PostChain`], die Trigger, Ink-Tags und die Konsole per
|
||||
//! `game::Action::SetPost` erreichen. Der Kern kennt die Kette nicht.
|
||||
//!
|
||||
//! Gerechnet wird auf zwei Ping-Pong-Targets in interner Auflösung. Bei
|
||||
//! 640×480 kostet ein zusätzlicher Fullscreen-Pass praktisch nichts —
|
||||
//! deshalb darf jeder Effekt seinen eigenen behalten, statt sie zu einem
|
||||
//! Über-Shader zu verschmelzen.
|
||||
|
||||
/// Die Kette in Ausführungsreihenfolge, mit ihrem Startzustand. `dither`
|
||||
/// quantisiert die Farbtiefe und muss deshalb zuletzt laufen.
|
||||
const EFFECTS: &[(&str, bool, &str)] = &[
|
||||
("normals", false, include_str!("normals.wgsl")),
|
||||
("outline", true, include_str!("outline.wgsl")),
|
||||
("dither", true, include_str!("dither.wgsl")),
|
||||
];
|
||||
|
||||
/// An/Aus je Post-Effekt, in Ketten-Reihenfolge. Das Fenster hält sie als
|
||||
/// eigenen Zustand (nicht der Kern), wendet die per `Session::take_post`
|
||||
/// aufgelaufenen `SetPost`-Schaltungen jeden Frame an und gibt die Kette an
|
||||
/// [`Post::run`].
|
||||
pub struct PostChain {
|
||||
effects: Vec<(String, bool)>,
|
||||
}
|
||||
|
||||
impl PostChain {
|
||||
/// Die Kette aus [`EFFECTS`] mit ihren Startzuständen.
|
||||
pub fn defaults() -> Self {
|
||||
Self {
|
||||
effects: EFFECTS.iter().map(|(n, on, _)| ((*n).to_string(), *on)).collect(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enabled(&self, name: &str) -> bool {
|
||||
self.effects.iter().any(|(n, on)| n == name && *on)
|
||||
}
|
||||
|
||||
/// Effekt `name` auf `on` setzen. Rückgabe: `false`, wenn kein Effekt so
|
||||
/// heißt — der Aufrufer meldet das (wie ein fehlendes WAV bei `play_sound`).
|
||||
pub fn set(&mut self, name: &str, on: bool) -> bool {
|
||||
match self.effects.iter_mut().find(|(n, _)| n == name) {
|
||||
Some(e) => { e.1 = on; true }
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Spiegelt `Uniforms` in den Effekt-Shadern. `near`/`far` müssen zur
|
||||
/// Projektion des Aufrufers passen — sie kommen von dort, damit kein Shader
|
||||
/// sie abschreibt und beim nächsten Ändern der Kamera stillschweigend lügt.
|
||||
/// `_pad` rundet auf 32 Byte (16er-Vielfaches, WGSL-Uniform-Regel).
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, bytemuck::Pod, bytemuck::Zeroable)]
|
||||
struct Uniforms {
|
||||
inv_res: [f32; 2],
|
||||
near: f32,
|
||||
far: f32,
|
||||
/// Sekunden seit Start — für animierte Effekte (Flackern, Wasser).
|
||||
time: f32,
|
||||
_pad: [f32; 3],
|
||||
}
|
||||
|
||||
pub struct Post {
|
||||
/// Ping-Pong-Targets. Die Szene zeichnet in `[0]`, jeder aktive Effekt
|
||||
/// liest das eine und schreibt ins andere.
|
||||
views: [wgpu::TextureView; 2],
|
||||
/// Zweites Ziel des Szenen-Passes (Normale + ID).
|
||||
normal_view: wgpu::TextureView,
|
||||
/// Eingangs-Bind-Group je Target (group 0).
|
||||
in_binds: [wgpu::BindGroup; 2],
|
||||
/// Normale + Tiefe (group 1) — für alle Effekte dieselbe.
|
||||
gbuf_bind: wgpu::BindGroup,
|
||||
/// Frame-Uniforms (group 2), jeden Frame per [`Post::prepare`] gefüllt.
|
||||
ubuf: wgpu::Buffer,
|
||||
uniform_bind: wgpu::BindGroup,
|
||||
inv_res: [f32; 2],
|
||||
near_far: [f32; 2],
|
||||
pipelines: Vec<(&'static str, wgpu::RenderPipeline)>,
|
||||
}
|
||||
|
||||
impl Post {
|
||||
pub fn new(
|
||||
device: &wgpu::Device,
|
||||
format: wgpu::TextureFormat,
|
||||
size: [u32; 2],
|
||||
depth_view: &wgpu::TextureView,
|
||||
near_far: [f32; 2],
|
||||
) -> Self {
|
||||
let views = [make_target(device, format, size, "post a"),
|
||||
make_target(device, format, size, "post b")];
|
||||
let normal_view = make_target(device, format, size, "gbuffer normal");
|
||||
|
||||
// Expliziter Layout statt `layout: None`: *der* Vertrag der Kette —
|
||||
// alle Effekte teilen ihn, damit dieselben Bind-Groups für jede
|
||||
// Pipeline passen.
|
||||
let bind_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||
label: Some("post input"),
|
||||
entries: &[wgpu::BindGroupLayoutEntry {
|
||||
binding: 0,
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Texture {
|
||||
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
||||
view_dimension: wgpu::TextureViewDimension::D2,
|
||||
multisampled: false,
|
||||
},
|
||||
count: None,
|
||||
}],
|
||||
});
|
||||
let in_binds = [make_bind(device, &bind_layout, &views[0]),
|
||||
make_bind(device, &bind_layout, &views[1])];
|
||||
|
||||
// Der G-Buffer. Beide Texturen werden per `textureLoad` gelesen
|
||||
// (1:1, kein Sampler) — deshalb steht hier keiner.
|
||||
let gbuf_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||
label: Some("post gbuffer"),
|
||||
entries: &[
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 0,
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Texture {
|
||||
sample_type: wgpu::TextureSampleType::Float { filterable: true },
|
||||
view_dimension: wgpu::TextureViewDimension::D2,
|
||||
multisampled: false,
|
||||
},
|
||||
count: None,
|
||||
},
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 1,
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Texture {
|
||||
sample_type: wgpu::TextureSampleType::Depth,
|
||||
view_dimension: wgpu::TextureViewDimension::D2,
|
||||
multisampled: false,
|
||||
},
|
||||
count: None,
|
||||
},
|
||||
],
|
||||
});
|
||||
let gbuf_bind = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||
label: Some("post gbuffer"),
|
||||
layout: &gbuf_layout,
|
||||
entries: &[
|
||||
wgpu::BindGroupEntry {
|
||||
binding: 0,
|
||||
resource: wgpu::BindingResource::TextureView(&normal_view),
|
||||
},
|
||||
wgpu::BindGroupEntry {
|
||||
binding: 1,
|
||||
resource: wgpu::BindingResource::TextureView(depth_view),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
let ubuf = device.create_buffer(&wgpu::BufferDescriptor {
|
||||
label: Some("post uniforms"),
|
||||
size: size_of::<Uniforms>() as u64,
|
||||
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
|
||||
mapped_at_creation: false,
|
||||
});
|
||||
let uniform_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||
label: Some("post uniforms"),
|
||||
entries: &[wgpu::BindGroupLayoutEntry {
|
||||
binding: 0,
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Buffer {
|
||||
ty: wgpu::BufferBindingType::Uniform,
|
||||
has_dynamic_offset: false,
|
||||
min_binding_size: None,
|
||||
},
|
||||
count: None,
|
||||
}],
|
||||
});
|
||||
let uniform_bind = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||
label: Some("post uniforms"),
|
||||
layout: &uniform_layout,
|
||||
entries: &[wgpu::BindGroupEntry { binding: 0, resource: ubuf.as_entire_binding() }],
|
||||
});
|
||||
|
||||
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
||||
label: Some("post"),
|
||||
bind_group_layouts: &[Some(&bind_layout), Some(&gbuf_layout), Some(&uniform_layout)],
|
||||
immediate_size: 0,
|
||||
});
|
||||
// Ein Fullscreen-Dreieck für alle: die Vertex-Stufe kommt aus einem
|
||||
// anderen Modul als die Fragment-Stufe.
|
||||
let fullscreen = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
||||
label: Some("fullscreen"),
|
||||
source: wgpu::ShaderSource::Wgsl(include_str!("fullscreen.wgsl").into()),
|
||||
});
|
||||
let pipelines = EFFECTS.iter().map(|(name, _, src)| {
|
||||
let module = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
||||
label: Some(name),
|
||||
source: wgpu::ShaderSource::Wgsl((*src).into()),
|
||||
});
|
||||
let p = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||
label: Some(name),
|
||||
layout: Some(&pipeline_layout),
|
||||
vertex: wgpu::VertexState {
|
||||
module: &fullscreen,
|
||||
entry_point: Some("vs_main"),
|
||||
compilation_options: Default::default(),
|
||||
buffers: &[],
|
||||
},
|
||||
fragment: Some(wgpu::FragmentState {
|
||||
module: &module,
|
||||
entry_point: Some("fs_main"),
|
||||
compilation_options: Default::default(),
|
||||
targets: &[Some(format.into())],
|
||||
}),
|
||||
primitive: wgpu::PrimitiveState::default(),
|
||||
depth_stencil: None,
|
||||
multisample: wgpu::MultisampleState::default(),
|
||||
multiview_mask: None,
|
||||
cache: None,
|
||||
});
|
||||
(*name, p)
|
||||
}).collect();
|
||||
|
||||
Self {
|
||||
views, normal_view, in_binds, gbuf_bind,
|
||||
ubuf, uniform_bind,
|
||||
inv_res: [1.0 / size[0] as f32, 1.0 / size[1] as f32],
|
||||
near_far,
|
||||
pipelines,
|
||||
}
|
||||
}
|
||||
|
||||
/// Frame-Uniforms hochladen — vor [`Post::run`] rufen.
|
||||
pub fn prepare(&self, queue: &wgpu::Queue, time: f32) {
|
||||
let u = Uniforms {
|
||||
inv_res: self.inv_res,
|
||||
near: self.near_far[0],
|
||||
far: self.near_far[1],
|
||||
time,
|
||||
_pad: [0.0; 3],
|
||||
};
|
||||
queue.write_buffer(&self.ubuf, 0, bytemuck::bytes_of(&u));
|
||||
}
|
||||
|
||||
/// Die Ziele des Szenen-Passes: Albedo (= Anfang der Kette) und Normale.
|
||||
pub fn scene_targets(&self) -> [&wgpu::TextureView; 2] {
|
||||
[&self.views[0], &self.normal_view]
|
||||
}
|
||||
|
||||
pub fn view(&self, i: usize) -> &wgpu::TextureView { &self.views[i] }
|
||||
|
||||
/// Die aktiven Effekte der Reihe nach ausführen. Rückgabe: Index des
|
||||
/// Targets, das jetzt das Bild trägt (0, wenn nichts aktiv war).
|
||||
pub fn run(&self, enc: &mut wgpu::CommandEncoder, chain: &PostChain) -> usize {
|
||||
let mut src = 0;
|
||||
for (name, pipeline) in &self.pipelines {
|
||||
if !chain.enabled(name) { continue; }
|
||||
let dst = 1 - src;
|
||||
let mut pass = enc.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
label: Some(name),
|
||||
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||
view: &self.views[dst],
|
||||
depth_slice: None,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
// Jedes Pixel wird geschrieben — Clear ist nur der
|
||||
// billigste definierte Startzustand.
|
||||
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
|
||||
store: wgpu::StoreOp::Store,
|
||||
},
|
||||
})],
|
||||
depth_stencil_attachment: None,
|
||||
timestamp_writes: None,
|
||||
occlusion_query_set: None,
|
||||
multiview_mask: None,
|
||||
});
|
||||
pass.set_pipeline(pipeline);
|
||||
pass.set_bind_group(0, &self.in_binds[src], &[]);
|
||||
pass.set_bind_group(1, &self.gbuf_bind, &[]);
|
||||
pass.set_bind_group(2, &self.uniform_bind, &[]);
|
||||
pass.draw(0..3, 0..1);
|
||||
src = dst;
|
||||
}
|
||||
src
|
||||
}
|
||||
}
|
||||
|
||||
fn make_target(
|
||||
device: &wgpu::Device,
|
||||
format: wgpu::TextureFormat,
|
||||
size: [u32; 2],
|
||||
label: &str,
|
||||
) -> wgpu::TextureView {
|
||||
let tex = device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: Some(label),
|
||||
size: wgpu::Extent3d { width: size[0], height: size[1], depth_or_array_layers: 1 },
|
||||
mip_level_count: 1,
|
||||
sample_count: 1,
|
||||
dimension: wgpu::TextureDimension::D2,
|
||||
format,
|
||||
usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::TEXTURE_BINDING,
|
||||
view_formats: &[],
|
||||
});
|
||||
tex.create_view(&Default::default())
|
||||
}
|
||||
|
||||
fn make_bind(
|
||||
device: &wgpu::Device,
|
||||
layout: &wgpu::BindGroupLayout,
|
||||
view: &wgpu::TextureView,
|
||||
) -> wgpu::BindGroup {
|
||||
device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||
label: Some("post input"),
|
||||
layout,
|
||||
entries: &[wgpu::BindGroupEntry {
|
||||
binding: 0,
|
||||
resource: wgpu::BindingResource::TextureView(view),
|
||||
}],
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn defaults_follow_effects_table() {
|
||||
let c = PostChain::defaults();
|
||||
// Startzustände aus EFFECTS.
|
||||
assert!(!c.enabled("normals"));
|
||||
assert!(c.enabled("outline"));
|
||||
assert!(c.enabled("dither"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_switches_and_reports_unknown() {
|
||||
let mut c = PostChain::defaults();
|
||||
assert!(c.set("outline", false));
|
||||
assert!(!c.enabled("outline"));
|
||||
assert!(c.set("outline", true));
|
||||
assert!(c.enabled("outline"));
|
||||
assert!(!c.set("bloom", true), "unbekannter Effekt");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_effect_is_off() {
|
||||
assert!(!PostChain::defaults().enabled("bloom"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
//! Blender-Modell → Render-Geometrie.
|
||||
//!
|
||||
//! Nimmt das geparste [`Model`] aus engine::gltf und baut daraus ein
|
||||
//! [`Mesh`] (Vertices + nach Textur gruppierte Index-Batches); mehrere
|
||||
//! Modelle verschmelzen über `Mesh::append` zu einem Buffer.
|
||||
//!
|
||||
//! Texturen liegen als Pixel im Modell (`model::Texture`, aus der `.glb`).
|
||||
//! Hier wird nur nach ihrem Schlüssel gruppiert; Texturen ohne Bild —
|
||||
//! Material ohne baseColorTexture oder unlesbar — landen unter
|
||||
//! [`FALLBACK_TEXTURE`], dessen Pixel der Aufrufer stellt.
|
||||
//!
|
||||
//! UVs kommen unverändert durch (Modell und `Image` teilen den
|
||||
//! Oben-links-Ursprung; `KHR_texture_transform` hat der Loader schon
|
||||
//! eingebacken). Nur `visible`-Objekte werden ausgegeben;
|
||||
//! Collider-/Zonen-Volumen sind Sache von engine::collision und
|
||||
//! engine::trigger.
|
||||
|
||||
use crate::engine::model::{Model, Texture};
|
||||
use crate::render::scene::{Batch, Mesh, Vertex};
|
||||
|
||||
/// Schlüssel für Texturen ohne eigenes Bild; der Aufrufer lädt die Pixel
|
||||
/// dazu (`assets/textures/placeholder.png`).
|
||||
pub const FALLBACK_TEXTURE: &str = "placeholder";
|
||||
|
||||
/// Distinkte Textur-Schlüssel des Modells (sortiert), bildlose bereits auf
|
||||
/// den Fallback gemappt.
|
||||
pub fn texture_keys(model: &Model) -> Vec<String> {
|
||||
let mut keys: Vec<String> = model.textures.iter()
|
||||
.map(|t| texture_key(t).to_string())
|
||||
.collect();
|
||||
keys.sort_unstable();
|
||||
keys.dedup();
|
||||
keys
|
||||
}
|
||||
|
||||
/// Gruppierungs-Schlüssel einer Textur: ihr eigener, sofern sie Pixel hat —
|
||||
/// sonst der Fallback. Der Renderer sammelt darüber die Pixel je Schlüssel.
|
||||
pub fn texture_key(t: &Texture) -> &str {
|
||||
match &t.image {
|
||||
Some(_) if !t.key.is_empty() => &t.key,
|
||||
_ => FALLBACK_TEXTURE,
|
||||
}
|
||||
}
|
||||
|
||||
/// Alle sichtbaren Objekte zu einem Mesh. `tex_names` gibt die Textur-
|
||||
/// Indizes vor — darf eine Obermenge sein, so teilen alle Modelle eine
|
||||
/// gemeinsame Texturliste.
|
||||
pub fn build(model: &Model, tex_names: &[String]) -> Mesh {
|
||||
let mut verts = Vec::new();
|
||||
let mut per_tex: Vec<Vec<u32>> = vec![Vec::new(); tex_names.len()];
|
||||
|
||||
// Laufende Objektnummer für den G-Buffer; nur sichtbare Objekte zählen,
|
||||
// unsichtbare Collider tauchen im Bild ja nie auf. Ab 1, damit die 0 im
|
||||
// Buffer „kein Objekt" heißt (der Hintergrund wird auf 0 geleert).
|
||||
let mut id = 1;
|
||||
for o in &model.objects {
|
||||
if !o.visible { continue; }
|
||||
let base = verts.len() as u32;
|
||||
for ((p, uv), n) in o.verts.iter().zip(&o.uvs).zip(&o.normals) {
|
||||
verts.push(Vertex { pos: *p, uv: *uv, normal: *n, id });
|
||||
}
|
||||
id += 1;
|
||||
for (t, &m) in o.tris.iter().zip(&o.tri_mats) {
|
||||
let name = texture_key(&model.textures[m]);
|
||||
let Some(ti) = tex_names.iter().position(|n| n == name) else { continue; };
|
||||
per_tex[ti].extend(t.map(|i| base + i as u32));
|
||||
}
|
||||
}
|
||||
|
||||
// Pro-Textur-Indexlisten zu einem Buffer + Batches verflachen.
|
||||
let mut indices = Vec::new();
|
||||
let mut batches = Vec::new();
|
||||
for (ti, list) in per_tex.into_iter().enumerate() {
|
||||
if list.is_empty() { continue; }
|
||||
batches.push(Batch { texture: ti, start: indices.len() as u32, count: list.len() as u32 });
|
||||
indices.extend_from_slice(&list);
|
||||
}
|
||||
Mesh { verts, indices, batches, objects: id - 1 }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::engine::image::Image;
|
||||
use crate::engine::model::{Model, Object, Props};
|
||||
|
||||
/// 1×1-Platzhalterbild, damit eine Textur „Pixel hat".
|
||||
fn pixel() -> Image {
|
||||
Image { width: 1, height: 1, rgba: vec![255, 255, 255, 255] }
|
||||
}
|
||||
|
||||
/// Textur mit Bild und Schlüssel `key`.
|
||||
fn tex(key: &str) -> Texture {
|
||||
Texture { key: key.into(), image: Some(pixel()) }
|
||||
}
|
||||
|
||||
/// Ein Dreieck mit UVs; `visible` steuert, ob es gerendert werden darf.
|
||||
fn tri(name: &str, visible: bool) -> Object {
|
||||
Object {
|
||||
name: name.into(),
|
||||
verts: vec![[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [1.0, 1.0, 0.0]],
|
||||
uvs: vec![[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]],
|
||||
normals: vec![[0.0, 0.0, 1.0]; 3],
|
||||
tris: vec![[0, 1, 2]],
|
||||
tri_mats: vec![0],
|
||||
visible, collider: !visible,
|
||||
props: Props::new(),
|
||||
}
|
||||
}
|
||||
|
||||
fn sample() -> Model {
|
||||
Model {
|
||||
objects: vec![tri("Ding", true), tri("Proxy", false)],
|
||||
empties: Vec::new(),
|
||||
textures: vec![tex("carpet")],
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn builds_only_visible_objects() {
|
||||
let m = sample();
|
||||
let names = texture_keys(&m);
|
||||
assert_eq!(names, vec!["carpet".to_string()]);
|
||||
let mesh = build(&m, &names);
|
||||
|
||||
// Nur „Ding" (der Proxy ist unsichtbar): 3 Vertices, 1 Dreieck.
|
||||
assert_eq!(mesh.verts.len(), 3);
|
||||
assert_eq!(mesh.indices, vec![0, 1, 2]);
|
||||
assert_eq!(mesh.batches.len(), 1);
|
||||
// UVs unverändert (geteilte Oben-links-Konvention).
|
||||
assert_eq!(mesh.verts[2].uv, [1.0, 1.0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn visible_objects_get_distinct_ids_across_models() {
|
||||
let names = texture_keys(&sample());
|
||||
// Zwei sichtbare Objekte + ein unsichtbarer Proxy je Modell.
|
||||
let mut m = sample();
|
||||
m.objects.insert(1, tri("Zweites", true));
|
||||
|
||||
let mut mesh = build(&m, &names);
|
||||
assert_eq!(mesh.objects, 2, "nur sichtbare zählen");
|
||||
assert_eq!(mesh.verts[0].id, 1, "0 bleibt dem Hintergrund vorbehalten");
|
||||
assert_eq!(mesh.verts[3].id, 2, "zweites Objekt, nächste Nummer");
|
||||
|
||||
// Zweites Modell anhängen: seine Nummern liegen über den bisherigen,
|
||||
// sonst hielte der Outline-Pass Objekte aus zwei .glb für dasselbe.
|
||||
mesh.append(build(&m, &names));
|
||||
assert_eq!(mesh.objects, 4);
|
||||
assert_eq!(mesh.verts[6].id, 3);
|
||||
assert_eq!(mesh.verts[9].id, 4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn imageless_texture_maps_to_fallback() {
|
||||
let mut m = sample();
|
||||
// Material ohne baseColorTexture: Schlüssel gesetzt, aber kein Bild.
|
||||
m.textures = vec![Texture { key: "nackt".into(), image: None }];
|
||||
assert_eq!(texture_keys(&m), vec![FALLBACK_TEXTURE.to_string()]);
|
||||
let mesh = build(&m, &texture_keys(&m));
|
||||
assert_eq!(mesh.batches.len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shares_texture_index_space_with_superset_list() {
|
||||
// Obermengen-Liste (wie beim Merge mehrerer Modelle): der Batch
|
||||
// zeigt auf den richtigen Index in der geteilten Liste.
|
||||
let names = vec!["aaa".to_string(), "carpet".to_string(), "zzz".to_string()];
|
||||
let mesh = build(&sample(), &names);
|
||||
assert_eq!(mesh.batches[0].texture, 1);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
//! Szenen-Pass: zeichnet die 3D-Welt ins interne Target.
|
||||
//!
|
||||
//! Stand Schritt 5: Geometrie + Texturen kommen vom Aufrufer (Brush-Welt
|
||||
//! aus der `.map`, siehe render::brush; Bilder aus engine::tga). Pro Textur
|
||||
//! eine Bind-Group + ein Draw-Batch (Material-Batching „pro Textur ein
|
||||
//! Draw" wie im Plan). Die Shader (scene.wgsl) sind die echten PS1-Shader.
|
||||
//! Geometrie + Texturen kommen vom Aufrufer (Blender-Modelle via
|
||||
//! render::props; Bilder als RGBA8-`Image`, aus der `.glb` dekodiert). Pro
|
||||
//! Textur eine Bind-Group + ein Draw-Batch („pro Textur ein Draw" wie im Plan).
|
||||
//! Die Shader (scene.wgsl) sind die echten PS1-Shader.
|
||||
|
||||
use wgpu::util::DeviceExt;
|
||||
|
||||
use crate::engine::tga::Image;
|
||||
use crate::engine::image::Image;
|
||||
use crate::render::math::Mat4;
|
||||
|
||||
#[repr(C)]
|
||||
@@ -15,6 +15,14 @@ use crate::render::math::Mat4;
|
||||
pub(crate) struct Vertex {
|
||||
pub(crate) pos: [f32; 3],
|
||||
pub(crate) uv: [f32; 2],
|
||||
/// Welt-Normale, normiert — Eingang des G-Buffers (siehe render::post).
|
||||
pub(crate) normal: [f32; 3],
|
||||
/// Laufende Objektnummer. Der Szenen-Pass legt sie (mod 256) ins Alpha
|
||||
/// des Normal-Buffers, damit der Outline-Pass Kanten zwischen zwei
|
||||
/// Objekten findet, die sich berühren und gleich ausgerichtet sind —
|
||||
/// Stuhl auf Boden, Bild an Wand. Benachbarte Nummern unterscheiden sich
|
||||
/// immer; erst 256 Objekte auseinander fallen zwei zusammen.
|
||||
pub(crate) id: u32,
|
||||
}
|
||||
|
||||
/// Ein Draw-Batch: ein zusammenhängender Index-Bereich, der mit *einer*
|
||||
@@ -28,10 +36,38 @@ pub(crate) struct Batch {
|
||||
|
||||
/// CPU-seitige Welt-Geometrie, fertig zum Hochladen. Die Indizes sind nach
|
||||
/// Textur gruppiert; `batches` zeigt in diese Reihenfolge.
|
||||
#[derive(Default)]
|
||||
pub(crate) struct Mesh {
|
||||
pub(crate) verts: Vec<Vertex>,
|
||||
pub(crate) indices: Vec<u32>,
|
||||
pub(crate) batches: Vec<Batch>,
|
||||
/// Vergebene Objektnummern (siehe [`Vertex::id`]) — [`Mesh::append`]
|
||||
/// verschiebt die des Anhängsels darüber, damit Objekte aus verschiedenen
|
||||
/// Modellen nicht dieselbe Nummer tragen.
|
||||
pub(crate) objects: u32,
|
||||
}
|
||||
|
||||
impl Mesh {
|
||||
/// Ein zweites Mesh anhängen (ein Vertex-/Index-Buffer für alles).
|
||||
/// Voraussetzung: beide wurden gegen *dieselbe* Texturliste gebaut —
|
||||
/// die Batch-Texturindizes bleiben dann unverändert gültig; nur die
|
||||
/// Buffer-Offsets verschieben sich.
|
||||
pub(crate) fn append(&mut self, other: Mesh) {
|
||||
let vbase = self.verts.len() as u32;
|
||||
let ibase = self.indices.len() as u32;
|
||||
let idbase = self.objects;
|
||||
self.objects += other.objects;
|
||||
self.verts.extend(other.verts.into_iter().map(|v| Vertex {
|
||||
id: v.id + idbase,
|
||||
..v
|
||||
}));
|
||||
self.indices.extend(other.indices.iter().map(|i| i + vbase));
|
||||
self.batches.extend(other.batches.iter().map(|b| Batch {
|
||||
texture: b.texture,
|
||||
start: b.start + ibase,
|
||||
count: b.count,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/// Spiegelt das `Uniforms`-Struct in scene.wgsl. `_pad` rundet die Größe
|
||||
@@ -48,15 +84,24 @@ struct Uniforms {
|
||||
const VERTEX_LAYOUT: wgpu::VertexBufferLayout<'static> = wgpu::VertexBufferLayout {
|
||||
array_stride: size_of::<Vertex>() as u64,
|
||||
step_mode: wgpu::VertexStepMode::Vertex,
|
||||
attributes: &wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x2],
|
||||
attributes: &wgpu::vertex_attr_array![
|
||||
0 => Float32x3, 1 => Float32x2, 2 => Float32x3, 3 => Uint32,
|
||||
],
|
||||
};
|
||||
|
||||
pub struct ScenePass {
|
||||
pipeline: wgpu::RenderPipeline,
|
||||
vbuf: wgpu::Buffer,
|
||||
ibuf: wgpu::Buffer,
|
||||
ubuf: wgpu::Buffer,
|
||||
uniform_bind: wgpu::BindGroup, // group 0
|
||||
sampler: wgpu::Sampler,
|
||||
/// Die aktuelle Welt — bei jedem Szenenwechsel ersetzt ([`ScenePass::set_world`]).
|
||||
world: World,
|
||||
}
|
||||
|
||||
/// GPU-Seite einer Szene: Geometrie-Buffer, Textur-Bind-Groups, Batches.
|
||||
struct World {
|
||||
vbuf: wgpu::Buffer,
|
||||
ibuf: wgpu::Buffer,
|
||||
tex_binds: Vec<wgpu::BindGroup>, // group 1, pro Textur
|
||||
batches: Vec<Batch>,
|
||||
}
|
||||
@@ -87,14 +132,14 @@ impl ScenePass {
|
||||
module: &shader,
|
||||
entry_point: Some("fs_main"),
|
||||
compilation_options: Default::default(),
|
||||
targets: &[Some(color_format.into())],
|
||||
// Zwei Ziele (MRT): Albedo und der Normal-/ID-Buffer. Beide
|
||||
// im internen Format; zusammen sind sie der G-Buffer, aus dem
|
||||
// die Post-Kette Beleuchtung und Kanten rechnet.
|
||||
targets: &[Some(color_format.into()), Some(color_format.into())],
|
||||
}),
|
||||
// Back-face Culling: Brush-Polygone werden CCW um ihre nach
|
||||
// außen zeigende Normale gewickelt (siehe render::brush), und
|
||||
// die Z-up→Y-up-Drehung erhält die Orientierung (det +1). Also
|
||||
// sind die Außenflächen front-facing — Rückseiten und alle
|
||||
// verdeckten Innenflächen zwischen Brushes fallen weg.
|
||||
// (Front-Face bleibt der wgpu-Default CCW.)
|
||||
// Back-face Culling: glTF-Dreiecke sind CCW von außen
|
||||
// gewickelt — die Außenflächen sind front-facing, Rückseiten
|
||||
// fallen weg. (Front-Face bleibt der wgpu-Default CCW.)
|
||||
primitive: wgpu::PrimitiveState {
|
||||
cull_mode: Some(wgpu::Face::Back),
|
||||
..Default::default()
|
||||
@@ -111,16 +156,6 @@ impl ScenePass {
|
||||
cache: None,
|
||||
});
|
||||
|
||||
let vbuf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||
label: Some("scene vertices"),
|
||||
contents: bytemuck::cast_slice(&mesh.verts),
|
||||
usage: wgpu::BufferUsages::VERTEX,
|
||||
});
|
||||
let ibuf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||
label: Some("scene indices"),
|
||||
contents: bytemuck::cast_slice(&mesh.indices),
|
||||
usage: wgpu::BufferUsages::INDEX,
|
||||
});
|
||||
let ubuf = device.create_buffer(&wgpu::BufferDescriptor {
|
||||
label: Some("scene uniforms"),
|
||||
size: size_of::<Uniforms>() as u64,
|
||||
@@ -136,24 +171,28 @@ impl ScenePass {
|
||||
}],
|
||||
});
|
||||
|
||||
// Nearest-Sampler: harte Texel, kein Filtering — PS1.
|
||||
// mag=Nearest hält nah dran die harten Texel (der knackige Look);
|
||||
// min/mipmap=Linear glätten nur die Verkleinerung in der Ferne und
|
||||
// blenden weich zwischen den Mip-Ebenen (kein Mip-Popping). Killt das
|
||||
// Texel-Flimmern hochauflösender Texturen auf der kleinen internen
|
||||
// Auflösung. Mipmaps werden in upload_texture per Box-Filter erzeugt.
|
||||
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
|
||||
label: Some("scene nearest"),
|
||||
label: Some("scene"),
|
||||
address_mode_u: wgpu::AddressMode::Repeat,
|
||||
address_mode_v: wgpu::AddressMode::Repeat,
|
||||
mag_filter: wgpu::FilterMode::Nearest,
|
||||
min_filter: wgpu::FilterMode::Nearest,
|
||||
min_filter: wgpu::FilterMode::Linear,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Linear,
|
||||
..Default::default()
|
||||
});
|
||||
let tex_layout = pipeline.get_bind_group_layout(1);
|
||||
let tex_binds = images.iter()
|
||||
.map(|img| upload_texture(device, queue, &tex_layout, &sampler, img))
|
||||
.collect();
|
||||
|
||||
Self {
|
||||
pipeline, vbuf, ibuf, ubuf, uniform_bind, tex_binds,
|
||||
batches: mesh.batches.clone(),
|
||||
let world = upload_world(device, queue, &pipeline, &sampler, mesh, images);
|
||||
Self { pipeline, ubuf, uniform_bind, sampler, world }
|
||||
}
|
||||
|
||||
/// Die Welt austauschen (Szenenwechsel): neue Buffer und Texturen
|
||||
/// hochladen; die alten gibt wgpu frei, sobald kein Frame sie mehr nutzt.
|
||||
pub fn set_world(&mut self, device: &wgpu::Device, queue: &wgpu::Queue, mesh: &Mesh, images: &[Image]) {
|
||||
self.world = upload_world(device, queue, &self.pipeline, &self.sampler, mesh, images);
|
||||
}
|
||||
|
||||
/// Uniforms für diesen Frame hochladen — vor dem Render-Pass rufen.
|
||||
@@ -164,35 +203,72 @@ impl ScenePass {
|
||||
}
|
||||
|
||||
pub fn draw(&self, pass: &mut wgpu::RenderPass) {
|
||||
let w = &self.world;
|
||||
// Leere Szene (fehlender Ordner, nur Empties): nichts zu zeichnen —
|
||||
// und ein leerer Buffer ließe sich gar nicht erst slicen.
|
||||
if w.batches.is_empty() { return; }
|
||||
pass.set_pipeline(&self.pipeline);
|
||||
pass.set_bind_group(0, &self.uniform_bind, &[]);
|
||||
pass.set_vertex_buffer(0, self.vbuf.slice(..));
|
||||
pass.set_index_buffer(self.ibuf.slice(..), wgpu::IndexFormat::Uint32);
|
||||
for b in &self.batches {
|
||||
pass.set_bind_group(1, &self.tex_binds[b.texture], &[]);
|
||||
pass.set_vertex_buffer(0, w.vbuf.slice(..));
|
||||
pass.set_index_buffer(w.ibuf.slice(..), wgpu::IndexFormat::Uint32);
|
||||
for b in &w.batches {
|
||||
pass.set_bind_group(1, &w.tex_binds[b.texture], &[]);
|
||||
pass.draw_indexed(b.start..b.start + b.count, 0, 0..1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Ein RGBA8-`Image` als GPU-Textur hochladen und die zugehörige
|
||||
/// Bind-Group (Textur + Sampler, group 1) bauen.
|
||||
fn upload_texture(
|
||||
fn upload_world(
|
||||
device: &wgpu::Device,
|
||||
queue: &wgpu::Queue,
|
||||
pipeline: &wgpu::RenderPipeline,
|
||||
sampler: &wgpu::Sampler,
|
||||
mesh: &Mesh,
|
||||
images: &[Image],
|
||||
) -> World {
|
||||
let vbuf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||
label: Some("scene vertices"),
|
||||
contents: bytemuck::cast_slice(&mesh.verts),
|
||||
usage: wgpu::BufferUsages::VERTEX,
|
||||
});
|
||||
let ibuf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||
label: Some("scene indices"),
|
||||
contents: bytemuck::cast_slice(&mesh.indices),
|
||||
usage: wgpu::BufferUsages::INDEX,
|
||||
});
|
||||
let tex_layout = pipeline.get_bind_group_layout(1);
|
||||
let tex_binds = images.iter()
|
||||
.map(|img| upload_texture(device, queue, &tex_layout, sampler, img, "scene texture", true))
|
||||
.collect();
|
||||
World { vbuf, ibuf, tex_binds, batches: mesh.batches.clone() }
|
||||
}
|
||||
|
||||
/// Ein RGBA8-`Image` als GPU-Textur hochladen und die zugehörige Bind-Group
|
||||
/// (Textur + Sampler, group 1) bauen — geteilt mit [`crate::render::sprite`].
|
||||
/// Mit `mips` entsteht die volle Mipchain (bis 1×1) per Box-Filter auf der
|
||||
/// CPU; UI-Sprites brauchen sie nicht, sie werden nie verkleinert.
|
||||
pub(crate) fn upload_texture(
|
||||
device: &wgpu::Device,
|
||||
queue: &wgpu::Queue,
|
||||
layout: &wgpu::BindGroupLayout,
|
||||
sampler: &wgpu::Sampler,
|
||||
img: &Image,
|
||||
label: &str,
|
||||
mips: bool,
|
||||
) -> wgpu::BindGroup {
|
||||
let size = wgpu::Extent3d {
|
||||
// floor(log2(max(w,h))) + 1 = volle Kette bis zur 1×1-Ebene.
|
||||
let mip_level_count = match mips {
|
||||
true => 32 - img.width.max(img.height).leading_zeros(),
|
||||
false => 1,
|
||||
};
|
||||
let texture = device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: Some(label),
|
||||
size: wgpu::Extent3d {
|
||||
width: img.width,
|
||||
height: img.height,
|
||||
depth_or_array_layers: 1,
|
||||
};
|
||||
let texture = device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: Some("scene texture"),
|
||||
size,
|
||||
mip_level_count: 1,
|
||||
},
|
||||
mip_level_count,
|
||||
sample_count: 1,
|
||||
dimension: wgpu::TextureDimension::D2,
|
||||
// Nicht-sRGB: die Quantisierung im Shader erwartet rohe Werte.
|
||||
@@ -200,24 +276,35 @@ fn upload_texture(
|
||||
usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST,
|
||||
view_formats: &[],
|
||||
});
|
||||
|
||||
// Ebene 0 ist das Originalbild; jede weitere wird aus der vorherigen
|
||||
// halbiert. `level` trägt die aktuell hochzuladenden Pixel.
|
||||
let mut level = img.rgba.clone();
|
||||
let (mut w, mut h) = (img.width, img.height);
|
||||
for mip in 0..mip_level_count {
|
||||
queue.write_texture(
|
||||
wgpu::TexelCopyTextureInfo {
|
||||
texture: &texture,
|
||||
mip_level: 0,
|
||||
mip_level: mip,
|
||||
origin: wgpu::Origin3d::ZERO,
|
||||
aspect: wgpu::TextureAspect::All,
|
||||
},
|
||||
&img.rgba,
|
||||
&level,
|
||||
wgpu::TexelCopyBufferLayout {
|
||||
offset: 0,
|
||||
bytes_per_row: Some(img.width * 4),
|
||||
rows_per_image: Some(img.height),
|
||||
bytes_per_row: Some(w * 4),
|
||||
rows_per_image: Some(h),
|
||||
},
|
||||
size,
|
||||
wgpu::Extent3d { width: w, height: h, depth_or_array_layers: 1 },
|
||||
);
|
||||
if mip + 1 < mip_level_count {
|
||||
(level, w, h) = downsample(&level, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
let view = texture.create_view(&Default::default());
|
||||
device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||
label: Some("scene texture"),
|
||||
label: Some(label),
|
||||
layout,
|
||||
entries: &[
|
||||
wgpu::BindGroupEntry { binding: 0, resource: wgpu::BindingResource::TextureView(&view) },
|
||||
@@ -225,3 +312,29 @@ fn upload_texture(
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
/// Eine RGBA8-Mip-Ebene per 2×2-Box-Filter auf die nächstkleinere halbieren.
|
||||
/// Gibt die neuen Pixel samt Maßen zurück. Ungerade Maße werden via `(d+1)/2`
|
||||
/// aufgerundet (sonst ginge die letzte Spalte/Zeile verloren); die fehlende
|
||||
/// Quell-Spalte/-Zeile wird auf den Rand geklemmt, statt den Mittelwert zu
|
||||
/// verfälschen. Mittelung im (gamma-kodierten) Speicherraum — für den
|
||||
/// stilisierten Look unkritisch.
|
||||
fn downsample(src: &[u8], w: u32, h: u32) -> (Vec<u8>, u32, u32) {
|
||||
let (nw, nh) = (w.div_ceil(2), h.div_ceil(2));
|
||||
let mut dst = vec![0u8; (nw * nh * 4) as usize];
|
||||
for y in 0..nh {
|
||||
for x in 0..nw {
|
||||
let (x0, y0) = (2 * x, 2 * y);
|
||||
let x1 = (x0 + 1).min(w - 1);
|
||||
let y1 = (y0 + 1).min(h - 1);
|
||||
let at = |px: u32, py: u32| ((py * w + px) * 4) as usize;
|
||||
let samples = [at(x0, y0), at(x1, y0), at(x0, y1), at(x1, y1)];
|
||||
let di = ((y * nw + x) * 4) as usize;
|
||||
for c in 0..4 {
|
||||
let sum: u32 = samples.iter().map(|&s| src[s + c] as u32).sum();
|
||||
dst[di + c] = ((sum + 2) / 4) as u8;
|
||||
}
|
||||
}
|
||||
}
|
||||
(dst, nw, nh)
|
||||
}
|
||||
|
||||