picture is correct now

This commit is contained in:
Nicole Dresselhaus 2014-10-24 21:20:46 +02:00
parent 1ee771cf98
commit 3ab4789740
2 changed files with 5 additions and 3 deletions

View File

@ -81,7 +81,7 @@ main = do
let (w,h) = (width . sceneCamera $ s, height . sceneCamera $ s)
imdata = map (render w h s) [0..w*h-1]
imvec = fromList imdata
im = generateImage (\x y -> imvec ! (x*w+y)) w h
im = generateImage (\x y -> imvec ! (x*w+(h-y-1))) w h
print s
print (w,h)
writePng "out.png" im

View File

@ -34,11 +34,13 @@ render w h s index = case pcolls of
(Background (V3 br bg bb)) = sceneBackground s
pcolls = map fromJust $ filter isJust $ (intersect ray) <$> (sceneObjects s)
(Collision pos _ coll) = foldl1 min pcolls
ray = camRay x y (sceneCamera s) --Ray (eye cam) $ rotCam x y w h (center cam ^-^ eye cam) (up cam) (fovy cam)
cam = sceneCamera s
ray = camRay x y (sceneCamera s)
y = fromIntegral $ index `mod` w
x = fromIntegral $ index `div` w
ci = floor . (*255)
--wrong format:
--Ray (eye cam) $ rotCam x y w h (center cam ^-^ eye cam) (up cam) (fovy cam)
--cam = sceneCamera s
camRay :: Float -> Float -> Camera -> Ray
camRay x y c = Ray (eye c) (lowerLeft c ^+^ x *^ xDir c ^+^ y *^ yDir c ^-^ eye c)