From a3621790a6f4466daab0f38f5eaf57fe064b2e92 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 21 Jan 2025 22:59:01 +0100 Subject: more work on armature --- client/src/armature.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 client/src/armature.rs (limited to 'client/src/armature.rs') 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, + joint_mat: Vec, + 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::() * 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()), + ); + } +} -- cgit v1.2.3-70-g09d2