2023-09-27 09:12:20 +00:00
|
|
|
use bytemuck::{Pod, Zeroable};
|
2024-02-06 04:28:22 +00:00
|
|
|
use strafesnet_common::model::{IndexedVertex,PolygonGroup};
|
2024-02-05 04:59:33 +00:00
|
|
|
#[derive(Clone,Copy,Pod,Zeroable)]
|
2023-09-27 09:12:20 +00:00
|
|
|
#[repr(C)]
|
2024-02-05 04:59:33 +00:00
|
|
|
pub struct GraphicsVertex{
|
|
|
|
pub pos:[f32;3],
|
|
|
|
pub tex:[f32;2],
|
|
|
|
pub normal:[f32;3],
|
|
|
|
pub color:[f32;4],
|
2023-09-27 09:12:20 +00:00
|
|
|
}
|
|
|
|
pub struct IndexedGroupFixedTexture{
|
2024-02-06 04:28:22 +00:00
|
|
|
pub polys:Vec<PolygonGroup>,
|
2023-09-27 09:12:20 +00:00
|
|
|
}
|
2023-10-26 02:51:24 +00:00
|
|
|
pub struct IndexedGraphicsModelSingleTexture{
|
2024-02-05 04:59:33 +00:00
|
|
|
pub unique_pos:Vec<[f32;3]>,
|
|
|
|
pub unique_tex:Vec<[f32;2]>,
|
|
|
|
pub unique_normal:Vec<[f32;3]>,
|
|
|
|
pub unique_color:Vec<[f32;4]>,
|
2023-09-27 09:12:20 +00:00
|
|
|
pub unique_vertices:Vec<IndexedVertex>,
|
|
|
|
pub texture:Option<u32>,//RenderPattern? material/texture/shader/flat color
|
2024-02-05 04:59:33 +00:00
|
|
|
pub groups:Vec<IndexedGroupFixedTexture>,
|
2023-10-26 02:51:24 +00:00
|
|
|
pub instances:Vec<GraphicsModelInstance>,
|
2023-09-27 09:12:20 +00:00
|
|
|
}
|
2023-10-30 23:31:17 +00:00
|
|
|
pub enum Entities{
|
|
|
|
U32(Vec<Vec<u32>>),
|
|
|
|
U16(Vec<Vec<u16>>),
|
|
|
|
}
|
2023-10-26 02:51:24 +00:00
|
|
|
pub struct GraphicsModelSingleTexture{
|
|
|
|
pub instances:Vec<GraphicsModelInstance>,
|
2023-10-30 23:31:17 +00:00
|
|
|
pub vertices:Vec<GraphicsVertex>,
|
|
|
|
pub entities:Entities,
|
|
|
|
pub texture:Option<u32>,
|
2023-09-27 09:12:20 +00:00
|
|
|
}
|
2023-10-06 22:46:02 +00:00
|
|
|
#[derive(Clone,PartialEq)]
|
2023-10-26 02:51:24 +00:00
|
|
|
pub struct GraphicsModelColor4(glam::Vec4);
|
|
|
|
impl GraphicsModelColor4{
|
2023-10-06 22:46:02 +00:00
|
|
|
pub const fn get(&self)->glam::Vec4{
|
|
|
|
self.0
|
|
|
|
}
|
|
|
|
}
|
2023-10-26 02:51:24 +00:00
|
|
|
impl From<glam::Vec4> for GraphicsModelColor4{
|
2023-10-06 22:46:02 +00:00
|
|
|
fn from(value:glam::Vec4)->Self{
|
|
|
|
Self(value)
|
|
|
|
}
|
|
|
|
}
|
2023-10-26 02:51:24 +00:00
|
|
|
impl std::hash::Hash for GraphicsModelColor4{
|
2023-10-06 22:46:02 +00:00
|
|
|
fn hash<H: std::hash::Hasher>(&self,state:&mut H) {
|
|
|
|
for &f in self.0.as_ref(){
|
|
|
|
bytemuck::cast::<f32,u32>(f).hash(state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-10-26 02:51:24 +00:00
|
|
|
impl Eq for GraphicsModelColor4{}
|
2023-09-27 09:12:20 +00:00
|
|
|
#[derive(Clone)]
|
2023-10-26 02:51:24 +00:00
|
|
|
pub struct GraphicsModelInstance{
|
2023-09-27 09:12:20 +00:00
|
|
|
pub transform:glam::Mat4,
|
|
|
|
pub normal_transform:glam::Mat3,
|
2023-10-26 02:51:24 +00:00
|
|
|
pub color:GraphicsModelColor4,
|
|
|
|
}
|