diff options
Diffstat (limited to 'world/src/main.rs')
-rw-r--r-- | world/src/main.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/world/src/main.rs b/world/src/main.rs index 28a4ec4..fd354b3 100644 --- a/world/src/main.rs +++ b/world/src/main.rs @@ -1,3 +1,4 @@ +#![feature(iter_array_chunks)] use anyhow::Result; use clap::Parser; use std::{ @@ -6,7 +7,7 @@ use std::{ }; use weareshared::{ packets::{Object, Packet}, - resources::{Part, Prefab, VertexAttributes}, + resources::{Indecies, Part, Prefab, VertexAttributes}, store::ResourceStore, }; @@ -36,6 +37,14 @@ fn main() -> Result<()> { attrs[1].push(p[1]); attrs[2].push(p[2]); } + let index = reader + .read_indices() + .unwrap() + .into_u32() + .map(|e| e as u16) + .array_chunks::<3>() + .collect::<Vec<_>>(); + let part = Part { vertex: attrs .into_iter() @@ -45,6 +54,11 @@ fn main() -> Result<()> { store.set(&out) }) .collect::<Result<Vec<_>, _>>()?, + index: Some({ + let mut out = Vec::new(); + Indecies(index).serialize(&mut out)?; + store.set(&out)? + }), ..Part::default() }; let mut out = Vec::new(); @@ -60,6 +74,12 @@ fn main() -> Result<()> { Packet::Add(Object::new(), prefab).serialize(&mut sock)?; + store.iter(|d| { + Packet::RespondResource(d.to_vec()) + .serialize(&mut sock) + .unwrap(); + })?; + loop { let packet = Packet::deserialize(&mut sock)?; match packet { |