| 995 | } |
| 996 | |
| 997 | bool ModelTool::ImportModel(const String& path, ModelData& data, Options& options, String& errorMsg, const String& autoImportOutput) |
| 998 | { |
| 999 | PROFILE_CPU(); |
| 1000 | LOG(Info, "Importing model from \'{0}\'", path); |
| 1001 | const auto startTime = DateTime::NowUTC(); |
| 1002 | |
| 1003 | // Import data |
| 1004 | switch (options.Type) |
| 1005 | { |
| 1006 | case ModelType::Model: |
| 1007 | options.ImportTypes = ImportDataTypes::Geometry | ImportDataTypes::Nodes; |
| 1008 | if (options.ImportMaterials) |
| 1009 | options.ImportTypes |= ImportDataTypes::Materials; |
| 1010 | if (options.ImportTextures) |
| 1011 | options.ImportTypes |= ImportDataTypes::Textures; |
| 1012 | break; |
| 1013 | case ModelType::SkinnedModel: |
| 1014 | options.ImportTypes = ImportDataTypes::Geometry | ImportDataTypes::Nodes | ImportDataTypes::Skeleton; |
| 1015 | if (options.ImportMaterials) |
| 1016 | options.ImportTypes |= ImportDataTypes::Materials; |
| 1017 | if (options.ImportTextures) |
| 1018 | options.ImportTypes |= ImportDataTypes::Textures; |
| 1019 | break; |
| 1020 | case ModelType::Animation: |
| 1021 | options.ImportTypes = ImportDataTypes::Animations; |
| 1022 | if (options.RootMotion == RootMotionMode::ExtractCenterOfMass) |
| 1023 | options.ImportTypes |= ImportDataTypes::Skeleton; |
| 1024 | break; |
| 1025 | case ModelType::Prefab: |
| 1026 | options.ImportTypes = ImportDataTypes::Geometry | ImportDataTypes::Nodes | ImportDataTypes::Skeleton | ImportDataTypes::Animations; |
| 1027 | if (options.ImportMaterials) |
| 1028 | options.ImportTypes |= ImportDataTypes::Materials; |
| 1029 | if (options.ImportTextures) |
| 1030 | options.ImportTypes |= ImportDataTypes::Textures; |
| 1031 | break; |
| 1032 | default: |
| 1033 | return true; |
| 1034 | } |
| 1035 | if (ImportData(path, data, options, errorMsg)) |
| 1036 | return true; |
| 1037 | |
| 1038 | // Copy over data format options |
| 1039 | data.PositionFormat = (ModelData::PositionFormats)options.PositionFormat; |
| 1040 | data.TexCoordFormat = (ModelData::TexCoordFormats)options.TexCoordFormat; |
| 1041 | |
| 1042 | // Validate result data |
| 1043 | if (EnumHasAnyFlags(options.ImportTypes, ImportDataTypes::Geometry)) |
| 1044 | { |
| 1045 | LOG(Info, "Imported model has {0} LODs, {1} meshes (in LOD0) and {2} materials", data.LODs.Count(), data.LODs.Count() != 0 ? data.LODs[0].Meshes.Count() : 0, data.Materials.Count()); |
| 1046 | |
| 1047 | // Process blend shapes |
| 1048 | for (auto& lod : data.LODs) |
| 1049 | { |
| 1050 | for (auto& mesh : lod.Meshes) |
| 1051 | { |
| 1052 | if (mesh->BlendShapes.IsEmpty()) |
| 1053 | continue; |
| 1054 | for (int32 blendShapeIndex = mesh->BlendShapes.Count() - 1; blendShapeIndex >= 0; blendShapeIndex--) |
nothing calls this directly
no test coverage detected