aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Spear/Math/Matrix4.hs11
-rw-r--r--Spear/Math/Spatial3.hs2
-rw-r--r--Spear/Math/Vector3.hs18
-rw-r--r--Spear/Scene/Loader.hs4
4 files changed, 14 insertions, 21 deletions
diff --git a/Spear/Math/Matrix4.hs b/Spear/Math/Matrix4.hs
index 82dc9d5..45a8171 100644
--- a/Spear/Math/Matrix4.hs
+++ b/Spear/Math/Matrix4.hs
@@ -201,7 +201,7 @@ lookAt :: Vector3 -- ^ Eye position.
201 201
202lookAt pos target = 202lookAt pos target =
203 let fwd = Vector3.normalise $ target - pos 203 let fwd = Vector3.normalise $ target - pos
204 r = fwd `cross` Vector3.unitY 204 r = fwd `cross` Vector3.unity
205 u = r `cross` fwd 205 u = r `cross` fwd
206 in 206 in
207 transform r u (-fwd) pos 207 transform r u (-fwd) pos
@@ -422,14 +422,7 @@ inverseTransform mat = mat4fromVec u v w p where
422 tdotu = t `Vector4.dot` col0 mat 422 tdotu = t `Vector4.dot` col0 mat
423 tdotv = t `Vector4.dot` col1 mat 423 tdotv = t `Vector4.dot` col1 mat
424 tdotw = t `Vector4.dot` col2 mat 424 tdotw = t `Vector4.dot` col2 mat
425 425
426
427-- | Invert the given matrix.
428{-inverse :: Matrix4 -> Matrix4
429inverse mat = mat4 i0 i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15
430 where
431 i0 = -}
432
433 426
434-- | Transform the given vector in 3D space with the given matrix. 427-- | Transform the given vector in 3D space with the given matrix.
435mul :: Float -> Matrix4 -> Vector3 -> Vector3 428mul :: Float -> Matrix4 -> Vector3 -> Vector3
diff --git a/Spear/Math/Spatial3.hs b/Spear/Math/Spatial3.hs
index 9f9812f..0ee680f 100644
--- a/Spear/Math/Spatial3.hs
+++ b/Spear/Math/Spatial3.hs
@@ -57,7 +57,7 @@ class Spatial3 s where
57 lookAt pt s = 57 lookAt pt s =
58 let position = pos s 58 let position = pos s
59 fwd = normalise $ pt - position 59 fwd = normalise $ pt - position
60 r = fwd `cross` unitY 60 r = fwd `cross` unity
61 u = r `cross` fwd 61 u = r `cross` fwd
62 in 62 in
63 setTransform (M.transform r u (-fwd) position) s 63 setTransform (M.transform r u (-fwd) position) s
diff --git a/Spear/Math/Vector3.hs b/Spear/Math/Vector3.hs
index 0d559c3..79cdcdd 100644
--- a/Spear/Math/Vector3.hs
+++ b/Spear/Math/Vector3.hs
@@ -6,9 +6,9 @@ module Spear.Math.Vector3
6, y 6, y
7, z 7, z
8 -- * Construction 8 -- * Construction
9, unitX 9, unitx
10, unitY 10, unity
11, unitZ 11, unitz
12, zero 12, zero
13, fromList 13, fromList
14, vec3 14, vec3
@@ -99,18 +99,18 @@ z (Vector3 _ _ az) = az
99 99
100 100
101-- | Unit vector along the X axis. 101-- | Unit vector along the X axis.
102unitX :: Vector3 102unitx :: Vector3
103unitX = Vector3 1 0 0 103unitx = Vector3 1 0 0
104 104
105 105
106-- | Unit vector along the Y axis. 106-- | Unit vector along the Y axis.
107unitY :: Vector3 107unity :: Vector3
108unitY = Vector3 0 1 0 108unity = Vector3 0 1 0
109 109
110 110
111-- | Unit vector along the Z axis. 111-- | Unit vector along the Z axis.
112unitZ :: Vector3 112unitz :: Vector3
113unitZ = Vector3 0 0 1 113unitz = Vector3 0 0 1
114 114
115 115
116-- | Zero vector. 116-- | Zero vector.
diff --git a/Spear/Scene/Loader.hs b/Spear/Scene/Loader.hs
index 64e81f1..c34d2e6 100644
--- a/Spear/Scene/Loader.hs
+++ b/Spear/Scene/Loader.hs
@@ -351,9 +351,9 @@ newObject' newGO sceneRes nid props = do
351 351
352vectors :: Maybe Vector3 -> (Vector3, Vector3, Vector3) 352vectors :: Maybe Vector3 -> (Vector3, Vector3, Vector3)
353vectors forward = case forward of 353vectors forward = case forward of
354 Nothing -> (V3.unitX, V3.unitY, V3.unitZ) 354 Nothing -> (V3.unitx, V3.unity, V3.unitz)
355 Just f -> 355 Just f ->
356 let r = f `cross` V3.unitY 356 let r = f `cross` V3.unity
357 u = r `cross` f 357 u = r `cross` f
358 in 358 in
359 (r, u, f) 359 (r, u, f)