Work on chase crit shape

This commit is contained in:
2026-04-01 13:46:27 +01:00
parent 5f886106e2
commit 6d1cdcc9f3
11 changed files with 154 additions and 128 deletions
+3 -3
View File
@@ -88,7 +88,7 @@ makeDebrisDirectedZ arcrad dir z dt bm p w =
{ _dbPos = p `v2z` z
, _dbType = dt
, _dbVel = v `v2z` 0
, _dbRot = Q.qID
, _dbRot = Q.qid
, _dbSpin = Q.axisAngle (vNormal v `v2z` 0) spinspeed
}
@@ -109,7 +109,7 @@ makeDebrisDirected arcrad dir dt bm p w =
{ _dbPos = p `v2z` h
, _dbType = dt
, _dbVel = v `v2z` 0
, _dbRot = Q.qID
, _dbRot = Q.qid
, _dbSpin = Q.axisAngle (vNormal v `v2z` 0) spinspeed
}
@@ -118,7 +118,7 @@ makeDebrisDirected arcrad dir dt bm p w =
-- & prPos .~ p
-- & prVel .~ v
-- & prQuatSpin .~ Q.axisAngle (vNormal v `v2z` 0) spinspeed
-- & prQuat .~ Q.qID
-- & prQuat .~ Q.qid
-- & prVelZ .~ 0
-- & prPosZ .~ h
+20 -20
View File
@@ -27,7 +27,7 @@ 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
@@ -40,7 +40,7 @@ equipSitePQ = \case
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
@@ -65,15 +65,15 @@ zeroOneSmooth x = (1 - cos (pi * x)) / 2
rightHandPQ :: Creature -> Point3Q
rightHandPQ cr
| oneH cr = (V3 11 (-3) 20, Q.qID)
| oneH cr = (V3 11 (-3) 20, Q.qid)
| twists cr = (V3 0 5 20, Q.qz (-1)) `Q.comp` (V3 4 (-10) 0, Q.qz 1)
| twoFlat cr = (V3 8 (-8) 12, Q.qID)
| twoFlat cr = (V3 8 (-8) 12, Q.qid)
| Just TwoHandTwist <- cr ^? crManipulation . manObject . imAimStance
= (V3 6 (-6) 10, Q.qID)
= (V3 6 (-6) 10, Q.qid)
| Just TwoHandFlat <- cr ^? crManipulation . manObject . imAimStance
= (V3 (8 - twoHandOffY cr) (-8) 12, Q.qID)
| Just p <- crRightHandWall cr = (20 & _xy .~ p, Q.qID)
| otherwise = (handWalkingPos LeftForward (-8) cr, Q.qID)
= (V3 (8 - twoHandOffY cr) (-8) 12, Q.qid)
| Just p <- crRightHandWall cr = (20 & _xy .~ p, Q.qid)
| otherwise = (handWalkingPos LeftForward (-8) cr, Q.qid)
crRightHandWall :: Creature -> Maybe Point2
crRightHandWall cr = do
@@ -115,19 +115,19 @@ translateToRightHand :: Creature -> SPic -> SPic
translateToRightHand = overPosSP . translatePointToRightHand
rightWristPQ :: Creature -> Point3Q
rightWristPQ cr = rightHandPQ cr `Q.comp` (V3 0 (-4) (-4), Q.qID)
rightWristPQ cr = rightHandPQ cr `Q.comp` (V3 0 (-4) (-4), Q.qid)
leftHandPQ :: Creature -> Point3Q
leftHandPQ cr
| twists cr = (V3 0 5 20, Q.qz (-1)) `Q.comp` (V3 12 4 0, Q.qz 0.4)
| twoFlat cr = (V3 8 8 12, Q.qID)
| twoFlat cr = (V3 8 8 12, Q.qid)
| Just TwoHandTwist <- cr ^? crManipulation . manObject . imAimStance
= (V3 (10 + twoHandOffY cr) 6 20, Q.qID)
= (V3 (10 + twoHandOffY cr) 6 20, Q.qid)
| Just TwoHandFlat <- cr ^? crManipulation . manObject . imAimStance
= (V3 (8 + twoHandOffY cr) 6 12, Q.qID)
| Just p <- crLeftHandWall cr = (20 & _xy .~ p, Q.qID)
= (V3 (8 + twoHandOffY cr) 6 12, Q.qid)
| Just p <- crLeftHandWall cr = (20 & _xy .~ p, Q.qid)
| oneH cr = (V3 0 8 10, Q.qz 0.4)
| otherwise = (handWalkingPos RightForward 8 cr, Q.qID)
| otherwise = (handWalkingPos RightForward 8 cr, Q.qid)
twoHandOffY :: Creature -> Float
twoHandOffY cr = zeroOneSmooth $ case cr ^. crStance . carriage of
@@ -146,16 +146,16 @@ twoHandOffY cr = zeroOneSmooth $ case cr ^. crStance . carriage of
_ -> 0
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
leftWristPQ :: Creature -> Point3Q
leftWristPQ cr = leftHandPQ cr `Q.comp` (V3 0 4 (-4), Q.qID)
leftWristPQ cr = leftHandPQ cr `Q.comp` (V3 0 4 (-4), Q.qid)
translateToLeftLeg :: Creature -> SPic -> SPic
translateToLeftLeg cr = overPosSP (\p -> fst (legPQ LeftForward cr `Q.comp` (p, Q.qID)))
translateToLeftLeg cr = overPosSP (\p -> fst (legPQ LeftForward cr `Q.comp` (p, Q.qid)))
legPQ :: FootForward -> Creature -> Point3Q
legPQ ff = case ff of
@@ -166,7 +166,7 @@ legPQ' :: (Float -> Float) -> Creature -> Point3Q
legPQ' g cr =
Q.comp
(0, Q.qz (_crMvDir cr - _crDir cr))
(V3 x (g off) 0, Q.qID)
(V3 x (g off) 0, Q.qid)
where
x = case cr ^? crStance . carriage of
Just (Walking sa LeftForward) -> -f sa
@@ -179,13 +179,13 @@ legPQ' g cr =
f i = g 8 * (sLen - i) / sLen
translateToRightLeg :: Creature -> SPic -> SPic
translateToRightLeg cr = overPosSP (\p -> fst (legPQ RightForward cr `Q.comp` (p, Q.qID)))
translateToRightLeg cr = overPosSP (\p -> fst (legPQ RightForward cr `Q.comp` (p, Q.qid)))
headPQ :: Creature -> Point3Q
headPQ cr
| twists cr = (V3 0 2 20, Q.qz (-1)) `Q.comp` (V3 (negate 2.5) 0.25 0, Q.qz 1)
| 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)
| otherwise = (V3 2.5 0 20, Q.qid)
chestPQ :: Creature -> Point3Q
chestPQ cr = backPQ cr `Q.comp` (0, Q.qz pi)
+1 -1
View File
@@ -26,6 +26,6 @@ defaultChaseMvType =
CrMvType
{ _mvSpeed = 2
, _mvTurnRad = FloatAbsCheckGreaterLess (pi / 4) 0.2 0.05
, _mvTurnJit = 0.2
, _mvTurnJit = 0.05
, _mvAimSpeed = FloatAbsCheckGreaterLess (pi / 8) 0.2 0.01
}
+23 -1
View File
@@ -10,6 +10,7 @@ module Dodge.Creature.Picture (
drawChaseCrit,
) where
import Linear
import Dodge.Data.Equipment.Misc
import Dodge.Creature.HandPos
import qualified Data.IntMap.Strict as IM
@@ -50,12 +51,33 @@ basicCrShape cr
rotmdir = rotateSH (_crMvDir cr - _crDir cr)
drawChaseCrit :: Creature -> Shape
drawChaseCrit cr = rotmdir $ colorSH (_skinLower cskin) $ feet cr
drawChaseCrit cr = mconcat
[ chaseUpperBody cr
, rotmdir $ colorSH (_skinLower cskin) $ feet cr
]
where
cskin = crShape $ _crType cr
crsize = 0.1 * crRad (cr ^. crType)
rotmdir = rotateSH (_crMvDir cr - _crDir cr)
chaseUpperBody :: Creature -> Shape
chaseUpperBody cr = colorSH (_skinUpper cskin)
(overPosSH (Q.apply torsoq) (upperPrismPolyHalfMI tz $ polyCirc 3 12
& each %~ vNormal
& each . _y *~ 0.6)
<> overPosSH (Q.apply neckq) (upperPrismPolyHalfMI 3 $ (+ V2 8 0) . vNormal <$> trapTBH 2 5 8)
)
<> colorSH (_skinHead cskin)
(overPosSH (Q.apply headq) (upperBox Medium Important 2 [V2 0 (-4), V2 9 0, V2 0 4]))
where
tz = 4
cskin = crShape $ _crType cr
torsoq = (V3 0 0 (10 + tz),Q.qid)
mcool = 1 - min 10 (fromIntegral . _meleeCooldown $ _crType cr) / 10
neckq = torsoq `Q.comp` (V3 6 0 0,Q.axisAngle (V3 0 1 0) (-1.8*mcool))
headq = neckq `Q.comp` (V3 16 0 0, Q.axisAngle (V3 0 1 0) (2*mcool))
oneSmooth :: Float -> Float
oneSmooth x = sin (pi * x * 0.5)
+1 -1
View File
@@ -224,7 +224,7 @@ shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ d
where
o = locOrient loc cr
itmtree = loc ^. locDT
(p, q) = o `Q.comp` (V3 5 0 0, Q.qID)
(p, q) = o `Q.comp` (V3 5 0 0, Q.qid)
x = 1
isammolink AmmoMagSF{} = True
isammolink _ = False
+1
View File
@@ -96,6 +96,7 @@ makeLenses ''BarrelType
makeLenses ''Vocalization
makeLenses ''CrMvType
makeLenses ''CreatureType
makeLenses ''CreatureShape
deriveJSON defaultOptions ''Pulse
--deriveJSON defaultOptions ''CreatureStatistics
+7 -7
View File
@@ -21,7 +21,7 @@ itemEquipPict cr itmtree
, Just attachpos <- equipAttachPos <$> itm ^? itType . ibtEquip =
equipPosition esite cr attachpos (itemSPic itm)
| itm ^? itLocation . ilInvID == cr ^? crManipulation . manObject . imRootSelectedItem =
overPosSP (Q.prePos $ handHandleOrient loc cr) (itemTreeSPic itmtree)
overPosSP (Q.apply $ handHandleOrient loc cr) (itemTreeSPic itmtree)
| otherwise = mempty
where
itm = itmtree ^. dtValue . _1
@@ -29,13 +29,13 @@ itemEquipPict cr itmtree
equipAttachPos :: EquipItemType -> Point3Q
equipAttachPos = \case
BATTERYPACK -> (V3 (-8) 0 10, Q.qID)
FUELPACK -> (V3 (-9) 0 10, Q.qID)
BULLETBELTPACK -> (V3 (-9) 0 10, Q.qID)
BULLETBELTBRACER -> (V3 (-9) 0 10, Q.qID)
_ -> (0, Q.qID)
BATTERYPACK -> (V3 (-8) 0 10, Q.qid)
FUELPACK -> (V3 (-9) 0 10, Q.qid)
BULLETBELTPACK -> (V3 (-9) 0 10, Q.qid)
BULLETBELTBRACER -> (V3 (-9) 0 10, Q.qid)
_ -> (0, Q.qid)
equipPosition :: EquipSite -> Creature -> Point3Q -> SPic -> SPic
equipPosition es cr q =
overPosSP
(\x -> fst $ equipSitePQ es cr `Q.comp` q `Q.comp` (x, Q.qID))
(\x -> fst $ equipSitePQ es cr `Q.comp` q `Q.comp` (x, Q.qid))
+6 -6
View File
@@ -31,18 +31,18 @@ transToHandle itm = (-.-.- (0 & _xy .~ handlePos itm))
handleOrient :: LocationDT CItem -> Point3Q
handleOrient loc = case loc ^. locDT . dtValue . _1 . itType of
HELD FLAMETHROWER -> (V3 (-1) 0 0, Q.qID)
_ -> (V3 (-3) 0 0, Q.qID)
HELD FLAMETHROWER -> (V3 (-1) 0 0, Q.qid)
_ -> (V3 (-3) 0 0, Q.qid)
---- note this is relative to the creature
---- the aimstance here should match any aimstance in Aiming
--handOrient :: Creature -> AimStance -> Point3Q
--handOrient cr = case cr ^. crStance . posture of
-- Aiming {} -> \case
-- TwoHandUnder -> (V3 (-3) 0 shoulderHeight, Q.qID)
-- TwoHandOver -> (V3 0 0 shoulderHeight, Q.qID)
-- OneHand -> (V3 13 (-2) shoulderHeight, Q.qID)
-- TwoHandFlat -> (V3 13 0 shoulderHeight, Q.qID)
-- TwoHandUnder -> (V3 (-3) 0 shoulderHeight, Q.qid)
-- TwoHandOver -> (V3 0 0 shoulderHeight, Q.qid)
-- OneHand -> (V3 13 (-2) shoulderHeight, Q.qid)
-- TwoHandFlat -> (V3 13 0 shoulderHeight, Q.qid)
-- AtEase -> \case
-- OneHand -> rightHandPQ cr
-- TwoHandFlat -> (V3 10 0 15, Q.axisAngle (V3 0 0 1) $ twoFlatHRot cr)
+19 -19
View File
@@ -18,31 +18,31 @@ import qualified Quaternion as Q
orientChild :: Item -> Point3Q
orientChild itm = case _itType itm of
--HELD LED -> (V3 0 5 0, Q.qID)
HELD LED -> (V3 (-x) 0 0, Q.qID)
AMMOMAG BATTERY -> (V3 0 0 1, Q.qID)
AMMOMAG {} -> (V3 0 (2-itemShapeMax _y itm) 0, Q.qID)
--HELD LASER -> (V3 15 (-5) 0, Q.qID)
LASER -> (V3 15 (-5) 0, Q.qID)
--HELD LED -> (V3 0 5 0, Q.qid)
HELD LED -> (V3 (-x) 0 0, Q.qid)
AMMOMAG BATTERY -> (V3 0 0 1, Q.qid)
AMMOMAG {} -> (V3 0 (2-itemShapeMax _y itm) 0, Q.qid)
--HELD LASER -> (V3 15 (-5) 0, Q.qid)
LASER -> (V3 15 (-5) 0, Q.qid)
ATTACH UNDERBARRELSLOT -> (V3 10 (-8) 0, r)
_ -> (0, Q.qID)
_ -> (0, Q.qid)
where
--r = Q.axisAngle (V3 0 0 1) (-pi/4)
r = Q.qID
r = Q.qid
-- y = itemShapeMin _y itm
x = itemShapeMaxX itm
orientByParentChSF :: Item -> ItemSF -> Point3Q
orientByParentChSF itm lt = case (_itType itm, lt) of
(HELD FLAMETHROWER, AmmoMagSF{}) -> (V3 4 (-6) 0, Q.qID)
(HELD FLAMETHROWER, AmmoMagSF{}) -> (V3 4 (-6) 0, Q.qid)
(HELD (VOLLEYGUN n), AmmoMagSF i _)
-> (V3 2 (2.5 + fromIntegral i * 5 - (0.5 * 5 * fromIntegral n)) 3, Q.qz (pi/2))
(HELD ALTERIFLE, AmmoMagSF i _) -> alteRifleAmmoOrient itm i
(HELD _, AmmoMagSF{_amsfType = ElectricalAmmo}) -> (V3 0 0 z, Q.qID)
(HELD _, AmmoMagSF{}) -> (V3 7 (itemShapeMin _y itm) 0, Q.qID)
(HELD _, WeaponScopeSF) -> (V3 5 0 5, Q.qID)
(HELD _, TorchSF) -> (V3 x y 0, Q.qID)
_ -> (0, Q.qID)
(HELD _, AmmoMagSF{_amsfType = ElectricalAmmo}) -> (V3 0 0 z, Q.qid)
(HELD _, AmmoMagSF{}) -> (V3 7 (itemShapeMin _y itm) 0, Q.qid)
(HELD _, WeaponScopeSF) -> (V3 5 0 5, Q.qid)
(HELD _, TorchSF) -> (V3 x y 0, Q.qid)
_ -> (0, Q.qid)
where
x = itemShapeMaxX itm
y = itemShapeMaxY itm
@@ -50,7 +50,7 @@ orientByParentChSF itm lt = case (_itType itm, lt) of
alteRifleAmmoOrient :: Item -> Int -> Point3Q
alteRifleAmmoOrient itm = \case
1 -> (V3 18 (itemShapeMin _y itm + s + 1) 0, Q.qID)
1 -> (V3 18 (itemShapeMin _y itm + s + 1) 0, Q.qid)
_ -> (V3 18 (itemShapeMax _y itm + s - 1) 0, Q.qz pi)
where
s | itm ^? itParams . alteRifleSwitch == Just 0 = 1
@@ -79,9 +79,9 @@ itemShapeMin g = f . (^. _1) . itemSPic
orientAttachment :: Item -> CItem -> Point3Q
orientAttachment par (ch,chsf) = case (_itType par, chsf) of
(ATTACH UNDERBARRELSLOT, _) -> (V3 (-5) (-8) 0, Q.qID)
(_,LaserWeaponXSF {}) -> (V3 2 8 0, Q.qID)
-- (_,TorchSF) -> (V3 2 8 0, Q.qID)
(ATTACH UNDERBARRELSLOT, _) -> (V3 (-5) (-8) 0, Q.qid)
(_,LaserWeaponXSF {}) -> (V3 2 8 0, Q.qid)
-- (_,TorchSF) -> (V3 2 8 0, Q.qid)
-- (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)
@@ -92,5 +92,5 @@ orientAttachment par (ch,chsf) = case (_itType par, chsf) of
propagateOrientation :: DTree CItem -> DTree OItem
propagateOrientation = dtStartPropagate g f
where
g (x,y) = (x,y,(V3 0 0 0,Q.qID))
g (x,y) = (x,y,(V3 0 0 0,Q.qid))
f (x,_,pq) (y,y1) = (y,y1,Q.comp pq $ orientAttachment x (y,y1))
+6 -6
View File
@@ -6,7 +6,7 @@ WARNING: orphan instances concerning Aeson classes and Linear.Quaternion datatyp
The warnings have been disabled.
-}
module Quaternion (
qID,
qid,
qz,
qToV3,
qToV2,
@@ -14,7 +14,7 @@ module Quaternion (
rotateToZ,
vToQuat,
comp,
prePos,
apply,
module Linear.Quaternion,
qNoRoll,
) where
@@ -69,14 +69,14 @@ qToV2 = (\(V3 x y _) -> V2 x y) . qToV3
qToAng :: Quaternion Float -> Float
qToAng = argV . qToV2
qID :: Q.Quaternion Float
qID = Q.axisAngle (V3 1 0 0) 0
qid :: Q.Quaternion Float
qid = Q.axisAngle (V3 1 0 0) 0
comp :: Point3Q -> Point3Q -> Point3Q
comp (p,q) (p1,q1) = (p + Q.rotate q p1, q * q1)
prePos :: Point3Q -> Point3 -> Point3
prePos (p,q) p1 = p + Q.rotate q p1
apply :: Point3Q -> Point3 -> Point3
apply (p,q) p1 = p + Q.rotate q p1
qz :: Float -> Q.Quaternion Float
qz = Q.axisAngle (V3 0 0 1)