From b5c689f8ff7e90319f6e604556accd9a19b9e11c Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 27 Sep 2023 15:00:53 -0700 Subject: [PATCH] implement roblox cube texture coordinates --- src/primitives.rs | 48 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/primitives.rs b/src/primitives.rs index b8fd1b06..146d4040 100644 --- a/src/primitives.rs +++ b/src/primitives.rs @@ -5,30 +5,30 @@ pub fn generate_partial_unit_cube(face_transforms:[Option;6])->ob let default_polys=[ // right (1, 0, 0) obj::SimplePolygon(vec![ - obj::IndexTuple(6,Some(0),Some(0)), + obj::IndexTuple(6,Some(2),Some(0)), obj::IndexTuple(5,Some(1),Some(0)), - obj::IndexTuple(2,Some(2),Some(0)), + obj::IndexTuple(2,Some(0),Some(0)), obj::IndexTuple(1,Some(3),Some(0)), ]), // top (0, 1, 0) obj::SimplePolygon(vec![ - obj::IndexTuple(5,Some(1),Some(1)), - obj::IndexTuple(4,Some(0),Some(1)), - obj::IndexTuple(3,Some(3),Some(1)), - obj::IndexTuple(2,Some(2),Some(1)), + obj::IndexTuple(5,Some(3),Some(1)), + obj::IndexTuple(4,Some(2),Some(1)), + obj::IndexTuple(3,Some(1),Some(1)), + obj::IndexTuple(2,Some(0),Some(1)), ]), // back (0, 0, 1) obj::SimplePolygon(vec![ - obj::IndexTuple(0,Some(0),Some(2)), - obj::IndexTuple(1,Some(1),Some(2)), - obj::IndexTuple(2,Some(2),Some(2)), - obj::IndexTuple(3,Some(3),Some(2)), + obj::IndexTuple(0,Some(3),Some(2)), + obj::IndexTuple(1,Some(2),Some(2)), + obj::IndexTuple(2,Some(1),Some(2)), + obj::IndexTuple(3,Some(0),Some(2)), ]), // left (-1, 0, 0) obj::SimplePolygon(vec![ - obj::IndexTuple(0,Some(0),Some(3)), + obj::IndexTuple(0,Some(2),Some(3)), obj::IndexTuple(3,Some(1),Some(3)), - obj::IndexTuple(4,Some(2),Some(3)), + obj::IndexTuple(4,Some(0),Some(3)), obj::IndexTuple(7,Some(3),Some(3)), ]), // bottom (0,-1, 0) @@ -40,10 +40,10 @@ pub fn generate_partial_unit_cube(face_transforms:[Option;6])->ob ]), // front (0, 0,-1) obj::SimplePolygon(vec![ - obj::IndexTuple(4,Some(0),Some(5)), - obj::IndexTuple(5,Some(1),Some(5)), - obj::IndexTuple(6,Some(2),Some(5)), - obj::IndexTuple(7,Some(3),Some(5)), + obj::IndexTuple(4,Some(1),Some(5)), + obj::IndexTuple(5,Some(0),Some(5)), + obj::IndexTuple(6,Some(3),Some(5)), + obj::IndexTuple(7,Some(2),Some(5)), ]), ]; let default_verts=[[0.0,0.0],[1.0,0.0],[1.0,1.0],[0.0,1.0]]; @@ -73,14 +73,14 @@ pub fn generate_partial_unit_cube(face_transforms:[Option;6])->ob } obj::ObjData{ position: vec![ - [-1.,-1., 1.],//left bottom back - [ 1.,-1., 1.],//right bottom back - [ 1., 1., 1.],//right top back - [-1., 1., 1.],//left top back - [-1., 1.,-1.],//left top front - [ 1., 1.,-1.],//right top front - [ 1.,-1.,-1.],//right bottom front - [-1.,-1.,-1.],//left bottom front + [-1.,-1., 1.],//0 left bottom back + [ 1.,-1., 1.],//1 right bottom back + [ 1., 1., 1.],//2 right top back + [-1., 1., 1.],//3 left top back + [-1., 1.,-1.],//4 left top front + [ 1., 1.,-1.],//5 right top front + [ 1.,-1.,-1.],//6 right bottom front + [-1.,-1.,-1.],//7 left bottom front ], texture: generated_verts, normal: vec![