add model.rs
This commit is contained in:
parent
2e786b090f
commit
eafcbae677
27
src/main.rs
27
src/main.rs
@ -1,16 +1,9 @@
|
|||||||
use bytemuck::{Pod, Zeroable};
|
|
||||||
use std::{borrow::Cow, time::Instant};
|
use std::{borrow::Cow, time::Instant};
|
||||||
use wgpu::{util::DeviceExt, AstcBlock, AstcChannel};
|
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 body;
|
||||||
|
mod model;
|
||||||
mod zeroes;
|
mod zeroes;
|
||||||
mod framework;
|
mod framework;
|
||||||
mod instruction;
|
mod instruction;
|
||||||
@ -21,22 +14,6 @@ struct Entity {
|
|||||||
index_buf: wgpu::Buffer,
|
index_buf: wgpu::Buffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ModelInstance {
|
|
||||||
transform: glam::Mat4,
|
|
||||||
color: glam::Vec4,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ModelData {
|
|
||||||
instances: Vec<ModelInstance>,
|
|
||||||
vertices: Vec<Vertex>,
|
|
||||||
entities: Vec<Vec<u16>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
struct ModelGraphics {
|
||||||
instances: Vec<ModelInstance>,
|
instances: Vec<ModelInstance>,
|
||||||
vertex_buf: wgpu::Buffer,
|
vertex_buf: wgpu::Buffer,
|
||||||
|
25
src/model.rs
Normal file
25
src/model.rs
Normal file
@ -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<ModelInstance>,
|
||||||
|
pub vertices: Vec<Vertex>,
|
||||||
|
pub entities: Vec<Vec<u16>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user