mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
move grab position to front of palm
This commit is contained in:
parent
2501be16cb
commit
1e69c12e87
1 changed files with 40 additions and 6 deletions
|
@ -236,17 +236,51 @@ void SkeletonModel::applyPalmData(int jointIndex, const PalmData& palm) {
|
|||
}
|
||||
|
||||
bool SkeletonModel::getLeftGrabPosition(glm::vec3& position) const {
|
||||
int index = _rig->indexOfJoint("LeftHandMiddle1");
|
||||
if (index >= 0) {
|
||||
return getJointPositionInWorldFrame(index, position);
|
||||
int knuckleIndex = _rig->indexOfJoint("LeftHandMiddle1");
|
||||
int handIndex = _rig->indexOfJoint("LeftHand");
|
||||
if (knuckleIndex >= 0 && handIndex >= 0) {
|
||||
glm::quat handRotation;
|
||||
glm::vec3 knucklePosition;
|
||||
glm::vec3 handPosition;
|
||||
if (!getJointPositionInWorldFrame(knuckleIndex, knucklePosition)) {
|
||||
return false;
|
||||
}
|
||||
if (!getJointPositionInWorldFrame(handIndex, handPosition)) {
|
||||
return false;
|
||||
}
|
||||
if (!getJointRotationInWorldFrame(handIndex, handRotation)) {
|
||||
return false;
|
||||
}
|
||||
float halfPalmLength = glm::distance(knucklePosition, handPosition) * 0.5f;
|
||||
// z azis is standardized to be out of the palm. move from the knuckle-joint away from the palm
|
||||
// by 1/2 the palm length.
|
||||
position = knucklePosition + handRotation * (glm::vec3(0.0f, 0.0f, 1.0f) * halfPalmLength);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SkeletonModel::getRightGrabPosition(glm::vec3& position) const {
|
||||
int index = _rig->indexOfJoint("RightHandMiddle1");
|
||||
if (index >= 0) {
|
||||
return getJointPositionInWorldFrame(index, position);
|
||||
int knuckleIndex = _rig->indexOfJoint("RightHandMiddle1");
|
||||
int handIndex = _rig->indexOfJoint("RightHand");
|
||||
if (knuckleIndex >= 0 && handIndex >= 0) {
|
||||
glm::quat handRotation;
|
||||
glm::vec3 knucklePosition;
|
||||
glm::vec3 handPosition;
|
||||
if (!getJointPositionInWorldFrame(knuckleIndex, knucklePosition)) {
|
||||
return false;
|
||||
}
|
||||
if (!getJointPositionInWorldFrame(handIndex, handPosition)) {
|
||||
return false;
|
||||
}
|
||||
if (!getJointRotationInWorldFrame(handIndex, handRotation)) {
|
||||
return false;
|
||||
}
|
||||
float halfPalmLength = glm::distance(knucklePosition, handPosition) * 0.5f;
|
||||
// z azis is standardized to be out of the palm. move from the knuckle-joint away from the palm
|
||||
// by 1/2 the palm length.
|
||||
position = knucklePosition + handRotation * (glm::vec3(0.0f, 0.0f, 1.0f) * halfPalmLength);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue