diff --git a/libraries/fbx/src/GLTFSerializer.cpp b/libraries/fbx/src/GLTFSerializer.cpp index 0916316ec1..ec4777933a 100755 --- a/libraries/fbx/src/GLTFSerializer.cpp +++ b/libraries/fbx/src/GLTFSerializer.cpp @@ -1550,7 +1550,6 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::VariantHash& typedef QPair WeightedIndex; hifi::VariantHash blendshapeMappings = mapping.value("bs").toHash(); QMultiHash blendshapeIndices; - for (int i = 0;; ++i) { auto blendshapeName = QString(BLENDSHAPE_NAMES[i]); if (blendshapeName.isEmpty()) { @@ -1561,7 +1560,7 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::VariantHash& // Use blendshape from mapping. foreach(const QVariant& mapping, mappings) { auto blendshapeMapping = mapping.toList(); - blendshapeIndices.insert(blendshapeMapping.at(0).toString(), + blendshapeIndices.insert(blendshapeMapping.at(0).toString(), WeightedIndex(i, blendshapeMapping.at(1).toFloat())); } } else { @@ -1572,6 +1571,19 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::VariantHash& } } + // Augment list of blendshapes from synonyms in model. + QMap>::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. if (!blendshapeIndices.isEmpty()) { mesh.blendshapes.resize((int)Blendshapes::BlendshapeCount); diff --git a/libraries/shared/src/BlendshapeConstants.h b/libraries/shared/src/BlendshapeConstants.h index c254e33910..47e887cf57 100644 --- a/libraries/shared/src/BlendshapeConstants.h +++ b/libraries/shared/src/BlendshapeConstants.h @@ -113,6 +113,24 @@ enum class Blendshapes : int { // * LipsUpperOpen (not in ARKit) // * LipsLowerOpen (not in ARKit) +const QMap> 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 { glm::uvec4 packedPosNorTan; };