|
|
|
@@ -1,4 +1,5 @@
|
|
|
|
|
{-# LANGUAGE LambdaCase #-}
|
|
|
|
|
|
|
|
|
|
module Dodge.Creature.HandPos (
|
|
|
|
|
equipSitePQ,
|
|
|
|
|
translatePointToLeftHand,
|
|
|
|
@@ -13,16 +14,16 @@ module Dodge.Creature.HandPos (
|
|
|
|
|
rightHandPQ,
|
|
|
|
|
) where
|
|
|
|
|
|
|
|
|
|
import Dodge.Data.Equipment.Misc
|
|
|
|
|
import qualified Quaternion as Q
|
|
|
|
|
import Control.Lens
|
|
|
|
|
import Dodge.Creature.Test
|
|
|
|
|
import Dodge.Data.Creature
|
|
|
|
|
import Dodge.Data.Equipment.Misc
|
|
|
|
|
import Geometry
|
|
|
|
|
import qualified Quaternion as Q
|
|
|
|
|
import ShapePicture
|
|
|
|
|
|
|
|
|
|
translateToES :: Creature -> EquipSite -> Point3 -> Point3
|
|
|
|
|
translateToES cr es p = fst (equipSitePQ es cr `Q.comp` (p,Q.qID))
|
|
|
|
|
translateToES cr es p = fst (equipSitePQ es cr `Q.comp` (p, Q.qID))
|
|
|
|
|
|
|
|
|
|
equipSitePQ :: EquipSite -> Creature -> Point3Q
|
|
|
|
|
equipSitePQ = \case
|
|
|
|
@@ -31,24 +32,26 @@ equipSitePQ = \case
|
|
|
|
|
OnHead -> headPQ
|
|
|
|
|
OnChest -> chestPQ
|
|
|
|
|
OnBack -> backPQ
|
|
|
|
|
OnLeftLeg -> leftLegPQ
|
|
|
|
|
OnRightLeg -> rightLegPQ
|
|
|
|
|
OnLeftLeg -> legPQ LeftForward
|
|
|
|
|
OnRightLeg -> legPQ RightForward
|
|
|
|
|
|
|
|
|
|
translatePointToRightHand :: Creature -> Point3 -> Point3
|
|
|
|
|
translatePointToRightHand cr p = fst (rightHandPQ cr `Q.comp` (p,Q.qID))
|
|
|
|
|
translatePointToRightHand cr p = fst (rightHandPQ cr `Q.comp` (p, Q.qID))
|
|
|
|
|
|
|
|
|
|
handWalkingPos :: FootForward -> Float -> Creature -> Point3
|
|
|
|
|
handWalkingPos b off cr = case cr ^. crStance . carriage of
|
|
|
|
|
Walking sa ff ->
|
|
|
|
|
Walking sa ff ->
|
|
|
|
|
let slen = cr ^. crStance . strideLength
|
|
|
|
|
f i | ff == b = 8 * (slen - i) / slen
|
|
|
|
|
f i
|
|
|
|
|
| ff == b = 8 * (slen - i) / slen
|
|
|
|
|
| otherwise = 8 * i / slen
|
|
|
|
|
in V3 (f sa) off 12
|
|
|
|
|
in V3 (f sa) off 12
|
|
|
|
|
Falling sa ff ->
|
|
|
|
|
let slen = cr ^. crStance . strideLength
|
|
|
|
|
f i | ff == b = 8 * (slen - i) / slen
|
|
|
|
|
f i
|
|
|
|
|
| ff == b = 8 * (slen - i) / slen
|
|
|
|
|
| otherwise = 8 * i / slen
|
|
|
|
|
in V3 (f sa) off 20
|
|
|
|
|
in V3 (f sa) off 20
|
|
|
|
|
Floating -> V3 0 off 12
|
|
|
|
|
Flying -> V3 0 off 12
|
|
|
|
|
Boosting _ -> V3 0 off 12
|
|
|
|
@@ -56,7 +59,7 @@ handWalkingPos b off cr = case cr ^. crStance . carriage of
|
|
|
|
|
rightHandPQ :: Creature -> Point3Q
|
|
|
|
|
rightHandPQ cr
|
|
|
|
|
| oneH cr = (V3 11 (-3) 20, Q.qID)
|
|
|
|
|
| twists cr = (V3 0 5 20, Q.qz (-1)) `Q.comp` (V3 4 (-10) 0,Q.qID)
|
|
|
|
|
| twists cr = (V3 0 5 20, Q.qz (-1)) `Q.comp` (V3 4 (-10) 0, Q.qID)
|
|
|
|
|
| twoFlat cr = (V3 4 (-8) 12, Q.qID)
|
|
|
|
|
| otherwise = (handWalkingPos LeftForward (-8) cr, Q.qID)
|
|
|
|
|
|
|
|
|
@@ -74,7 +77,7 @@ leftHandPQ cr
|
|
|
|
|
| otherwise = (handWalkingPos RightForward 8 cr, Q.qID)
|
|
|
|
|
|
|
|
|
|
translatePointToLeftHand :: Creature -> Point3 -> Point3
|
|
|
|
|
translatePointToLeftHand cr p = fst (leftHandPQ cr `Q.comp` (p,Q.qID))
|
|
|
|
|
translatePointToLeftHand cr p = fst (leftHandPQ cr `Q.comp` (p, Q.qID))
|
|
|
|
|
|
|
|
|
|
translateToLeftHand :: Creature -> SPic -> SPic
|
|
|
|
|
translateToLeftHand = overPosSP . translatePointToLeftHand
|
|
|
|
@@ -82,27 +85,19 @@ translateToLeftHand = overPosSP . translatePointToLeftHand
|
|
|
|
|
leftWristPQ :: Creature -> Point3Q
|
|
|
|
|
leftWristPQ cr = leftHandPQ cr `Q.comp` (V3 0 4 (-4), Q.qID)
|
|
|
|
|
|
|
|
|
|
leftLegPQ :: Creature -> Point3Q
|
|
|
|
|
leftLegPQ cr = Q.comp (0,Q.qz (_crMvDir cr - _crDir cr))
|
|
|
|
|
(V3 x off 0,Q.qID)
|
|
|
|
|
where
|
|
|
|
|
x = case cr ^? crStance . carriage of
|
|
|
|
|
Just (Walking sa LeftForward) -> f sa
|
|
|
|
|
Just (Walking sa RightForward) -> - f sa
|
|
|
|
|
Just (Falling sa LeftForward) -> f sa
|
|
|
|
|
Just (Falling sa RightForward) -> - f sa
|
|
|
|
|
_ -> 0
|
|
|
|
|
off = 5
|
|
|
|
|
sLen = _strideLength $ _crStance cr
|
|
|
|
|
f i = 8 * (sLen - i) / sLen
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
translateToLeftLeg :: Creature -> SPic -> SPic
|
|
|
|
|
translateToLeftLeg cr = overPosSP (\p -> fst (leftLegPQ cr `Q.comp` (p,Q.qID)))
|
|
|
|
|
translateToLeftLeg cr = overPosSP (\p -> fst (legPQ LeftForward cr `Q.comp` (p, Q.qID)))
|
|
|
|
|
|
|
|
|
|
rightLegPQ :: Creature -> Point3Q
|
|
|
|
|
rightLegPQ cr = Q.comp (0,Q.qz (_crMvDir cr - _crDir cr))
|
|
|
|
|
(V3 x off 0,Q.qID)
|
|
|
|
|
legPQ :: FootForward -> Creature -> Point3Q
|
|
|
|
|
legPQ ff = case ff of
|
|
|
|
|
LeftForward -> legPQ' id
|
|
|
|
|
RightForward -> legPQ' negate
|
|
|
|
|
|
|
|
|
|
legPQ' :: (Float -> Float) -> Creature -> Point3Q
|
|
|
|
|
legPQ' g cr =
|
|
|
|
|
Q.comp
|
|
|
|
|
(0, Q.qz (_crMvDir cr - _crDir cr))
|
|
|
|
|
(V3 x (g off) 0, Q.qID)
|
|
|
|
|
where
|
|
|
|
|
x = case cr ^? crStance . carriage of
|
|
|
|
|
Just (Walking sa LeftForward) -> -f sa
|
|
|
|
@@ -112,10 +107,10 @@ rightLegPQ cr = Q.comp (0,Q.qz (_crMvDir cr - _crDir cr))
|
|
|
|
|
_ -> 0
|
|
|
|
|
off = -5
|
|
|
|
|
sLen = _strideLength $ _crStance cr
|
|
|
|
|
f i = 8 * (sLen - i) / sLen
|
|
|
|
|
f i = g 8 * (sLen - i) / sLen
|
|
|
|
|
|
|
|
|
|
translateToRightLeg :: Creature -> SPic -> SPic
|
|
|
|
|
translateToRightLeg cr = overPosSP (\p -> fst (rightLegPQ cr `Q.comp` (p,Q.qID)))
|
|
|
|
|
translateToRightLeg cr = overPosSP (\p -> fst (legPQ RightForward cr `Q.comp` (p, Q.qID)))
|
|
|
|
|
|
|
|
|
|
headPQ :: Creature -> Point3Q
|
|
|
|
|
headPQ cr
|
|
|
|
@@ -123,11 +118,8 @@ headPQ cr
|
|
|
|
|
| oneH cr = (V3 0 0 20, Q.qz 0.5) `Q.comp` (V3 2.5 0 0, Q.qz (-0.5))
|
|
|
|
|
| otherwise = (V3 2.5 0 20, Q.qID)
|
|
|
|
|
|
|
|
|
|
--translatePointToHead :: IM.IntMap Item -> Creature -> Point3 -> Point3
|
|
|
|
|
--translatePointToHead m cr p = fst (headPQ cr `Q.comp` (p,Q.qID))
|
|
|
|
|
|
|
|
|
|
chestPQ :: Creature -> Point3Q
|
|
|
|
|
chestPQ cr = backPQ cr `Q.comp` (0,Q.qz pi)
|
|
|
|
|
chestPQ cr = backPQ cr `Q.comp` (0, Q.qz pi)
|
|
|
|
|
|
|
|
|
|
backPQ :: Creature -> Point3Q
|
|
|
|
|
backPQ cr
|
|
|
|
|