本文整理汇总了C++中USkeleton::GetBoneTree方法的典型用法代码示例。如果您正苦于以下问题:C++ USkeleton::GetBoneTree方法的具体用法?C++ USkeleton::GetBoneTree怎么用?C++ USkeleton::GetBoneTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类USkeleton
的用法示例。
在下文中一共展示了USkeleton::GetBoneTree方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExportText
bool UAnimExporterITP::ExportText(const FExportObjectInnerContext* Context, UObject* Object, const TCHAR* Type, FOutputDevice& Ar, FFeedbackContext* Warn, uint32 PortFlags /*= 0*/)
{
UAnimSequence* AnimSeq = CastChecked<UAnimSequence>(Object);
USkeleton* Skeleton = AnimSeq->GetSkeleton();
const FReferenceSkeleton& RefSkeleton = Skeleton->GetReferenceSkeleton();
USkeletalMesh* SkelMesh = Skeleton->GetPreviewMesh();
if (AnimSeq->SequenceLength == 0.f)
{
// something is wrong
return false;
}
const float FrameRate = AnimSeq->NumFrames / AnimSeq->SequenceLength;
// Open another archive
FArchive* File = IFileManager::Get().CreateFileWriter(*UExporter::CurrentFilename);
// Let's try the header...
File->Logf(TEXT("{"));
File->Logf(TEXT("\t\"metadata\":{"));
File->Logf(TEXT("\t\t\"type\":\"itpanim\","));
File->Logf(TEXT("\t\t\"version\":2"));
File->Logf(TEXT("\t},"));
File->Logf(TEXT("\t\"sequence\":{"));
File->Logf(TEXT("\t\t\"frames\":%d,"), AnimSeq->NumFrames);
File->Logf(TEXT("\t\t\"length\":%f,"), AnimSeq->SequenceLength);
File->Logf(TEXT("\t\t\"bonecount\":%d,"), RefSkeleton.GetNum());
File->Logf(TEXT("\t\t\"tracks\":["));
bool firstOutput = false;
for (int32 BoneIndex = 0; BoneIndex < RefSkeleton.GetNum(); ++BoneIndex)
{
//int32 BoneTreeIndex = Skeleton->GetSkeletonBoneIndexFromMeshBoneIndex(SkelMesh, BoneIndex);
int32 BoneTrackIndex = Skeleton->GetAnimationTrackIndex(BoneIndex, AnimSeq);
if (BoneTrackIndex == INDEX_NONE)
{
// If this sequence does not have a track for the current bone, then skip it
continue;
}
if (firstOutput)
{
File->Logf(TEXT("\t\t\t},"));
}
firstOutput = true;
File->Logf(TEXT("\t\t\t{"));
File->Logf(TEXT("\t\t\t\t\"bone\":%d,"), BoneIndex);
File->Logf(TEXT("\t\t\t\t\"transforms\":["));
float AnimTime = 0.0f;
float AnimEndTime = AnimSeq->SequenceLength;
// Subtracts 1 because NumFrames includes an initial pose for 0.0 second
double TimePerKey = (AnimSeq->SequenceLength / (AnimSeq->NumFrames - 1));
const float AnimTimeIncrement = TimePerKey;
bool bLastKey = false;
// Step through each frame and add the bone's transformation data
while (!bLastKey)
{
const TArray<FBoneNode>& BoneTree = Skeleton->GetBoneTree();
FTransform BoneAtom;
AnimSeq->GetBoneTransform(BoneAtom, BoneTrackIndex, AnimTime, true);
bLastKey = AnimTime >= AnimEndTime;
File->Logf(TEXT("\t\t\t\t\t{"));
FQuat rot = BoneAtom.GetRotation();
// For the root bone, we need to fix-up the rotation because Unreal exports
// animations with Y-forward for some reason (maybe because Maya?)
if (BoneIndex == 0)
{
FQuat addRot(FVector(0.0f, 0.0f, 1.0f), -1.57f);
rot = addRot * rot;
}
File->Logf(TEXT("\t\t\t\t\t\t\"rot\":[%f,%f,%f,%f],"), rot.X, rot.Y, rot.Z, rot.W);
FVector trans = BoneAtom.GetTranslation();
// Sanjay: If it's skeleton retargeting, change the translation to be from the ref pose skeleton
if (BoneTree[BoneIndex].TranslationRetargetingMode == EBoneTranslationRetargetingMode::Skeleton)
{
const FTransform& BoneTransform = RefSkeleton.GetRefBonePose()[BoneIndex];
trans = BoneTransform.GetTranslation();
}
File->Logf(TEXT("\t\t\t\t\t\t\"trans\":[%f,%f,%f]"), trans.X, trans.Y, trans.Z);
if (!bLastKey)
{
File->Logf(TEXT("\t\t\t\t\t},"));
}
else
{
File->Logf(TEXT("\t\t\t\t\t}"));
//.........这里部分代码省略.........