diff options
Diffstat (limited to 'world/src/main.rs')
-rw-r--r-- | world/src/main.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/world/src/main.rs b/world/src/main.rs index 772c87d..fe71e79 100644 --- a/world/src/main.rs +++ b/world/src/main.rs @@ -6,8 +6,9 @@ use std::{ path::PathBuf, }; use weareshared::{ + Affine3A, Mat3A, Vec3A, packets::{Object, Packet, ReadWrite}, - resources::{Attribute, AttributeArray, IndexArray, Part}, + resources::{Attribute, AttributeArray, IndexArray, Part, Prefab}, store::ResourceStore, }; @@ -26,6 +27,7 @@ fn main() -> Result<()> { let (gltf, buffers, _) = gltf::import(args.scene)?; + let mut prefab = Prefab::default(); for node in gltf.nodes() { if let Some(mesh) = node.mesh() { for p in mesh.primitives() { @@ -71,11 +73,21 @@ fn main() -> Result<()> { } .write_alloc(), )?; - Packet::Add(Object::new(), part).write(&mut sock)?; + + let mat = node.transform().matrix(); + let aff = Affine3A::from_cols_array_2d(&[ + [mat[0][0], mat[0][1], mat[0][2]], + [mat[1][0], mat[1][1], mat[1][2]], + [mat[2][0], mat[2][1], mat[2][2]], + [mat[3][0], mat[3][1], mat[3][2]], + ]); + prefab.0.push((aff, part)) } } } + Packet::Add(Object::new(), store.set(&prefab.write_alloc())?).write(&mut sock)?; + store.iter(|d| { Packet::RespondResource(d.to_vec()) .write(&mut sock) |