Hello everyone! I’m making code to import a model into static mesh (c++) but the asset itself if emptyand UE4 does not see him. I see this asset in Windows and weighs only 332 bytes.
UnFbx::FFbxImporter* importFBX = UnFbx::FFbxImporter::GetInstance();
FString FbxPath = TEXT("C:\\Users\\Vick\\Documents\\Unreal Projects\\vrprj\\Source\\vrprj\\RosesOrange.fbx");
//FString FbxPath2 = TEXT("C:\Users\Vick\Documents\Unreal Projects\vrprj\Source\vrprj\RosesOrange.fbx");
if (importFBX->ImportFromFile(TEXT("C:\\Users\\Vick\\Documents\\Unreal Projects\\vrprj\\Source\\vrprj\\RosesOrange.fbx"), TEXT("fbx"))) {
TArray<FbxNode*> FbxMeshArray;
FbxGeometryConverter *pFbxGeometryConverter = importFBX->GetGeometryConverter();
importFBX->FillFbxMeshArray(importFBX->Scene->GetRootNode(), FbxMeshArray, importFBX);
UFbxStaticMeshImportData* importData = NewObject<UFbxStaticMeshImportData>(GetTransientPackage(), NAME_None, RF_NoFlags, NULL);
importData->bImportMeshLODs = true;
importData->StaticMeshLODGroup = FName(TEXT("HighDetailLOD"));
FBXImportOptions *pFBXImportOptions =importFBX->GetImportOptions();
pFBXImportOptions->bAutoComputeLodDistances=true;
pFBXImportOptions->bPreserveSmoothingGroups = true;
for (int i = 0; i < FbxMeshArray.Num(); i++) {
pFbxGeometryConverter->ConvertNurbsSurfaceToNurbsInPlace(FbxMeshArray[i]);
TArray<FbxNode*> array;
array.Add(FbxMeshArray[i]);
UStaticMesh* mesh = NewObject<UStaticMesh>();
mesh = (UStaticMesh*)importFBX->ImportStaticMesh(GetTransientPackage(), FbxMeshArray[i], FbxMeshArray[i]->GetName(), RF_NoFlags, importData, mesh, 1);
//UFbxAnimSequenceImportData* animData = NewObject<UFbxAnimSequenceImportData>();
if (mesh->GetFullName() != "None")
{
UE_LOG(LogTemp, Warning, TEXT("ImportStaticMeshAsSingle success mesh"));
UE_LOG(LogTemp, Warning, TEXT("%s"), importFBX->GetErrorMessage());
UPackage* Package = CreatePackage(NULL, TEXT("/Game/MyMeshFolderTest2/Mesh")); //Create package if not exist
Package->FullyLoad(); //Load full package for import
Package->MarkPackageDirty(); // Mark package dirty to be able to save
FAssetRegistryModule::AssetCreated(mesh); //Notifies registry of new asset in-memory
FString PackageFileName = FPackageName::LongPackageNameToFilename(TEXT("/Game/MyMeshFolderTest2/Mesh"), FPackageName::GetAssetPackageExtension());
bool bSaved = UPackage::SavePackage(Package, mesh, EObjectFlags::RF_Public, *PackageFileName, GError, nullptr, true, true);
if (bSaved == true)
{
UE_LOG(LogTemp, Warning, TEXT("Saved package"));
}
UE_LOG(LogTemp, Warning, TEXT("Start02"));
UFbxFactory* factory = NewObject<UFbxFactory>(UFbxFactory::StaticClass(), FName("Factory"), RF_NoFlags);
factory->ImportUI->StaticMeshImportData->bCombineMeshes = true;
bool canceled = false;
//UPackage* Package = CreatePackage(NULL, TEXT("/Game/MyMeshFolder/Mesh")); //Create package if not exist
factory->ImportObject(factory->ResolveSupportedClass(), Package, FName("MyMesh_%s", i), RF_Public | RF_Standalone, FbxPath, nullptr, canceled);
if (canceled == true)
{
UE_LOG(LogTemp, Warning, TEXT("Import canceled."));
}
}
}
}
This code compiling, and then a click start-buttom, i have this warning : “LogFbx: Warning: No smoothing group information was found in this FBX scene. Please make sure to enable the ‘Export Smoothing Groups’ option in the FBX Exporter plug-in before exporting the file. Even for tools that don’t support smoothing groups, the FBX Exporter will generate appropriate smoothing data at export-time so that correct vertex normals can be
inferred while importing.” and "FBXImport: Warning: Can’t detect import type. No mesh is found or animation track. " I experimented witch FBXImportOptions and UFbxStaticMeshImportData, but its does not help. How i can fix this problem?