mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 16:33:33 +02:00
joint mapping. adding to fbx reader and avatar classes to get non standard names to map to hifi
This commit is contained in:
parent
eb00435353
commit
fd9c05ce80
4 changed files with 35 additions and 0 deletions
libraries
|
@ -1437,6 +1437,21 @@ int Avatar::getJointIndex(const QString& name) const {
|
|||
withValidJointIndicesCache([&]() {
|
||||
if (_modelJointIndicesCache.contains(name)) {
|
||||
result = _modelJointIndicesCache[name] - 1;
|
||||
if (_skeletonModel && _skeletonModel->isActive()) {
|
||||
qCDebug(avatars_renderer) << "the other head id is this" << _skeletonModel->getHFMModel().fbxToHifiJointNameMapping["Head"];
|
||||
qCDebug(avatars_renderer) << "joint indices cache " << name << " " << _modelJointIndicesCache[name];
|
||||
if (_modelJointIndicesCache.contains(_skeletonModel->getHFMModel().fbxToHifiJointNameMapping["Head"])) {
|
||||
qCDebug(avatars_renderer) << "joint alternate name " << _skeletonModel->getHFMModel().fbxToHifiJointNameMapping["Head"] << " " << _modelJointIndicesCache[_skeletonModel->getHFMModel().fbxToHifiJointNameMapping["Head"]];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// doesn't contain name.
|
||||
qCDebug(avatars_renderer) << "name is not here";
|
||||
if (_skeletonModel && _skeletonModel->isActive()) {
|
||||
if (_modelJointIndicesCache.contains(_skeletonModel->getHFMModel().fbxToHifiJointNameMapping["Head"])) {
|
||||
qCDebug(avatars_renderer) << "the other head id is this" << _skeletonModel->getHFMModel().fbxToHifiJointNameMapping["Head"] << " " << _modelJointIndicesCache[_skeletonModel->getHFMModel().fbxToHifiJointNameMapping["Head"]];;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
|
|
|
@ -417,6 +417,21 @@ QByteArray fileOnUrl(const QByteArray& filepath, const QString& url) {
|
|||
return filepath.mid(filepath.lastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
QMap<QString, QString> getJointNameMapping(const QVariantHash& mapping) {
|
||||
static const QString JOINT_NAME_MAPPING_FIELD = "jointMap";
|
||||
QMap<QString, QString> fbxToHifiJointNameMap;
|
||||
if (!mapping.isEmpty() && mapping.contains(JOINT_NAME_MAPPING_FIELD) && mapping[JOINT_NAME_MAPPING_FIELD].type() == QVariant::Hash) {
|
||||
auto jointNames = mapping[JOINT_NAME_MAPPING_FIELD].toHash();
|
||||
for (auto itr = jointNames.begin(); itr != jointNames.end(); itr++) {
|
||||
qCDebug(modelformat) << "found a joint mapping field key " << itr.key() << " value " << itr.value().toString();
|
||||
fbxToHifiJointNameMap.insert(itr.key(), itr.value().toString());
|
||||
qCDebug(modelformat) << "the mapped key (Head) has a value of " << fbxToHifiJointNameMap[itr.key()];
|
||||
}
|
||||
|
||||
}
|
||||
return fbxToHifiJointNameMap;
|
||||
}
|
||||
|
||||
QMap<QString, glm::quat> getJointRotationOffsets(const QVariantHash& mapping) {
|
||||
QMap<QString, glm::quat> jointRotationOffsets;
|
||||
static const QString JOINT_ROTATION_OFFSET_FIELD = "jointRotationOffset";
|
||||
|
@ -1830,6 +1845,9 @@ HFMModel* FBXReader::extractHFMModel(const QVariantHash& mapping, const QString&
|
|||
qCDebug(modelformat) << "Joint Rotation Offset added to Rig._jointRotationOffsets : " << " jointName: " << jointName << " jointIndex: " << jointIndex << " rotation offset: " << rotationOffset;
|
||||
}
|
||||
|
||||
hfmModel.fbxToHifiJointNameMapping.clear();
|
||||
hfmModel.fbxToHifiJointNameMapping = getJointNameMapping(mapping);
|
||||
|
||||
return hfmModelPtr;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ static const QString JOINT_FIELD = "joint";
|
|||
static const QString FREE_JOINT_FIELD = "freeJoint";
|
||||
static const QString BLENDSHAPE_FIELD = "bs";
|
||||
static const QString SCRIPT_FIELD = "script";
|
||||
static const QString JOINT_NAME_MAPPING_FIELD = "jointMap";
|
||||
|
||||
class FSTReader {
|
||||
public:
|
||||
|
|
|
@ -313,6 +313,7 @@ public:
|
|||
QList<QString> blendshapeChannelNames;
|
||||
|
||||
QMap<int, glm::quat> jointRotationOffsets;
|
||||
QMap<QString, QString> fbxToHifiJointNameMapping;
|
||||
};
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue