diff options
Diffstat (limited to 'engine/src/lighting.rs')
-rw-r--r-- | engine/src/lighting.rs | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/engine/src/lighting.rs b/engine/src/lighting.rs new file mode 100644 index 0000000..e7fb901 --- /dev/null +++ b/engine/src/lighting.rs @@ -0,0 +1,93 @@ +use crate::color::Color; +use crate::vector::Vec3; + +#[derive(Debug, Clone)] +pub struct LightSettings +{ + pub ambient_light_strength: f32, + pub specular_light_strength: f32, + pub specular_shininess: u32, +} + +impl Default for LightSettings +{ + fn default() -> Self + { + Self { + ambient_light_strength: 1.0, + specular_light_strength: 0.0, + specular_shininess: 32, + } + } +} + +#[derive(Debug, Clone)] +pub struct LightSource +{ + position: Vec3<f32>, + color: Color<f32>, +} + +impl LightSource +{ + #[must_use] + pub fn position(&self) -> &Vec3<f32> + { + &self.position + } + + #[must_use] + pub fn color(&self) -> &Color<f32> + { + &self.color + } + + pub fn translate(&mut self, translation: Vec3<f32>) + { + self.position += translation; + } +} + +#[derive(Debug, Clone, Default)] +pub struct LightSourceBuilder +{ + position: Vec3<f32>, + color: Color<f32>, +} + +impl LightSourceBuilder +{ + #[must_use] + pub fn new() -> Self + { + Self { + position: Vec3::default(), + color: Color::WHITE_F32, + } + } + + #[must_use] + pub fn position(mut self, position: Vec3<f32>) -> Self + { + self.position = position; + + self + } + + #[must_use] + pub fn color(mut self, color: Color<f32>) -> Self + { + self.color = color; + + self + } + + #[must_use] + pub fn build(&self) -> LightSource + { + LightSource { + position: self.position.clone(), + color: self.color.clone(), + } + } +} |