Files
loop/src/Dodge/LightSources.hs
T

61 lines
1.5 KiB
Haskell

module Dodge.LightSources where
import Dodge.Data
--import Dodge.Base
import Dodge.Picture.Layer
import Dodge.LevelGen.Data
--import Geometry
import Picture
import Geometry.Data
--import qualified Data.IntMap.Strict as IM
lightAt :: Point3 -> Int -> LightSource
lightAt (V3 x y z) i =
LS {_lsID = i
,_lsPos = V3 x y z
,_lsDir = 0
,_lsRad = 700
,_lsIntensity = 0.75
}
basicLS :: PSType
basicLS = PutLS ls dec
where
ls = lightAt (V3 0 0 0) 0
dec = onLayer PtLayer $ color white $ circleSolid 8
tLightFade :: Int -> Float -> (Int -> Float) -> Point2 -> TempLightSource
tLightFade 0 rmax intensityF (V2 x y) = TLS
{ _tlsPos = V3 x y 0
, _tlsRad = rmax
, _tlsIntensity = intensityF 0
, _tlsUpdate = \w _ -> (w, Nothing)
}
tLightFade i rmax intensityF p@(V2 x y) = TLS
{ _tlsPos = V3 x y 0
, _tlsRad = rmax
, _tlsIntensity = intensityF i
, _tlsUpdate = \w _ -> (w, Just $ tLightFade (i-1) rmax intensityF p)
}
tLightRad
:: Int
-> Float -- ^ maximal radius
-> Float -- ^ minimal radius (unused)
-> Point2
-> TempLightSource
tLightRad 0 rmax _ (V2 x y) = TLS
{ _tlsPos = V3 x y 0
, _tlsRad = rmax
, _tlsIntensity = 0.5
, _tlsUpdate = \w _ -> (w, Nothing)
}
tLightRad i rmax rmin p@(V2 x y) = TLS
{ _tlsPos = V3 x y 0
, _tlsRad = rmax
, _tlsIntensity = 0.5
, _tlsUpdate = \w _ -> (w, Just $ tLightRad (i-1) rmax rmin p)
}
tLightAt :: Int -> Point2 -> TempLightSource
tLightAt i = tLightRad i 100 0