module HGamer3D.Graphics3D.Geometry
(
Shape (..),
Geometry (..),
ctGeometry,
ctGraphicsElement
)
where
import Data.MessagePack
import Fresco
import Data.Text
import HGamer3D.Data
import HGamer3D.Graphics3D.Material
data Shape = Sphere
| Cube
| Plane
| Cylinder
| Pyramid
| Torus
deriving (Eq, Read, Show)
instance ComponentClass Shape where
toObj (Sphere) = ObjectArray [ObjectInt 0, ObjectArray []]
toObj (Cube) = ObjectArray [ObjectInt 1, ObjectArray []]
toObj (Plane) = ObjectArray [ObjectInt 2, ObjectArray []]
toObj (Cylinder) = ObjectArray [ObjectInt 3, ObjectArray []]
toObj (Pyramid) = ObjectArray [ObjectInt 4, ObjectArray []]
toObj (Torus) = ObjectArray [ObjectInt 5, ObjectArray []]
fromObj (ObjectArray [ObjectInt 0, ObjectArray []]) = Sphere
fromObj (ObjectArray [ObjectInt 1, ObjectArray []]) = Cube
fromObj (ObjectArray [ObjectInt 2, ObjectArray []]) = Plane
fromObj (ObjectArray [ObjectInt 3, ObjectArray []]) = Cylinder
fromObj (ObjectArray [ObjectInt 4, ObjectArray []]) = Pyramid
fromObj (ObjectArray [ObjectInt 5, ObjectArray []]) = Torus
data Geometry = ShapeGeometry Shape
| ResourceGeometry Text
deriving (Eq, Read, Show)
instance ComponentClass Geometry where
toObj (ShapeGeometry v1) = ObjectArray [ObjectInt 0, ObjectArray [(toObj v1)]]
toObj (ResourceGeometry v1) = ObjectArray [ObjectInt 1, ObjectArray [(toObj v1)]]
fromObj (ObjectArray [ObjectInt 0, ObjectArray [v1]]) = ShapeGeometry (fromObj v1)
fromObj (ObjectArray [ObjectInt 1, ObjectArray [v1]]) = ResourceGeometry (fromObj v1)
ctGeometry :: ComponentType Geometry
ctGeometry = ComponentType 0xee433d1a4b964591
ctGraphicsElement :: ComponentType ()
ctGraphicsElement = ComponentType 0x65114ba821671643