mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 01:00:44 +02:00
Support ReadyPlayerMe blendshapes in glTF files
This commit is contained in:
parent
71bcabfc0a
commit
0b536f0cae
2 changed files with 32 additions and 2 deletions
|
@ -1550,7 +1550,6 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::VariantHash&
|
||||||
typedef QPair<int, float> WeightedIndex;
|
typedef QPair<int, float> WeightedIndex;
|
||||||
hifi::VariantHash blendshapeMappings = mapping.value("bs").toHash();
|
hifi::VariantHash blendshapeMappings = mapping.value("bs").toHash();
|
||||||
QMultiHash<QString, WeightedIndex> blendshapeIndices;
|
QMultiHash<QString, WeightedIndex> blendshapeIndices;
|
||||||
|
|
||||||
for (int i = 0;; ++i) {
|
for (int i = 0;; ++i) {
|
||||||
auto blendshapeName = QString(BLENDSHAPE_NAMES[i]);
|
auto blendshapeName = QString(BLENDSHAPE_NAMES[i]);
|
||||||
if (blendshapeName.isEmpty()) {
|
if (blendshapeName.isEmpty()) {
|
||||||
|
@ -1572,6 +1571,19 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::VariantHash&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Augment list of blendshapes from synonyms in model.
|
||||||
|
QMap<QString, QPair<QString, float>>::const_iterator synonym = BLENDSHAPE_SYNONYMS_MAP.constBegin();
|
||||||
|
while (synonym != BLENDSHAPE_SYNONYMS_MAP.constEnd()) {
|
||||||
|
if (_file.meshes[node.mesh].extras.targetNames.contains(synonym.key())) {
|
||||||
|
auto blendshape = BLENDSHAPE_LOOKUP_MAP.find(synonym.value().first);
|
||||||
|
if (blendshape != BLENDSHAPE_LOOKUP_MAP.end()) {
|
||||||
|
blendshapeIndices.insert(synonym.key(),
|
||||||
|
WeightedIndex(blendshape.value(), synonym.value().second));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++synonym;
|
||||||
|
}
|
||||||
|
|
||||||
// Create blendshapes.
|
// Create blendshapes.
|
||||||
if (!blendshapeIndices.isEmpty()) {
|
if (!blendshapeIndices.isEmpty()) {
|
||||||
mesh.blendshapes.resize((int)Blendshapes::BlendshapeCount);
|
mesh.blendshapes.resize((int)Blendshapes::BlendshapeCount);
|
||||||
|
|
|
@ -113,6 +113,24 @@ enum class Blendshapes : int {
|
||||||
// * LipsUpperOpen (not in ARKit)
|
// * LipsUpperOpen (not in ARKit)
|
||||||
// * LipsLowerOpen (not in ARKit)
|
// * LipsLowerOpen (not in ARKit)
|
||||||
|
|
||||||
|
const QMap<QString, QPair<QString, float>> BLENDSHAPE_SYNONYMS_MAP {
|
||||||
|
// ReadyPlayerMe
|
||||||
|
{"browDownLeft", {"BrowsD_L", 0.5f}},
|
||||||
|
{"browDownRight", {"BrowsD_R", 0.5f}},
|
||||||
|
{"browInnerUp", {"BrowsU_C", 0.3f}},
|
||||||
|
{"browOuterUpLeft", {"BrowsU_L", 0.3f}},
|
||||||
|
{"browOuterUpRight", {"BrowsU_R", 0.3f}},
|
||||||
|
{"eyeBlinkLeft", {"EyeBlink_L", 1.0f}},
|
||||||
|
{"eyeBlinkRight", {"EyeBlink_R", 1.0f}},
|
||||||
|
{"eyeWideLeft", {"EyeOpen_L", 1.0f}},
|
||||||
|
{"eyeWideRight", {"EyeOpen_R", 1.0f}},
|
||||||
|
{"mouthLeft", {"MouthSmile_L", 0.6f}},
|
||||||
|
{"mouthOpen", {"JawOpen", 1.0f}},
|
||||||
|
{"mouthRight", {"MouthSmile_R", 0.6f}},
|
||||||
|
{"mouthShrugLower", {"LipsUpperClose", 0.1f}},
|
||||||
|
{"viseme_O", {"LipsFunnel", 0.5f}}
|
||||||
|
};
|
||||||
|
|
||||||
struct BlendshapeOffsetPacked {
|
struct BlendshapeOffsetPacked {
|
||||||
glm::uvec4 packedPosNorTan;
|
glm::uvec4 packedPosNorTan;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue