module HGamer3D.Graphics3D.Light
(
LightType (..),
Light (..),
ctLight
)
where
import Data.MessagePack
import Fresco
import HGamer3D.Data
data LightType = PointLight
| DirectionalLight
| SpotLight Angle Float
instance ComponentClass LightType where
toObj PointLight = ObjectArray [ObjectInt 0]
toObj DirectionalLight = ObjectArray [ObjectInt 1]
toObj (SpotLight fov ar) = ObjectArray [ObjectInt 2, toObj fov, ObjectFloat ar]
fromObj (ObjectArray [ObjectInt 0]) = PointLight
fromObj (ObjectArray [ObjectInt 1]) = DirectionalLight
fromObj (ObjectArray [ObjectInt 2, fov_o, ObjectFloat ar]) = SpotLight (fromObj fov_o) ar
data Light = Light
LightType
Float
Float
Float
instance ComponentClass Light where
toObj (Light lt b r s) = ObjectArray [toObj lt, ObjectFloat b, ObjectFloat r, ObjectFloat s]
fromObj (ObjectArray [lt_o, ObjectFloat b, ObjectFloat r, ObjectFloat s]) = Light (fromObj lt_o) b r s
ctLight :: ComponentType Light
ctLight = ComponentType 0x981e80e50d994ea9