chose other reference points.

- camera is smoother now
- but still a bit shaky
This commit is contained in:
Nicole Dresselhaus 2014-08-17 23:50:28 +02:00
parent e265e5a021
commit e5b2a7d620
No known key found for this signature in database
GPG Key ID: BC16D887851A1A80

View File

@ -5,6 +5,8 @@ import Map.Types
import Data.Array (bounds, (!)) import Data.Array (bounds, (!))
import Data.List (sort, group) import Data.List (sort, group)
import Debug.Trace
-- WARNING: Does NOT Check for neighbours exceeding maximum map coordinates yet. -- WARNING: Does NOT Check for neighbours exceeding maximum map coordinates yet.
unsafeGiveNeighbours :: (Int, Int) -- ^ original coordinates unsafeGiveNeighbours :: (Int, Int) -- ^ original coordinates
-> [(Int,Int)] -- ^ list of neighbours -> [(Int,Int)] -- ^ list of neighbours
@ -43,9 +45,20 @@ giveMapHeight :: PlayMap
-> Double -> Double
giveMapHeight mop (x, z) giveMapHeight mop (x, z)
| outsideMap (x,z') = 0.0 | outsideMap (x,z') = 0.0
| otherwise = sum $ map (\(p,d) -> hlu p * (d / totald)) tups | otherwise = height --sum $ map (\(p,d) -> hlu p * (d / totald)) tups
where where
z' = z * 2/ sqrt 3 z' = z * 2/ sqrt 3
rx = x - (fromIntegral $ floor (x +0.5))
rz = z' - (fromIntegral $ floor (z'+0.5))
hoi = map (hlu . clmp . tadd (floor x, floor z')) mods
where
mods = [(0,0),(0,1),(1,0),(1,1)]
tadd (a,b) (c,d) = (a+c,b+d)
height = --trace (show [rx,rz] ++ show hoi)
rz * (rx * (hoi !! 0) + (1-rx) * (hoi !! 2))
+ (1-rz) * (rx * (hoi !! 1) + (1-rx) * (hoi !! 3))
outsideMap :: (Double, Double) -> Bool outsideMap :: (Double, Double) -> Bool
outsideMap (mx, mz) = let ((a,b),(c,d)) = bounds mop outsideMap (mx, mz) = let ((a,b),(c,d)) = bounds mop