mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 00:13:29 +02:00
first pass hookup of seated rotation with acceleration and animation response
This commit is contained in:
parent
8e11d91c03
commit
c36c4a17b1
3 changed files with 51 additions and 2 deletions
|
@ -3513,8 +3513,21 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
||||||
}
|
}
|
||||||
setWorldOrientation(glm::slerp(getWorldOrientation(), faceRotation, blend));
|
setWorldOrientation(glm::slerp(getWorldOrientation(), faceRotation, blend));
|
||||||
} else if (isRotatingWhileSeated) {
|
} else if (isRotatingWhileSeated) {
|
||||||
float rotatingWhileSeatedYaw = -getDriveKey(TRANSLATE_X) * _yawSpeed * deltaTime;
|
|
||||||
setWorldOrientation(getWorldOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, rotatingWhileSeatedYaw, 0.0f))));
|
float seatedTargetSpeed = -getDriveKey(TRANSLATE_X) * _yawSpeed;
|
||||||
|
|
||||||
|
const float SEATED_ROTATION_RAMP_TIMESCALE = 0.5f;
|
||||||
|
float blend = deltaTime / SEATED_ROTATION_RAMP_TIMESCALE;
|
||||||
|
if (blend > 1.0f) {
|
||||||
|
blend = 1.0f;
|
||||||
|
}
|
||||||
|
_seatedBodyYawDelta = (1.0f - blend) * _seatedBodyYawDelta + blend * seatedTargetSpeed;
|
||||||
|
setWorldOrientation(getWorldOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, _seatedBodyYawDelta, 0.0f))));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//float rotatingWhileSeatedYaw = -getDriveKey(TRANSLATE_X) * _yawSpeed * deltaTime;
|
||||||
|
//setWorldOrientation(getWorldOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, rotatingWhileSeatedYaw, 0.0f))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1245,6 +1245,9 @@ void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPos
|
||||||
_animVars.set("isNotInAir", true);
|
_animVars.set("isNotInAir", true);
|
||||||
_animVars.set("isSeated", false);
|
_animVars.set("isSeated", false);
|
||||||
_animVars.set("isNotSeated", true);
|
_animVars.set("isNotSeated", true);
|
||||||
|
_animVars.set("isSeatedTurningRight", false);
|
||||||
|
_animVars.set("isSeatedTurningLeft", false);
|
||||||
|
_animVars.set("isSeatedNotTurning", false);
|
||||||
|
|
||||||
} else if (_state == RigRole::Turn) {
|
} else if (_state == RigRole::Turn) {
|
||||||
if (turningSpeed > 0.0f) {
|
if (turningSpeed > 0.0f) {
|
||||||
|
@ -1275,6 +1278,9 @@ void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPos
|
||||||
_animVars.set("isNotInAir", true);
|
_animVars.set("isNotInAir", true);
|
||||||
_animVars.set("isSeated", false);
|
_animVars.set("isSeated", false);
|
||||||
_animVars.set("isNotSeated", true);
|
_animVars.set("isNotSeated", true);
|
||||||
|
_animVars.set("isSeatedTurningRight", false);
|
||||||
|
_animVars.set("isSeatedTurningLeft", false);
|
||||||
|
_animVars.set("isSeatedNotTurning", false);
|
||||||
|
|
||||||
} else if (_state == RigRole::Idle) {
|
} else if (_state == RigRole::Idle) {
|
||||||
// default anim vars to notMoving and notTurning
|
// default anim vars to notMoving and notTurning
|
||||||
|
@ -1298,6 +1304,9 @@ void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPos
|
||||||
_animVars.set("isNotInAir", true);
|
_animVars.set("isNotInAir", true);
|
||||||
_animVars.set("isSeated", false);
|
_animVars.set("isSeated", false);
|
||||||
_animVars.set("isNotSeated", true);
|
_animVars.set("isNotSeated", true);
|
||||||
|
_animVars.set("isSeatedTurningRight", false);
|
||||||
|
_animVars.set("isSeatedTurningLeft", false);
|
||||||
|
_animVars.set("isSeatedNotTurning", false);
|
||||||
|
|
||||||
} else if (_state == RigRole::Hover) {
|
} else if (_state == RigRole::Hover) {
|
||||||
// flying.
|
// flying.
|
||||||
|
@ -1321,6 +1330,9 @@ void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPos
|
||||||
_animVars.set("isNotInAir", true);
|
_animVars.set("isNotInAir", true);
|
||||||
_animVars.set("isSeated", false);
|
_animVars.set("isSeated", false);
|
||||||
_animVars.set("isNotSeated", true);
|
_animVars.set("isNotSeated", true);
|
||||||
|
_animVars.set("isSeatedTurningRight", false);
|
||||||
|
_animVars.set("isSeatedTurningLeft", false);
|
||||||
|
_animVars.set("isSeatedNotTurning", false);
|
||||||
|
|
||||||
} else if (_state == RigRole::Takeoff) {
|
} else if (_state == RigRole::Takeoff) {
|
||||||
// jumping in-air
|
// jumping in-air
|
||||||
|
@ -1352,6 +1364,9 @@ void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPos
|
||||||
_animVars.set("isNotInAir", false);
|
_animVars.set("isNotInAir", false);
|
||||||
_animVars.set("isSeated", false);
|
_animVars.set("isSeated", false);
|
||||||
_animVars.set("isNotSeated", true);
|
_animVars.set("isNotSeated", true);
|
||||||
|
_animVars.set("isSeatedTurningRight", false);
|
||||||
|
_animVars.set("isSeatedTurningLeft", false);
|
||||||
|
_animVars.set("isSeatedNotTurning", false);
|
||||||
|
|
||||||
} else if (_state == RigRole::InAir) {
|
} else if (_state == RigRole::InAir) {
|
||||||
// jumping in-air
|
// jumping in-air
|
||||||
|
@ -1372,6 +1387,9 @@ void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPos
|
||||||
_animVars.set("isNotTakeoff", true);
|
_animVars.set("isNotTakeoff", true);
|
||||||
_animVars.set("isSeated", false);
|
_animVars.set("isSeated", false);
|
||||||
_animVars.set("isNotSeated", true);
|
_animVars.set("isNotSeated", true);
|
||||||
|
_animVars.set("isSeatedTurningRight", false);
|
||||||
|
_animVars.set("isSeatedTurningLeft", false);
|
||||||
|
_animVars.set("isSeatedNotTurning", false);
|
||||||
|
|
||||||
bool inAirRun = forwardSpeed > 0.1f;
|
bool inAirRun = forwardSpeed > 0.1f;
|
||||||
if (inAirRun) {
|
if (inAirRun) {
|
||||||
|
@ -1394,6 +1412,23 @@ void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPos
|
||||||
|
|
||||||
_animVars.set("inAirAlpha", alpha);
|
_animVars.set("inAirAlpha", alpha);
|
||||||
} else if (_state == RigRole::Seated) {
|
} else if (_state == RigRole::Seated) {
|
||||||
|
if (turningSpeed > 0.05f) {
|
||||||
|
// seated turning right
|
||||||
|
_animVars.set("isSeatedTurningRight", true);
|
||||||
|
_animVars.set("isSeatedTurningLeft", false);
|
||||||
|
_animVars.set("isSeatedNotTurning", false);
|
||||||
|
} else if (turningSpeed < -0.05f) {
|
||||||
|
// seated turning left
|
||||||
|
_animVars.set("isSeatedTurningRight", false);
|
||||||
|
_animVars.set("isSeatedTurningLeft", true);
|
||||||
|
_animVars.set("isSeatedNotTurning", false);
|
||||||
|
} else {
|
||||||
|
// seated not turning
|
||||||
|
_animVars.set("isSeatedTurningRight", false);
|
||||||
|
_animVars.set("isSeatedTurningLeft", false);
|
||||||
|
_animVars.set("isSeatedNotTurning", true);
|
||||||
|
}
|
||||||
|
|
||||||
_animVars.set("isMovingForward", false);
|
_animVars.set("isMovingForward", false);
|
||||||
_animVars.set("isMovingBackward", false);
|
_animVars.set("isMovingBackward", false);
|
||||||
_animVars.set("isMovingRight", false);
|
_animVars.set("isMovingRight", false);
|
||||||
|
|
|
@ -662,6 +662,7 @@ protected:
|
||||||
std::vector<std::shared_ptr<Model>> _attachmentsToDelete;
|
std::vector<std::shared_ptr<Model>> _attachmentsToDelete;
|
||||||
|
|
||||||
float _bodyYawDelta { 0.0f }; // degrees/sec
|
float _bodyYawDelta { 0.0f }; // degrees/sec
|
||||||
|
float _seatedBodyYawDelta{ 0.0f }; //degrees/sec
|
||||||
|
|
||||||
// These position histories and derivatives are in the world-frame.
|
// These position histories and derivatives are in the world-frame.
|
||||||
// The derivatives are the MEASURED results of all external and internal forces
|
// The derivatives are the MEASURED results of all external and internal forces
|
||||||
|
|
Loading…
Reference in a new issue