summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2025-01-17 19:20:22 +0100
committerHampusM <hampus@hampusmat.com>2025-01-17 19:20:22 +0100
commite69f05739e56d62361e5bb0dcc4db17289b0c2df (patch)
tree29c5b8a1beaebd79440e678268937fb40c7b7584
parent6fc7c0b2bf5547159b1d45c2ef9016df1f565dd8 (diff)
chore: replace cube obj with generated cube mesh
-rw-r--r--res/cube.obj43
-rw-r--r--src/main.rs14
2 files changed, 12 insertions, 45 deletions
diff --git a/res/cube.obj b/res/cube.obj
deleted file mode 100644
index 59c3fd8..0000000
--- a/res/cube.obj
+++ /dev/null
@@ -1,43 +0,0 @@
-o Cube
-v 1.000000 1.000000 -1.000000
-v 1.000000 -1.000000 -1.000000
-v 1.000000 1.000000 1.000000
-v 1.000000 -1.000000 1.000000
-v -1.000000 1.000000 -1.000000
-v -1.000000 -1.000000 -1.000000
-v -1.000000 1.000000 1.000000
-v -1.000000 -1.000000 1.000000
-vn -0.0000 1.0000 -0.0000
-vn -0.0000 -0.0000 1.0000
-vn -1.0000 -0.0000 -0.0000
-vn -0.0000 -1.0000 -0.0000
-vn 1.0000 -0.0000 -0.0000
-vn -0.0000 -0.0000 -1.0000
-vt 0.875000 0.500000
-vt 0.625000 0.750000
-vt 0.625000 0.500000
-vt 0.375000 1.000000
-vt 0.375000 0.750000
-vt 0.625000 0.000000
-vt 0.375000 0.250000
-vt 0.375000 0.000000
-vt 0.375000 0.500000
-vt 0.125000 0.750000
-vt 0.125000 0.500000
-vt 0.625000 0.250000
-vt 0.875000 0.750000
-vt 0.625000 1.000000
-s 0
-f 5//1 3//1 1//1
-f 5/1/1 3/2/1 1/3/1
-f 3/2/2 8/4/2 4/5/2
-f 7/6/3 6/7/3 8/8/3
-f 2/9/4 8/10/4 6/11/4
-f 1/3/5 4/5/5 2/9/5
-f 5/12/6 2/9/6 6/7/6
-f 5/1/1 7/13/1 3/2/1
-f 3/2/2 7/14/2 8/4/2
-f 7/6/3 5/12/3 6/7/3
-f 2/9/4 4/5/4 8/10/4
-f 1/3/5 3/2/5 4/5/5
-f 5/12/6 1/3/6 2/9/6
diff --git a/src/main.rs b/src/main.rs
index a982dbb..3055e28 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -17,6 +17,10 @@ use engine::file_format::wavefront::obj::parse as parse_obj;
use engine::input::Extension as InputExtension;
use engine::lighting::{AttenuationParams, GlobalLight, PointLight};
use engine::material::{Builder as MaterialBuilder, Flags as MaterialFlags};
+use engine::mesh::cube::{
+ create as cube_mesh_create,
+ CreationSpec as CubeMeshCreationSpec,
+};
use engine::renderer::opengl::Extension as OpenglRendererExtension;
use engine::transform::Position;
use engine::vector::Vec3;
@@ -82,8 +86,14 @@ fn main() -> Result<(), Box<dyn Error>>
})
.build(),
Position::from(Vec3 { x: -6.0, y: 3.0, z: 3.0 }),
- parse_obj(&read_to_string(Path::new(RESOURCE_DIR).join("cube.obj"))?)?
- .to_mesh()?,
+ cube_mesh_create(
+ CubeMeshCreationSpec::builder()
+ .width(2.0)
+ .height(2.0)
+ .depth(2.0)
+ .build(),
+ |face_verts, _, _| face_verts,
+ ),
MaterialBuilder::new().ambient(YELLOW * 5.0).build(),
MaterialFlags::builder().use_ambient_color(true).build(),
));