parseMeshGeometry method

dynamic parseMeshGeometry(
  1. dynamic relationships,
  2. dynamic geoNode,
  3. dynamic deformers
)

Implementation

parseMeshGeometry(relationships, geoNode, deformers) {
  var skeletons = deformers["skeletons"];
  var morphTargets = [];

  List modelNodes = relationships["parents"].map((parent) {
    return fbxTree.objects["Model"][parent["ID"]];
  }).toList();

  // don't create geometry if it is not associated with any models
  if (modelNodes.isEmpty) return;

  var skeleton;
  for (var child in relationships["children"]) {
    if (skeletons[child["ID"]] != null) {
      skeleton = skeletons[child["ID"]];
    }
  }

  relationships["children"].forEach((child) {
    if (deformers["morphTargets"][child["ID"]] != null) {
      morphTargets.add(deformers["morphTargets"][child["ID"]]);
    }
  });

  // Assume one model and get the preRotation from that
  // if there is more than one model associated with the geometry this may cause problems
  Map modelNode = modelNodes[0];

  var transformData = {};

  if (modelNode['RotationOrder'] != null) {
    transformData["eulerOrder"] = getEulerOrder(modelNode["RotationOrder"]["value"]);
  }
  if (modelNode['InheritType'] != null) transformData["inheritType"] = parseInt(modelNode["InheritType"]["value"]);

  if (modelNode['GeometricTranslation'] != null) {
    transformData["translation"] = modelNode["GeometricTranslation"]["value"];
  }
  if (modelNode['GeometricRotation'] != null) transformData["rotation"] = modelNode["GeometricRotation"]["value"];
  if (modelNode['GeometricScaling'] != null) transformData["scale"] = modelNode["GeometricScaling"]["value"];

  var transform = generateTransform(transformData);

  return genGeometry(geoNode, skeleton, morphTargets, transform);
}