Refactor light sources
This commit is contained in:
+48
-28
@@ -1,8 +1,13 @@
|
||||
module Dodge.LightSource
|
||||
( tLightTimedIntensity
|
||||
, tLight
|
||||
, lightAt
|
||||
, colorLightAt
|
||||
( tlsTimeRadFunPos
|
||||
, tlsTimeRadColPos
|
||||
, lsRadCol
|
||||
, lsPosRadCol
|
||||
, lsColPosRad
|
||||
, lsPosColRad
|
||||
, lsColPos
|
||||
, lsPosCol
|
||||
, lsColPosID
|
||||
)
|
||||
where
|
||||
import Dodge.Data
|
||||
@@ -11,24 +16,16 @@ import Dodge.Default
|
||||
|
||||
import Control.Lens
|
||||
|
||||
colorLightAt :: Point3 -> Point3 -> Int -> LightSource
|
||||
colorLightAt col pos i =
|
||||
LS {_lsID = i
|
||||
,_lsPos = pos
|
||||
,_lsDir = 0
|
||||
,_lsRad = 700
|
||||
,_lsIntensity = col
|
||||
,_lsPict = defLSPic
|
||||
}
|
||||
lsPosRad :: Point3 -> Float -> LightSource
|
||||
lsPosRad = lsColPosRad 0.75
|
||||
|
||||
lightAt :: Point3 -> Int -> LightSource
|
||||
lightAt = colorLightAt 0.75
|
||||
|
||||
tLightTimedIntensity :: Int -> Float -> (Int -> Float) -> Point2 -> TempLightSource
|
||||
tLightTimedIntensity t rmax intensityF (V2 x y) = TLS
|
||||
{ _tlsPos = V3 x y 0
|
||||
, _tlsRad = rmax
|
||||
, _tlsIntensity = f $ intensityF t
|
||||
tlsTimeRadFunPos :: Int -> Float -> (Int -> Float) -> Point3 -> TempLightSource
|
||||
tlsTimeRadFunPos t rmax intensityF p = TLS
|
||||
{ _tlsParam = LSParam
|
||||
{ _lsPos = p
|
||||
, _lsRad = rmax
|
||||
, _lsCol = f $ intensityF t
|
||||
}
|
||||
, _tlsUpdate = upF
|
||||
, _tlsTime = t
|
||||
}
|
||||
@@ -37,19 +34,43 @@ tLightTimedIntensity t rmax intensityF (V2 x y) = TLS
|
||||
| _tlsTime tls <= 0 = Nothing
|
||||
| otherwise = Just $ tls
|
||||
& tlsTime -~ 1
|
||||
& tlsIntensity .~ f (intensityF (_tlsTime tls) )
|
||||
& tlsParam . lsCol .~ f (intensityF (_tlsTime tls) )
|
||||
f x' = V3 x' x' x'
|
||||
|
||||
tLight
|
||||
lsPosColRad p col = lsColPosRad col p
|
||||
|
||||
lsPosRadCol p r col = defaultLS
|
||||
& lsParam . lsPos .~ p
|
||||
& lsParam . lsRad .~ r
|
||||
& lsParam . lsCol .~ col
|
||||
|
||||
lsColPosID :: Point3 -> Point3 -> Int -> LightSource
|
||||
lsColPosID col p i = lsColPos col p & lsID .~ i
|
||||
|
||||
lsColPos :: Point3 -> Point3 -> LightSource
|
||||
lsColPos col pos = lsColPosRad col pos 700
|
||||
|
||||
lsPosCol :: Point3 -> Point3 -> LightSource
|
||||
lsPosCol pos col = lsColPos col pos
|
||||
|
||||
lsColPosRad :: Point3 -> Point3 -> Float -> LightSource
|
||||
lsColPosRad col pos r = lsPosRadCol pos r col
|
||||
|
||||
lsRadCol r col = defaultLS & lsParam . lsRad .~ r
|
||||
& lsParam . lsCol .~ col
|
||||
|
||||
tlsTimeRadColPos
|
||||
:: Int
|
||||
-> Float -- ^ maximal radius
|
||||
-> Point3
|
||||
-> Point3
|
||||
-> TempLightSource
|
||||
tLight t rmax col (V3 x y z) = TLS
|
||||
{ _tlsPos = V3 x y z
|
||||
, _tlsRad = rmax
|
||||
, _tlsIntensity = col
|
||||
tlsTimeRadColPos t rmax col (V3 x y z) = TLS
|
||||
{ _tlsParam = LSParam
|
||||
{ _lsPos = V3 x y z
|
||||
, _lsRad = rmax
|
||||
, _lsCol = col
|
||||
}
|
||||
, _tlsUpdate = upF
|
||||
, _tlsTime = t
|
||||
}
|
||||
@@ -58,4 +79,3 @@ tLight t rmax col (V3 x y z) = TLS
|
||||
| _tlsTime tls <= 0 = Nothing
|
||||
| otherwise = Just $ tls
|
||||
& tlsTime -~ 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user