mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:36:57 +02:00
Added left hand/hand rotation setters in preparation for Leap integration.
This commit is contained in:
parent
b56d47929b
commit
4f34d89c4a
4 changed files with 42 additions and 0 deletions
|
@ -696,6 +696,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
QString jointRootName = processID(joints.value("jointRoot", "jointRoot").toString());
|
QString jointRootName = processID(joints.value("jointRoot", "jointRoot").toString());
|
||||||
QString jointLeanName = processID(joints.value("jointLean", "jointLean").toString());
|
QString jointLeanName = processID(joints.value("jointLean", "jointLean").toString());
|
||||||
QString jointHeadName = processID(joints.value("jointHead", "jointHead").toString());
|
QString jointHeadName = processID(joints.value("jointHead", "jointHead").toString());
|
||||||
|
QString jointLeftHandName = processID(joints.value("jointLeftHand", "jointLeftHand").toString());
|
||||||
QString jointRightHandName = processID(joints.value("jointRightHand", "jointRightHand").toString());
|
QString jointRightHandName = processID(joints.value("jointRightHand", "jointRightHand").toString());
|
||||||
QString jointEyeLeftID;
|
QString jointEyeLeftID;
|
||||||
QString jointEyeRightID;
|
QString jointEyeRightID;
|
||||||
|
@ -703,6 +704,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
QString jointRootID;
|
QString jointRootID;
|
||||||
QString jointLeanID;
|
QString jointLeanID;
|
||||||
QString jointHeadID;
|
QString jointHeadID;
|
||||||
|
QString jointLeftHandID;
|
||||||
QString jointRightHandID;
|
QString jointRightHandID;
|
||||||
|
|
||||||
QVariantHash blendshapeMappings = mapping.value("bs").toHash();
|
QVariantHash blendshapeMappings = mapping.value("bs").toHash();
|
||||||
|
@ -778,6 +780,9 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
} else if (name == jointHeadName) {
|
} else if (name == jointHeadName) {
|
||||||
jointHeadID = getID(object.properties);
|
jointHeadID = getID(object.properties);
|
||||||
|
|
||||||
|
} else if (name == jointLeftHandName) {
|
||||||
|
jointLeftHandID = getID(object.properties);
|
||||||
|
|
||||||
} else if (name == jointRightHandName) {
|
} else if (name == jointRightHandName) {
|
||||||
jointRightHandID = getID(object.properties);
|
jointRightHandID = getID(object.properties);
|
||||||
}
|
}
|
||||||
|
@ -1028,6 +1033,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
geometry.rootJointIndex = modelIDs.indexOf(jointRootID);
|
geometry.rootJointIndex = modelIDs.indexOf(jointRootID);
|
||||||
geometry.leanJointIndex = modelIDs.indexOf(jointLeanID);
|
geometry.leanJointIndex = modelIDs.indexOf(jointLeanID);
|
||||||
geometry.headJointIndex = modelIDs.indexOf(jointHeadID);
|
geometry.headJointIndex = modelIDs.indexOf(jointHeadID);
|
||||||
|
geometry.leftHandJointIndex = modelIDs.indexOf(jointLeftHandID);
|
||||||
geometry.rightHandJointIndex = modelIDs.indexOf(jointRightHandID);
|
geometry.rightHandJointIndex = modelIDs.indexOf(jointRightHandID);
|
||||||
|
|
||||||
// extract the translation component of the neck transform
|
// extract the translation component of the neck transform
|
||||||
|
|
|
@ -130,6 +130,7 @@ public:
|
||||||
int rootJointIndex;
|
int rootJointIndex;
|
||||||
int leanJointIndex;
|
int leanJointIndex;
|
||||||
int headJointIndex;
|
int headJointIndex;
|
||||||
|
int leftHandJointIndex;
|
||||||
int rightHandJointIndex;
|
int rightHandJointIndex;
|
||||||
|
|
||||||
glm::vec3 neckPivot;
|
glm::vec3 neckPivot;
|
||||||
|
|
|
@ -413,10 +413,22 @@ bool Model::getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePos
|
||||||
getJointPosition(geometry.rightEyeJointIndex, secondEyePosition);
|
getJointPosition(geometry.rightEyeJointIndex, secondEyePosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Model::setLeftHandPosition(const glm::vec3& position) {
|
||||||
|
return isActive() && setJointPosition(_geometry->getFBXGeometry().leftHandJointIndex, position);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Model::setLeftHandRotation(const glm::quat& rotation) {
|
||||||
|
return isActive() && setJointRotation(_geometry->getFBXGeometry().leftHandJointIndex, rotation);
|
||||||
|
}
|
||||||
|
|
||||||
bool Model::setRightHandPosition(const glm::vec3& position) {
|
bool Model::setRightHandPosition(const glm::vec3& position) {
|
||||||
return isActive() && setJointPosition(_geometry->getFBXGeometry().rightHandJointIndex, position);
|
return isActive() && setJointPosition(_geometry->getFBXGeometry().rightHandJointIndex, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Model::setRightHandRotation(const glm::quat& rotation) {
|
||||||
|
return isActive() && setJointRotation(_geometry->getFBXGeometry().rightHandJointIndex, rotation);
|
||||||
|
}
|
||||||
|
|
||||||
void Model::setURL(const QUrl& url) {
|
void Model::setURL(const QUrl& url) {
|
||||||
// don't recreate the geometry if it's the same URL
|
// don't recreate the geometry if it's the same URL
|
||||||
if (_url == url) {
|
if (_url == url) {
|
||||||
|
@ -535,6 +547,16 @@ bool Model::setJointPosition(int jointIndex, const glm::vec3& position) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Model::setJointRotation(int jointIndex, const glm::quat& rotation) {
|
||||||
|
if (jointIndex == -1 || _jointStates.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
JointState& state = _jointStates[jointIndex];
|
||||||
|
state.rotation = state.rotation * glm::inverse(state.combinedRotation) * rotation *
|
||||||
|
glm::inverse(_geometry->getFBXGeometry().joints.at(jointIndex).inverseBindRotation);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Model::deleteGeometry() {
|
void Model::deleteGeometry() {
|
||||||
foreach (Model* attachment, _attachments) {
|
foreach (Model* attachment, _attachments) {
|
||||||
delete attachment;
|
delete attachment;
|
||||||
|
|
|
@ -70,10 +70,22 @@ public:
|
||||||
/// \return whether or not both eye meshes were found
|
/// \return whether or not both eye meshes were found
|
||||||
bool getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const;
|
bool getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const;
|
||||||
|
|
||||||
|
/// Sets the position of the left hand using inverse kinematics.
|
||||||
|
/// \return whether or not the left hand joint was found
|
||||||
|
bool setLeftHandPosition(const glm::vec3& position);
|
||||||
|
|
||||||
|
/// Sets the rotation of the left hand.
|
||||||
|
/// \return whether or not the left hand joint was found
|
||||||
|
bool setLeftHandRotation(const glm::quat& rotation);
|
||||||
|
|
||||||
/// Sets the position of the right hand using inverse kinematics.
|
/// Sets the position of the right hand using inverse kinematics.
|
||||||
/// \return whether or not the right hand joint was found
|
/// \return whether or not the right hand joint was found
|
||||||
bool setRightHandPosition(const glm::vec3& position);
|
bool setRightHandPosition(const glm::vec3& position);
|
||||||
|
|
||||||
|
/// Sets the rotation of the right hand.
|
||||||
|
/// \return whether or not the right hand joint was found
|
||||||
|
bool setRightHandRotation(const glm::quat& rotation);
|
||||||
|
|
||||||
/// Returns the average color of all meshes in the geometry.
|
/// Returns the average color of all meshes in the geometry.
|
||||||
glm::vec4 computeAverageColor() const;
|
glm::vec4 computeAverageColor() const;
|
||||||
|
|
||||||
|
@ -106,6 +118,7 @@ protected:
|
||||||
bool getJointRotation(int jointIndex, glm::quat& rotation) const;
|
bool getJointRotation(int jointIndex, glm::quat& rotation) const;
|
||||||
|
|
||||||
bool setJointPosition(int jointIndex, const glm::vec3& position);
|
bool setJointPosition(int jointIndex, const glm::vec3& position);
|
||||||
|
bool setJointRotation(int jointIndex, const glm::quat& rotation);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue