Allow determination of attach item relative positions
This commit is contained in:
@@ -5,22 +5,25 @@ module Dodge.Item.Orientation
|
||||
import Dodge.Data.ComposedItem
|
||||
import Geometry.Data
|
||||
import Dodge.Data.Item
|
||||
import qualified Linear.Quaternion as Q
|
||||
import qualified 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)
|
||||
HELD TORCH -> (V3 0 20 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.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)
|
||||
(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 -> Maybe (Point3, Q.Quaternion Float)
|
||||
orientAttachment par lnk ch = Just (t1 + Q.rotate q1 t2, q1 * q2)
|
||||
orientAttachment par lnk ch = Just $ case (_itType par,lnk,_itType ch) of
|
||||
(HELD BURSTRIFLE,_,HELD TORCH) -> (V3 20 0 0, Q.qID)
|
||||
(HELD LAUNCHER,_,HELD TORCH) -> (V3 0 20 0, Q.qID)
|
||||
_ -> (t1 + Q.rotate q1 t2, q1 * q2)
|
||||
where
|
||||
(t1,q1) = orientByLink par lnk
|
||||
(t2,q2) = orientChild ch
|
||||
|
||||
Reference in New Issue
Block a user