Merge pull request #4023 from PhilipRosedale/master

Torso twists to follow head, fix bug with head rotations
This commit is contained in:
Andrew Meadows 2014-12-31 08:01:39 -08:00
commit ec1ef39a7f
7 changed files with 24 additions and 32 deletions

View file

@ -3636,16 +3636,6 @@ void Application::updateWindowTitle(){
QString title = QString() + (!username.isEmpty() ? username + " @ " : QString()) QString title = QString() + (!username.isEmpty() ? username + " @ " : QString())
+ AddressManager::getInstance().getCurrentDomain() + connectionStatus + buildVersion; + AddressManager::getInstance().getCurrentDomain() + connectionStatus + buildVersion;
AccountManager& accountManager = AccountManager::getInstance();
if (accountManager.getAccountInfo().hasBalance()) {
float creditBalance = accountManager.getAccountInfo().getBalance() / SATOSHIS_PER_CREDIT;
QString creditBalanceString;
creditBalanceString.sprintf("%.8f", creditBalance);
title += " - ₵" + creditBalanceString;
}
#ifndef WIN32 #ifndef WIN32
// crashes with vs2013/win32 // crashes with vs2013/win32
qDebug("Application title set to: %s", title.toStdString().c_str()); qDebug("Application title set to: %s", title.toStdString().c_str());

View file

@ -46,13 +46,18 @@ void FaceModel::simulate(float deltaTime, bool fullUpdate) {
} }
void FaceModel::maybeUpdateNeckRotation(const JointState& parentState, const FBXJoint& joint, JointState& state) { void FaceModel::maybeUpdateNeckRotation(const JointState& parentState, const FBXJoint& joint, JointState& state) {
Avatar* owningAvatar = static_cast<Avatar*>(_owningHead->_owningAvatar);
// get the rotation axes in joint space and use them to adjust the rotation // get the rotation axes in joint space and use them to adjust the rotation
glm::mat3 axes = glm::mat3_cast(glm::quat()); glm::mat3 axes = glm::mat3_cast(glm::quat());
glm::mat3 inverse = glm::mat3(glm::inverse(parentState.getTransform() * glm::translate(state.getDefaultTranslationInConstrainedFrame()) * glm::mat3 inverse = glm::mat3(glm::inverse(parentState.getTransform() * glm::translate(state.getDefaultTranslationInConstrainedFrame()) *
joint.preTransform * glm::mat4_cast(joint.preRotation))); joint.preTransform * glm::mat4_cast(joint.preRotation)));
state.setRotationInConstrainedFrame(glm::angleAxis(- RADIANS_PER_DEGREE * _owningHead->getFinalRoll(), glm::normalize(inverse * axes[2])) state.setRotationInConstrainedFrame(
* glm::angleAxis(RADIANS_PER_DEGREE * _owningHead->getFinalYaw(), glm::normalize(inverse * axes[1])) glm::angleAxis(- RADIANS_PER_DEGREE * (_owningHead->getFinalRoll() - owningAvatar->getHead()->getFinalLeanSideways()),
* glm::angleAxis(- RADIANS_PER_DEGREE * _owningHead->getFinalPitch(), glm::normalize(inverse * axes[0])) glm::normalize(inverse * axes[2]))
* glm::angleAxis(RADIANS_PER_DEGREE * (_owningHead->getFinalYaw() - _owningHead->getTorsoTwist()),
glm::normalize(inverse * axes[1]))
* glm::angleAxis(- RADIANS_PER_DEGREE * (_owningHead->getFinalPitch() - owningAvatar->getHead()->getFinalLeanForward()),
glm::normalize(inverse * axes[0]))
* joint.rotation, DEFAULT_PRIORITY); * joint.rotation, DEFAULT_PRIORITY);
} }

View file

@ -54,6 +54,7 @@ Head::Head(Avatar* owningAvatar) :
_deltaRoll(0.0f), _deltaRoll(0.0f),
_deltaLeanSideways(0.0f), _deltaLeanSideways(0.0f),
_deltaLeanForward(0.0f), _deltaLeanForward(0.0f),
_torsoTwist(0.0f),
_isCameraMoving(false), _isCameraMoving(false),
_isLookingAtMe(false), _isLookingAtMe(false),
_faceModel(this) _faceModel(this)
@ -88,7 +89,14 @@ void Head::simulate(float deltaTime, bool isMine, bool billboard) {
_blendshapeCoefficients = faceTracker->getBlendshapeCoefficients(); _blendshapeCoefficients = faceTracker->getBlendshapeCoefficients();
} }
} }
// Twist the upper body to follow the rotation of the head, but only do this with my avatar,
// since everyone else will see the full joint rotations for other people.
const float BODY_FOLLOW_HEAD_YAW_RATE = 0.1f;
const float BODY_FOLLOW_HEAD_FACTOR = 0.66f;
float currentTwist = getTorsoTwist();
setTorsoTwist(currentTwist + (getFinalYaw() * BODY_FOLLOW_HEAD_FACTOR - currentTwist) * BODY_FOLLOW_HEAD_YAW_RATE);
} }
// Update audio trailing average for rendering facial animations // Update audio trailing average for rendering facial animations
const float AUDIO_AVERAGING_SECS = 0.05f; const float AUDIO_AVERAGING_SECS = 0.05f;
const float AUDIO_LONG_TERM_AVERAGING_SECS = 30.0f; const float AUDIO_LONG_TERM_AVERAGING_SECS = 30.0f;

View file

@ -76,6 +76,9 @@ public:
float getFinalLeanSideways() const { return _leanSideways + _deltaLeanSideways; } float getFinalLeanSideways() const { return _leanSideways + _deltaLeanSideways; }
float getFinalLeanForward() const { return _leanForward + _deltaLeanForward; } float getFinalLeanForward() const { return _leanForward + _deltaLeanForward; }
float getTorsoTwist() const { return _torsoTwist; }
void setTorsoTwist(float torsoTwist) { _torsoTwist = torsoTwist; }
glm::quat getEyeRotation(const glm::vec3& eyePosition) const; glm::quat getEyeRotation(const glm::vec3& eyePosition) const;
const glm::vec3& getRightEyePosition() const { return _rightEyePosition; } const glm::vec3& getRightEyePosition() const { return _rightEyePosition; }
@ -149,6 +152,8 @@ private:
float _deltaLeanSideways; float _deltaLeanSideways;
float _deltaLeanForward; float _deltaLeanForward;
float _torsoTwist;
bool _isCameraMoving; bool _isCameraMoving;
bool _isLookingAtMe; bool _isLookingAtMe;
FaceModel _faceModel; FaceModel _faceModel;

View file

@ -296,11 +296,13 @@ void SkeletonModel::maybeUpdateLeanRotation(const JointState& parentState, Joint
} }
// get the rotation axes in joint space and use them to adjust the rotation // get the rotation axes in joint space and use them to adjust the rotation
glm::vec3 xAxis(1.0f, 0.0f, 0.0f); glm::vec3 xAxis(1.0f, 0.0f, 0.0f);
glm::vec3 yAxis(0.0f, 1.0f, 0.0f);
glm::vec3 zAxis(0.0f, 0.0f, 1.0f); glm::vec3 zAxis(0.0f, 0.0f, 1.0f);
glm::quat inverse = glm::inverse(parentState.getRotation() * state.getDefaultRotationInParentFrame()); glm::quat inverse = glm::inverse(parentState.getRotation() * state.getDefaultRotationInParentFrame());
state.setRotationInConstrainedFrame( state.setRotationInConstrainedFrame(
glm::angleAxis(- RADIANS_PER_DEGREE * _owningAvatar->getHead()->getFinalLeanSideways(), inverse * zAxis) glm::angleAxis(- RADIANS_PER_DEGREE * _owningAvatar->getHead()->getFinalLeanSideways(), inverse * zAxis)
* glm::angleAxis(- RADIANS_PER_DEGREE * _owningAvatar->getHead()->getFinalLeanForward(), inverse * xAxis) * glm::angleAxis(- RADIANS_PER_DEGREE * _owningAvatar->getHead()->getFinalLeanForward(), inverse * xAxis)
* glm::angleAxis(RADIANS_PER_DEGREE * _owningAvatar->getHead()->getTorsoTwist(), inverse * yAxis)
* state.getFBXJoint().rotation, LEAN_PRIORITY); * state.getFBXJoint().rotation, LEAN_PRIORITY);
} }

View file

@ -73,16 +73,3 @@ void HeadData::setBlendshape(QString name, float val) {
_blendshapeCoefficients[it.value()] = val; _blendshapeCoefficients[it.value()] = val;
} }
} }
void HeadData::addYaw(float yaw) {
setBaseYaw(_baseYaw + yaw);
}
void HeadData::addPitch(float pitch) {
setBasePitch(_basePitch + pitch);
}
void HeadData::addRoll(float roll) {
setBaseRoll(_baseRoll + roll);
}

View file

@ -65,11 +65,6 @@ public:
float getPupilDilation() const { return _pupilDilation; } float getPupilDilation() const { return _pupilDilation; }
void setPupilDilation(float pupilDilation) { _pupilDilation = pupilDilation; } void setPupilDilation(float pupilDilation) { _pupilDilation = pupilDilation; }
// degrees
void addYaw(float yaw);
void addPitch(float pitch);
void addRoll(float roll);
const glm::vec3& getLookAtPosition() const { return _lookAtPosition; } const glm::vec3& getLookAtPosition() const { return _lookAtPosition; }
void setLookAtPosition(const glm::vec3& lookAtPosition) { _lookAtPosition = lookAtPosition; } void setLookAtPosition(const glm::vec3& lookAtPosition) { _lookAtPosition = lookAtPosition; }