diff options
Diffstat (limited to 'engine/src/material.rs')
-rw-r--r-- | engine/src/material.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/engine/src/material.rs b/engine/src/material.rs index c292af4..6839fd1 100644 --- a/engine/src/material.rs +++ b/engine/src/material.rs @@ -1,7 +1,7 @@ use ecs::Component; use crate::color::Color; -use crate::texture::Id as TextureId; +use crate::texture::{Id as TextureId, Texture}; #[derive(Debug, Clone, Component)] pub struct Material @@ -12,6 +12,7 @@ pub struct Material ambient_map: TextureId, diffuse_map: TextureId, specular_map: TextureId, + textures: Vec<Texture>, shininess: f32, } @@ -54,6 +55,12 @@ impl Material } #[must_use] + pub fn textures(&self) -> &[Texture] + { + &self.textures + } + + #[must_use] pub fn shininess(&self) -> f32 { self.shininess @@ -70,6 +77,7 @@ pub struct Builder ambient_map: Option<TextureId>, diffuse_map: Option<TextureId>, specular_map: Option<TextureId>, + textures: Vec<Texture>, shininess: f32, } @@ -85,6 +93,7 @@ impl Builder ambient_map: None, diffuse_map: None, specular_map: None, + textures: Vec::new(), shininess: 32.0, } } @@ -138,6 +147,14 @@ impl Builder } #[must_use] + pub fn textures(mut self, textures: impl IntoIterator<Item = Texture>) -> Self + { + self.textures = textures.into_iter().collect(); + + self + } + + #[must_use] pub fn shininess(mut self, shininess: f32) -> Self { self.shininess = shininess; @@ -150,7 +167,7 @@ impl Builder /// # Panics /// Will panic if no ambient map, diffuse map or specular map is set. #[must_use] - pub fn build(&self) -> Material + pub fn build(self) -> Material { Material { ambient: self.ambient.clone(), @@ -159,6 +176,7 @@ impl Builder ambient_map: self.ambient_map.unwrap(), diffuse_map: self.diffuse_map.unwrap(), specular_map: self.specular_map.unwrap(), + textures: self.textures, shininess: self.shininess, } } |