PitchTweak and friends become DeltaPitch

This commit is contained in:
Andrew Meadows 2014-03-27 11:14:26 -07:00
parent c354e980a8
commit 7949be0319
6 changed files with 37 additions and 37 deletions

View file

@ -50,9 +50,9 @@ void FaceModel::maybeUpdateNeckRotation(const JointState& parentState, const FBX
glm::mat3 axes = glm::mat3_cast(_rotation); glm::mat3 axes = glm::mat3_cast(_rotation);
glm::mat3 inverse = glm::mat3(glm::inverse(parentState.transform * glm::translate(state.translation) * glm::mat3 inverse = glm::mat3(glm::inverse(parentState.transform * glm::translate(state.translation) *
joint.preTransform * glm::mat4_cast(joint.preRotation))); joint.preTransform * glm::mat4_cast(joint.preRotation)));
state.rotation = glm::angleAxis(- RADIANS_PER_DEGREE * _owningHead->getTweakedRoll(), glm::normalize(inverse * axes[2])) state.rotation = glm::angleAxis(- RADIANS_PER_DEGREE * _owningHead->getFinalRoll(), glm::normalize(inverse * axes[2]))
* glm::angleAxis(RADIANS_PER_DEGREE * _owningHead->getTweakedYaw(), glm::normalize(inverse * axes[1])) * glm::angleAxis(RADIANS_PER_DEGREE * _owningHead->getFinalYaw(), glm::normalize(inverse * axes[1]))
* glm::angleAxis(- RADIANS_PER_DEGREE * _owningHead->getTweakedPitch(), glm::normalize(inverse * axes[0])) * glm::angleAxis(- RADIANS_PER_DEGREE * _owningHead->getFinalPitch(), glm::normalize(inverse * axes[0]))
* joint.rotation; * joint.rotation;
} }

View file

@ -36,9 +36,9 @@ Head::Head(Avatar* owningAvatar) :
_leftEyeBlinkVelocity(0.0f), _leftEyeBlinkVelocity(0.0f),
_rightEyeBlinkVelocity(0.0f), _rightEyeBlinkVelocity(0.0f),
_timeWithoutTalking(0.0f), _timeWithoutTalking(0.0f),
_pitchTweak(0.f), _deltaPitch(0.f),
_yawTweak(0.f), _deltaYaw(0.f),
_rollTweak(0.f), _deltaRoll(0.f),
_isCameraMoving(false), _isCameraMoving(false),
_faceModel(this) _faceModel(this)
{ {
@ -180,7 +180,7 @@ void Head::setScale (float scale) {
glm::quat Head::getFinalOrientation() const { glm::quat Head::getFinalOrientation() const {
return _owningAvatar->getOrientation() * glm::quat(glm::radians( return _owningAvatar->getOrientation() * glm::quat(glm::radians(
glm::vec3(getTweakedPitch(), getTweakedYaw(), getTweakedRoll() ))); glm::vec3(getFinalPitch(), getFinalYaw(), getFinalRoll() )));
} }
glm::quat Head::getCameraOrientation () const { glm::quat Head::getCameraOrientation () const {
@ -197,16 +197,16 @@ glm::vec3 Head::getScalePivot() const {
return _faceModel.isActive() ? _faceModel.getTranslation() : _position; return _faceModel.isActive() ? _faceModel.getTranslation() : _position;
} }
float Head::getTweakedYaw() const { float Head::getFinalYaw() const {
return glm::clamp(_baseYaw + _yawTweak, MIN_HEAD_YAW, MAX_HEAD_YAW); return glm::clamp(_baseYaw + _deltaYaw, MIN_HEAD_YAW, MAX_HEAD_YAW);
} }
float Head::getTweakedPitch() const { float Head::getFinalPitch() const {
return glm::clamp(_basePitch + _pitchTweak, MIN_HEAD_PITCH, MAX_HEAD_PITCH); return glm::clamp(_basePitch + _deltaPitch, MIN_HEAD_PITCH, MAX_HEAD_PITCH);
} }
float Head::getTweakedRoll() const { float Head::getFinalRoll() const {
return glm::clamp(_baseRoll + _rollTweak, MIN_HEAD_ROLL, MAX_HEAD_ROLL); return glm::clamp(_baseRoll + _deltaRoll, MIN_HEAD_ROLL, MAX_HEAD_ROLL);
} }
void Head::renderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosition, glm::vec3 lookatPosition) { void Head::renderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosition, glm::vec3 lookatPosition) {

View file

@ -74,18 +74,18 @@ public:
/// Returns the point about which scaling occurs. /// Returns the point about which scaling occurs.
glm::vec3 getScalePivot() const; glm::vec3 getScalePivot() const;
void setPitchTweak(float pitch) { _pitchTweak = pitch; } void setDeltaPitch(float pitch) { _deltaPitch = pitch; }
float getPitchTweak() const { return _pitchTweak; } float getDeltaPitch() const { return _deltaPitch; }
void setYawTweak(float yaw) { _yawTweak = yaw; } void setDeltaYaw(float yaw) { _deltaYaw = yaw; }
float getYawTweak() const { return _yawTweak; } float getDeltaYaw() const { return _deltaYaw; }
void setRollTweak(float roll) { _rollTweak = roll; } void setDeltaRoll(float roll) { _deltaRoll = roll; }
float getRollTweak() const { return _rollTweak; } float getDeltaRoll() const { return _deltaRoll; }
virtual float getTweakedPitch() const; virtual float getFinalPitch() const;
virtual float getTweakedYaw() const; virtual float getFinalYaw() const;
virtual float getTweakedRoll() const; virtual float getFinalRoll() const;
private: private:
// disallow copies of the Head, copy of owning Avatar is disallowed too // disallow copies of the Head, copy of owning Avatar is disallowed too
@ -111,9 +111,9 @@ private:
float _timeWithoutTalking; float _timeWithoutTalking;
// tweaked angles affect the rendered head, but not the camera // tweaked angles affect the rendered head, but not the camera
float _pitchTweak; float _deltaPitch;
float _yawTweak; float _deltaYaw;
float _rollTweak; float _deltaRoll;
bool _isCameraMoving; bool _isCameraMoving;
FaceModel _faceModel; FaceModel _faceModel;

View file

@ -364,9 +364,9 @@ void MyAvatar::updateFromGyros(float deltaTime) {
// restore rotation, lean to neutral positions // restore rotation, lean to neutral positions
const float RESTORE_PERIOD = 0.25f; // seconds const float RESTORE_PERIOD = 0.25f; // seconds
float restorePercentage = glm::clamp(deltaTime/RESTORE_PERIOD, 0.f, 1.f); float restorePercentage = glm::clamp(deltaTime/RESTORE_PERIOD, 0.f, 1.f);
head->setPitchTweak(glm::mix(head->getPitchTweak(), 0.0f, restorePercentage)); head->setDeltaPitch(glm::mix(head->getDeltaPitch(), 0.0f, restorePercentage));
head->setYawTweak(glm::mix(head->getYawTweak(), 0.0f, restorePercentage)); head->setDeltaYaw(glm::mix(head->getDeltaYaw(), 0.0f, restorePercentage));
head->setRollTweak(glm::mix(head->getRollTweak(), 0.0f, restorePercentage)); head->setDeltaRoll(glm::mix(head->getDeltaRoll(), 0.0f, restorePercentage));
head->setLeanSideways(glm::mix(head->getLeanSideways(), 0.0f, restorePercentage)); head->setLeanSideways(glm::mix(head->getLeanSideways(), 0.0f, restorePercentage));
head->setLeanForward(glm::mix(head->getLeanForward(), 0.0f, restorePercentage)); head->setLeanForward(glm::mix(head->getLeanForward(), 0.0f, restorePercentage));
return; return;
@ -377,9 +377,9 @@ void MyAvatar::updateFromGyros(float deltaTime) {
const float AVATAR_HEAD_PITCH_MAGNIFY = 1.0f; const float AVATAR_HEAD_PITCH_MAGNIFY = 1.0f;
const float AVATAR_HEAD_YAW_MAGNIFY = 1.0f; const float AVATAR_HEAD_YAW_MAGNIFY = 1.0f;
const float AVATAR_HEAD_ROLL_MAGNIFY = 1.0f; const float AVATAR_HEAD_ROLL_MAGNIFY = 1.0f;
head->setPitchTweak(estimatedRotation.x * AVATAR_HEAD_PITCH_MAGNIFY); head->setDeltaPitch(estimatedRotation.x * AVATAR_HEAD_PITCH_MAGNIFY);
head->setYawTweak(estimatedRotation.y * AVATAR_HEAD_YAW_MAGNIFY); head->setDeltaYaw(estimatedRotation.y * AVATAR_HEAD_YAW_MAGNIFY);
head->setRollTweak(estimatedRotation.z * AVATAR_HEAD_ROLL_MAGNIFY); head->setDeltaRoll(estimatedRotation.z * AVATAR_HEAD_ROLL_MAGNIFY);
// Update torso lean distance based on accelerometer data // Update torso lean distance based on accelerometer data
const float TORSO_LENGTH = 0.5f; const float TORSO_LENGTH = 0.5f;

View file

@ -93,9 +93,9 @@ QByteArray AvatarData::toByteArray() {
destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _targetScale); destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _targetScale);
// Head rotation (NOTE: This needs to become a quaternion to save two bytes) // Head rotation (NOTE: This needs to become a quaternion to save two bytes)
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getTweakedYaw()); destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalYaw());
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getTweakedPitch()); destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalPitch());
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getTweakedRoll()); destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->getFinalRoll());
// Head lean X,Z (head lateral and fwd/back motion relative to torso) // Head lean X,Z (head lateral and fwd/back motion relative to torso)
memcpy(destinationBuffer, &_headData->_leanSideways, sizeof(_headData->_leanSideways)); memcpy(destinationBuffer, &_headData->_leanSideways, sizeof(_headData->_leanSideways));

View file

@ -42,9 +42,9 @@ public:
void setBasePitch(float pitch) { _basePitch = glm::clamp(pitch, MIN_HEAD_PITCH, MAX_HEAD_PITCH); } void setBasePitch(float pitch) { _basePitch = glm::clamp(pitch, MIN_HEAD_PITCH, MAX_HEAD_PITCH); }
float getBaseRoll() const { return _baseRoll; } float getBaseRoll() const { return _baseRoll; }
void setBaseRoll(float roll) { _baseRoll = glm::clamp(roll, MIN_HEAD_ROLL, MAX_HEAD_ROLL); } void setBaseRoll(float roll) { _baseRoll = glm::clamp(roll, MIN_HEAD_ROLL, MAX_HEAD_ROLL); }
virtual float getTweakedYaw() const { return _baseYaw; } virtual float getFinalYaw() const { return _baseYaw; }
virtual float getTweakedPitch() const { return _basePitch; } virtual float getFinalPitch() const { return _basePitch; }
virtual float getTweakedRoll() const { return _baseRoll; } virtual float getFinalRoll() const { return _baseRoll; }
glm::quat getOrientation() const; glm::quat getOrientation() const;
void setOrientation(const glm::quat& orientation); void setOrientation(const glm::quat& orientation);