diff --git a/Cargo.lock b/Cargo.lock index 5d77832..abc6909 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,18 +23,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" -[[package]] -name = "aes" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" -dependencies = [ - "cfg-if", - "cipher", - "cpufeatures", - "opaque-debug", -] - [[package]] name = "ahash" version = "0.8.6" @@ -162,12 +150,6 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "beef" version = "0.5.2" @@ -245,7 +227,7 @@ checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -260,34 +242,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" -[[package]] -name = "bzip2" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" -dependencies = [ - "bzip2-sys", - "libc", -] - -[[package]] -name = "bzip2-sys" -version = "0.1.11+1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" -dependencies = [ - "cc", - "libc", - "pkg-config", -] - [[package]] name = "cc" version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ - "jobserver", "libc", ] @@ -307,15 +267,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "cipher" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" -dependencies = [ - "generic-array", -] - [[package]] name = "clap" version = "4.4.11" @@ -347,7 +298,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -368,12 +319,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "cpufeatures" version = "0.2.11" @@ -459,15 +404,6 @@ dependencies = [ "byteorder 1.5.0", ] -[[package]] -name = "deranged" -version = "0.3.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eb30d70a07a3b04884d2677f06bec33509dc67ca60d92949e5535352d3191dc" -dependencies = [ - "powerfmt", -] - [[package]] name = "digest" version = "0.10.7" @@ -476,7 +412,6 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", - "subtle", ] [[package]] @@ -626,7 +561,7 @@ dependencies = [ "inflections", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -659,15 +594,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - [[package]] name = "image" version = "0.23.14" @@ -750,15 +676,6 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" -[[package]] -name = "jobserver" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" -dependencies = [ - "libc", -] - [[package]] name = "jpeg-decoder" version = "0.1.22" @@ -860,7 +777,7 @@ dependencies = [ "proc-macro2", "quote", "regex-syntax 0.6.29", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -944,7 +861,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -986,6 +903,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "nu-ansi-term" +version = "0.49.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c073d3c1930d0751774acf49e66653acecb416c3a54c6ec095a9b11caddb5a68" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "num-integer" version = "0.1.45" @@ -1056,7 +982,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -1074,12 +1000,6 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - [[package]] name = "overload" version = "0.1.1" @@ -1115,18 +1035,7 @@ dependencies = [ "regex", "regex-syntax 0.7.5", "structmeta", - "syn 2.0.41", -] - -[[package]] -name = "password-hash" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" -dependencies = [ - "base64ct", - "rand_core", - "subtle", + "syn 2.0.42", ] [[package]] @@ -1135,18 +1044,6 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" -[[package]] -name = "pbkdf2" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" -dependencies = [ - "digest", - "hmac", - "password-hash", - "sha2", -] - [[package]] name = "pest" version = "2.7.5" @@ -1178,7 +1075,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -1198,12 +1095,6 @@ version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" -[[package]] -name = "pkg-config" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" - [[package]] name = "png" version = "0.16.8" @@ -1229,12 +1120,6 @@ dependencies = [ "miniz_oxide 0.7.1", ] -[[package]] -name = "powerfmt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" - [[package]] name = "proc-macro-crate" version = "2.0.1" @@ -1287,12 +1172,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" - [[package]] name = "rayon" version = "1.8.0" @@ -1437,7 +1316,7 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -1459,18 +1338,7 @@ checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", -] - -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", + "syn 2.0.42", ] [[package]] @@ -1545,7 +1413,7 @@ dependencies = [ "proc-macro2", "quote", "structmeta-derive", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -1556,15 +1424,9 @@ checksum = "a60bcaff7397072dca0017d1db428e30d5002e00b6847703e2e42005c95fbe00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - [[package]] name = "supports-color" version = "2.1.0" @@ -1606,9 +1468,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.41" +version = "2.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" +checksum = "5b7d0a2c048d661a1a59fcd7355baa232f7ed34e0ee4df2eef3c1c1c0d3852d8" dependencies = [ "proc-macro2", "quote", @@ -1670,14 +1532,13 @@ dependencies = [ [[package]] name = "tf-asset-loader" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b1d0b394de3284708b0e78c1a91e420219d425c14bbf1276c23f97a2e96b123" +checksum = "b07d2e567d626d92da18e28d2a2f3d06ac2f44d67d7393542e5ac7d6ca8820c1" dependencies = [ "steamlocate", "thiserror", "tracing", - "vbsp", "vpk", "zip-lzma", ] @@ -1699,7 +1560,7 @@ checksum = "01742297787513b79cf8e29d1056ede1313e2420b7b3b15d0a768b4921f549df" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -1723,35 +1584,6 @@ dependencies = [ "weezl", ] -[[package]] -name = "time" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" -dependencies = [ - "deranged", - "itoa", - "powerfmt", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" - -[[package]] -name = "time-macros" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" -dependencies = [ - "time-core", -] - [[package]] name = "toml_datetime" version = "0.6.3" @@ -1788,7 +1620,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -1801,17 +1633,6 @@ dependencies = [ "valuable", ] -[[package]] -name = "tracing-log" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" -dependencies = [ - "log", - "once_cell", - "tracing-core", -] - [[package]] name = "tracing-log" version = "0.2.0" @@ -1830,7 +1651,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", - "nu-ansi-term", + "nu-ansi-term 0.46.0", "once_cell", "regex", "sharded-slab", @@ -1838,18 +1659,18 @@ dependencies = [ "thread_local", "tracing", "tracing-core", - "tracing-log 0.2.0", + "tracing-log", ] [[package]] name = "tracing-tree" -version = "0.2.5" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ec6adcab41b1391b08a308cc6302b79f8095d1673f6947c2dc65ffb028b0b2d" +checksum = "65139ecd2c3f6484c3b99bc01c77afe21e95473630747c7aca525e78b0666675" dependencies = [ - "nu-ansi-term", + "nu-ansi-term 0.49.0", "tracing-core", - "tracing-log 0.1.4", + "tracing-log", "tracing-subscriber", ] @@ -1909,9 +1730,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "vbsp" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fbafc832b8ea1ccbc41869f2103498c3a1f94e4330b1e775d12fd59f007141d" +checksum = "3bfc192b57e196fa102d254788e34af2cf0f605ffab70b38ec31d4babfa15ff7" dependencies = [ "ahash", "arrayvec", @@ -1945,6 +1766,7 @@ name = "vbsp-to-gltf" version = "0.1.0" dependencies = [ "bytemuck", + "cgmath", "clap", "gltf", "gltf-json", @@ -1964,7 +1786,8 @@ dependencies = [ [[package]] name = "vdf-reader" version = "0.1.0" -source = "git+https://github.com/icewind1991/vdf-reader#63b3bdbefdb97d7ea20858697702a8530b541e70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff9669f8e9cf7a82acac623509d7dbd119b4bc90da2469f1e7501097e04c5a3" dependencies = [ "logos", "miette", @@ -1982,7 +1805,8 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "vmdl" version = "0.1.0" -source = "git+https://github.com/icewind1991/vmdl#5cd7c3d859996102c47f77a8f292570c55d8438c" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d980a01e72742ffb370720f95b7695be64d5f06e6f565709391a77620852bdc" dependencies = [ "arrayvec", "bitflags 1.3.2", @@ -1997,7 +1821,8 @@ dependencies = [ [[package]] name = "vmt-parser" version = "0.1.0" -source = "git+https://github.com/icewind1991/vmt-parser#105afbc9550178c25143695091ab10ff869b5df6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1c071256bc38ca5a1f322052106da23ea3cd8bd0a5f18e9a3bd81ad040092bf" dependencies = [ "miette", "serde", @@ -2217,22 +2042,22 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.31" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c4061bedbb353041c12f413700357bec76df2c7e2ca8e4df8bac24c6bf68e3d" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.31" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3c129550b3e6de3fd0ba67ba5c81818f9805e58b8d7fee80a3a59d2c9fc601a" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.42", ] [[package]] @@ -2241,46 +2066,8 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b480cb31fccfb2786565c0e0712865fd6f1ea0ea850c50316f643c3948196e63" dependencies = [ - "aes", "byteorder 1.5.0", - "bzip2", - "constant_time_eq", "crc32fast", "crossbeam-utils", - "flate2", - "hmac", "lzma", - "pbkdf2", - "sha1", - "time", - "zstd", -] - -[[package]] -name = "zstd" -version = "0.10.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4a6bd64f22b5e3e94b4e238669ff9f10815c27a5180108b849d24174a83847" -dependencies = [ - "zstd-safe", -] - -[[package]] -name = "zstd-safe" -version = "4.1.6+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b61c51bb270702d6167b8ce67340d2754b088d0c091b06e593aa772c3ee9bb" -dependencies = [ - "libc", - "zstd-sys", -] - -[[package]] -name = "zstd-sys" -version = "1.6.3+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc49afa5c8d634e75761feda8c592051e7eeb4683ba827211eb0d731d3402ea8" -dependencies = [ - "cc", - "libc", ] diff --git a/Cargo.toml b/Cargo.toml index d506993..557b445 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,19 +6,20 @@ rust-version = "1.70.0" [dependencies] miette = { version = "5.5.0", features = ["fancy"] } -vbsp = "0.4.0" +vbsp = "0.4.1" thiserror = "1.0.37" tracing = "0.1.37" tracing-subscriber = { version = "0.3.16", features = ["env-filter"] } -tracing-tree = "0.2.2" +tracing-tree = "0.3.0" vtf = "0.1.6" -vmt-parser = { version = "0.1", git = "https://github.com/icewind1991/vmt-parser" } +vmt-parser = "0.1" image = "0.23.14" -tf-asset-loader = { version = "0.1", features = ["bsp"] } -vmdl = { version = "*", git = "https://github.com/icewind1991/vmdl" } +tf-asset-loader = { version = "0.1", features = ["zip"] } +vmdl = "0.1" clap = { version = "4.0.29", features = ["derive"] } gltf-json = "=1.3.0" gltf = "=1.3.0" +cgmath = "0.18.0" bytemuck = { version = "1.14.0", features = ["derive"] } [profile.dev.package."*"] diff --git a/src/bsp.rs b/src/bsp.rs index 4a1c545..845005d 100644 --- a/src/bsp.rs +++ b/src/bsp.rs @@ -62,6 +62,7 @@ fn bounding_box(vertices: impl IntoIterator) -> ([f32; 3], [f32; #[repr(C)] pub struct BspVertexData { position: [f32; 3], + normal: [f32; 3], uv: [f32; 2], } @@ -120,6 +121,7 @@ pub fn push_bsp_face( let texture = face.texture(); let vertices = face.vertex_positions().map(move |pos| BspVertexData { position: map_coords(pos), + normal: map_coords(face.normal()), uv: texture.uv(pos), }); @@ -154,6 +156,20 @@ pub fn push_bsp_face( normalized: false, sparse: None, }; + let normals = Accessor { + buffer_view: Some(vertex_view), + byte_offset: Some(offset_of!(BspVertexData, normal) as u32), + count: vertex_count, + component_type: Valid(GenericComponentType(ComponentType::F32)), + extensions: Default::default(), + extras: Default::default(), + type_: Valid(Type::Vec3), + min: None, + max: None, + name: None, + normalized: false, + sparse: None, + }; let uvs = Accessor { buffer_view: Some(vertex_view), byte_offset: Some(offset_of!(BspVertexData, uv) as u32), @@ -171,6 +187,7 @@ pub fn push_bsp_face( let accessor_start = gltf.accessors.len() as u32; gltf.accessors.push(positions); + gltf.accessors.push(normals); gltf.accessors.push(uvs); let material_index = push_or_get_material(buffer, gltf, loader, face.texture().name()); @@ -179,9 +196,10 @@ pub fn push_bsp_face( attributes: { let mut map = std::collections::BTreeMap::new(); map.insert(Valid(Semantic::Positions), Index::new(accessor_start)); + map.insert(Valid(Semantic::Normals), Index::new(accessor_start + 1)); map.insert( Valid(Semantic::TexCoords(0)), - Index::new(accessor_start + 1), + Index::new(accessor_start + 2), ); map }, diff --git a/src/main.rs b/src/main.rs index da486da..717c583 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,7 +54,7 @@ fn main() -> miette::Result<()> { let mut loader = Loader::new().map_err(Error::from)?; let data = read(args.source).map_err(Error::from)?; let map = Bsp::read(&data).map_err(Error::from)?; - loader.add_source(map.pack.clone()); + loader.add_source(map.pack.clone().into_zip()); let glb = export(map, &loader)?; diff --git a/src/materials.rs b/src/materials.rs index 2945b50..cf63a90 100644 --- a/src/materials.rs +++ b/src/materials.rs @@ -86,7 +86,9 @@ pub fn load_material( }); } - let base_texture = material.base_texture(); + let base_texture = material + .base_texture() + .ok_or_else(|| Error::Other("no basetexture".into()))?; let translucent = material.translucent(); let glass = material.surface_prop() == Some("glass");