| 682 | } |
| 683 | |
| 684 | bool ModelTool::ImportData(const String& path, ModelData& data, Options& options, String& errorMsg) |
| 685 | { |
| 686 | PROFILE_CPU(); |
| 687 | |
| 688 | // Validate options |
| 689 | options.Scale = Math::Clamp(options.Scale, 0.0001f, 100000.0f); |
| 690 | options.SmoothingNormalsAngle = Math::Clamp(options.SmoothingNormalsAngle, 0.0f, 175.0f); |
| 691 | options.SmoothingTangentsAngle = Math::Clamp(options.SmoothingTangentsAngle, 0.0f, 45.0f); |
| 692 | options.FramesRange.Y = Math::Max(options.FramesRange.Y, options.FramesRange.X); |
| 693 | options.DefaultFrameRate = Math::Max(0.0f, options.DefaultFrameRate); |
| 694 | options.SamplingRate = Math::Max(0.0f, options.SamplingRate); |
| 695 | if (options.SplitObjects || options.Type == ModelType::Prefab) |
| 696 | options.MergeMeshes = false; // Meshes merging doesn't make sense when we want to import each mesh individually |
| 697 | // TODO: maybe we could update meshes merger to collapse meshes within the same name if splitting is enabled? |
| 698 | |
| 699 | // Call importing backend |
| 700 | #if (USE_AUTODESK_FBX_SDK || USE_OPEN_FBX) && USE_ASSIMP |
| 701 | if (path.EndsWith(TEXT(".fbx"), StringSearchCase::IgnoreCase)) |
| 702 | { |
| 703 | #if USE_AUTODESK_FBX_SDK |
| 704 | if (ImportDataAutodeskFbxSdk(path, data, options, errorMsg)) |
| 705 | return true; |
| 706 | #elif USE_OPEN_FBX |
| 707 | if (ImportDataOpenFBX(path, data, options, errorMsg)) |
| 708 | return true; |
| 709 | #endif |
| 710 | } |
| 711 | else |
| 712 | { |
| 713 | if (ImportDataAssimp(path, data, options, errorMsg)) |
| 714 | return true; |
| 715 | } |
| 716 | #elif USE_ASSIMP |
| 717 | if (ImportDataAssimp(path, data, options, errorMsg)) |
| 718 | return true; |
| 719 | #elif USE_AUTODESK_FBX_SDK |
| 720 | if (ImportDataAutodeskFbxSdk(path, data, options, errorMsg)) |
| 721 | return true; |
| 722 | #elif USE_OPEN_FBX |
| 723 | if (ImportDataOpenFBX(path, data, options, errorMsg)) |
| 724 | return true; |
| 725 | #else |
| 726 | LOG(Error, "Compiled without model importing backend."); |
| 727 | return true; |
| 728 | #endif |
| 729 | |
| 730 | // Remove namespace prefixes from the nodes names |
| 731 | { |
| 732 | for (auto& node : data.Nodes) |
| 733 | { |
| 734 | RemoveNamespace(node.Name); |
| 735 | } |
| 736 | for (auto& node : data.Skeleton.Nodes) |
| 737 | { |
| 738 | RemoveNamespace(node.Name); |
| 739 | } |
| 740 | for (auto& animation : data.Animations) |
| 741 | { |
nothing calls this directly
no test coverage detected