summaryrefslogtreecommitdiff
path: root/client/src/armature.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-01-21 22:59:01 +0100
committermetamuffin <metamuffin@disroot.org>2025-01-21 22:59:01 +0100
commita3621790a6f4466daab0f38f5eaf57fe064b2e92 (patch)
treecb4d6ef53a65abdd87969cbbf6ad4c9a54b54225 /client/src/armature.rs
parent12bf2f3302efc9042f12ca17104928c35700c229 (diff)
downloadweareserver-a3621790a6f4466daab0f38f5eaf57fe064b2e92.tar
weareserver-a3621790a6f4466daab0f38f5eaf57fe064b2e92.tar.bz2
weareserver-a3621790a6f4466daab0f38f5eaf57fe064b2e92.tar.zst
more work on armature
Diffstat (limited to 'client/src/armature.rs')
-rw-r--r--client/src/armature.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/client/src/armature.rs b/client/src/armature.rs
new file mode 100644
index 0000000..d955415
--- /dev/null
+++ b/client/src/armature.rs
@@ -0,0 +1,34 @@
+use std::sync::Arc;
+
+use glam::Mat4;
+use weareshared::resources::Armature;
+use wgpu::{Buffer, BufferDescriptor, BufferUsages, Device, Queue};
+
+pub struct RArmature {
+ pub joint_mat_uniform_buffer: Arc<Buffer>,
+ joint_mat: Vec<Mat4>,
+ data: Armature,
+}
+
+impl RArmature {
+ pub fn new(device: &Device, armature: Armature) -> Self {
+ Self {
+ joint_mat_uniform_buffer: Arc::new(device.create_buffer(&BufferDescriptor {
+ label: Some("joint uniform"),
+ size: (armature.parent.as_ref().unwrap().len() * size_of::<f32>() * 16) as u64,
+ usage: BufferUsages::COPY_DST | BufferUsages::UNIFORM,
+ mapped_at_creation: false,
+ })),
+ data: armature,
+ joint_mat: vec![],
+ }
+ }
+ pub fn update(&mut self) {}
+ pub fn write_uniform(&self, queue: &Queue) {
+ queue.write_buffer(
+ &self.joint_mat_uniform_buffer,
+ 0,
+ bytemuck::cast_slice(self.joint_mat.as_slice()),
+ );
+ }
+}