Work on crab feet
This commit is contained in:
@@ -69,7 +69,7 @@ drawHoverCrit cr = colorSH (_skinHead cskin)
|
||||
drawCrabCrit :: World -> Creature -> Shape
|
||||
drawCrabCrit w cr = mconcat
|
||||
[ crabUpperBody w cr
|
||||
, colorSH (_skinLower cskin) $ crabFeet cr
|
||||
, colorSH (_skinLower cskin) $ crabFeet w cr
|
||||
]
|
||||
where
|
||||
cskin = crShape $ _crType cr
|
||||
@@ -169,27 +169,48 @@ feet cr = case (cr ^? crType . strideAmount,cr ^? crType . footForward) of
|
||||
-- f i = 8 * (sLen - 2*i) / sLen
|
||||
f i = 8 * oneSmooth ((sLen - 2*i) / sLen)
|
||||
|
||||
crabFeet :: Creature -> Shape
|
||||
crabFeet :: World -> Creature -> Shape
|
||||
{-# INLINE crabFeet #-}
|
||||
crabFeet cr =
|
||||
uncurryV translateSHxy rpos afoot
|
||||
<> uncurryV translateSHxy (f (V2 0 10) rpos) afoot
|
||||
<> uncurryV translateSHxy lpos afoot
|
||||
<> uncurryV translateSHxy (f (V2 0 (-10)) lpos) afoot
|
||||
-- <> uncurryV translateSHxy (rotateV cdir $ cr ^?! crType . lFootPos - cxy) afoot
|
||||
-- <> uncurryV translateSHxy (rotateV cdir $ cxy - cr ^?! crType . lFootPos) afoot
|
||||
-- case (cr ^? crType . strideAmount,cr ^? crType . footForward) of
|
||||
-- (Just sa,Just LeftForward) -> sh (f sa)
|
||||
-- (Just sa,Just RightForward) -> sh (-f sa)
|
||||
-- _ -> sh 0
|
||||
crabFeet _ cr =
|
||||
uncurryV translateSHxy rpos (afoot & each . sfVs . each %~ Q.rotate r1)
|
||||
<> (afoot
|
||||
& each . sfVs . each %~ Q.rotate r2
|
||||
& each . sfVs . each +~ V3 0 2 5)
|
||||
<> uncurryV translateSHxy rpos' (afoot & each . sfVs . each %~ Q.rotate r1')
|
||||
<> (afoot
|
||||
& each . sfVs . each %~ Q.rotate r2'
|
||||
& each . sfVs . each +~ V3 0 2 5)
|
||||
<> uncurryV translateSHxy lpos (afoot & each . sfVs . each %~ Q.rotate l1)
|
||||
<> (afoot
|
||||
& each . sfVs . each %~ Q.rotate l2
|
||||
& each . sfVs . each +~ V3 0 (-2) 5)
|
||||
<> uncurryV translateSHxy lpos' (afoot & each . sfVs . each %~ Q.rotate l1')
|
||||
<> (afoot
|
||||
& each . sfVs . each %~ Q.rotate l2'
|
||||
& each . sfVs . each +~ V3 0 (-2) 5)
|
||||
where
|
||||
rpos = rot ( cr ^?! crType . rFootPos - cxy)
|
||||
rpos = rot (cr ^?! crType . rFootPos - cxy)
|
||||
rot = rotateV cdir
|
||||
lpos = rot ( cr ^?! crType . lFootPos - cxy)
|
||||
f p q = q + 2 *^ (p - q)
|
||||
cdir = -cr ^. crDir
|
||||
cxy = cr ^. crPos . _xy
|
||||
afoot = upperPrismPolyST 10 $ polyCirc 3 2
|
||||
(r1,r2) = spiderJoint (0 & _xy .~ rpos) (V3 0 2 5)
|
||||
rpos' = f (V2 0 10) rpos
|
||||
(r1',r2') = spiderJoint (0 & _xy .~ rpos') (V3 0 2 5)
|
||||
(l1,l2) = spiderJoint (0 & _xy .~ lpos) (V3 0 (-2) 5)
|
||||
lpos' = (f (V2 0 (-10)) lpos)
|
||||
(l1',l2') = spiderJoint (0 & _xy .~ lpos') (V3 0 (-2) 5)
|
||||
|
||||
spiderJoint :: Point3 -> Point3 -> (Q.Quaternion Float, Q.Quaternion Float)
|
||||
spiderJoint p q = (f $ Q.axisAngle (V3 0 (-1) 0) (pi - (a+b)), f . Q.axisAngle (V3 0 (-1) 0) $ a - b)
|
||||
--spiderJoint p q = (Q.qz c, Q.axisAngle (V3 0 (-1) 0) $ a)
|
||||
where
|
||||
a = angleThreeSides 10 (distance p q) 10
|
||||
b = angleVV3 (q-p) (V3 0 0 (-1))
|
||||
c = argV $ (p-q) ^. _xy
|
||||
f x = Q.qz c * x
|
||||
|
||||
deadFeet :: Creature -> Shape
|
||||
{-# INLINE deadFeet #-}
|
||||
|
||||
@@ -67,6 +67,12 @@ angleVV a b
|
||||
d = a `dotV` b
|
||||
in acos $ d / (ma * mb)
|
||||
|
||||
-- returns the angle opposite length a
|
||||
angleThreeSides :: Float -> Float -> Float -> Float
|
||||
angleThreeSides a b c = acos $ (f b + f c - f a) / (2*b*c)
|
||||
where
|
||||
f = (^ (2 ::Int))
|
||||
|
||||
-- | Safe version of 'angleVV' that returns 0 if either vector is null.
|
||||
safeAngleVV :: Point2 -> Point2 -> Float
|
||||
{-# INLINE safeAngleVV #-}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{-# LANGUAGE BangPatterns #-}
|
||||
module Geometry.Vector3D
|
||||
where
|
||||
import Linear
|
||||
import Geometry.Vector
|
||||
import Geometry.Data
|
||||
|
||||
@@ -121,7 +122,7 @@ dotV3 (V3 x y z) (V3 a b c) = x*a + y*b + z*c
|
||||
|
||||
angleVV3 :: Point3 -> Point3 -> Float
|
||||
angleVV3 a b
|
||||
| a == b = 0
|
||||
| a == b || norm a == 0 || norm b == 0 = 0
|
||||
| otherwise = acos $ dotV3 a b / (magV3 a * magV3 b)
|
||||
|
||||
--projV3 :: Point3 -> Point3 -> Point3
|
||||
|
||||
Reference in New Issue
Block a user