From eafcbae677ccc59e9fc07598c581aa4a4a45a48d Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 22 Sep 2023 15:21:13 -0700 Subject: [PATCH] add model.rs --- src/main.rs | 27 ++------------------------- src/model.rs | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 25 deletions(-) create mode 100644 src/model.rs diff --git a/src/main.rs b/src/main.rs index 088891fd..6d9f0fd9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,16 +1,9 @@ -use bytemuck::{Pod, Zeroable}; use std::{borrow::Cow, time::Instant}; use wgpu::{util::DeviceExt, AstcBlock, AstcChannel}; +use model::{Vertex,ModelData,ModelInstance}; -#[derive(Clone, Copy, Pod, Zeroable)] -#[repr(C)] -struct Vertex { - pos: [f32; 3], - texture: [f32; 2], - normal: [f32; 3], - color: [f32; 4], -} mod body; +mod model; mod zeroes; mod framework; mod instruction; @@ -21,22 +14,6 @@ struct Entity { index_buf: wgpu::Buffer, } -struct ModelInstance { - transform: glam::Mat4, - color: glam::Vec4, -} - -struct ModelData { - instances: Vec, - vertices: Vec, - entities: Vec>, -} - -impl ModelData { - const COLOR_FLOATS_WHITE: [f32;4] = [1.0,1.0,1.0,1.0]; - const COLOR_VEC4_WHITE: glam::Vec4 = glam::vec4(1.0,1.0,1.0,1.0); -} - struct ModelGraphics { instances: Vec, vertex_buf: wgpu::Buffer, diff --git a/src/model.rs b/src/model.rs new file mode 100644 index 00000000..e2ac139a --- /dev/null +++ b/src/model.rs @@ -0,0 +1,25 @@ +use bytemuck::{Pod, Zeroable}; +#[derive(Clone, Copy, Pod, Zeroable)] +#[repr(C)] +pub struct Vertex { + pub pos: [f32; 3], + pub texture: [f32; 2], + pub normal: [f32; 3], + pub color: [f32; 4], +} + +pub struct ModelInstance { + pub transform: glam::Mat4, + pub color: glam::Vec4, +} + +pub struct ModelData { + pub instances: Vec, + pub vertices: Vec, + pub entities: Vec>, +} + +impl ModelData { + pub const COLOR_FLOATS_WHITE: [f32;4] = [1.0,1.0,1.0,1.0]; + pub const COLOR_VEC4_WHITE: glam::Vec4 = glam::vec4(1.0,1.0,1.0,1.0); +} \ No newline at end of file