From ad4d6c690cdbc3c034fcac83e2c6b569ff615bda Mon Sep 17 00:00:00 2001 From: Marc Sunet Date: Sun, 2 Sep 2012 15:38:05 +0200 Subject: Fixed Y-Z axis correspondence; change rpgTransform to take a position --- Spear.lkshw | 2 +- Spear/Math/MatrixUtils.hs | 10 +++++----- Spear/Scene/GameObject.hs | 4 ++-- 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 @@ Version of workspace file format: 1 Time of storage: - "Sun Sep 2 11:28:18 CEST 2012" + "Sun Sep 2 15:36:42 CEST 2012" Name of the workspace: "Spear" File 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 :: Float -- ^ The height above the ground -> Float -- ^ Angle of rotation -> Vector3 -- ^ Axis of rotation - -> Matrix3 + -> Vector2 -- ^ Object's position. -> Matrix4 -rpgTransform h a axis mat = +rpgTransform h a axis pos = {-let r = let r' = M3.right mat in vec3 (V2.x r') (V2.y r') 0 u = V3.unity f = let f' = M3.forward mat in vec3 (V2.x f') 0 (V2.y f') @@ -43,7 +43,7 @@ rpgTransform h a axis mat = r = M4.right mat' u = M4.up mat' f = M4.forward mat' - t = vec3 0 h 0 + let t' = M3.position mat in vec3 (V2.x t') 0 (V2.y t') + t = vec3 0 h 0 + vec3 (V2.x pos) 0 (-V2.y pos) in mat4 (V3.x r) (V3.x u) (V3.x f) (V3.x t) (V3.y r) (V3.y u) (V3.y f) (V3.y t) @@ -76,9 +76,9 @@ rpgInverse :: Float -- ^ The height above the ground -> Float -- ^ Angle of rotation -> Vector3 -- ^ Axis of rotation - -> Matrix3 + -> Vector2 -> Matrix4 -rpgInverse h a rot = M4.inverseTransform . rpgTransform h a rot +rpgInverse h a rot pos = M4.inverseTransform $ rpgTransform h a rot pos -- | 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 -- | Get the game object's 3D transform. go3Dtransform :: GameObject -> M4.Matrix4 -go3Dtransform go = rpgTransform 0 (angle go) (axis go) . S2.transform $ go +go3Dtransform go = rpgTransform 0 (angle go) (axis go) (S2.pos go) -- | Get the game object's current animation. @@ -251,7 +251,7 @@ goRender' :: (ProgramUniforms u, Program p) goRender' style a axis prog uniforms model cam bindRenderer render = let view = M4.inverseTransform $ Cam.transform cam modelview = case style of - RPG -> view * rpgTransform 0 a axis model + RPG -> view * rpgTransform 0 a axis (M3.position model) PLT -> view * pltTransform model normalmat = fastNormalMatrix modelview in do -- cgit v1.2.3