diff options
-rw-r--r-- | engine/src/file_format/wavefront/mtl.rs | 20 | ||||
-rw-r--r-- | src/main.rs | 11 |
2 files changed, 26 insertions, 5 deletions
diff --git a/engine/src/file_format/wavefront/mtl.rs b/engine/src/file_format/wavefront/mtl.rs index 7d1c570..f3c7a64 100644 --- a/engine/src/file_format/wavefront/mtl.rs +++ b/engine/src/file_format/wavefront/mtl.rs @@ -234,6 +234,24 @@ fn statements_to_materials( path: Path::new(texture_file_path).to_path_buf(), }); } + Keyword::Ns => { + if statement.arguments.len() != 1 { + return Err(Error::UnsupportedArgumentCount { + keyword: statement.keyword.to_string(), + arg_count: statement.arguments.len(), + line_no, + }); + } + + let shininess = statement.get_float_arg(0, line_no)?; + + tracing::debug!( + "Adding shininess {shininess} to material {}", + curr_material.name + ); + + curr_material.shininess = shininess; + } Keyword::Newmtl => {} } } @@ -279,5 +297,7 @@ keyword! { #[keyword(rename = "map_Ks")] MapKs, + + Ns, } } diff --git a/src/main.rs b/src/main.rs index 438b2bf..c1ea1cd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,7 +23,7 @@ use engine::mesh::cube::{ }; use engine::renderer::opengl::Extension as OpenglRendererExtension; use engine::texture::Texture; -use engine::transform::Position; +use engine::transform::WorldPosition; use engine::vector::Vec3; use engine::window::{ Builder as WindowBuilder, @@ -78,7 +78,8 @@ fn main() -> Result<(), Box<dyn Error>> let mut teapot_mat_builder = Material::builder() .ambient(teapot_named_mat.ambient) .diffuse(teapot_named_mat.diffuse) - .specular(teapot_named_mat.specular); + .specular(teapot_named_mat.specular) + .shininess(teapot_named_mat.shininess); if let Some(ambient_map) = teapot_named_mat.ambient_map { let texture = Texture::open(&ambient_map.path).unwrap(); @@ -107,7 +108,7 @@ fn main() -> Result<(), Box<dyn Error>> engine.spawn(( teapot_obj.to_mesh()?, teapot_mat_builder.build(), - Position::from(Vec3 { x: 1.6, y: 0.0, z: 0.0 }), + WorldPosition::from(Vec3 { x: 1.6, y: 0.0, z: 0.0 }), )); engine.spawn(( @@ -119,7 +120,7 @@ fn main() -> Result<(), Box<dyn Error>> ..Default::default() }) .build(), - Position::from(Vec3 { x: -6.0, y: 3.0, z: 3.0 }), + WorldPosition::from(Vec3 { x: -6.0, y: 3.0, z: 3.0 }), cube_mesh_create( CubeMeshCreationSpec::builder() .width(2.0) @@ -134,7 +135,7 @@ fn main() -> Result<(), Box<dyn Error>> engine.spawn(( Camera::default(), - Position { + WorldPosition { position: Vec3 { x: 0.0, y: 0.0, z: 3.0 }, }, ActiveCamera, |