mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 08:49:05 +02:00
Provide option to align wrists with forearms.
This commit is contained in:
parent
09bb51261a
commit
0386dec2a6
3 changed files with 20 additions and 2 deletions
|
@ -336,6 +336,7 @@ Menu::Menu() :
|
||||||
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::PlaySlaps, 0, false);
|
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::PlaySlaps, 0, false);
|
||||||
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::HandsCollideWithSelf, 0, false);
|
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::HandsCollideWithSelf, 0, false);
|
||||||
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::ShowIKConstraints, 0, false);
|
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::ShowIKConstraints, 0, false);
|
||||||
|
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::AlignForearmsWithWrists, 0, true);
|
||||||
|
|
||||||
addDisabledActionAndSeparator(developerMenu, "Testing");
|
addDisabledActionAndSeparator(developerMenu, "Testing");
|
||||||
|
|
||||||
|
|
|
@ -256,6 +256,7 @@ private:
|
||||||
|
|
||||||
namespace MenuOption {
|
namespace MenuOption {
|
||||||
const QString AboutApp = "About Interface";
|
const QString AboutApp = "About Interface";
|
||||||
|
const QString AlignForearmsWithWrists = "Align Forearms with Wrists";
|
||||||
const QString AmbientOcclusion = "Ambient Occlusion";
|
const QString AmbientOcclusion = "Ambient Occlusion";
|
||||||
const QString Atmosphere = "Atmosphere";
|
const QString Atmosphere = "Atmosphere";
|
||||||
const QString AudioNoiseReduction = "Audio Noise Reduction";
|
const QString AudioNoiseReduction = "Audio Noise Reduction";
|
||||||
|
|
|
@ -148,10 +148,18 @@ void SkeletonModel::applyPalmData(int jointIndex, const QVector<int>& fingerJoin
|
||||||
}
|
}
|
||||||
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
||||||
float sign = (jointIndex == geometry.rightHandJointIndex) ? 1.0f : -1.0f;
|
float sign = (jointIndex == geometry.rightHandJointIndex) ? 1.0f : -1.0f;
|
||||||
|
int parentJointIndex = geometry.joints.at(jointIndex).parentIndex;
|
||||||
|
if (parentJointIndex == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// rotate palm to align with palm direction
|
// rotate palm to align with palm direction
|
||||||
glm::quat palmRotation;
|
glm::quat palmRotation;
|
||||||
getJointRotation(jointIndex, palmRotation, true);
|
if (Menu::getInstance()->isOptionChecked(MenuOption::AlignForearmsWithWrists)) {
|
||||||
|
getJointRotation(parentJointIndex, palmRotation, true);
|
||||||
|
} else {
|
||||||
|
getJointRotation(jointIndex, palmRotation, true);
|
||||||
|
}
|
||||||
palmRotation = rotationBetween(palmRotation * geometry.palmDirection, palm.getNormal()) * palmRotation;
|
palmRotation = rotationBetween(palmRotation * geometry.palmDirection, palm.getNormal()) * palmRotation;
|
||||||
|
|
||||||
// sort the finger indices by raw x, get the average direction
|
// sort the finger indices by raw x, get the average direction
|
||||||
|
@ -177,7 +185,15 @@ void SkeletonModel::applyPalmData(int jointIndex, const QVector<int>& fingerJoin
|
||||||
}
|
}
|
||||||
|
|
||||||
// set hand position, rotation
|
// set hand position, rotation
|
||||||
setJointPosition(jointIndex, palm.getPosition(), palmRotation, true);
|
if (Menu::getInstance()->isOptionChecked(MenuOption::AlignForearmsWithWrists)) {
|
||||||
|
glm::vec3 forearmVector = palmRotation * glm::vec3(sign, 0.0f, 0.0f);
|
||||||
|
setJointPosition(parentJointIndex, palm.getPosition() + forearmVector *
|
||||||
|
geometry.joints.at(jointIndex).distanceToParent * extractUniformScale(_scale), palmRotation, true);
|
||||||
|
_jointStates[jointIndex].rotation = glm::quat();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
setJointPosition(jointIndex, palm.getPosition(), palmRotation, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonModel::updateJointState(int index) {
|
void SkeletonModel::updateJointState(int index) {
|
||||||
|
|
Loading…
Reference in a new issue