mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-24 13:45:31 +02:00
Attempting to rotate longitudinally at elbow, rather than wrist.
This commit is contained in:
parent
2633223f4e
commit
817946bed5
3 changed files with 22 additions and 3 deletions
|
@ -141,6 +141,24 @@ void SkeletonModel::applyPalmData(int jointIndex, const QVector<int>& fingerJoin
|
|||
float sign = (jointIndex == geometry.rightHandJointIndex) ? 1.0f : -1.0f;
|
||||
glm::quat palmRotation;
|
||||
getJointRotation(jointIndex, palmRotation, true);
|
||||
|
||||
// start by rotating the elbow into place
|
||||
int parentIndex = geometry.joints[jointIndex].parentIndex;
|
||||
if (parentIndex != -1) {
|
||||
glm::vec3 boneVector = extractTranslation(_jointStates[jointIndex].transform) -
|
||||
extractTranslation(_jointStates[parentIndex].transform);
|
||||
float boneLength = glm::length(boneVector);
|
||||
if (boneLength > EPSILON) {
|
||||
boneVector /= boneLength;
|
||||
applyRotationDelta(parentIndex, rotationBetween(
|
||||
glm::cross(boneVector, glm::cross(palmRotation * geometry.palmDirection, boneVector)),
|
||||
glm::cross(boneVector, glm::cross(palm.getNormal(), boneVector))), false);
|
||||
updateJointState(jointIndex);
|
||||
getJointRotation(jointIndex, palmRotation, true);
|
||||
}
|
||||
}
|
||||
|
||||
// continue with the wrist
|
||||
applyRotationDelta(jointIndex, rotationBetween(palmRotation * geometry.palmDirection, palm.getNormal()));
|
||||
getJointRotation(jointIndex, palmRotation, true);
|
||||
|
||||
|
|
|
@ -680,10 +680,11 @@ float Model::getLimbLength(int jointIndex) const {
|
|||
return length;
|
||||
}
|
||||
|
||||
void Model::applyRotationDelta(int jointIndex, const glm::quat& delta) {
|
||||
void Model::applyRotationDelta(int jointIndex, const glm::quat& delta, bool constrain) {
|
||||
JointState& state = _jointStates[jointIndex];
|
||||
const FBXJoint& joint = _geometry->getFBXGeometry().joints[jointIndex];
|
||||
if (joint.rotationMin == glm::vec3(-180.0f, -180.0f, -180.0f) && joint.rotationMax == glm::vec3(180.0f, 180.0f, 180.0f)) {
|
||||
if (!constrain || (joint.rotationMin == glm::vec3(-180.0f, -180.0f, -180.0f) &&
|
||||
joint.rotationMax == glm::vec3(180.0f, 180.0f, 180.0f))) {
|
||||
// no constraints
|
||||
state.rotation = state.rotation * glm::inverse(state.combinedRotation) * delta * state.combinedRotation;
|
||||
state.combinedRotation = delta * state.combinedRotation;
|
||||
|
|
|
@ -157,7 +157,7 @@ protected:
|
|||
/// first free ancestor.
|
||||
float getLimbLength(int jointIndex) const;
|
||||
|
||||
void applyRotationDelta(int jointIndex, const glm::quat& delta);
|
||||
void applyRotationDelta(int jointIndex, const glm::quat& delta, bool constrain = true);
|
||||
|
||||
private:
|
||||
|
||||
|
|
Loading…
Reference in a new issue