mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 15:38:00 +02:00
Adjustments to wrist rotations.
This commit is contained in:
parent
f0e72d8d0c
commit
4360621daf
5 changed files with 19 additions and 10 deletions
|
@ -136,10 +136,11 @@ bool operator<(const IndexValue& firstIndex, const IndexValue& secondIndex) {
|
||||||
|
|
||||||
void SkeletonModel::applyPalmData(int jointIndex, const QVector<int>& fingertipJointIndices, PalmData& palm) {
|
void SkeletonModel::applyPalmData(int jointIndex, const QVector<int>& fingertipJointIndices, PalmData& palm) {
|
||||||
setJointPosition(jointIndex, palm.getPosition());
|
setJointPosition(jointIndex, palm.getPosition());
|
||||||
setJointRotation(jointIndex, rotationBetween(_rotation * IDENTITY_UP, palm.getNormal()) * _rotation);
|
setJointRotation(jointIndex, rotationBetween(_rotation * IDENTITY_UP, palm.getNormal()) * _rotation *
|
||||||
|
glm::angleAxis(90.0f, 0.0f, jointIndex == _geometry->getFBXGeometry().rightHandJointIndex ? 1.0f : -1.0f, 0.0f), true);
|
||||||
|
|
||||||
// no point in continuing if there are no fingers
|
// no point in continuing if there are no fingers
|
||||||
if (palm.getNumFingers() == 0) {
|
if (true || palm.getNumFingers() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1073,17 +1073,18 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
glm::quat combinedRotation = model.preRotation * model.rotation * model.postRotation;
|
glm::quat combinedRotation = model.preRotation * model.rotation * model.postRotation;
|
||||||
if (joint.parentIndex == -1) {
|
if (joint.parentIndex == -1) {
|
||||||
joint.transform = geometry.offset * model.preTransform * glm::mat4_cast(combinedRotation) * model.postTransform;
|
joint.transform = geometry.offset * model.preTransform * glm::mat4_cast(combinedRotation) * model.postTransform;
|
||||||
joint.inverseBindRotation = glm::inverse(combinedRotation);
|
joint.inverseDefaultRotation = glm::inverse(combinedRotation);
|
||||||
joint.distanceToParent = 0.0f;
|
joint.distanceToParent = 0.0f;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const FBXJoint& parentJoint = geometry.joints.at(joint.parentIndex);
|
const FBXJoint& parentJoint = geometry.joints.at(joint.parentIndex);
|
||||||
joint.transform = parentJoint.transform *
|
joint.transform = parentJoint.transform *
|
||||||
model.preTransform * glm::mat4_cast(combinedRotation) * model.postTransform;
|
model.preTransform * glm::mat4_cast(combinedRotation) * model.postTransform;
|
||||||
joint.inverseBindRotation = glm::inverse(combinedRotation) * parentJoint.inverseBindRotation;
|
joint.inverseDefaultRotation = glm::inverse(combinedRotation) * parentJoint.inverseDefaultRotation;
|
||||||
joint.distanceToParent = glm::distance(extractTranslation(parentJoint.transform),
|
joint.distanceToParent = glm::distance(extractTranslation(parentJoint.transform),
|
||||||
extractTranslation(joint.transform));
|
extractTranslation(joint.transform));
|
||||||
}
|
}
|
||||||
|
joint.inverseBindRotation = joint.inverseDefaultRotation;
|
||||||
geometry.joints.append(joint);
|
geometry.joints.append(joint);
|
||||||
geometry.jointIndices.insert(model.name, geometry.joints.size() - 1);
|
geometry.jointIndices.insert(model.name, geometry.joints.size() - 1);
|
||||||
}
|
}
|
||||||
|
@ -1202,6 +1203,10 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
}
|
}
|
||||||
fbxCluster.inverseBindMatrix = glm::inverse(cluster.transformLink) * modelTransform;
|
fbxCluster.inverseBindMatrix = glm::inverse(cluster.transformLink) * modelTransform;
|
||||||
extracted.mesh.clusters.append(fbxCluster);
|
extracted.mesh.clusters.append(fbxCluster);
|
||||||
|
|
||||||
|
// override the bind rotation with the transform link
|
||||||
|
geometry.joints[fbxCluster.jointIndex].inverseBindRotation =
|
||||||
|
glm::inverse(extractRotation(cluster.transformLink));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ public:
|
||||||
glm::quat postRotation;
|
glm::quat postRotation;
|
||||||
glm::mat4 postTransform;
|
glm::mat4 postTransform;
|
||||||
glm::mat4 transform;
|
glm::mat4 transform;
|
||||||
|
glm::quat inverseDefaultRotation;
|
||||||
glm::quat inverseBindRotation;
|
glm::quat inverseBindRotation;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -574,12 +574,13 @@ bool Model::getJointPosition(int jointIndex, glm::vec3& position) const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Model::getJointRotation(int jointIndex, glm::quat& rotation) const {
|
bool Model::getJointRotation(int jointIndex, glm::quat& rotation, bool fromBind) const {
|
||||||
if (jointIndex == -1 || _jointStates.isEmpty()) {
|
if (jointIndex == -1 || _jointStates.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
rotation = _jointStates[jointIndex].combinedRotation *
|
rotation = _jointStates[jointIndex].combinedRotation *
|
||||||
_geometry->getFBXGeometry().joints[jointIndex].inverseBindRotation;
|
(fromBind ? _geometry->getFBXGeometry().joints[jointIndex].inverseBindRotation :
|
||||||
|
_geometry->getFBXGeometry().joints[jointIndex].inverseDefaultRotation);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,13 +672,14 @@ bool Model::setJointPosition(int jointIndex, const glm::vec3& position, int last
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Model::setJointRotation(int jointIndex, const glm::quat& rotation) {
|
bool Model::setJointRotation(int jointIndex, const glm::quat& rotation, bool fromBind) {
|
||||||
if (jointIndex == -1 || _jointStates.isEmpty()) {
|
if (jointIndex == -1 || _jointStates.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
JointState& state = _jointStates[jointIndex];
|
JointState& state = _jointStates[jointIndex];
|
||||||
state.rotation = state.rotation * glm::inverse(state.combinedRotation) * rotation *
|
state.rotation = state.rotation * glm::inverse(state.combinedRotation) * rotation *
|
||||||
glm::inverse(_geometry->getFBXGeometry().joints.at(jointIndex).inverseBindRotation);
|
glm::inverse(fromBind ? _geometry->getFBXGeometry().joints.at(jointIndex).inverseBindRotation :
|
||||||
|
_geometry->getFBXGeometry().joints.at(jointIndex).inverseDefaultRotation);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,10 +141,10 @@ protected:
|
||||||
virtual void maybeUpdateEyeRotation(const JointState& parentState, const FBXJoint& joint, JointState& state);
|
virtual void maybeUpdateEyeRotation(const JointState& parentState, const FBXJoint& joint, JointState& state);
|
||||||
|
|
||||||
bool getJointPosition(int jointIndex, glm::vec3& position) const;
|
bool getJointPosition(int jointIndex, glm::vec3& position) const;
|
||||||
bool getJointRotation(int jointIndex, glm::quat& rotation) const;
|
bool getJointRotation(int jointIndex, glm::quat& rotation, bool fromBind = false) const;
|
||||||
|
|
||||||
bool setJointPosition(int jointIndex, const glm::vec3& position, int lastFreeIndex = -1);
|
bool setJointPosition(int jointIndex, const glm::vec3& position, int lastFreeIndex = -1);
|
||||||
bool setJointRotation(int jointIndex, const glm::quat& rotation);
|
bool setJointRotation(int jointIndex, const glm::quat& rotation, bool fromBind = false);
|
||||||
|
|
||||||
/// Restores the indexed joint to its default position.
|
/// Restores the indexed joint to its default position.
|
||||||
/// \param percent the percentage of the default position to apply (i.e., 0.25f to slerp one fourth of the way to
|
/// \param percent the percentage of the default position to apply (i.e., 0.25f to slerp one fourth of the way to
|
||||||
|
|
Loading…
Reference in a new issue