tweak primitives
This commit is contained in:
parent
1ba7b0591b
commit
d0d2e6eca3
@ -42,50 +42,6 @@ const CUBE_DEFAULT_NORMALS:[Planar64Vec3;6]=[
|
|||||||
vec3::int( 0,-1, 0),//CubeFace::Bottom
|
vec3::int( 0,-1, 0),//CubeFace::Bottom
|
||||||
vec3::int( 0, 0,-1),//CubeFace::Front
|
vec3::int( 0, 0,-1),//CubeFace::Front
|
||||||
];
|
];
|
||||||
const CUBE_DEFAULT_POLYS:[[[u32;3];4];6]=[
|
|
||||||
// right (1, 0, 0)
|
|
||||||
[
|
|
||||||
[6,2,0],//[vertex,tex,norm]
|
|
||||||
[5,1,0],
|
|
||||||
[2,0,0],
|
|
||||||
[1,3,0],
|
|
||||||
],
|
|
||||||
// top (0, 1, 0)
|
|
||||||
[
|
|
||||||
[5,3,1],
|
|
||||||
[4,2,1],
|
|
||||||
[3,1,1],
|
|
||||||
[2,0,1],
|
|
||||||
],
|
|
||||||
// back (0, 0, 1)
|
|
||||||
[
|
|
||||||
[0,3,2],
|
|
||||||
[1,2,2],
|
|
||||||
[2,1,2],
|
|
||||||
[3,0,2],
|
|
||||||
],
|
|
||||||
// left (-1, 0, 0)
|
|
||||||
[
|
|
||||||
[0,2,3],
|
|
||||||
[3,1,3],
|
|
||||||
[4,0,3],
|
|
||||||
[7,3,3],
|
|
||||||
],
|
|
||||||
// bottom (0,-1, 0)
|
|
||||||
[
|
|
||||||
[1,1,4],
|
|
||||||
[0,0,4],
|
|
||||||
[7,3,4],
|
|
||||||
[6,2,4],
|
|
||||||
],
|
|
||||||
// front (0, 0,-1)
|
|
||||||
[
|
|
||||||
[4,1,5],
|
|
||||||
[5,0,5],
|
|
||||||
[6,3,5],
|
|
||||||
[7,2,5],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
#[derive(Hash,PartialEq,Eq)]
|
#[derive(Hash,PartialEq,Eq)]
|
||||||
pub enum WedgeFace{
|
pub enum WedgeFace{
|
||||||
@ -132,8 +88,8 @@ impl CubeFaceDescription{
|
|||||||
pub fn insert(&mut self,index:CubeFace,value:FaceDescription){
|
pub fn insert(&mut self,index:CubeFace,value:FaceDescription){
|
||||||
self.0[index as usize]=Some(value);
|
self.0[index as usize]=Some(value);
|
||||||
}
|
}
|
||||||
pub fn pairs(self)->std::iter::FilterMap<std::iter::Enumerate<std::array::IntoIter<Option<FaceDescription>,6>>,impl FnMut((usize,Option<FaceDescription>))->Option<(usize,FaceDescription)>>{
|
pub fn pairs(self)->impl Iterator<Item=(usize,FaceDescription)>{
|
||||||
self.0.into_iter().enumerate().filter_map(|v|v.1.map(|u|(v.0,u)))
|
self.0.into_iter().enumerate().filter_map(|(i,v)|v.map(|u|(i,u)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn unit_cube(render:RenderConfigId)->Mesh{
|
pub fn unit_cube(render:RenderConfigId)->Mesh{
|
||||||
@ -201,6 +157,50 @@ impl FaceDescription{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->Mesh{
|
pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->Mesh{
|
||||||
|
const CUBE_DEFAULT_POLYS:[[[u32;3];4];6]=[
|
||||||
|
// right (1, 0, 0)
|
||||||
|
[
|
||||||
|
[6,2,0],//[vertex,tex,norm]
|
||||||
|
[5,1,0],
|
||||||
|
[2,0,0],
|
||||||
|
[1,3,0],
|
||||||
|
],
|
||||||
|
// top (0, 1, 0)
|
||||||
|
[
|
||||||
|
[5,3,1],
|
||||||
|
[4,2,1],
|
||||||
|
[3,1,1],
|
||||||
|
[2,0,1],
|
||||||
|
],
|
||||||
|
// back (0, 0, 1)
|
||||||
|
[
|
||||||
|
[0,3,2],
|
||||||
|
[1,2,2],
|
||||||
|
[2,1,2],
|
||||||
|
[3,0,2],
|
||||||
|
],
|
||||||
|
// left (-1, 0, 0)
|
||||||
|
[
|
||||||
|
[0,2,3],
|
||||||
|
[3,1,3],
|
||||||
|
[4,0,3],
|
||||||
|
[7,3,3],
|
||||||
|
],
|
||||||
|
// bottom (0,-1, 0)
|
||||||
|
[
|
||||||
|
[1,1,4],
|
||||||
|
[0,0,4],
|
||||||
|
[7,3,4],
|
||||||
|
[6,2,4],
|
||||||
|
],
|
||||||
|
// front (0, 0,-1)
|
||||||
|
[
|
||||||
|
[4,1,5],
|
||||||
|
[5,0,5],
|
||||||
|
[6,3,5],
|
||||||
|
[7,2,5],
|
||||||
|
],
|
||||||
|
];
|
||||||
let mut generated_pos=Vec::new();
|
let mut generated_pos=Vec::new();
|
||||||
let mut generated_tex=Vec::new();
|
let mut generated_tex=Vec::new();
|
||||||
let mut generated_normal=Vec::new();
|
let mut generated_normal=Vec::new();
|
||||||
@ -279,35 +279,35 @@ pub fn generate_partial_unit_cube(face_descriptions:CubeFaceDescription)->Mesh{
|
|||||||
}
|
}
|
||||||
//don't think too hard about the copy paste because this is all going into the map tool eventually...
|
//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)->Mesh{
|
pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->Mesh{
|
||||||
let wedge_default_polys=[
|
const WEDGE_DEFAULT_POLYS:[&[[u32;3]];5]=[
|
||||||
// right (1, 0, 0)
|
// right (1, 0, 0)
|
||||||
vec![
|
&[
|
||||||
[6,2,0],//[vertex,tex,norm]
|
[6,2,0],//[vertex,tex,norm]
|
||||||
[2,0,0],
|
[2,0,0],
|
||||||
[1,3,0],
|
[1,3,0],
|
||||||
],
|
],
|
||||||
// FrontTop (0, 1, -1)
|
// FrontTop (0, 1, -1)
|
||||||
vec![
|
&[
|
||||||
[3,1,1],
|
[3,1,1],
|
||||||
[2,0,1],
|
[2,0,1],
|
||||||
[6,3,1],
|
[6,3,1],
|
||||||
[7,2,1],
|
[7,2,1],
|
||||||
],
|
],
|
||||||
// back (0, 0, 1)
|
// back (0, 0, 1)
|
||||||
vec![
|
&[
|
||||||
[0,3,2],
|
[0,3,2],
|
||||||
[1,2,2],
|
[1,2,2],
|
||||||
[2,1,2],
|
[2,1,2],
|
||||||
[3,0,2],
|
[3,0,2],
|
||||||
],
|
],
|
||||||
// left (-1, 0, 0)
|
// left (-1, 0, 0)
|
||||||
vec![
|
&[
|
||||||
[0,2,3],
|
[0,2,3],
|
||||||
[3,1,3],
|
[3,1,3],
|
||||||
[7,3,3],
|
[7,3,3],
|
||||||
],
|
],
|
||||||
// bottom (0,-1, 0)
|
// bottom (0,-1, 0)
|
||||||
vec![
|
&[
|
||||||
[1,1,4],
|
[1,1,4],
|
||||||
[0,0,4],
|
[0,0,4],
|
||||||
[7,3,4],
|
[7,3,4],
|
||||||
@ -351,7 +351,7 @@ pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->Mesh
|
|||||||
//push vertices as they are needed
|
//push vertices as they are needed
|
||||||
let group_id=PolygonGroupId::new(polygon_groups.len() as u32);
|
let group_id=PolygonGroupId::new(polygon_groups.len() as u32);
|
||||||
polygon_groups.push(PolygonGroup::PolygonList(PolygonList::new(vec![
|
polygon_groups.push(PolygonGroup::PolygonList(PolygonList::new(vec![
|
||||||
wedge_default_polys[face_id].iter().map(|tup|{
|
WEDGE_DEFAULT_POLYS[face_id].iter().map(|tup|{
|
||||||
let pos=CUBE_DEFAULT_VERTICES[tup[0] as usize];
|
let pos=CUBE_DEFAULT_VERTICES[tup[0] as usize];
|
||||||
let pos_index=if let Some(pos_index)=generated_pos.iter().position(|&p|p==pos){
|
let pos_index=if let Some(pos_index)=generated_pos.iter().position(|&p|p==pos){
|
||||||
pos_index
|
pos_index
|
||||||
@ -392,34 +392,34 @@ pub fn generate_partial_unit_wedge(face_descriptions:WedgeFaceDescription)->Mesh
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescription)->Mesh{
|
pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescription)->Mesh{
|
||||||
let cornerwedge_default_polys=[
|
const CORNERWEDGE_DEFAULT_POLYS:[&[[u32;3]];5]=[
|
||||||
// right (1, 0, 0)
|
// right (1, 0, 0)
|
||||||
vec![
|
&[
|
||||||
[6,2,0],//[vertex,tex,norm]
|
[6,2,0],//[vertex,tex,norm]
|
||||||
[5,1,0],
|
[5,1,0],
|
||||||
[1,3,0],
|
[1,3,0],
|
||||||
],
|
],
|
||||||
// BackTop (0, 1, 1)
|
// BackTop (0, 1, 1)
|
||||||
vec![
|
&[
|
||||||
[5,3,1],
|
[5,3,1],
|
||||||
[0,1,1],
|
[0,1,1],
|
||||||
[1,0,1],
|
[1,0,1],
|
||||||
],
|
],
|
||||||
// LeftTop (-1, 1, 0)
|
// LeftTop (-1, 1, 0)
|
||||||
vec![
|
&[
|
||||||
[5,3,2],
|
[5,3,2],
|
||||||
[7,2,2],
|
[7,2,2],
|
||||||
[0,1,2],
|
[0,1,2],
|
||||||
],
|
],
|
||||||
// bottom (0,-1, 0)
|
// bottom (0,-1, 0)
|
||||||
vec![
|
&[
|
||||||
[1,1,3],
|
[1,1,3],
|
||||||
[0,0,3],
|
[0,0,3],
|
||||||
[7,3,3],
|
[7,3,3],
|
||||||
[6,2,3],
|
[6,2,3],
|
||||||
],
|
],
|
||||||
// front (0, 0,-1)
|
// front (0, 0,-1)
|
||||||
vec![
|
&[
|
||||||
[5,0,4],
|
[5,0,4],
|
||||||
[6,3,4],
|
[6,3,4],
|
||||||
[7,2,4],
|
[7,2,4],
|
||||||
@ -462,7 +462,7 @@ pub fn generate_partial_unit_cornerwedge(face_descriptions:CornerWedgeFaceDescri
|
|||||||
//push vertices as they are needed
|
//push vertices as they are needed
|
||||||
let group_id=PolygonGroupId::new(polygon_groups.len() as u32);
|
let group_id=PolygonGroupId::new(polygon_groups.len() as u32);
|
||||||
polygon_groups.push(PolygonGroup::PolygonList(PolygonList::new(vec![
|
polygon_groups.push(PolygonGroup::PolygonList(PolygonList::new(vec![
|
||||||
cornerwedge_default_polys[face_id].iter().map(|tup|{
|
CORNERWEDGE_DEFAULT_POLYS[face_id].iter().map(|tup|{
|
||||||
let pos=CUBE_DEFAULT_VERTICES[tup[0] as usize];
|
let pos=CUBE_DEFAULT_VERTICES[tup[0] as usize];
|
||||||
let pos_index=if let Some(pos_index)=generated_pos.iter().position(|&p|p==pos){
|
let pos_index=if let Some(pos_index)=generated_pos.iter().position(|&p|p==pos){
|
||||||
pos_index
|
pos_index
|
||||||
|
Loading…
x
Reference in New Issue
Block a user