mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 01:56:54 +02:00
works two joint avatar with luis's new code. remains to do the engineer
This commit is contained in:
parent
11bb448f9f
commit
dce040978c
3 changed files with 14 additions and 40 deletions
|
@ -26,7 +26,10 @@ AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel) {
|
||||||
joints.push_back(joint);
|
joints.push_back(joint);
|
||||||
}
|
}
|
||||||
|
|
||||||
buildSkeletonFromJoints(joints, hfmModel.jointOffsets);
|
glm::quat offset1(0.5f, 0.5f, 0.5f, -0.5f);
|
||||||
|
glm::quat offset2(0.7071f, 0.0f, 0.7071f, 0.0f);
|
||||||
|
|
||||||
|
buildSkeletonFromJoints(joints, hfmModel.jointRotationOffsets);
|
||||||
// add offsets for spine2 and the neck
|
// add offsets for spine2 and the neck
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,15 +47,17 @@ AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel) {
|
||||||
|
|
||||||
if (cluster.jointIndex == 62) {
|
if (cluster.jointIndex == 62) {
|
||||||
qCDebug(animation) << "Neck";
|
qCDebug(animation) << "Neck";
|
||||||
qCDebug(animation) << "found a joint offset to add " << cluster.jointIndex << " " << jointOffsets[cluster.jointIndex] << " cluster " << cluster.jointIndex;
|
qCDebug(animation) << "found a joint offset to add " << cluster.jointIndex << " " << offset2 << " cluster " << cluster.jointIndex;
|
||||||
AnimPose localOffset(jointOffsets[cluster.jointIndex], glm::vec3());
|
AnimPose localOffset(hfmModel.jointRotationOffsets[cluster.jointIndex], glm::vec3());
|
||||||
|
//AnimPose localOffset(offset2, glm::vec3());
|
||||||
cluster.inverseBindMatrix = (glm::mat4)localOffset.inverse() * cluster.inverseBindMatrix;
|
cluster.inverseBindMatrix = (glm::mat4)localOffset.inverse() * cluster.inverseBindMatrix;
|
||||||
cluster.inverseBindTransform.evalFromRawMatrix(cluster.inverseBindMatrix);
|
cluster.inverseBindTransform.evalFromRawMatrix(cluster.inverseBindMatrix);
|
||||||
}
|
}
|
||||||
if (cluster.jointIndex == 13) {
|
if (cluster.jointIndex == 13) {
|
||||||
qCDebug(animation) << "Spine2";
|
qCDebug(animation) << "Spine2";
|
||||||
qCDebug(animation) << "found a joint offset to add " << cluster.jointIndex << " " << jointOffsets[cluster.jointIndex] << " cluster " << cluster.jointIndex;
|
qCDebug(animation) << "found a joint offset to add " << cluster.jointIndex << " " << offset1<< " cluster " << cluster.jointIndex;
|
||||||
AnimPose localOffset(jointOffsets[cluster.jointIndex], glm::vec3());
|
AnimPose localOffset(hfmModel.jointRotationOffsets[cluster.jointIndex], glm::vec3());
|
||||||
|
//AnimPose localOffset(offset1, glm::vec3());
|
||||||
cluster.inverseBindMatrix = (glm::mat4)localOffset.inverse() * cluster.inverseBindMatrix;
|
cluster.inverseBindMatrix = (glm::mat4)localOffset.inverse() * cluster.inverseBindMatrix;
|
||||||
cluster.inverseBindTransform.evalFromRawMatrix(cluster.inverseBindMatrix);
|
cluster.inverseBindTransform.evalFromRawMatrix(cluster.inverseBindMatrix);
|
||||||
}
|
}
|
||||||
|
@ -257,40 +262,7 @@ void AnimSkeleton::buildSkeletonFromJoints(const std::vector<HFMJoint>& joints,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
AnimPose newAbsPose;
|
|
||||||
if (parentIndex >= 0) {
|
|
||||||
newAbsPose = _absoluteDefaultPoses[parentIndex] * AnimPose(relDefaultPose.rot(),glm::vec3());
|
|
||||||
} else {
|
|
||||||
newAbsPose = relDefaultPose;
|
|
||||||
}
|
|
||||||
|
|
||||||
// putting the pipeline code is
|
|
||||||
// remember the inverse bind pose already has the offset added into it. the total effect is offset^-1 * relDefPose * offset.
|
|
||||||
// this gives us the correct transform for the joint that has been put in t-pose with an offset rotation.
|
|
||||||
//relDefaultPose = relDefaultPose * _avatarTPoseOffsets[i];
|
|
||||||
|
|
||||||
QString jointName = getJointName(i);
|
|
||||||
if (jointOffsets.contains(i)) {
|
|
||||||
//QString parentIndex = getJointName(parentIndex);
|
|
||||||
AnimPose localOffset(jointOffsets[i], glm::vec3());
|
|
||||||
newAbsPose = newAbsPose * localOffset;
|
|
||||||
}
|
|
||||||
if ((parentIndex >= 0) && jointOffsets.contains(parentIndex)) {
|
|
||||||
AnimPose localParentOffset(jointOffsets[parentIndex], glm::vec3());
|
|
||||||
newAbsPose = localParentOffset.inverse() * AnimPose(glm::quat(), relDefaultPose.trans()) * localParentOffset * AnimPose(newAbsPose.rot(), glm::vec3());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parentIndex >= 0) {
|
|
||||||
relDefaultPose = _absoluteDefaultPoses[parentIndex].inverse() * newAbsPose;
|
|
||||||
}
|
|
||||||
_relativeDefaultPoses.push_back(relDefaultPose);
|
|
||||||
|
|
||||||
|
|
||||||
_absoluteDefaultPoses.push_back(newAbsPose);
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
for (int i = 0; i < _jointsSize; i++) {
|
for (int i = 0; i < _jointsSize; i++) {
|
||||||
_jointIndicesByName[_joints[i].name] = i;
|
_jointIndicesByName[_joints[i].name] = i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ public:
|
||||||
using Pointer = std::shared_ptr<AnimSkeleton>;
|
using Pointer = std::shared_ptr<AnimSkeleton>;
|
||||||
using ConstPointer = std::shared_ptr<const AnimSkeleton>;
|
using ConstPointer = std::shared_ptr<const AnimSkeleton>;
|
||||||
|
|
||||||
explicit AnimSkeleton(const HFMModel& hfmModel, const QMap<int, glm::quat> jointOffsets);
|
explicit AnimSkeleton(const HFMModel& hfmModel);
|
||||||
explicit AnimSkeleton(const std::vector<HFMJoint>& joints, const QMap<int, glm::quat> jointOffsets);
|
explicit AnimSkeleton(const std::vector<HFMJoint>& joints, const QMap<int, glm::quat> jointOffsets);
|
||||||
|
|
||||||
int nameToJointIndex(const QString& jointName) const;
|
int nameToJointIndex(const QString& jointName) const;
|
||||||
|
|
|
@ -2027,6 +2027,8 @@ HFMModel* FBXReader::extractHFMModel(const QVariantHash& mapping, const QString&
|
||||||
}
|
}
|
||||||
qCDebug(modelformat) << "Joint Rotation Offset added to Rig._jointRotationOffsets : " << " jointName: " << jointName << " jointIndex: " << jointIndex << " rotation offset: " << rotationOffset;
|
qCDebug(modelformat) << "Joint Rotation Offset added to Rig._jointRotationOffsets : " << " jointName: " << jointName << " jointIndex: " << jointIndex << " rotation offset: " << rotationOffset;
|
||||||
}
|
}
|
||||||
|
hfmModel.jointRotationOffsets.insert(13, glm::quat(0.5f, 0.5f, 0.5f, -0.5f));
|
||||||
|
hfmModel.jointRotationOffsets.insert(62, glm::quat(0.7071f, 0.0f, -0.7071f, 0.0f));
|
||||||
|
|
||||||
return hfmModelPtr;
|
return hfmModelPtr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue