diff options
Diffstat (limited to 'client/src/armature.rs')
-rw-r--r-- | client/src/armature.rs | 34 |
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()), + ); + } +} |