split out model
This commit is contained in:
parent
4bbd11dbb6
commit
9ca2f0a194
60
src/model.rs
60
src/model.rs
@ -1,11 +1,12 @@
|
|||||||
use bytemuck::{Pod, Zeroable};
|
use crate::integer::{Unit32Vec3,Planar64,Planar64Vec3,Planar64Affine3};
|
||||||
#[derive(Clone, Copy, Pod, Zeroable)]
|
pub struct TextureCoordinate([f32;2]);
|
||||||
#[repr(C)]
|
pub struct Color4(glam::Vec4);
|
||||||
pub struct Vertex {
|
|
||||||
pub pos: [f32; 3],
|
pub struct ModelVertex {
|
||||||
pub tex: [f32; 2],
|
pub pos:Planar64Vec3,
|
||||||
pub normal: [f32; 3],
|
pub normal:Unit32Vec3,
|
||||||
pub color: [f32; 4],
|
pub tex:TextureCoordinate,
|
||||||
|
pub color:Color4,
|
||||||
}
|
}
|
||||||
#[derive(Clone,Hash,PartialEq,Eq)]
|
#[derive(Clone,Hash,PartialEq,Eq)]
|
||||||
pub struct IndexedVertex{
|
pub struct IndexedVertex{
|
||||||
@ -30,42 +31,17 @@ pub struct IndexedModel{
|
|||||||
pub groups: Vec<IndexedGroup>,
|
pub groups: Vec<IndexedGroup>,
|
||||||
pub instances:Vec<ModelInstance>,
|
pub instances:Vec<ModelInstance>,
|
||||||
}
|
}
|
||||||
pub struct IndexedGroupFixedTexture{
|
|
||||||
pub polys:Vec<IndexedPolygon>,
|
|
||||||
}
|
|
||||||
pub struct IndexedModelSingleTexture{
|
|
||||||
pub unique_pos:Vec<[f32; 3]>,
|
|
||||||
pub unique_tex:Vec<[f32; 2]>,
|
|
||||||
pub unique_normal:Vec<[f32; 3]>,
|
|
||||||
pub unique_color:Vec<[f32; 4]>,
|
|
||||||
pub unique_vertices:Vec<IndexedVertex>,
|
|
||||||
pub texture:Option<u32>,//RenderPattern? material/texture/shader/flat color
|
|
||||||
pub groups: Vec<IndexedGroupFixedTexture>,
|
|
||||||
pub instances:Vec<ModelGraphicsInstance>,
|
|
||||||
}
|
|
||||||
pub struct ModelSingleTexture{
|
|
||||||
pub instances: Vec<ModelGraphicsInstance>,
|
|
||||||
pub vertices: Vec<Vertex>,
|
|
||||||
pub entities: Vec<Vec<u16>>,
|
|
||||||
pub texture: Option<u32>,
|
|
||||||
}
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct ModelGraphicsInstance{
|
|
||||||
pub transform:glam::Mat4,
|
|
||||||
pub normal_transform:glam::Mat3,
|
|
||||||
pub color:glam::Vec4,
|
|
||||||
}
|
|
||||||
pub struct ModelInstance{
|
pub struct ModelInstance{
|
||||||
//pub id:u64,//this does not actually help with map fixes resimulating bots, they must always be resimulated
|
//pub id:u64,//this does not actually help with map fixes resimulating bots, they must always be resimulated
|
||||||
pub transform:glam::Affine3A,
|
pub transform:Planar64Affine3,
|
||||||
pub color:glam::Vec4,//transparency is in here
|
pub color:Color4,//transparency is in here
|
||||||
pub attributes:CollisionAttributes,
|
pub attributes:CollisionAttributes,
|
||||||
pub temp_indexing:Vec<TempIndexedAttributes>,
|
pub temp_indexing:Vec<TempIndexedAttributes>,
|
||||||
}
|
}
|
||||||
impl std::default::Default for ModelInstance{
|
impl std::default::Default for ModelInstance{
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self{
|
Self{
|
||||||
color:glam::Vec4::ONE,
|
color:Color4(glam::Vec4::ONE),
|
||||||
transform:Default::default(),
|
transform:Default::default(),
|
||||||
attributes:Default::default(),
|
attributes:Default::default(),
|
||||||
temp_indexing:Default::default(),
|
temp_indexing:Default::default(),
|
||||||
@ -77,7 +53,7 @@ pub struct IndexedModelInstances{
|
|||||||
pub models:Vec<IndexedModel>,
|
pub models:Vec<IndexedModel>,
|
||||||
//may make this into an object later.
|
//may make this into an object later.
|
||||||
pub modes:Vec<ModeDescription>,
|
pub modes:Vec<ModeDescription>,
|
||||||
pub spawn_point:glam::Vec3,
|
pub spawn_point:Planar64Vec3,
|
||||||
}
|
}
|
||||||
//stage description referencing flattened ids is spooky, but the map loading is meant to be deterministic.
|
//stage description referencing flattened ids is spooky, but the map loading is meant to be deterministic.
|
||||||
pub struct ModeDescription{
|
pub struct ModeDescription{
|
||||||
@ -131,13 +107,13 @@ pub struct ContactingLadder{
|
|||||||
//you have this effect while intersecting
|
//you have this effect while intersecting
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct IntersectingWater{
|
pub struct IntersectingWater{
|
||||||
pub viscosity:i64,
|
pub viscosity:Planar64,
|
||||||
pub density:i64,
|
pub density:Planar64,
|
||||||
pub current:glam::Vec3,
|
pub current:Planar64Vec3,
|
||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct IntersectingAccelerator{
|
pub struct IntersectingAccelerator{
|
||||||
pub acceleration:glam::Vec3
|
pub acceleration:Planar64Vec3
|
||||||
}
|
}
|
||||||
//All models can be given these attributes
|
//All models can be given these attributes
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -146,7 +122,7 @@ pub struct GameMechanicJumpLimit{
|
|||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct GameMechanicBooster{
|
pub struct GameMechanicBooster{
|
||||||
pub velocity:glam::Vec3,
|
pub velocity:Planar64Vec3,
|
||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum ZoneBehaviour{
|
pub enum ZoneBehaviour{
|
||||||
|
35
src/model_graphics.rs
Normal file
35
src/model_graphics.rs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
use bytemuck::{Pod, Zeroable};
|
||||||
|
use crate::model::{IndexedVertex,IndexedPolygon};
|
||||||
|
#[derive(Clone, Copy, Pod, Zeroable)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct GraphicsVertex {
|
||||||
|
pub pos: [f32; 3],
|
||||||
|
pub tex: [f32; 2],
|
||||||
|
pub normal: [f32; 3],
|
||||||
|
pub color: [f32; 4],
|
||||||
|
}
|
||||||
|
pub struct IndexedGroupFixedTexture{
|
||||||
|
pub polys:Vec<IndexedPolygon>,
|
||||||
|
}
|
||||||
|
pub struct IndexedModelGraphicsSingleTexture{
|
||||||
|
pub unique_pos:Vec<[f32; 3]>,
|
||||||
|
pub unique_tex:Vec<[f32; 2]>,
|
||||||
|
pub unique_normal:Vec<[f32; 3]>,
|
||||||
|
pub unique_color:Vec<[f32; 4]>,
|
||||||
|
pub unique_vertices:Vec<IndexedVertex>,
|
||||||
|
pub texture:Option<u32>,//RenderPattern? material/texture/shader/flat color
|
||||||
|
pub groups: Vec<IndexedGroupFixedTexture>,
|
||||||
|
pub instances:Vec<ModelGraphicsInstance>,
|
||||||
|
}
|
||||||
|
pub struct ModelGraphicsSingleTexture{
|
||||||
|
pub instances: Vec<ModelGraphicsInstance>,
|
||||||
|
pub vertices: Vec<GraphicsVertex>,
|
||||||
|
pub entities: Vec<Vec<u16>>,
|
||||||
|
pub texture: Option<u32>,
|
||||||
|
}
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct ModelGraphicsInstance{
|
||||||
|
pub transform:glam::Mat4,
|
||||||
|
pub normal_transform:glam::Mat3,
|
||||||
|
pub color:glam::Vec4,
|
||||||
|
}
|
1
src/model_physics.rs
Normal file
1
src/model_physics.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
//
|
Loading…
Reference in New Issue
Block a user