AssImpImporterUtilities.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <assimp/matrix4x4.h>
  10. #include <AzCore/std/containers/unordered_map.h>
  11. #include <AzCore/std/string/string.h>
  12. #include <SceneAPI/SceneCore/DataTypes/MatrixType.h>
  13. struct aiBone;
  14. struct aiNode;
  15. struct aiScene;
  16. struct aiString;
  17. namespace AZ::SceneAPI::SceneBuilder
  18. {
  19. inline constexpr char PivotNodeMarker[] = "_$AssimpFbx$_";
  20. bool IsSkinnedMesh(const aiNode& node, const aiScene& scene);
  21. // Checks if a node name is a pivot node and optionally returns the position in the name of the pivot marker (for splitting out the parts later)
  22. bool IsPivotNode(const aiString& nodeName, size_t* pos = nullptr);
  23. // Returns the bone name and type of a pivot node
  24. void SplitPivotNodeName(const aiString& nodeName, size_t pivotPos, AZStd::string_view& baseNodeName, AZStd::string_view& pivotType);
  25. // Gets the entire, combined local transform for a node taking pivot nodes into account. When pivot nodes are not used, this just returns the node's transform
  26. aiMatrix4x4 GetConcatenatedLocalTransform(const aiNode* currentNode);
  27. DataTypes::MatrixType GetLocalSpaceBindPoseTransform(const aiScene* scene, const aiNode* node);
  28. // Gather all bones from the scene. (Bone in AssImp corresponds to nodes that influence any of the vertices).
  29. void FindAllBones(const aiScene* scene, AZStd::unordered_multimap<AZStd::string, const aiBone*>& outBoneByNameMap);
  30. // Find the first bone with the name of the given node.
  31. const aiBone* FindFirstBoneByNodeName(const aiNode* node, AZStd::unordered_multimap<AZStd::string, const aiBone*>& boneByNameMap);
  32. // Check if the given node or any of its children, or children of children, is a bone by checking if the node name is part of the given maps.
  33. bool RecursiveHasChildBone(const aiNode* node, const AZStd::unordered_multimap<AZStd::string, const aiBone*>& boneByNameMap, const AZStd::unordered_set<AZStd::string>& animatedNodesMap);
  34. } // namespace AZ