mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:24:00 +02:00
PitchTweak and friends become DeltaPitch
This commit is contained in:
parent
c354e980a8
commit
7949be0319
6 changed files with 37 additions and 37 deletions
|
@ -50,9 +50,9 @@ void FaceModel::maybeUpdateNeckRotation(const JointState& parentState, const FBX
|
|||
glm::mat3 axes = glm::mat3_cast(_rotation);
|
||||
glm::mat3 inverse = glm::mat3(glm::inverse(parentState.transform * glm::translate(state.translation) *
|
||||
joint.preTransform * glm::mat4_cast(joint.preRotation)));
|
||||
state.rotation = glm::angleAxis(- RADIANS_PER_DEGREE * _owningHead->getTweakedRoll(), glm::normalize(inverse * axes[2]))
|
||||
* glm::angleAxis(RADIANS_PER_DEGREE * _owningHead->getTweakedYaw(), glm::normalize(inverse * axes[1]))
|
||||
* glm::angleAxis(- RADIANS_PER_DEGREE * _owningHead->getTweakedPitch(), glm::normalize(inverse * axes[0]))
|
||||
state.rotation = glm::angleAxis(- RADIANS_PER_DEGREE * _owningHead->getFinalRoll(), glm::normalize(inverse * axes[2]))
|
||||
* glm::angleAxis(RADIANS_PER_DEGREE * _owningHead->getFinalYaw(), glm::normalize(inverse * axes[1]))
|
||||
* glm::angleAxis(- RADIANS_PER_DEGREE * _owningHead->getFinalPitch(), glm::normalize(inverse * axes[0]))
|
||||
* joint.rotation;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,9 +36,9 @@ Head::Head(Avatar* owningAvatar) :
|
|||
_leftEyeBlinkVelocity(0.0f),
|
||||
_rightEyeBlinkVelocity(0.0f),
|
||||
_timeWithoutTalking(0.0f),
|
||||
_pitchTweak(0.f),
|
||||
_yawTweak(0.f),
|
||||
_rollTweak(0.f),
|
||||
_deltaPitch(0.f),
|
||||
_deltaYaw(0.f),
|
||||
_deltaRoll(0.f),
|
||||
_isCameraMoving(false),
|
||||
_faceModel(this)
|
||||
{
|
||||
|
@ -180,7 +180,7 @@ void Head::setScale (float scale) {
|
|||
|
||||
glm::quat Head::getFinalOrientation() const {
|
||||
return _owningAvatar->getOrientation() * glm::quat(glm::radians(
|
||||
glm::vec3(getTweakedPitch(), getTweakedYaw(), getTweakedRoll() )));
|
||||
glm::vec3(getFinalPitch(), getFinalYaw(), getFinalRoll() )));
|
||||
}
|
||||
|
||||
glm::quat Head::getCameraOrientation () const {
|
||||
|
@ -197,16 +197,16 @@ glm::vec3 Head::getScalePivot() const {
|
|||
return _faceModel.isActive() ? _faceModel.getTranslation() : _position;
|
||||
}
|
||||
|
||||
float Head::getTweakedYaw() const {
|
||||
return glm::clamp(_baseYaw + _yawTweak, MIN_HEAD_YAW, MAX_HEAD_YAW);
|
||||
float Head::getFinalYaw() const {
|
||||
return glm::clamp(_baseYaw + _deltaYaw, MIN_HEAD_YAW, MAX_HEAD_YAW);
|
||||
}
|
||||
|
||||
float Head::getTweakedPitch() const {
|
||||
return glm::clamp(_basePitch + _pitchTweak, MIN_HEAD_PITCH, MAX_HEAD_PITCH);
|
||||
float Head::getFinalPitch() const {
|
||||
return glm::clamp(_basePitch + _deltaPitch, MIN_HEAD_PITCH, MAX_HEAD_PITCH);
|
||||
}
|
||||
|
||||
float Head::getTweakedRoll() const {
|
||||
return glm::clamp(_baseRoll + _rollTweak, MIN_HEAD_ROLL, MAX_HEAD_ROLL);
|
||||
float Head::getFinalRoll() const {
|
||||
return glm::clamp(_baseRoll + _deltaRoll, MIN_HEAD_ROLL, MAX_HEAD_ROLL);
|
||||
}
|
||||
|
||||
void Head::renderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosition, glm::vec3 lookatPosition) {
|
||||
|
|
|
@ -74,18 +74,18 @@ public:
|
|||
/// Returns the point about which scaling occurs.
|
||||
glm::vec3 getScalePivot() const;
|
||||
|
||||
void setPitchTweak(float pitch) { _pitchTweak = pitch; }
|
||||
float getPitchTweak() const { return _pitchTweak; }
|
||||
void setDeltaPitch(float pitch) { _deltaPitch = pitch; }
|
||||
float getDeltaPitch() const { return _deltaPitch; }
|
||||
|
||||
void setYawTweak(float yaw) { _yawTweak = yaw; }
|
||||
float getYawTweak() const { return _yawTweak; }
|
||||
void setDeltaYaw(float yaw) { _deltaYaw = yaw; }
|
||||
float getDeltaYaw() const { return _deltaYaw; }
|
||||
|
||||
void setRollTweak(float roll) { _rollTweak = roll; }
|
||||
float getRollTweak() const { return _rollTweak; }
|
||||
void setDeltaRoll(float roll) { _deltaRoll = roll; }
|
||||
float getDeltaRoll() const { return _deltaRoll; }
|
||||
|
||||
virtual float getTweakedPitch() const;
|
||||
virtual float getTweakedYaw() const;
|
||||
virtual float getTweakedRoll() const;
|
||||
virtual float getFinalPitch() const;
|
||||
virtual float getFinalYaw() const;
|
||||
virtual float getFinalRoll() const;
|
||||
|
||||
private:
|
||||
// disallow copies of the Head, copy of owning Avatar is disallowed too
|
||||
|
@ -111,9 +111,9 @@ private:
|
|||
float _timeWithoutTalking;
|
||||
|
||||
// tweaked angles affect the rendered head, but not the camera
|
||||
float _pitchTweak;
|
||||
float _yawTweak;
|
||||
float _rollTweak;
|
||||
float _deltaPitch;
|
||||
float _deltaYaw;
|
||||
float _deltaRoll;
|
||||
|
||||
bool _isCameraMoving;
|
||||
FaceModel _faceModel;
|
||||
|
|
|
@ -364,9 +364,9 @@ void MyAvatar::updateFromGyros(float deltaTime) {
|
|||
// restore rotation, lean to neutral positions
|
||||
const float RESTORE_PERIOD = 0.25f; // seconds
|
||||
float restorePercentage = glm::clamp(deltaTime/RESTORE_PERIOD, 0.f, 1.f);
|
||||
head->setPitchTweak(glm::mix(head->getPitchTweak(), 0.0f, restorePercentage));
|
||||
head->setYawTweak(glm::mix(head->getYawTweak(), 0.0f, restorePercentage));
|
||||
head->setRollTweak(glm::mix(head->getRollTweak(), 0.0f, restorePercentage));
|
||||
head->setDeltaPitch(glm::mix(head->getDeltaPitch(), 0.0f, restorePercentage));
|
||||
head->setDeltaYaw(glm::mix(head->getDeltaYaw(), 0.0f, restorePercentage));
|
||||
head->setDeltaRoll(glm::mix(head->getDeltaRoll(), 0.0f, restorePercentage));
|
||||
head->setLeanSideways(glm::mix(head->getLeanSideways(), 0.0f, restorePercentage));
|
||||
head->setLeanForward(glm::mix(head->getLeanForward(), 0.0f, restorePercentage));
|
||||
return;
|
||||
|
@ -377,9 +377,9 @@ void MyAvatar::updateFromGyros(float deltaTime) {
|
|||
const float AVATAR_HEAD_PITCH_MAGNIFY = 1.0f;
|
||||
const float AVATAR_HEAD_YAW_MAGNIFY = 1.0f;
|
||||
const float AVATAR_HEAD_ROLL_MAGNIFY = 1.0f;
|
||||
head->setPitchTweak(estimatedRotation.x * AVATAR_HEAD_PITCH_MAGNIFY);
|
||||
head->setYawTweak(estimatedRotation.y * AVATAR_HEAD_YAW_MAGNIFY);
|
||||
head->setRollTweak(estimatedRotation.z * AVATAR_HEAD_ROLL_MAGNIFY);
|
||||
head->setDeltaPitch(estimatedRotation.x * AVATAR_HEAD_PITCH_MAGNIFY);
|
||||
head->setDeltaYaw(estimatedRotation.y * AVATAR_HEAD_YAW_MAGNIFY);
|
||||
head->setDeltaRoll(estimatedRotation.z * AVATAR_HEAD_ROLL_MAGNIFY);
|
||||
|
||||
// Update torso lean distance based on accelerometer data
|
||||
const float TORSO_LENGTH = 0.5f;
|
||||
|
|
|
@ -93,9 +93,9 @@ QByteArray AvatarData::toByteArray() {
|
|||
destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _targetScale);
|
||||
|
||||
// Head rotation (NOTE: This needs to become a quaternion to save two bytes)
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getTweakedYaw());
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getTweakedPitch());
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getTweakedRoll());
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalYaw());
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalPitch());
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalRoll());
|
||||
|
||||
// Head lean X,Z (head lateral and fwd/back motion relative to torso)
|
||||
memcpy(destinationBuffer, &_headData->_leanSideways, sizeof(_headData->_leanSideways));
|
||||
|
|
|
@ -42,9 +42,9 @@ public:
|
|||
void setBasePitch(float pitch) { _basePitch = glm::clamp(pitch, MIN_HEAD_PITCH, MAX_HEAD_PITCH); }
|
||||
float getBaseRoll() const { return _baseRoll; }
|
||||
void setBaseRoll(float roll) { _baseRoll = glm::clamp(roll, MIN_HEAD_ROLL, MAX_HEAD_ROLL); }
|
||||
virtual float getTweakedYaw() const { return _baseYaw; }
|
||||
virtual float getTweakedPitch() const { return _basePitch; }
|
||||
virtual float getTweakedRoll() const { return _baseRoll; }
|
||||
virtual float getFinalYaw() const { return _baseYaw; }
|
||||
virtual float getFinalPitch() const { return _basePitch; }
|
||||
virtual float getFinalRoll() const { return _baseRoll; }
|
||||
|
||||
glm::quat getOrientation() const;
|
||||
void setOrientation(const glm::quat& orientation);
|
||||
|
|
Loading…
Reference in a new issue