diff options
author | Joe Crayne <joe@jerkface.net> | 2019-04-22 05:05:31 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-04-22 05:05:31 -0400 |
commit | 158564b28f4316b4c140457d543ec4d65391a043 (patch) | |
tree | 7889891c8112bfa05af8bd94d6d8de053f617456 /Matrix.hs | |
parent | a5be1222b3522dd9e58a10dfb4d3210970faab02 (diff) |
Pass entire model-view-projection matrix from haskell.
Diffstat (limited to 'Matrix.hs')
-rw-r--r-- | Matrix.hs | 13 |
1 files changed, 4 insertions, 9 deletions
@@ -54,11 +54,6 @@ lookat pos target up = fromRows | |||
54 | {-# SPECIALIZE lookat :: Vector R -> Vector R -> Vector R -> Matrix R #-} | 54 | {-# SPECIALIZE lookat :: Vector R -> Vector R -> Vector R -> Matrix R #-} |
55 | 55 | ||
56 | 56 | ||
57 | |||
58 | -- lookat pos target up <> rot t | ||
59 | -- == lookat ((((pos - target) <# rot (-t))) + target) | ||
60 | -- target | ||
61 | -- | ||
62 | -- | Perspective transformation 4×4 matrix. | 57 | -- | Perspective transformation 4×4 matrix. |
63 | perspective :: (Storable a, Floating a) => | 58 | perspective :: (Storable a, Floating a) => |
64 | a -- ^ Near plane clipping distance (always positive). | 59 | a -- ^ Near plane clipping distance (always positive). |
@@ -67,10 +62,10 @@ perspective :: (Storable a, Floating a) => | |||
67 | -> a -- ^ Aspect ratio, i.e. screen's width\/height. | 62 | -> a -- ^ Aspect ratio, i.e. screen's width\/height. |
68 | -> Matrix a | 63 | -> Matrix a |
69 | perspective n f fovy aspect = (4><4) | 64 | perspective n f fovy aspect = (4><4) |
70 | [ (2*n/(r-l)) , 0 , 0 , 0 | 65 | [ (2*n/(r-l)) , 0 , (-(r+l)/(r-l)) , 0 |
71 | , 0 , (2*n/(t-b)) , 0 , 0 | 66 | , 0 , (2*n/(t-b)) , ((t+b)/(t-b)) , 0 |
72 | , (-(r+l)/(r-l)) , ((t+b)/(t-b)) , (-(f+n)/(f-n)) , (-1) | 67 | , 0 , 0 , (-(f+n)/(f-n)) , (-2*f*n/(f-n)) |
73 | , 0 , 0 , (-2*f*n/(f-n)) , 0 ] | 68 | , 0 , 0 , (-1) , 0 ] |
74 | where | 69 | where |
75 | t = n*tan(fovy/2) | 70 | t = n*tan(fovy/2) |
76 | b = -t | 71 | b = -t |