Remove unnecessary uniforms

This commit is contained in:
jgk
2021-06-10 18:07:26 +02:00
parent 95f8e57e45
commit 02511afa80
10 changed files with 69 additions and 93 deletions
+28 -5
View File
@@ -1,5 +1,6 @@
module MatrixHelper
( perspectiveMatrix
, isoMatrix
) where
import Geometry
@@ -25,11 +26,6 @@ perspectiveMatrix rot zoom (tranx,trany) (winx,winy) (viewFromx,viewFromy) =
(V4 (sin rot) (cos rot) 0 0)
(V4 0 0 1 0)
(V4 0 0 0 1)
--tranMat3 = Linear.Matrix.transpose $
-- V4 (V4 1 0 0 0)
-- (V4 0 1 0 0)
-- (V4 0 0 1 0)
-- (V4 (-tranx) (-trany) 0 1)
tranMat2 = Linear.Matrix.transpose $
V4 (V4 1 0 0 0)
(V4 0 1 0 0)
@@ -48,3 +44,30 @@ perspectiveMatrix rot zoom (tranx,trany) (winx,winy) (viewFromx,viewFromy) =
wmat = scalMat !*! rotMat !*! tranMat2 !*! perMat !*! tranMat1
vToL (V4 a b c d) = [a,b,c,d]
in concatMap vToL $ vToL wmat
{- | A matrix that gives a top down view with no perspective. -}
isoMatrix
:: Float -- ^ Rotation
-> Float -- ^ Zoom
-> Point2 -- ^ Translation
-> Point2 -- ^ Window size
-> Point2 -- ^ View froms
-> [GLfloat]
isoMatrix rot czoom (tranx,trany) (winx,winy) _ =
let scalMat = Linear.Matrix.transpose $
V4 (V4 (2*czoom/winx) 0 0 (0::GLfloat))
(V4 0 (2*czoom/winy) 0 0)
(V4 0 0 1 0)
(V4 0 0 0 1)
rotMat = Linear.Matrix.transpose $
V4 (V4 (cos rot) (sin (-rot)) 0 0)
(V4 (sin rot) (cos rot) 0 0)
(V4 0 0 1 0)
(V4 0 0 0 1)
tranMat = Linear.Matrix.transpose $
V4 (V4 1 0 0 0)
(V4 0 1 0 0)
(V4 0 0 1 0)
(V4 (-tranx) (-trany) 0 1)
wmat = scalMat !*! rotMat !*! tranMat
vToL (V4 a b c d) = [a,b,c,d]
in concatMap vToL $ vToL wmat