本文整理汇总了C++中unfbx::FFbxImporter::FindFBXMeshesByBone方法的典型用法代码示例。如果您正苦于以下问题:C++ FFbxImporter::FindFBXMeshesByBone方法的具体用法?C++ FFbxImporter::FindFBXMeshesByBone怎么用?C++ FFbxImporter::FindFBXMeshesByBone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unfbx::FFbxImporter
的用法示例。
在下文中一共展示了FFbxImporter::FindFBXMeshesByBone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReimportFbxAnimation
bool UEditorEngine::ReimportFbxAnimation( USkeleton* Skeleton, UAnimSequence* AnimSequence, UFbxAnimSequenceImportData* ImportData, const TCHAR* InFilename)
{
check(Skeleton);
GWarn->BeginSlowTask( LOCTEXT("ImportingFbxAnimations", "Importing FBX animations"), true );
UnFbx::FFbxImporter* FbxImporter = UnFbx::FFbxImporter::GetInstance();
// logger for all error/warnings
// this one prints all messages that are stored in FFbxImporter
UnFbx::FFbxLoggerSetter Logger(FbxImporter);
const bool bPrevImportMorph = (AnimSequence->RawCurveData.FloatCurves.Num() > 0) ;
if ( ImportData )
{
// Prepare the import options
UFbxImportUI* ReimportUI = NewObject<UFbxImportUI>();
ReimportUI->MeshTypeToImport = FBXIT_Animation;
ReimportUI->bOverrideFullName = false;
ReimportUI->AnimSequenceImportData = ImportData;
ApplyImportUIToImportOptions(ReimportUI, *FbxImporter->ImportOptions);
}
else
{
FbxImporter->ImportOptions->ResetForReimportAnimation();
}
if ( !FbxImporter->ImportFromFile( InFilename, FPaths::GetExtension( InFilename ) ) )
{
// Log the error message and fail the import.
FbxImporter->FlushToTokenizedErrorMessage(EMessageSeverity::Error);
}
else
{
// Log the import message and import the mesh.
FbxImporter->FlushToTokenizedErrorMessage(EMessageSeverity::Warning);
const FString Filename( InFilename );
// Get Mesh nodes array that bind to the skeleton system, then morph animation is imported.
TArray<FbxNode*> FBXMeshNodeArray;
FbxNode* SkeletonRoot = FbxImporter->FindFBXMeshesByBone(Skeleton->GetReferenceSkeleton().GetBoneName(0), true, FBXMeshNodeArray);
if (!SkeletonRoot)
{
FbxImporter->AddTokenizedErrorMessage(FTokenizedMessage::Create(EMessageSeverity::Error, FText::Format(LOCTEXT("Error_CouldNotFindFbxTrack", "Mesh contains {0} bone as root but animation doesn't contain the root track.\nImport failed."), FText::FromName(Skeleton->GetReferenceSkeleton().GetBoneName(0)))), FFbxErrors::Animation_CouldNotFindTrack);
FbxImporter->ReleaseScene();
GWarn->EndSlowTask();
return false;
}
// for now import all the time?
bool bImportMorphTracks = true;
// Check for blend shape curves that are not skinned. Unskinned geometry can still contain morph curves
if( bImportMorphTracks )
{
TArray<FbxNode*> MeshNodes;
FbxImporter->FillFbxMeshArray( FbxImporter->Scene->GetRootNode(), MeshNodes, FbxImporter );
for( int32 NodeIndex = 0; NodeIndex < MeshNodes.Num(); ++NodeIndex )
{
// Its possible the nodes already exist so make sure they are only added once
FBXMeshNodeArray.AddUnique( MeshNodes[NodeIndex] );
}
}
TArray<FbxNode*> SortedLinks;
FbxImporter->RecursiveBuildSkeleton(SkeletonRoot, SortedLinks);
if(SortedLinks.Num() == 0)
{
FbxImporter->AddTokenizedErrorMessage(FTokenizedMessage::Create(EMessageSeverity::Warning, LOCTEXT("Error_CouldNotBuildValidSkeleton", "Could not create a valid skeleton from the import data that matches the given Skeletal Mesh. Check the bone names of both the Skeletal Mesh for this AnimSet and the animation data you are trying to import.")), FFbxErrors::Animation_CouldNotBuildSkeleton);
}
else
{
// find the correct animation based on import data
FbxAnimStack* CurAnimStack = nullptr;
//ignore the source animation name if there's only one animation in the file.
//this is to make it easier for people who use content creation programs that only export one animation and/or ones that don't allow naming animations
if (FbxImporter->Scene->GetSrcObjectCount(FbxCriteria::ObjectType(FbxAnimStack::ClassId)) > 1 && !ImportData->SourceAnimationName.IsEmpty())
{
CurAnimStack = FbxCast<FbxAnimStack>(FbxImporter->Scene->FindSrcObject(FbxCriteria::ObjectType(FbxAnimStack::ClassId), TCHAR_TO_UTF8(*ImportData->SourceAnimationName), 0));
}
else
{
CurAnimStack = FbxCast<FbxAnimStack>(FbxImporter->Scene->GetSrcObject(FbxCriteria::ObjectType(FbxAnimStack::ClassId), 0));
}
if (CurAnimStack)
{
// set current anim stack
int32 ResampleRate = DEFAULT_SAMPLERATE;
if (FbxImporter->ImportOptions->bResample)
{
ResampleRate = FbxImporter->GetMaxSampleRate(SortedLinks, FBXMeshNodeArray);
}
//.........这里部分代码省略.........
示例2: Filename
UAnimSequence * UEditorEngine::ImportFbxAnimation( USkeleton* Skeleton, UObject* Outer, UFbxAnimSequenceImportData* TemplateImportData, const TCHAR* InFilename, const TCHAR* AnimName, bool bImportMorphTracks )
{
check(Skeleton);
UAnimSequence * NewAnimation=NULL;
UnFbx::FFbxImporter* FFbxImporter = UnFbx::FFbxImporter::GetInstance();
const bool bPrevImportMorph = FFbxImporter->ImportOptions->bImportMorph;
FFbxImporter->ImportOptions->bImportMorph = bImportMorphTracks;
if ( !FFbxImporter->ImportFromFile( InFilename, FPaths::GetExtension( InFilename ) ) )
{
// Log the error message and fail the import.
FFbxImporter->FlushToTokenizedErrorMessage(EMessageSeverity::Error);
}
else
{
// Log the import message and import the mesh.
FFbxImporter->FlushToTokenizedErrorMessage(EMessageSeverity::Warning);
const FString Filename( InFilename );
// Get Mesh nodes array that bind to the skeleton system, then morph animation is imported.
TArray<FbxNode*> FBXMeshNodeArray;
FbxNode* SkeletonRoot = FFbxImporter->FindFBXMeshesByBone(Skeleton->GetReferenceSkeleton().GetBoneName(0), true, FBXMeshNodeArray);
if (!SkeletonRoot)
{
FFbxImporter->AddTokenizedErrorMessage(FTokenizedMessage::Create(EMessageSeverity::Error, FText::Format(LOCTEXT("Error_CouldNotFindFbxTrack", "Mesh contains {0} bone as root but animation doesn't contain the root track.\nImport failed."), FText::FromName(Skeleton->GetReferenceSkeleton().GetBoneName(0)))), FFbxErrors::Animation_CouldNotFindRootTrack);
FFbxImporter->ReleaseScene();
return NULL;
}
// Check for blend shape curves that are not skinned. Unskinned geometry can still contain morph curves
if( bImportMorphTracks )
{
TArray<FbxNode*> MeshNodes;
FFbxImporter->FillFbxMeshArray( FFbxImporter->Scene->GetRootNode(), MeshNodes, FFbxImporter );
for( int32 NodeIndex = 0; NodeIndex < MeshNodes.Num(); ++NodeIndex )
{
// Its possible the nodes already exist so make sure they are only added once
FBXMeshNodeArray.AddUnique( MeshNodes[NodeIndex] );
}
}
TArray<FbxNode*> SortedLinks;
FFbxImporter->RecursiveBuildSkeleton(SkeletonRoot, SortedLinks);
if(SortedLinks.Num() == 0)
{
FFbxImporter->AddTokenizedErrorMessage(FTokenizedMessage::Create(EMessageSeverity::Warning, LOCTEXT("Error_CouldNotBuildValidSkeleton", "Could not create a valid skeleton from the import data that matches the given Skeletal Mesh. Check the bone names of both the Skeletal Mesh for this AnimSet and the animation data you are trying to import.")),
FFbxErrors::Animation_CouldNotBuildSkeleton);
}
else
{
NewAnimation = FFbxImporter->ImportAnimations( Skeleton, Outer, SortedLinks, AnimName, TemplateImportData, FBXMeshNodeArray);
if( NewAnimation )
{
// since to know full path, reimport will need to do same
UFbxAnimSequenceImportData* ImportData = UFbxAnimSequenceImportData::GetImportDataForAnimSequence(NewAnimation, TemplateImportData);
ImportData->Update(UFactory::CurrentFilename);
}
}
}
FFbxImporter->ImportOptions->bImportMorph = bPrevImportMorph;
FFbxImporter->ReleaseScene();
return NewAnimation;
}