mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +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 {
|
bool SkeletonModel::getLeftGrabPosition(glm::vec3& position) const {
|
||||||
int index = _rig->indexOfJoint("LeftHandMiddle1");
|
int knuckleIndex = _rig->indexOfJoint("LeftHandMiddle1");
|
||||||
if (index >= 0) {
|
int handIndex = _rig->indexOfJoint("LeftHand");
|
||||||
return getJointPositionInWorldFrame(index, position);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkeletonModel::getRightGrabPosition(glm::vec3& position) const {
|
bool SkeletonModel::getRightGrabPosition(glm::vec3& position) const {
|
||||||
int index = _rig->indexOfJoint("RightHandMiddle1");
|
int knuckleIndex = _rig->indexOfJoint("RightHandMiddle1");
|
||||||
if (index >= 0) {
|
int handIndex = _rig->indexOfJoint("RightHand");
|
||||||
return getJointPositionInWorldFrame(index, position);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue