1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use color::RGB;
use linear::V3;
use std::default::Default;

#[derive(Clone, Copy, Debug, PartialEq)]
pub struct LightProp {
  pub diff: RGB,
  _pad_0: f32,
  pub spec: RGB,
  pub gloss: f32,
}

impl LightProp {
  pub fn new(diff: RGB, spec: RGB, gloss: f32) -> Self {
    LightProp {
      diff: diff,
      _pad_0: 0.,
      spec: spec,
      gloss: gloss,
    }
  }
}

impl Default for LightProp {
  fn default() -> Self {
    LightProp::new(
      RGB::new(0.6, 0.6, 0.7),
      RGB::new(0.6, 0.6, 0.7),
      10.
    )
  }
}

#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Light<L> {
  pub prop: LightProp,
  pub feature: L
}

impl<L> Light<L> {
  pub fn new(prop: LightProp, feature: L) -> Self {
    Light {
      prop: prop,
      feature: feature 
    }
  }
}

#[derive(Clone, Copy, Debug, PartialEq)]
pub struct LightDir {
  dir: V3<f32>,
  _pad: f32
}

impl From<V3<f32>> for LightDir {
  fn from(dir: V3<f32>) -> Self {
    LightDir {
      dir: dir,
      _pad: 0.
    }
  }
}

#[derive(Clone, Copy, Debug, PartialEq)]
pub struct LightPos {
  pos: V3<f32>,
  _pad: f32
}

impl From<V3<f32>> for LightPos {
  fn from(pos: V3<f32>) -> Self {
    LightPos {
      pos: pos,
      _pad: 0.
    }
  }
}

pub type Dir = Light<LightDir>;
pub type Omni = Light<LightPos>;