BabylonNode.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #pragma once
  2. #include <fbxsdk.h>
  3. #include <vector>
  4. #include <cstdint>
  5. #include "NodeHelpers.h"
  6. #include "BabylonVertex.h"
  7. #include "MatrixDecomposition.h"
  8. enum class BabylonNodeType{
  9. Camera,
  10. Mesh,
  11. Skeleton,
  12. Light,
  13. Empty
  14. };
  15. class BabylonNode;
  16. class BabylonNode
  17. {
  18. private:
  19. FbxNode* _node;
  20. std::vector<BabylonNode> _children;
  21. public:
  22. BabylonNode() :_node(nullptr){}
  23. explicit BabylonNode(FbxNode* fbxNode);
  24. BabylonNode(const BabylonNode&) = default;
  25. BabylonNode(BabylonNode&& moved);
  26. std::vector<BabylonNode>& children(){
  27. return _children;
  28. }
  29. BabylonNodeType nodeType();
  30. FbxNode* fbxNode(){ return _node; }
  31. bool isEmptySkeletonOrEmptyMesh();
  32. bool isEmptySkeletonOrEmptyMeshRecursive();
  33. void appendChild(FbxNode* fbxNode){
  34. _children.emplace_back(fbxNode);
  35. }
  36. std::uint64_t uniqueId()const{
  37. return _node->GetUniqueID();
  38. }
  39. std::string name() const{
  40. return std::string(_node->GetName());
  41. }
  42. bool hasOnlySkeletonDescendants(){
  43. if (nodeType() != BabylonNodeType::Skeleton){
  44. return false;
  45. }
  46. for (auto& child : _children){
  47. if (!child.hasOnlySkeletonDescendants()){
  48. return false;
  49. }
  50. }
  51. return true;
  52. }
  53. MatrixDecomposition GetLocal() {
  54. return MatrixDecomposition(ConvertToBabylonCoordinateSystem(_node->EvaluateLocalTransform()));
  55. }
  56. MatrixDecomposition GetLocal(const FbxTime& time) {
  57. return MatrixDecomposition(ConvertToBabylonCoordinateSystem(_node->EvaluateLocalTransform(time)));
  58. }
  59. };