x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to import FBX Animation Sequence from code

I found the function UEditorEngine::ImportFbxAnimation

but I don't know how to use this function.

I'd like to create Animation Sequence without Import Option Dialog.

Here is my code:

 TArray<FAssetData> SK_Skeleton;
 AssetRegistry.GetAssetsByPackageName(FName("/Game/SK_Skeleton"), SK_Skeleton);
 USkeleton* Skeleton = Cast<USkeleton>(SK_Skeleton[0].GetAsset());
 FName AssetName = TEXT("Anim");
 FString PackagePath = TEXT("/Game/Anim");
 UPackage* Package = CreatePackage(NULL, *PackagePath);
 FString FileName = TEXT("F:/SK_Anim.fbx");
 UFbxAnimSequenceImportData* Data = NewObject<UFbxAnimSequenceImportData>();
 UAnimSequence* NewAnim = UEditorEngine::ImportFbxAnimation(Skeleton, Package,  Data, *Filename, *AssetName.ToString(), true);

What about the ImportData?

The imported asset is not correct.

alt text

(Import button)

alt text

please help, thank you.

Product Version: UE 4.13
Tags:
notvalid.jpg (13.2 kB)
valid.jpg (18.0 kB)
more ▼

asked Feb 20 '17 at 01:17 PM in C++ Programming

avatar image

tsqp
7 4 6 7

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

I think it needs to mark package dirty after your code.

 // Update notice
 NewAnim->MarkPackageDirty();
 ULevel::LevelDirtiedEvent.Broadcast();
 NewAnim->PostEditChange();

And then you had better create UnFbx::FBXImportOptions object and initialize options before calling UEditorEngine::ImportFbxAnimation.

Please refer to UFbxFactory::FactoryCreateBinary in FbxFactory.cpp.

more ▼

answered Feb 21 '17 at 02:53 AM

avatar image

dtakura
103 4 4 8

avatar image tsqp Feb 21 '17 at 08:05 AM

thank you very much.

I added the above code after my code and create FBXImportOptions.

(refered to ApplyImportUIToImportOptions in FbxMainImport.cpp)

I got the correct info.

always thankful for the help.

avatar image Vinayaka_P Dec 13 '18 at 06:05 AM

Hi tsqp

Code snippet in your question is not quite clear that how you import FBX animation from disk in c++? I couldn't find a way to do that. I too don't know how to use UEditorEngine::ImportFbxAnimation(...) function. Can you please help me with that?

avatar image tsqp Dec 13 '18 at 07:10 AM

hi Vinayaka_P

OK, You should create UnFbx::FBXImportOptions object and initialize before calling UEditorEngine::ImportFbxAnimation(...) function.

I attatched sample code. Please check it out. I wish for your help. :-)

link text

avatar image Vinayaka_P Dec 13 '18 at 07:35 AM

Hi,

Thanks for detailed code.

May i know how you managed to get UnFbx::FFbxImporter working?

I tried, 1. including FFbxImporter.h file -> got unresolved external symbol error as in this post 2. modified project.build.cs file to include FBX -> didn't help.

From this post i came to know that i should modify engine code. Should I?

Engine version i'm using is 4.19

Here's another post i looked into

avatar image tsqp Dec 13 '18 at 08:17 AM

hi Vinayaka_P

Try including FbxImporter.h.
not FFbxImporter.h. and then

 UAnimSequence* NewAnim = FTosFBX::ImportAnimationSequence <= function in attached file
 SkeletalMeshActor->GetSkeletalMeshComponent()->SetAnimationMode(EAnimationMode::AnimationSingleNode);
 SkeletalMeshActor->GetSkeletalMeshComponent()->AnimationData.AnimToPlay = NewAnim;
 SkeletalMeshActor->GetSkeletalMeshComponent()->SetAnimation(NewAnim);


Please do your best.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question