Work on held item positioning

This commit is contained in:
2022-07-14 00:28:28 +01:00
parent 090408b438
commit dcc0596a25
6 changed files with 59 additions and 50 deletions
+33 -30
View File
@@ -4,6 +4,7 @@ module Dodge.Item.Draw
, twoFlatHRot
, itemSPic
, itemEquipPict
, heldItemOffset
) where
import Dodge.Data
import ShapePicture
@@ -45,38 +46,40 @@ pictureWeaponOnAimItem
-> Int -- ^ Position of item in inventory
-> SPic
pictureWeaponOnAimItem p' cr posInInv
| isSelected && _posture (_crStance cr) == Aiming =
shoulderD $ translateSPf (aimingWeaponZeroPos cr theIt) 0 p'
| isSelected && isTwoHandFlat
= handD holsteredTwoFlat
| isSelected && isOneHand
= handD holsteredOneHandWep
| isSelected
= handD holsteredWep
| _itIsHeld theIt = overPosSP (heldItemOffset theIt cr) p'
| otherwise = mempty
-- | isSelected && _posture (_crStance cr) == Aiming =
-- shoulderD $ translateSPf (aimingWeaponZeroPos cr theIt) 0 p'
-- | isSelected && isTwoHandFlat
-- = handD holsteredTwoFlat
-- | isSelected && isOneHand
-- = handD holsteredOneHandWep
-- | isSelected
-- = handD holsteredWep
-- | otherwise = mempty
where
shoulderD = translateSPz 18
handD = translateSPz 15
isSelected = crSel cr == posInInv
twistWep = translateSPf (-5) 0 p
holsteredWep = translateSPf (_crRad cr) 0
(rotateSP (strideRot cr + 1.2) (translateSPf (-5) 0 twistWep))
holsteredTwoFlat = translateSPf (_crRad cr) 0 (rotateSP (twoFlatHRot cr) p)
holsteredOneHandWep = translateSPf (_crRad cr * 0.7 + handPos) (_crRad cr * negate 0.7)
(translateSPf (-2) 0 p)
handPos = case cr^? crStance . carriage of
Just (Walking x LeftForward) -> f x * 50
_ -> 0
-- shoulderD = translateSPz 18
-- handD = translateSPz 15
-- isSelected = crSel cr == posInInv
-- twistWep = translateSPf (-5) 0 p
-- holsteredWep = translateSPf (_crRad cr) 0
-- (rotateSP (strideRot cr + 1.2) (translateSPf (-5) 0 twistWep))
-- holsteredTwoFlat = translateSPf (_crRad cr) 0 (rotateSP (twoFlatHRot cr) p)
-- holsteredOneHandWep = translateSPf (_crRad cr * 0.7 + handPos) (_crRad cr * negate 0.7)
-- (translateSPf (-2) 0 p)
-- handPos = case cr^? crStance . carriage of
-- Just (Walking x LeftForward) -> f x * 50
-- _ -> 0
theIt = _crInv cr IM.! posInInv
p = fromMaybe p' $ do
x <- theIt ^? itUse . useAim . aimHandlePos
return $translateSPf (-x) 0 p'
isOneHand = theIt ^? itUseAimStance == Just OneHand
|| isNothing (theIt ^? itUseAimStance)
isTwoHandFlat = theIt ^? itUseAimStance == Just TwoHandFlat
itUseAimStance = itUse . useAim . aimStance
f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
sLen = _strideLength $ _crStance cr
-- p = fromMaybe p' $ do
-- x <- theIt ^? itUse . useAim . aimHandlePos
-- return $translateSPf (-x) 0 p'
-- isOneHand = theIt ^? itUseAimStance == Just OneHand
-- || isNothing (theIt ^? itUseAimStance)
-- isTwoHandFlat = theIt ^? itUseAimStance == Just TwoHandFlat
-- itUseAimStance = itUse . useAim . aimStance
-- f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
-- sLen = _strideLength $ _crStance cr
heldItemOffset :: Item -> Creature -> Point3 -> Point3
heldItemOffset itm cr
@@ -96,7 +99,7 @@ heldItemOffset itm cr
. (+.+.+ V3 (_crRad cr) 0 0)
. rotate3 (strideRot cr + 1.2)
. (+.+.+ V3 (-5) 0 0)
. (+.+.+ V3 (-5) 0 0)
-- . (+.+.+ V3 (-5) 0 0)
. transToHandle
| otherwise = id
where