aboutsummaryrefslogtreecommitdiff
path: root/Spear/Scene/Light.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Spear/Scene/Light.hs')
-rw-r--r--Spear/Scene/Light.hs55
1 files changed, 0 insertions, 55 deletions
diff --git a/Spear/Scene/Light.hs b/Spear/Scene/Light.hs
index 5f43b19..f63b91d 100644
--- a/Spear/Scene/Light.hs
+++ b/Spear/Scene/Light.hs
@@ -29,58 +29,3 @@ data Light
29 , specular :: Vector3 29 , specular :: Vector3
30 , transform :: M.Matrix4 30 , transform :: M.Matrix4
31 } 31 }
32
33
34instance S.Spatial3 Light where
35 move _ l@DirectionalLight {} = l
36 move v l = l { transform = M.translv v * transform l}
37
38 moveFwd _ l@DirectionalLight {} = l
39 moveFwd f l = l { transform = M.translv (scale f $ S.fwd l) * transform l }
40
41 moveBack _ l@DirectionalLight {} = l
42 moveBack f l = l { transform = M.translv (scale (-f) $ S.fwd l) * transform l }
43
44 strafeLeft _ l@DirectionalLight {} = l
45 strafeLeft f l = l { transform = M.translv (scale (-f) $ S.right l) * transform l }
46
47 strafeRight _ l@DirectionalLight {} = l
48 strafeRight f l = l { transform = M.translv (scale f $ S.right l) * transform l }
49
50 pitch _ l@DirectionalLight {} = l
51 pitch a l = l { transform = transform l * M.axisAngle (S.right l) a }
52
53 yaw _ l@DirectionalLight {} = l
54 yaw a l = l { transform = transform l * M.axisAngle (S.up l) a }
55
56 roll _ l@DirectionalLight {} = l
57 roll a l = l { transform = transform l * M.axisAngle (S.fwd l) a }
58
59 pos l@DirectionalLight {} = vec3 0 0 0
60 pos l = M.position . transform $ l
61
62 fwd (DirectionalLight _ _ _ f) = f
63 fwd l = M.forward . transform $ l
64
65 up l@DirectionalLight {} = vec3 0 1 0
66 up l = M.up . transform $ l
67
68 right l@DirectionalLight {} = vec3 1 0 0
69 right l = M.right . transform $ l
70
71 transform (PointLight _ _ _ transf) = transf
72 transform (DirectionalLight _ _ _ fwd) =
73 let up' = vec3 0 1 0
74 right = up `cross` fwd
75 up = fwd `cross` right
76 in
77 M.transform up right fwd (vec3 0 0 0)
78 transform (SpotLight _ _ _ transf) = transf
79
80 setTransform _ l@DirectionalLight {} = l
81 setTransform t l = l { Spear.Scene.Light.transform = t }
82
83 setPos _ l@DirectionalLight {} = l
84 setPos pos l =
85 let t = Spear.Scene.Light.transform l
86 in l { transform = M.transform (M.right t) (M.up t) (M.forward t) pos }