summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/src/helper.rs42
-rw-r--r--shared/src/resources.rs25
2 files changed, 67 insertions, 0 deletions
diff --git a/shared/src/helper.rs b/shared/src/helper.rs
index d46a830..723f91e 100644
--- a/shared/src/helper.rs
+++ b/shared/src/helper.rs
@@ -161,6 +161,48 @@ impl ReadWrite for Vec<[u32; 3]> {
.collect())
}
}
+impl ReadWrite for Vec<[u16; 4]> {
+ fn write(&self, w: &mut dyn Write) -> Result<()> {
+ for e in self {
+ w.write_all(&e[0].to_be_bytes())?;
+ w.write_all(&e[1].to_be_bytes())?;
+ w.write_all(&e[2].to_be_bytes())?;
+ w.write_all(&e[3].to_be_bytes())?;
+ }
+ Ok(())
+ }
+ fn read(r: &mut dyn Read) -> Result<Self> {
+ let mut buf = Vec::new();
+ r.read_to_end(&mut buf)?;
+ Ok(buf
+ .into_iter()
+ .array_chunks::<{ size_of::<u16>() }>()
+ .map(u16::from_be_bytes)
+ .array_chunks::<4>()
+ .collect())
+ }
+}
+impl ReadWrite for Vec<[f32; 4]> {
+ fn write(&self, w: &mut dyn Write) -> Result<()> {
+ for e in self {
+ w.write_all(&e[0].to_be_bytes())?;
+ w.write_all(&e[1].to_be_bytes())?;
+ w.write_all(&e[2].to_be_bytes())?;
+ w.write_all(&e[3].to_be_bytes())?;
+ }
+ Ok(())
+ }
+ fn read(r: &mut dyn Read) -> Result<Self> {
+ let mut buf = Vec::new();
+ r.read_to_end(&mut buf)?;
+ Ok(buf
+ .into_iter()
+ .array_chunks::<{ size_of::<f32>() }>()
+ .map(f32::from_be_bytes)
+ .array_chunks::<4>()
+ .collect())
+ }
+}
impl ReadWrite for Vec<f32> {
fn write(&self, w: &mut dyn Write) -> Result<()> {
for e in self {
diff --git a/shared/src/resources.rs b/shared/src/resources.rs
index 54a34b8..59d88b6 100644
--- a/shared/src/resources.rs
+++ b/shared/src/resources.rs
@@ -50,6 +50,7 @@ pub struct EnvironmentPart {
pub struct MeshPart {
pub name: Option<String>,
pub index: Option<Resource<Vec<[u32; 3]>>>,
+ pub armature: Option<Armature>,
pub g_metallic: Option<f32>,
pub g_roughness: Option<f32>,
pub g_albedo: Option<Vec3A>,
@@ -72,6 +73,8 @@ pub struct MeshPart {
pub va_transmission: Option<Resource<Vec<f32>>>,
pub va_alpha: Option<Resource<Vec<f32>>>,
pub va_emission: Option<Resource<Vec<Vec3A>>>,
+ pub va_joint_index: Option<Resource<Vec<[u16; 4]>>>,
+ pub va_joint_weight: Option<Resource<Vec<[f32; 4]>>>,
pub tex_normal: Option<Resource<Image<'static>>>,
pub tex_roughness: Option<Resource<Image<'static>>>,
pub tex_metallic: Option<Resource<Image<'static>>>,
@@ -81,6 +84,14 @@ pub struct MeshPart {
pub tex_emission: Option<Resource<Image<'static>>>,
pub tex_thickness: Option<Resource<Image<'static>>>,
pub tex_occlusion: Option<Resource<Image<'static>>>,
+ pub hint_mirror: Option<()>,
+}
+
+#[derive(Debug, Default, Clone)]
+pub struct Armature {
+ pub parent: Option<Vec<u32>>,
+ pub transform: Option<Vec<Affine3A>>,
+ pub name: Option<Vec<String>>,
}
#[derive(Debug, Default, Clone)]
@@ -122,6 +133,14 @@ impl ReadWrite for PrefabIndex {
}
}
+impl ReadWrite for Armature {
+ fn write(&self, w: &mut dyn Write) -> Result<()> {
+ todo!()
+ }
+ fn read(r: &mut dyn Read) -> Result<Self> {
+ todo!()
+ }
+}
impl ReadWrite for CollisionPart {
fn write(&self, w: &mut dyn Write) -> Result<()> {
write_kv_opt(w, b"restitution_coeff", &self.restitution_coeff)?;
@@ -249,6 +268,8 @@ impl ReadWrite for MeshPart {
write_kv_opt(w, b"va_transmission", &self.va_transmission)?;
write_kv_opt(w, b"va_alpha", &self.va_transmission)?;
write_kv_opt(w, b"va_emission", &self.va_emission)?;
+ write_kv_opt(w, b"va_joint_weight", &self.va_joint_weight)?;
+ write_kv_opt(w, b"va_joint_index", &self.va_joint_index)?;
write_kv_opt(w, b"tex_normal", &self.tex_normal)?;
write_kv_opt(w, b"tex_roughness", &self.tex_roughness)?;
write_kv_opt(w, b"tex_metallic", &self.tex_metallic)?;
@@ -257,6 +278,7 @@ impl ReadWrite for MeshPart {
write_kv_opt(w, b"tex_alpha", &self.tex_alpha)?;
write_kv_opt(w, b"tex_emission", &self.tex_emission)?;
write_kv_opt(w, b"tex_occlusion", &self.tex_occlusion)?;
+ write_kv_opt(w, b"hint_mirror", &self.hint_mirror)?;
Ok(())
}
fn read(r: &mut dyn Read) -> Result<Self> {
@@ -282,6 +304,8 @@ impl ReadWrite for MeshPart {
b"va_transmission" => Ok(s.va_transmission = Some(read_slice(v)?)),
b"va_alpha" => Ok(s.va_alpha = Some(read_slice(v)?)),
b"va_emission" => Ok(s.va_emission = Some(read_slice(v)?)),
+ b"va_joint_weight" => Ok(s.va_joint_weight = Some(read_slice(v)?)),
+ b"va_joint_index" => Ok(s.va_joint_index = Some(read_slice(v)?)),
b"tex_normal" => Ok(s.tex_normal = Some(read_slice(v)?)),
b"tex_roughness" => Ok(s.tex_roughness = Some(read_slice(v)?)),
b"tex_metallic" => Ok(s.tex_metallic = Some(read_slice(v)?)),
@@ -290,6 +314,7 @@ impl ReadWrite for MeshPart {
b"tex_alpha" => Ok(s.tex_alpha = Some(read_slice(v)?)),
b"tex_emission" => Ok(s.tex_emission = Some(read_slice(v)?)),
b"tex_occlusion" => Ok(s.tex_occlusion = Some(read_slice(v)?)),
+ b"hint_mirror" => Ok(s.hint_mirror = Some(read_slice(v)?)),
x => Ok(warn!(
"unknown mesh part key: {:?}",
String::from_utf8_lossy(x)