primitives wip

This commit is contained in:
Quaternions 2024-02-01 22:17:44 -08:00
parent 2cc7d76a48
commit 451808f9af

View File

@ -126,7 +126,7 @@ const CORNERWEDGE_DEFAULT_NORMALS:[Planar64Vec3;5]=[
Planar64Vec3::int( 0,-1, 0),//CornerWedge::Bottom
Planar64Vec3::int( 0, 0,-1),//CornerWedge::Front
];
pub fn unit_sphere()->crate::model::IndexedModel{
pub fn unit_sphere()->IndexedModel{
unit_cube()
}
#[derive(Default)]
@ -139,7 +139,7 @@ impl CubeFaceDescription{
self.0.into_iter().enumerate().filter_map(|v|v.1.map(|u|(v.0,u)))
}
}
pub fn unit_cube()->crate::model::IndexedModel{
pub fn unit_cube()->IndexedModel{
let mut t=CubeFaceDescription::default();
t.insert(CubeFace::Right,FaceDescription::default());
t.insert(CubeFace::Top,FaceDescription::default());
@ -149,7 +149,7 @@ pub fn unit_cube()->crate::model::IndexedModel{
t.insert(CubeFace::Front,FaceDescription::default());
generate_partial_unit_cube(t)
}
pub fn unit_cylinder()->crate::model::IndexedModel{
pub fn unit_cylinder()->IndexedModel{
unit_cube()
}
#[derive(Default)]
@ -162,7 +162,7 @@ impl WedgeFaceDescription{
self.0.into_iter().enumerate().filter_map(|v|v.1.map(|u|(v.0,u)))
}
}
pub fn unit_wedge()->crate::model::IndexedModel{
pub fn unit_wedge()->IndexedModel{
let mut t=WedgeFaceDescription::default();
t.insert(WedgeFace::Right,FaceDescription::default());
t.insert(WedgeFace::TopFront,FaceDescription::default());
@ -181,7 +181,7 @@ impl CornerWedgeFaceDescription{
self.0.into_iter().enumerate().filter_map(|v|v.1.map(|u|(v.0,u)))
}
}
pub fn unit_cornerwedge()->crate::model::IndexedModel{
pub fn unit_cornerwedge()->IndexedModel{
let mut t=CornerWedgeFaceDescription::default();
t.insert(CornerWedgeFace::Right,FaceDescription::default());
t.insert(CornerWedgeFace::TopBack,FaceDescription::default());
@ -208,7 +208,7 @@ impl std::default::Default for FaceDescription{
}
//TODO: it's probably better to use a shared vertex buffer between all primitives and use indexed rendering instead of generating a unique vertex buffer for each primitive.
//implementation: put all roblox primitives into one model.groups <- this won't work but I forget why
pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->crate::model::IndexedModel{
pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->IndexedModel{
let mut generated_pos=Vec::new();
let mut generated_tex=Vec::new();
let mut generated_normal=Vec::new();
@ -276,11 +276,10 @@ pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->crate:
unique_color:generated_color,
unique_vertices:generated_vertices,
groups,
instances:Vec::new(),
}
}
//don't think too hard about the copy paste because this is all going into the map tool eventually...
pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->crate::model::IndexedModel{
pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->IndexedModel{
let wedge_default_polys=vec![
// right (1, 0, 0)
vec![
@ -383,11 +382,10 @@ pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->crat
unique_color:generated_color,
unique_vertices:generated_vertices,
groups,
instances:Vec::new(),
}
}
pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescription)->crate::model::IndexedModel{
pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescription)->IndexedModel{
let cornerwedge_default_polys=vec![
// right (1, 0, 0)
vec![
@ -488,6 +486,5 @@ pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescri
unique_color:generated_color,
unique_vertices:generated_vertices,
groups,
instances:Vec::new(),
}
}