diff --git a/code/beginner/tutorial9-models/res/happy-cube.mtl b/code/beginner/tutorial9-models/res/happy-cube.mtl new file mode 100644 index 000000000..d235419cc --- /dev/null +++ b/code/beginner/tutorial9-models/res/happy-cube.mtl @@ -0,0 +1,13 @@ +# Blender MTL File: 'happy-cube.blend' +# Material Count: 1 + +newmtl Material +Ns 250.000000 +Ka 1.000000 1.000000 1.000000 +Kd 0.800000 0.800000 0.800000 +Ks 0.500000 0.500000 0.500000 +Ke 0.000000 0.000000 0.000000 +Ni 1.450000 +d 1.000000 +illum 2 +map_Kd happy-tree.png diff --git a/code/beginner/tutorial9-models/res/happy-cube.obj b/code/beginner/tutorial9-models/res/happy-cube.obj new file mode 100644 index 000000000..d2f0d816c --- /dev/null +++ b/code/beginner/tutorial9-models/res/happy-cube.obj @@ -0,0 +1,124 @@ +# Blender v3.6.5 OBJ File: 'happy-cube.blend' +# www.blender.org +mtllib happy-cube.mtl +o Cube +v 0.950565 0.950565 -1.000000 +v 0.950565 1.000000 -0.950565 +v 1.000000 0.950565 -0.950565 +v 0.950565 -1.000000 -0.950565 +v 0.950565 -0.950565 -1.000000 +v 1.000000 -0.950565 -0.950565 +v 1.000000 0.950565 0.950565 +v 0.950565 1.000000 0.950565 +v 0.950565 0.950565 1.000000 +v 1.000000 -0.950565 0.950565 +v 0.950565 -0.950565 1.000000 +v 0.950565 -1.000000 0.950565 +v -0.950565 0.950565 -1.000000 +v -1.000000 0.950565 -0.950565 +v -0.950565 1.000000 -0.950565 +v -1.000000 -0.950565 -0.950565 +v -0.950565 -0.950565 -1.000000 +v -0.950565 -1.000000 -0.950565 +v -1.000000 0.950565 0.950565 +v -0.950565 0.950565 1.000000 +v -0.950565 1.000000 0.950565 +v -0.950565 -1.000000 0.950565 +v -0.950565 -0.950565 1.000000 +v -1.000000 -0.950565 0.950565 +vt 0.024718 0.975282 +vt 0.975282 0.975282 +vt 0.975282 0.024718 +vt 0.024718 0.024718 +vt 0.024718 0.024718 +vt 0.024718 0.975282 +vt 0.975282 0.975282 +vt 0.975282 0.024718 +vt 0.975282 0.024718 +vt 0.975282 0.975282 +vt 0.024718 0.975282 +vt 0.024718 0.024718 +vt 0.975282 0.975282 +vt 0.024718 0.975282 +vt 0.024718 0.024718 +vt 0.975282 0.024718 +vt 0.975282 0.024718 +vt 0.975282 0.975282 +vt 0.024718 0.975282 +vt 0.024718 0.024718 +vt 0.975282 1.000000 +vt 1.000000 0.975282 +vt 0.975282 1.000000 +vt 1.000000 0.975282 +vt 1.000000 0.024718 +vt 0.975282 0.000000 +vt 1.000000 0.024718 +vt 0.975282 0.000000 +vt 0.024718 1.000000 +vt 0.000000 0.975282 +vt 0.000000 0.975282 +vt 0.024718 1.000000 +vt 0.000000 0.024718 +vt 0.024718 0.000000 +vt 0.024718 0.000000 +vt 0.000000 0.024718 +vt 1.000000 0.024718 +vt 0.975282 0.024718 +vt 0.975282 0.975282 +vt 0.000000 0.975282 +vt 1.000000 0.975282 +vt 0.024718 0.975282 +vt 0.024718 0.024718 +vt 0.000000 0.024718 +vn -0.3416 -0.8756 -0.3416 +vn 0.3416 -0.8756 -0.3416 +vn 0.3416 -0.8756 0.3416 +vn -0.3416 -0.8756 0.3416 +vn -0.8756 -0.3416 0.3416 +vn -0.8756 0.3416 0.3416 +vn -0.8756 0.3416 -0.3416 +vn -0.8756 -0.3416 -0.3416 +vn 0.3416 -0.3416 0.8756 +vn 0.3416 0.3416 0.8756 +vn -0.3416 0.3416 0.8756 +vn -0.3416 -0.3416 0.8756 +vn 0.3416 0.8756 -0.3416 +vn -0.3416 0.8756 -0.3416 +vn -0.3416 0.8756 0.3416 +vn 0.3416 0.8756 0.3416 +vn 0.8756 -0.3416 -0.3416 +vn 0.8756 0.3416 -0.3416 +vn 0.8756 0.3416 0.3416 +vn 0.8756 -0.3416 0.3416 +vn 0.3416 0.3416 -0.8756 +vn 0.3416 -0.3416 -0.8756 +vn -0.3416 0.3416 -0.8756 +vn -0.3416 -0.3416 -0.8756 +usemtl Material +s 1 +f 18/1/1 4/2/2 12/3/3 22/4/4 +f 24/5/5 19/6/6 14/7/7 16/8/8 +f 11/9/9 9/10/10 20/11/11 23/12/12 +f 2/13/13 15/14/14 21/15/15 8/16/16 +f 6/17/17 3/18/18 7/19/19 10/20/20 +f 1/21/21 2/13/13 3/22/18 +f 4/2/2 5/23/22 6/24/17 +f 7/25/19 8/16/16 9/26/10 +f 10/27/20 11/28/9 12/3/3 +f 13/29/23 14/30/7 15/14/14 +f 16/31/8 17/32/24 18/1/1 +f 19/33/6 20/34/11 21/15/15 +f 22/4/4 23/35/12 24/36/5 +f 18/1/1 22/4/4 24/36/5 16/31/8 +f 4/2/2 18/1/1 17/32/24 5/23/22 +f 3/22/18 6/37/17 5/38/22 1/39/21 +f 23/12/12 20/11/11 19/40/6 24/36/5 +f 9/10/10 11/9/9 10/27/20 7/41/19 +f 13/42/23 17/43/24 16/44/8 14/30/7 +f 8/16/16 21/15/15 20/34/11 9/26/10 +f 2/13/13 8/16/16 7/25/19 3/22/18 +f 22/4/4 12/3/3 11/28/9 23/35/12 +f 21/15/15 15/14/14 14/30/7 19/33/6 +f 15/14/14 2/13/13 1/21/21 13/29/23 +f 12/3/3 4/2/2 6/24/17 10/27/20 +f 17/43/24 13/42/23 1/39/21 5/38/22 diff --git a/code/beginner/tutorial5-textures/src/happy-tree.png b/code/beginner/tutorial9-models/res/happy-tree.png similarity index 100% rename from code/beginner/tutorial5-textures/src/happy-tree.png rename to code/beginner/tutorial9-models/res/happy-tree.png diff --git a/code/beginner/tutorial9-models/src/resources.rs b/code/beginner/tutorial9-models/src/resources.rs index 2b49057cf..fd8738aae 100644 --- a/code/beginner/tutorial9-models/src/resources.rs +++ b/code/beginner/tutorial9-models/src/resources.rs @@ -124,7 +124,7 @@ pub async fn load_model( m.mesh.positions[i * 3 + 1], m.mesh.positions[i * 3 + 2], ], - tex_coords: [m.mesh.texcoords[i * 2], m.mesh.texcoords[i * 2 + 1]], + tex_coords: [m.mesh.texcoords[i * 2], 1.0 - m.mesh.texcoords[i * 2 + 1]], normal: [ m.mesh.normals[i * 3], m.mesh.normals[i * 3 + 1], diff --git a/code/intermediate/tutorial10-lighting/src/resources.rs b/code/intermediate/tutorial10-lighting/src/resources.rs index 2b49057cf..fd8738aae 100644 --- a/code/intermediate/tutorial10-lighting/src/resources.rs +++ b/code/intermediate/tutorial10-lighting/src/resources.rs @@ -124,7 +124,7 @@ pub async fn load_model( m.mesh.positions[i * 3 + 1], m.mesh.positions[i * 3 + 2], ], - tex_coords: [m.mesh.texcoords[i * 2], m.mesh.texcoords[i * 2 + 1]], + tex_coords: [m.mesh.texcoords[i * 2], 1.0 - m.mesh.texcoords[i * 2 + 1]], normal: [ m.mesh.normals[i * 3], m.mesh.normals[i * 3 + 1], diff --git a/code/intermediate/tutorial11-normals/src/resources.rs b/code/intermediate/tutorial11-normals/src/resources.rs index d076fbd56..1183ebcd2 100644 --- a/code/intermediate/tutorial11-normals/src/resources.rs +++ b/code/intermediate/tutorial11-normals/src/resources.rs @@ -114,7 +114,7 @@ pub async fn load_model( m.mesh.positions[i * 3 + 1], m.mesh.positions[i * 3 + 2], ], - tex_coords: [m.mesh.texcoords[i * 2], m.mesh.texcoords[i * 2 + 1]], + tex_coords: [m.mesh.texcoords[i * 2], 1.0 - m.mesh.texcoords[i * 2 + 1]], normal: [ m.mesh.normals[i * 3], m.mesh.normals[i * 3 + 1], diff --git a/code/intermediate/tutorial12-camera/src/resources.rs b/code/intermediate/tutorial12-camera/src/resources.rs index d076fbd56..1183ebcd2 100644 --- a/code/intermediate/tutorial12-camera/src/resources.rs +++ b/code/intermediate/tutorial12-camera/src/resources.rs @@ -114,7 +114,7 @@ pub async fn load_model( m.mesh.positions[i * 3 + 1], m.mesh.positions[i * 3 + 2], ], - tex_coords: [m.mesh.texcoords[i * 2], m.mesh.texcoords[i * 2 + 1]], + tex_coords: [m.mesh.texcoords[i * 2], 1.0 - m.mesh.texcoords[i * 2 + 1]], normal: [ m.mesh.normals[i * 3], m.mesh.normals[i * 3 + 1], diff --git a/code/intermediate/tutorial13-hdr/src/resources.rs b/code/intermediate/tutorial13-hdr/src/resources.rs index dc30f5386..954120a93 100644 --- a/code/intermediate/tutorial13-hdr/src/resources.rs +++ b/code/intermediate/tutorial13-hdr/src/resources.rs @@ -115,7 +115,7 @@ pub async fn load_model( m.mesh.positions[i * 3 + 1], m.mesh.positions[i * 3 + 2], ], - tex_coords: [m.mesh.texcoords[i * 2], m.mesh.texcoords[i * 2 + 1]], + tex_coords: [m.mesh.texcoords[i * 2], 1.0 - m.mesh.texcoords[i * 2 + 1]], normal: [ m.mesh.normals[i * 3], m.mesh.normals[i * 3 + 1], diff --git a/code/intermediate/wip-terrain/src/resources.rs b/code/intermediate/wip-terrain/src/resources.rs index de2eaaea7..e8ba9647a 100644 --- a/code/intermediate/wip-terrain/src/resources.rs +++ b/code/intermediate/wip-terrain/src/resources.rs @@ -130,7 +130,7 @@ pub async fn load_model( m.mesh.positions[i * 3 + 1], m.mesh.positions[i * 3 + 2], ], - tex_coords: [m.mesh.texcoords[i * 2], m.mesh.texcoords[i * 2 + 1]], + tex_coords: [m.mesh.texcoords[i * 2], 1.0 - m.mesh.texcoords[i * 2 + 1]], normal: [ m.mesh.normals[i * 3], m.mesh.normals[i * 3 + 1], diff --git a/code/showcase/compute/src/model.rs b/code/showcase/compute/src/model.rs index b66c43fc8..4d51142b1 100644 --- a/code/showcase/compute/src/model.rs +++ b/code/showcase/compute/src/model.rs @@ -298,7 +298,7 @@ impl ModelLoader { m.mesh.positions[i * 3 + 2], ], // tex_coords: [m.mesh.texcoords[i * 2], m.mesh.texcoords[i * 2 + 1], 0.0] - tex_coords: [m.mesh.texcoords[i * 2], m.mesh.texcoords[i * 2 + 1]], + tex_coords: [m.mesh.texcoords[i * 2], 1.0 - m.mesh.texcoords[i * 2 + 1]], normal: [ m.mesh.normals[i * 3], m.mesh.normals[i * 3 + 1], diff --git a/code/showcase/mouse-picking/src/resources.rs b/code/showcase/mouse-picking/src/resources.rs index 511cc3e93..2e437711b 100644 --- a/code/showcase/mouse-picking/src/resources.rs +++ b/code/showcase/mouse-picking/src/resources.rs @@ -140,7 +140,7 @@ pub async fn load_model( ); model::ModelVertex { position: p.into(), // UPDATED! - tex_coords: [m.mesh.texcoords[i * 2], m.mesh.texcoords[i * 2 + 1]], + tex_coords: [m.mesh.texcoords[i * 2], 1.0 - m.mesh.texcoords[i * 2 + 1]], normal: [ m.mesh.normals[i * 3], m.mesh.normals[i * 3 + 1], diff --git a/code/showcase/threading/src/resources.rs b/code/showcase/threading/src/resources.rs index 505320f25..546932457 100644 --- a/code/showcase/threading/src/resources.rs +++ b/code/showcase/threading/src/resources.rs @@ -114,7 +114,7 @@ pub async fn load_model( m.mesh.positions[i * 3 + 1], m.mesh.positions[i * 3 + 2], ], - tex_coords: [m.mesh.texcoords[i * 2], m.mesh.texcoords[i * 2 + 1]], + tex_coords: [m.mesh.texcoords[i * 2], 1.0 - m.mesh.texcoords[i * 2 + 1]], normal: [ m.mesh.normals[i * 3], m.mesh.normals[i * 3 + 1], diff --git a/docs/beginner/tutorial9-models/README.md b/docs/beginner/tutorial9-models/README.md index 210353be2..f12566329 100644 --- a/docs/beginner/tutorial9-models/README.md +++ b/docs/beginner/tutorial9-models/README.md @@ -348,7 +348,7 @@ pub async fn load_model( m.mesh.positions[i * 3 + 1], m.mesh.positions[i * 3 + 2], ], - tex_coords: [m.mesh.texcoords[i * 2], m.mesh.texcoords[i * 2 + 1]], + tex_coords: [m.mesh.texcoords[i * 2], 1.0 - m.mesh.texcoords[i * 2 + 1]], normal: [ m.mesh.normals[i * 3], m.mesh.normals[i * 3 + 1], diff --git a/docs/intermediate/tutorial11-normals/README.md b/docs/intermediate/tutorial11-normals/README.md index a674e6119..8d42d5d17 100644 --- a/docs/intermediate/tutorial11-normals/README.md +++ b/docs/intermediate/tutorial11-normals/README.md @@ -245,7 +245,7 @@ let meshes = models m.mesh.positions[i * 3 + 1], m.mesh.positions[i * 3 + 2], ], - tex_coords: [m.mesh.texcoords[i * 2], m.mesh.texcoords[i * 2 + 1]], + tex_coords: [m.mesh.texcoords[i * 2], 1.0 - m.mesh.texcoords[i * 2 + 1]], normal: [ m.mesh.normals[i * 3], m.mesh.normals[i * 3 + 1],