mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 13:28:09 +02:00
Align hand with forearm in mouse-pointing mode.
This commit is contained in:
parent
7178147535
commit
0461335887
2 changed files with 26 additions and 1 deletions
|
@ -42,7 +42,7 @@ void SkeletonModel::simulate(float deltaTime) {
|
||||||
if (_owningAvatar->getHandState() == HAND_STATE_NULL) {
|
if (_owningAvatar->getHandState() == HAND_STATE_NULL) {
|
||||||
restoreRightHandPosition(HAND_RESTORATION_RATE);
|
restoreRightHandPosition(HAND_RESTORATION_RATE);
|
||||||
} else {
|
} else {
|
||||||
setRightHandPosition(_owningAvatar->getHandPosition());
|
applyHandPosition(geometry.rightHandJointIndex, _owningAvatar->getHandPosition());
|
||||||
}
|
}
|
||||||
restoreLeftHandPosition(HAND_RESTORATION_RATE);
|
restoreLeftHandPosition(HAND_RESTORATION_RATE);
|
||||||
|
|
||||||
|
@ -125,6 +125,29 @@ bool operator<(const IndexValue& firstIndex, const IndexValue& secondIndex) {
|
||||||
return firstIndex.value < secondIndex.value;
|
return firstIndex.value < secondIndex.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SkeletonModel::applyHandPosition(int jointIndex, const glm::vec3& position) {
|
||||||
|
if (jointIndex == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setJointPosition(jointIndex, position);
|
||||||
|
|
||||||
|
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
||||||
|
glm::vec3 handPosition, elbowPosition;
|
||||||
|
getJointPosition(jointIndex, handPosition);
|
||||||
|
getJointPosition(geometry.joints.at(jointIndex).parentIndex, elbowPosition);
|
||||||
|
glm::vec3 forearmVector = handPosition - elbowPosition;
|
||||||
|
float forearmLength = glm::length(forearmVector);
|
||||||
|
if (forearmLength < EPSILON) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
glm::quat handRotation;
|
||||||
|
getJointRotation(jointIndex, handRotation, true);
|
||||||
|
|
||||||
|
// align hand with forearm
|
||||||
|
float sign = (jointIndex == geometry.rightHandJointIndex) ? 1.0f : -1.0f;
|
||||||
|
applyRotationDelta(jointIndex, rotationBetween(handRotation * glm::vec3(-sign, 0.0f, 0.0f), forearmVector), false);
|
||||||
|
}
|
||||||
|
|
||||||
void SkeletonModel::applyPalmData(int jointIndex, const QVector<int>& fingerJointIndices,
|
void SkeletonModel::applyPalmData(int jointIndex, const QVector<int>& fingerJointIndices,
|
||||||
const QVector<int>& fingertipJointIndices, PalmData& palm) {
|
const QVector<int>& fingertipJointIndices, PalmData& palm) {
|
||||||
if (jointIndex == -1) {
|
if (jointIndex == -1) {
|
||||||
|
|
|
@ -28,6 +28,8 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
void applyHandPosition(int jointIndex, const glm::vec3& position);
|
||||||
|
|
||||||
void applyPalmData(int jointIndex, const QVector<int>& fingerJointIndices,
|
void applyPalmData(int jointIndex, const QVector<int>& fingerJointIndices,
|
||||||
const QVector<int>& fingertipJointIndices, PalmData& palm);
|
const QVector<int>& fingertipJointIndices, PalmData& palm);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue