31 lines
1.1 KiB
Haskell
31 lines
1.1 KiB
Haskell
module Dodge.Item.Orientation (
|
|
orientAttachment,
|
|
) where
|
|
|
|
import Dodge.Data.ComposedItem
|
|
import Dodge.Data.Item
|
|
import Geometry.Data
|
|
import qualified Quaternion as Q
|
|
|
|
orientChild :: Item -> (Point3, Q.Quaternion Float)
|
|
orientChild itm = case _itType itm of
|
|
HELD TORCH -> (V3 0 5 0, Q.qID)
|
|
HELD LASER -> (V3 15 (-5) 0, Q.qID)
|
|
_ -> (0, Q.qID)
|
|
|
|
orientByLink :: Item -> ComposeLinkType -> (Point3, Q.Quaternion Float)
|
|
orientByLink itm lt = case (_itType itm, lt) of
|
|
(HELD FLAMETHROWER, AmmoInLink{}) -> (V3 4 (-6) 0, Q.qID)
|
|
(HELD _, AmmoInLink{}) -> (V3 7 (-2) 0, Q.qID)
|
|
(HELD _, WeaponScopeLink) -> (V3 5 0 5, Q.qID)
|
|
_ -> (0, Q.qID)
|
|
|
|
orientAttachment :: Item -> ComposeLinkType -> Item -> (Point3, Q.Quaternion Float)
|
|
orientAttachment par lnk ch = case (_itType par, lnk, _itType ch) of
|
|
-- (HELD BURSTRIFLE, _, HELD TORCH) -> (V3 20 0 0, Q.axisAngle (V3 0 0 1) (pi/2))
|
|
-- (HELD LAUNCHER, _, HELD TORCH) -> (V3 0 20 0, Q.axisAngle (V3 0 0 1) (pi/4))
|
|
_ -> (t1 + Q.rotate q1 t2, q1 * q2)
|
|
where
|
|
(t1, q1) = orientByLink par lnk
|
|
(t2, q2) = orientChild ch
|