aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Sunet <jeannekamikaze@gmail.com>2012-09-02 15:38:05 +0200
committerMarc Sunet <jeannekamikaze@gmail.com>2012-09-02 15:38:05 +0200
commitad4d6c690cdbc3c034fcac83e2c6b569ff615bda (patch)
treee9dc184dfd1ff4fd18a6f56dba2072f4f2df4fb6
parentff420d5b1380453e9be810b0693373146a7781b8 (diff)
Fixed Y-Z axis correspondence; change rpgTransform to take a position
-rw-r--r--Spear.lkshw2
-rw-r--r--Spear/Math/MatrixUtils.hs10
-rw-r--r--Spear/Scene/GameObject.hs4
3 files changed, 8 insertions, 8 deletions
diff --git a/Spear.lkshw b/Spear.lkshw
index c0d466b..a54198c 100644
--- a/Spear.lkshw
+++ b/Spear.lkshw
@@ -1,7 +1,7 @@
1Version of workspace file format: 1Version of workspace file format:
2 1 2 1
3Time of storage: 3Time of storage:
4 "Sun Sep 2 11:28:18 CEST 2012" 4 "Sun Sep 2 15:36:42 CEST 2012"
5Name of the workspace: 5Name of the workspace:
6 "Spear" 6 "Spear"
7File paths of contained packages: 7File paths of contained packages:
diff --git a/Spear/Math/MatrixUtils.hs b/Spear/Math/MatrixUtils.hs
index 7502234..44af2c0 100644
--- a/Spear/Math/MatrixUtils.hs
+++ b/Spear/Math/MatrixUtils.hs
@@ -32,9 +32,9 @@ rpgTransform
32 :: Float -- ^ The height above the ground 32 :: Float -- ^ The height above the ground
33 -> Float -- ^ Angle of rotation 33 -> Float -- ^ Angle of rotation
34 -> Vector3 -- ^ Axis of rotation 34 -> Vector3 -- ^ Axis of rotation
35 -> Matrix3 35 -> Vector2 -- ^ Object's position.
36 -> Matrix4 36 -> Matrix4
37rpgTransform h a axis mat = 37rpgTransform h a axis pos =
38 {-let r = let r' = M3.right mat in vec3 (V2.x r') (V2.y r') 0 38 {-let r = let r' = M3.right mat in vec3 (V2.x r') (V2.y r') 0
39 u = V3.unity 39 u = V3.unity
40 f = let f' = M3.forward mat in vec3 (V2.x f') 0 (V2.y f') 40 f = let f' = M3.forward mat in vec3 (V2.x f') 0 (V2.y f')
@@ -43,7 +43,7 @@ rpgTransform h a axis mat =
43 r = M4.right mat' 43 r = M4.right mat'
44 u = M4.up mat' 44 u = M4.up mat'
45 f = M4.forward mat' 45 f = M4.forward mat'
46 t = vec3 0 h 0 + let t' = M3.position mat in vec3 (V2.x t') 0 (V2.y t') 46 t = vec3 0 h 0 + vec3 (V2.x pos) 0 (-V2.y pos)
47 in mat4 47 in mat4
48 (V3.x r) (V3.x u) (V3.x f) (V3.x t) 48 (V3.x r) (V3.x u) (V3.x f) (V3.x t)
49 (V3.y r) (V3.y u) (V3.y f) (V3.y t) 49 (V3.y r) (V3.y u) (V3.y f) (V3.y t)
@@ -76,9 +76,9 @@ rpgInverse
76 :: Float -- ^ The height above the ground 76 :: Float -- ^ The height above the ground
77 -> Float -- ^ Angle of rotation 77 -> Float -- ^ Angle of rotation
78 -> Vector3 -- ^ Axis of rotation 78 -> Vector3 -- ^ Axis of rotation
79 -> Matrix3 79 -> Vector2
80 -> Matrix4 80 -> Matrix4
81rpgInverse h a rot = M4.inverseTransform . rpgTransform h a rot 81rpgInverse h a rot pos = M4.inverseTransform $ rpgTransform h a rot pos
82 82
83 83
84-- | Compute the inverse transform of the given transformation matrix. 84-- | Compute the inverse transform of the given transformation matrix.
diff --git a/Spear/Scene/GameObject.hs b/Spear/Scene/GameObject.hs
index b892b7d..fc35c2b 100644
--- a/Spear/Scene/GameObject.hs
+++ b/Spear/Scene/GameObject.hs
@@ -177,7 +177,7 @@ goAABBs = fmap getAABB . collisioners
177 177
178-- | Get the game object's 3D transform. 178-- | Get the game object's 3D transform.
179go3Dtransform :: GameObject -> M4.Matrix4 179go3Dtransform :: GameObject -> M4.Matrix4
180go3Dtransform go = rpgTransform 0 (angle go) (axis go) . S2.transform $ go 180go3Dtransform go = rpgTransform 0 (angle go) (axis go) (S2.pos go)
181 181
182 182
183-- | Get the game object's current animation. 183-- | Get the game object's current animation.
@@ -251,7 +251,7 @@ goRender' :: (ProgramUniforms u, Program p)
251goRender' style a axis prog uniforms model cam bindRenderer render = 251goRender' style a axis prog uniforms model cam bindRenderer render =
252 let view = M4.inverseTransform $ Cam.transform cam 252 let view = M4.inverseTransform $ Cam.transform cam
253 modelview = case style of 253 modelview = case style of
254 RPG -> view * rpgTransform 0 a axis model 254 RPG -> view * rpgTransform 0 a axis (M3.position model)
255 PLT -> view * pltTransform model 255 PLT -> view * pltTransform model
256 normalmat = fastNormalMatrix modelview 256 normalmat = fastNormalMatrix modelview
257 in do 257 in do