module Dodge.Item.Orientation 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 {} -> (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{}) -> undefined --(V3 4 (-6) 0,0) (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) _ -> (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