std::vector FbxBlendShapesAccess::extractChannels()

in src/fbx/FbxBlendShapesAccess.cpp [43:72]


std::vector<FbxBlendShapesAccess::BlendChannel> FbxBlendShapesAccess::extractChannels(
    FbxMesh* mesh) const {
  std::vector<BlendChannel> channels;
  for (int shapeIx = 0; shapeIx < mesh->GetDeformerCount(FbxDeformer::eBlendShape); shapeIx++) {
    auto* fbxBlendShape =
        static_cast<FbxBlendShape*>(mesh->GetDeformer(shapeIx, FbxDeformer::eBlendShape));

    for (int channelIx = 0; channelIx < fbxBlendShape->GetBlendShapeChannelCount(); ++channelIx) {
      FbxBlendShapeChannel* fbxChannel = fbxBlendShape->GetBlendShapeChannel(channelIx);

      if (fbxChannel->GetTargetShapeCount() > 0) {
        std::vector<TargetShape> targetShapes;
        const double* fullWeights = fbxChannel->GetTargetShapeFullWeights();
        std::string name = std::string(fbxChannel->GetName());

        if (verboseOutput) {
          fmt::printf("\rblendshape channel: %s\n", name);
        }

        for (int targetIx = 0; targetIx < fbxChannel->GetTargetShapeCount(); targetIx++) {
          FbxShape* fbxShape = fbxChannel->GetTargetShape(targetIx);
          targetShapes.emplace_back(fbxShape, fullWeights[targetIx]);
        }
        channels.emplace_back(
            mesh, shapeIx, channelIx, fbxChannel->DeformPercent * 0.01, targetShapes, name);
      }
    }
  }
  return channels;
}