diff options
author | Joe Crayne <joe@jerkface.net> | 2019-04-29 16:04:24 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-04-29 16:04:24 -0400 |
commit | edbc09c280c1699933c443795686394c1e9e8de5 (patch) | |
tree | 533a2849f8a9ebe4a86d3efa5dd7062c27f73b07 /mainObj.hs | |
parent | 3af8c040637d4289e39577c04fc8b68f8d868f05 (diff) |
mainObj.hs: Slower animation, more straight-forward grid calculation.
Diffstat (limited to 'mainObj.hs')
-rw-r--r-- | mainObj.hs | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -59,7 +59,7 @@ uploadState obj glarea storage = do | |||
59 | -- add OBJ to pipeline input | 59 | -- add OBJ to pipeline input |
60 | addOBJToObjectArray storage "objects" objMesh gpuMtlLib | 60 | addOBJToObjectArray storage "objects" objMesh gpuMtlLib |
61 | -- grid plane | 61 | -- grid plane |
62 | uploadMeshToGPU xyplane >>= addMeshToObjectArray storage "plane" [] | 62 | uploadMeshToGPU xzplane >>= addMeshToObjectArray storage "plane" [] |
63 | 63 | ||
64 | -- setup FrameClock | 64 | -- setup FrameClock |
65 | tm <- newTimeKeeper | 65 | tm <- newTimeKeeper |
@@ -79,10 +79,10 @@ deg30 = pi/6 | |||
79 | 79 | ||
80 | setUniforms :: glctx -> GLStorage -> State -> IO () | 80 | setUniforms :: glctx -> GLStorage -> State -> IO () |
81 | setUniforms gl storage st = do | 81 | setUniforms gl storage st = do |
82 | t <- getSeconds $ stTimeKeeper st | 82 | t <- (/ 10.0) <$> getSeconds (stTimeKeeper st) |
83 | let tf = realToFrac t :: Float | 83 | let tf = realToFrac t :: Float |
84 | rot = rotMatrixZ (-tf) <> rotMatrixX (-tf) | 84 | rot = rotMatrixZ (-tf) <> rotMatrixX (-tf) |
85 | pos = rot #> fromList [0,0,10] | 85 | pos = rot #> fromList [2,2,10] |
86 | up = rot #> fromList [0,1,0] | 86 | up = rot #> fromList [0,1,0] |
87 | cam = lookat pos 0 up | 87 | cam = lookat pos 0 up |
88 | aspect = 1 | 88 | aspect = 1 |
@@ -90,7 +90,8 @@ setUniforms gl storage st = do | |||
90 | mvp = proj <> cam | 90 | mvp = proj <> cam |
91 | 91 | ||
92 | LC.updateUniforms storage $ do | 92 | LC.updateUniforms storage $ do |
93 | "cam" @= return (mvp :: Matrix Float) | 93 | "CameraPosition" @= return (pos :: Vector Float) |
94 | "ViewProjection" @= return (mvp :: Matrix Float) | ||
94 | 95 | ||
95 | main :: IO () | 96 | main :: IO () |
96 | main = do | 97 | main = do |
@@ -105,7 +106,8 @@ main = do | |||
105 | defObjectArray "plane" Triangles $ do | 106 | defObjectArray "plane" Triangles $ do |
106 | "position" @: Attribute_V4F | 107 | "position" @: Attribute_V4F |
107 | defUniforms $ do | 108 | defUniforms $ do |
108 | "cam" @: M44F | 109 | "CameraPosition" @: V3F |
110 | "ViewProjection" @: M44F | ||
109 | "diffuseTexture" @: FTexture2D | 111 | "diffuseTexture" @: FTexture2D |
110 | "diffuseColor" @: V4F | 112 | "diffuseColor" @: V4F |
111 | return $ (,) <$> mobj <*> mpipeline | 113 | return $ (,) <$> mobj <*> mpipeline |