ANIMATION: updated swim animation
parent
33943a1e02
commit
8b86ed2deb
|
@ -13,13 +13,14 @@ void update(float animTime, float velocity, CharacterSkeleton &skeleton, const C
|
|||
const float timeFactor = skeletonAttr.runTimeFactor;
|
||||
const float sine = glm::sin(animTime * timeFactor);
|
||||
const float cosine = glm::cos(animTime * timeFactor);
|
||||
const float cosineSlow = glm::cos(animTime * timeFactor / 4.0f);
|
||||
const float movement = sine * 0.15f;
|
||||
const glm::vec2 headLook(glm::cos(animTime) * 0.01f + glm::radians(10.0f), sine * 0.1f);
|
||||
const glm::vec2 headLook(glm::cos(animTime) * 0.1f + glm::radians(-30.0f), sine * 0.1f);
|
||||
|
||||
velocity = glm::clamp(velocity / 20.0f, 0.1f, 2.5f);
|
||||
|
||||
Bone &head = skeleton.headBone(skeletonAttr);
|
||||
head.translation = glm::vec3(0.0f, skeletonAttr.neckHeight + skeletonAttr.headY + cosine * 1.3f, -1.0f + skeletonAttr.neckForward);
|
||||
head.translation = glm::vec3(0.0f, skeletonAttr.neckHeight + skeletonAttr.headY + cosine * 1.3f + 0.5f, -1.0f + skeletonAttr.neckForward);
|
||||
head.orientation = rotateXY(headLook.x, headLook.y);
|
||||
|
||||
const float bodyMoveY = cosine * 0.5f;
|
||||
|
@ -36,17 +37,17 @@ void update(float animTime, float velocity, CharacterSkeleton &skeleton, const C
|
|||
pants.orientation = rotateY(movement);
|
||||
|
||||
const float handAngle = sine * 0.05f;
|
||||
const float handMoveY = cosine * 4.0f;
|
||||
const float handMoveX = cosine * 2.0f;
|
||||
const float handMoveY = cosineSlow * 3.0f;
|
||||
const float handMoveX = glm::abs(cosineSlow * 4.0f);
|
||||
Bone &righthand = skeleton.handBone(BoneId::RightHand, skeletonAttr);
|
||||
righthand.translation = glm::vec3(skeletonAttr.handRight + handMoveX, handMoveY, skeletonAttr.handForward);
|
||||
righthand.translation = glm::vec3(skeletonAttr.handRight + 0.1f + handMoveX, handMoveY, skeletonAttr.handForward);
|
||||
righthand.orientation = rotateX(handAngle);
|
||||
|
||||
Bone &lefthand = skeleton.handBone(BoneId::LeftHand, skeletonAttr);
|
||||
lefthand = mirrorXZ(righthand);
|
||||
lefthand.orientation = rotateX(-handAngle);
|
||||
|
||||
const float footAngle = cosine * 0.05f;
|
||||
const float footAngle = cosine * 0.5f;
|
||||
const float footMoveY = cosine * 0.001f;
|
||||
Bone &rightfoot = skeleton.footBone(BoneId::RightFoot, skeletonAttr);
|
||||
rightfoot.translation = glm::vec3(skeletonAttr.footRight, skeletonAttr.hipOffset - footMoveY, 0.0f);
|
||||
|
@ -56,13 +57,16 @@ void update(float animTime, float velocity, CharacterSkeleton &skeleton, const C
|
|||
leftfoot = mirrorX(rightfoot);
|
||||
leftfoot.orientation = rotateX(-footAngle);
|
||||
|
||||
skeleton.toolBone(skeletonAttr, cosine * 0.25f);
|
||||
Bone& tool = skeleton.bone(BoneId::Tool);
|
||||
tool.scale = glm::vec3(skeletonAttr.toolScale * 0.8f);
|
||||
tool.translation = glm::vec3(skeletonAttr.toolRight, skeletonAttr.pantsY, skeletonAttr.toolForward);
|
||||
tool.orientation = rotateYZ(glm::radians(-90.0f), glm::radians(110.0f));
|
||||
|
||||
Bone &rightshoulder = skeleton.shoulderBone(BoneId::RightShoulder, skeletonAttr, rotateX(sine * 0.15f));
|
||||
|
||||
Bone &torso = skeleton.torsoBone(skeletonAttr.scaler);
|
||||
torso.translation = glm::vec3(0.0f, 0.5f + sine * 0.04f, 0.0f);
|
||||
torso.orientation = rotateXZ(glm::half_pi<float>() + cosine * 0.1f, cosine * 0.1f);
|
||||
torso.translation = glm::vec3(0.0f, 0.5f + sine * 0.04f, -skeletonAttr.beltY * torso.scale.z);
|
||||
torso.orientation = rotateXZ(glm::half_pi<float>() + -0.2f + cosine * 0.15f, cosine * 0.1f);
|
||||
|
||||
skeleton.bone(BoneId::Glider) = zero();
|
||||
skeleton.bone(BoneId::LeftShoulder) = mirrorX(rightshoulder);
|
||||
|
|
Loading…
Reference in New Issue