27 lines
971 B
Haskell
27 lines
971 B
Haskell
module Dodge.Item.Orientation
|
|
( orientAttachment
|
|
) where
|
|
|
|
import Dodge.Data.ComposedItem
|
|
import Geometry.Data
|
|
import Dodge.Data.Item
|
|
import qualified Linear.Quaternion as Q
|
|
|
|
orientChild :: Item -> (Point3, Q.Quaternion Float)
|
|
orientChild itm = case _itType itm of
|
|
HELD TORCH -> (V3 5 0 0,Q.axisAngle (V3 1 0 0) 0)
|
|
_ -> (0,Q.axisAngle (V3 1 0 0) 0)
|
|
|
|
orientByLink :: Item -> ComposeLinkType -> (Point3, Q.Quaternion Float)
|
|
orientByLink itm lt = case (_itType itm,lt) of
|
|
(HELD FLAMETHROWER, AmmoInLink{}) -> (V3 4 (-6) 0, Q.axisAngle (V3 1 0 0) 0)
|
|
(HELD _,AmmoInLink{}) -> (V3 7 (-2) 0, Q.axisAngle (V3 1 0 0) 0)
|
|
(HELD _,WeaponScopeLink) -> (V3 5 0 5, Q.axisAngle (V3 1 0 0) 0)
|
|
_ -> (0,Q.axisAngle (V3 1 0 0) 0)
|
|
|
|
orientAttachment :: Item -> ComposeLinkType -> Item -> Maybe (Point3, Q.Quaternion Float)
|
|
orientAttachment par lnk ch = Just (t1 + Q.rotate q1 t2, q1 * q2)
|
|
where
|
|
(t1,q1) = orientByLink par lnk
|
|
(t2,q2) = orientChild ch
|