Compare commits

...

4 Commits

Author SHA1 Message Date
41e46f248c load roblox map with epic cube code 2023-09-19 20:37:17 -07:00
8a9d99cae3 load_roblox module 2023-09-19 20:37:17 -07:00
3216cbb25f add roblox map 2023-09-19 20:37:17 -07:00
5da40b73ea add roblox deps 2023-09-19 20:37:17 -07:00
6 changed files with 412 additions and 0 deletions

255
Cargo.lock generated
View File

@ -157,6 +157,12 @@ dependencies = [
"rustc-demangle", "rustc-demangle",
] ]
[[package]]
name = "base64"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
[[package]] [[package]]
name = "bit-set" name = "bit-set"
version = "0.5.3" version = "0.5.3"
@ -184,12 +190,35 @@ version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
[[package]]
name = "blake3"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5"
dependencies = [
"arrayref",
"arrayvec",
"cc",
"cfg-if",
"constant_time_eq",
"digest",
]
[[package]] [[package]]
name = "block" name = "block"
version = "0.1.6" version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
[[package]]
name = "block-buffer"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
dependencies = [
"generic-array",
]
[[package]] [[package]]
name = "block-sys" name = "block-sys"
version = "0.1.0-beta.1" version = "0.1.0-beta.1"
@ -302,6 +331,12 @@ dependencies = [
"crossbeam-utils", "crossbeam-utils",
] ]
[[package]]
name = "constant_time_eq"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2"
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.9.3" version = "0.9.3"
@ -360,6 +395,16 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "crypto-common"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
dependencies = [
"generic-array",
"typenum",
]
[[package]] [[package]]
name = "d3d12" name = "d3d12"
version = "0.7.0" version = "0.7.0"
@ -382,6 +427,17 @@ dependencies = [
"enum_primitive", "enum_primitive",
] ]
[[package]]
name = "digest"
version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
"block-buffer",
"crypto-common",
"subtle",
]
[[package]] [[package]]
name = "dispatch" name = "dispatch"
version = "0.2.0" version = "0.2.0"
@ -555,6 +611,16 @@ dependencies = [
"waker-fn", "waker-fn",
] ]
[[package]]
name = "generic-array"
version = "0.14.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
dependencies = [
"typenum",
"version_check",
]
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.10" version = "0.2.10"
@ -822,6 +888,26 @@ version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "lz4"
version = "1.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e9e2dd86df36ce760a60f6ff6ad526f7ba1f14ba0356f8254fb6905e6494df1"
dependencies = [
"libc",
"lz4-sys",
]
[[package]]
name = "lz4-sys"
version = "1.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57d27b317e207b10f69f5e75494119e391a96f48861ae870d1da6edac98ca900"
dependencies = [
"cc",
"libc",
]
[[package]] [[package]]
name = "malloc_buf" name = "malloc_buf"
version = "0.0.6" version = "0.0.6"
@ -1198,6 +1284,12 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2"
[[package]]
name = "ppv-lite86"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]] [[package]]
name = "proc-macro-crate" name = "proc-macro-crate"
version = "1.3.1" version = "1.3.1"
@ -1222,6 +1314,19 @@ name = "profiling"
version = "1.0.9" version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46b2164ebdb1dfeec5e337be164292351e11daf63a05174c6776b2f47460f0c9" checksum = "46b2164ebdb1dfeec5e337be164292351e11daf63a05174c6776b2f47460f0c9"
dependencies = [
"profiling-procmacros",
]
[[package]]
name = "profiling-procmacros"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74c55e9e629af5298a40e0fa106435b2da30484c4ec76b41d19bc4d00dd8b903"
dependencies = [
"quote",
"syn 2.0.29",
]
[[package]] [[package]]
name = "quote" name = "quote"
@ -1232,6 +1337,36 @@ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "rand"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
"rand_chacha",
"rand_core",
]
[[package]]
name = "rand_chacha"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"getrandom",
]
[[package]] [[package]]
name = "range-alloc" name = "range-alloc"
version = "0.1.3" version = "0.1.3"
@ -1244,6 +1379,69 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9"
[[package]]
name = "rbx_binary"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e50573021d04b680018955662eba7dc4aac3de92219231798f6c9b41e38ab01"
dependencies = [
"log",
"lz4",
"profiling",
"rbx_dom_weak",
"rbx_reflection",
"rbx_reflection_database",
"thiserror",
]
[[package]]
name = "rbx_dom_weak"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "161729449bbb0cfa657ce7bcca6a160d0af06d8b8d9efdc9abe14735dccacdb9"
dependencies = [
"rbx_types",
"serde",
]
[[package]]
name = "rbx_reflection"
version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08bd48487192046fec8f805f3fa29f3d7d5beb9890b0859b1a92bd8aff580343"
dependencies = [
"rbx_types",
"serde",
"thiserror",
]
[[package]]
name = "rbx_reflection_database"
version = "0.2.7+roblox-588"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1be6cf674182806f11ad4899dd1feafe977591f1ae035ae05a58d4b74e487276"
dependencies = [
"lazy_static",
"rbx_reflection",
"rmp-serde",
"serde",
]
[[package]]
name = "rbx_types"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "070106e926b8ae54c7bc443e5db4d868d7f0af51c1d7cfd7efe1364c1753d8a3"
dependencies = [
"base64",
"bitflags 1.3.2",
"blake3",
"lazy_static",
"rand",
"serde",
"thiserror",
]
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.3.5" version = "0.3.5"
@ -1288,6 +1486,28 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "216080ab382b992234dda86873c18d4c48358f5cfcb70fd693d7f6f2131b628b" checksum = "216080ab382b992234dda86873c18d4c48358f5cfcb70fd693d7f6f2131b628b"
[[package]]
name = "rmp"
version = "0.8.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f9860a6cc38ed1da53456442089b4dfa35e7cedaa326df63017af88385e6b20"
dependencies = [
"byteorder",
"num-traits 0.2.16",
"paste",
]
[[package]]
name = "rmp-serde"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bffea85eea980d8a74453e5d02a8d93028f3c34725de143085a844ebe953258a"
dependencies = [
"byteorder",
"rmp",
"serde",
]
[[package]] [[package]]
name = "rustc-demangle" name = "rustc-demangle"
version = "0.1.23" version = "0.1.23"
@ -1338,6 +1558,26 @@ dependencies = [
"tiny-skia", "tiny-skia",
] ]
[[package]]
name = "serde"
version = "1.0.188"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.188"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.29",
]
[[package]] [[package]]
name = "simd-adler32" name = "simd-adler32"
version = "0.3.7" version = "0.3.7"
@ -1415,6 +1655,9 @@ dependencies = [
"log", "log",
"obj", "obj",
"pollster", "pollster",
"rbx_binary",
"rbx_dom_weak",
"rbx_reflection_database",
"wgpu", "wgpu",
"winit", "winit",
] ]
@ -1425,6 +1668,12 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731"
[[package]]
name = "subtle"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.109" version = "1.0.109"
@ -1524,6 +1773,12 @@ version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a464a4b34948a5f67fddd2b823c62d9d92e44be75058b99939eae6c5b6960b33" checksum = "a464a4b34948a5f67fddd2b823c62d9d92e44be75058b99939eae6c5b6960b33"
[[package]]
name = "typenum"
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.11" version = "1.0.11"

View File

@ -14,6 +14,9 @@ glam = "0.24.1"
log = "0.4.20" log = "0.4.20"
obj = "0.10.2" obj = "0.10.2"
pollster = "0.3.0" pollster = "0.3.0"
rbx_binary = "0.7.1"
rbx_dom_weak = "2.5.0"
rbx_reflection_database = "0.2.7"
wgpu = "0.17.0" wgpu = "0.17.0"
winit = "0.28.6" winit = "0.28.6"

BIN
maps/bhop_easyhop.rbxm Normal file

Binary file not shown.

View File

@ -2,3 +2,4 @@ pub mod framework;
pub mod body; pub mod body;
pub mod zeroes; pub mod zeroes;
pub mod instruction; pub mod instruction;
pub mod load_roblox;

28
src/load_roblox.rs Normal file
View File

@ -0,0 +1,28 @@
fn class_is_a(class: &str, superclass: &str) -> bool {
if class==superclass {
return true
}
let class_descriptor=rbx_reflection_database::get().classes.get(class);
if let Some(descriptor) = &class_descriptor {
if let Some(class_super) = &descriptor.superclass {
return class_is_a(&class_super, superclass)
}
}
return false
}
pub fn get_objects(buf_thing: std::io::BufReader<&[u8]>, superclass: &str) -> Result<std::vec::Vec<rbx_dom_weak::Instance>, Box<dyn std::error::Error>> {
// Using buffered I/O is recommended with rbx_binary
let dom = rbx_binary::from_reader(buf_thing)?;
let mut objects = std::vec::Vec::<rbx_dom_weak::Instance>::new();
//move matching instances into objects
let (_,mut instances) = dom.into_raw();
for (_,instance) in instances.drain() {
if class_is_a(instance.class.as_str(), superclass) {
objects.push(instance);
}
}
return Ok(objects)
}

View File

@ -230,6 +230,131 @@ impl strafe_client::framework::Example for Skybox {
modeldatas[1].transform=glam::Mat4::from_translation(glam::vec3(10.,5.,10.)); modeldatas[1].transform=glam::Mat4::from_translation(glam::vec3(10.,5.,10.));
modeldatas[2].transform=glam::Mat4::from_translation(glam::vec3(-10.,5.,10.)); modeldatas[2].transform=glam::Mat4::from_translation(glam::vec3(-10.,5.,10.));
let input = std::io::BufReader::new(&include_bytes!("../maps/bhop_easyhop.rbxm")[..]);
match strafe_client::load_roblox::get_objects(input, "BasePart") {
Ok(objects)=>{
for object in objects.iter() {
if let (
Some(rbx_dom_weak::types::Variant::CFrame(cf)),
Some(rbx_dom_weak::types::Variant::Vector3(size)),
Some(rbx_dom_weak::types::Variant::Float32(transparency)),
) = (
object.properties.get("CFrame"),
object.properties.get("Size"),
object.properties.get("Transparency"),
)
{
if *transparency==1.0 {
continue;
}
//simply draw a box
let face_data = [
[0.0f32, 0., 1.],
[0.0f32, 0., -1.],
[1.0f32, 0., 0.],
[-1.0f32, 0., 0.],
[0.0f32, 1., 0.],
[0.0f32, -1., 0.],
];
let texture_data = [
[1.0f32, 0.],
[0.0f32, 0.],
[0.0f32, 1.],
[1.0f32, 1.],
];
let vertex_data = [
// top (0, 0, 1)
[-1.0f32, -1., 1.],
[1.0f32, -1., 1.],
[1.0f32, 1., 1.],
[-1.0f32, 1., 1.],
// bottom (0, 0, -1)
[-1.0f32, 1., -1.],
[1.0f32, 1., -1.],
[1.0f32, -1., -1.],
[-1.0f32, -1., -1.],
// right (1, 0, 0)
[1.0f32, -1., -1.],
[1.0f32, 1., -1.],
[1.0f32, 1., 1.],
[1.0f32, -1., 1.],
// left (-1, 0, 0)
[-1.0f32, -1., 1.],
[-1.0f32, 1., 1.],
[-1.0f32, 1., -1.],
[-1.0f32, -1., -1.],
// front (0, 1, 0)
[1.0f32, 1., -1.],
[-1.0f32, 1., -1.],
[-1.0f32, 1., 1.],
[1.0f32, 1., 1.],
// back (0, -1, 0)
[1.0f32, -1., 1.],
[-1.0f32, -1., 1.],
[-1.0f32, -1., -1.],
[1.0f32, -1., -1.],
];
let mut indices = Vec::new();
let mut vertices = Vec::new();
let mut vertex_index = std::collections::HashMap::<usize,u16>::new();
for face in 0..6 {
for end_index in 2..4 {
for &index in &[0, end_index - 1, end_index] {
let vert = face*4+index;
let unique_id=(vert * 1<<0) + (index * 1<<8) + (face * 1<<16);
if let Some(&i)=vertex_index.get(&unique_id){
indices.push(i);
}else{
let i=vertices.len() as u16;
vertices.push(Vertex {
pos: vertex_data[vert],
texture: texture_data[index],
normal: face_data[face],
});
vertex_index.insert(unique_id,i);
indices.push(i);
}
}
}
}
let index_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Index"),
contents: bytemuck::cast_slice(&indices),
usage: wgpu::BufferUsages::INDEX,
});
let mut entities = Vec::<Entity>::new();
entities.push(Entity {
index_buf,
index_count: indices.len() as u32,
});
let vertex_buf = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("Vertex"),
contents: bytemuck::cast_slice(&vertices),
usage: wgpu::BufferUsages::VERTEX,
});
modeldatas.push(ModelData {
transform: glam::Mat4::from_translation(
glam::Vec3::new(cf.position.x,cf.position.y,cf.position.z)
)
* glam::Mat4::from_mat3(
glam::Mat3::from_cols(
glam::Vec3::new(cf.orientation.x.x,cf.orientation.y.x,cf.orientation.z.x),
glam::Vec3::new(cf.orientation.x.y,cf.orientation.y.y,cf.orientation.z.y),
glam::Vec3::new(cf.orientation.x.z,cf.orientation.y.z,cf.orientation.z.z),
),
)
* glam::Mat4::from_scale(
glam::Vec3::new(size.x,size.y,size.z)/2.0
),
vertex_buf,
entities,
});
}
}
},
Err(e) => println!("lmao err {:?}", e),
}
let main_bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { let main_bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: None, label: None,
entries: &[ entries: &[