本文整理汇总了C++中USkeleton::GetReferenceSkeleton方法的典型用法代码示例。如果您正苦于以下问题:C++ USkeleton::GetReferenceSkeleton方法的具体用法?C++ USkeleton::GetReferenceSkeleton怎么用?C++ USkeleton::GetReferenceSkeleton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类USkeleton
的用法示例。
在下文中一共展示了USkeleton::GetReferenceSkeleton方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PyErr_Format
PyObject *py_ue_skeletal_mesh_set_skeleton(ue_PyUObject * self, PyObject * args)
{
ue_py_check(self);
PyObject *py_skeleton;
if (!PyArg_ParseTuple(args, "O:skeletal_mesh_set_skeleton", &py_skeleton))
return nullptr;
USkeletalMesh *mesh = ue_py_check_type<USkeletalMesh>(self);
if (!mesh)
return PyErr_Format(PyExc_Exception, "UObject is not a USkeletalMesh.");
USkeleton *skeleton = ue_py_check_type<USkeleton>(py_skeleton);
if (!skeleton)
return PyErr_Format(PyExc_Exception, "argument is not a USkeleton.");
mesh->ReleaseResources();
mesh->ReleaseResourcesFence.Wait();
mesh->Skeleton = skeleton;
mesh->RefSkeleton = skeleton->GetReferenceSkeleton();
mesh->RefBasesInvMatrix.Empty();
mesh->CalculateInvRefMatrices();
#if WITH_EDITOR
mesh->PostEditChange();
#endif
mesh->InitResources();
mesh->MarkPackageDirty();
Py_RETURN_NONE;
}
示例2: MoveSelectActorLocation
void UAnimGraphNode_TwoBoneIK::MoveSelectActorLocation(const USkeletalMeshComponent* SkelComp, FAnimNode_SkeletalControlBase* AnimNode)
{
USkeleton * Skeleton = SkelComp->SkeletalMesh->Skeleton;
// create a bone select actor
if (!BoneSelectActor.IsValid())
{
if (Node.JointTargetLocationSpace == EBoneControlSpace::BCS_BoneSpace ||
Node.JointTargetLocationSpace == EBoneControlSpace::BCS_ParentBoneSpace)
{
int32 JointTargetIndex = Skeleton->GetReferenceSkeleton().FindBoneIndex(Node.JointTargetSpaceBoneName);
if (JointTargetIndex != INDEX_NONE)
{
UWorld* World = SkelComp->GetWorld();
check(World);
BoneSelectActor = World->SpawnActor<ABoneSelectActor>(FVector(0), FRotator(0, 0, 0));
check(BoneSelectActor.IsValid());
}
}
}
if (!BoneSelectActor.IsValid())
{
return;
}
// move the actor's position
if (BoneSelectMode == BSM_JointTarget)
{
FName BoneName;
int32 EffectorBoneIndex = SkelComp->GetBoneIndex(Node.EffectorSpaceBoneName);
if (EffectorBoneIndex != INDEX_NONE)
{
BoneName = Node.EffectorSpaceBoneName;
}
else
{
BoneName = Node.IKBone.BoneName;
}
FVector ActorLocation = ConvertWidgetLocation(SkelComp, AnimNode->ForwardedPose, BoneName, Node.EffectorLocation, Node.EffectorLocationSpace);
BoneSelectActor->SetActorLocation(ActorLocation + FVector(0, 10, 0));
}
else if (BoneSelectMode == BSM_EndEffector)
{
int32 JointTargetIndex = SkelComp->GetBoneIndex(Node.JointTargetSpaceBoneName);
if (JointTargetIndex != INDEX_NONE)
{
FVector ActorLocation = ConvertWidgetLocation(SkelComp, AnimNode->ForwardedPose, Node.JointTargetSpaceBoneName, Node.JointTargetLocation, Node.JointTargetLocationSpace);
BoneSelectActor->SetActorLocation(ActorLocation + FVector(0, 10, 0));
}
}
}
示例3: 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}"));
//.........这里部分代码省略.........
示例4: ConvertToComponentSpaceTransform
void UAnimGraphNode_SkeletalControlBase::ConvertToComponentSpaceTransform(const USkeletalMeshComponent* SkelComp, const FTransform & InTransform, FTransform & OutCSTransform, int32 BoneIndex, EBoneControlSpace Space) const
{
USkeleton * Skeleton = SkelComp->SkeletalMesh->Skeleton;
switch (Space)
{
case BCS_WorldSpace:
{
OutCSTransform = InTransform;
OutCSTransform.SetToRelativeTransform(SkelComp->ComponentToWorld);
}
break;
case BCS_ComponentSpace:
{
// Component Space, no change.
OutCSTransform = InTransform;
}
break;
case BCS_ParentBoneSpace:
if (BoneIndex != INDEX_NONE)
{
const int32 ParentIndex = Skeleton->GetReferenceSkeleton().GetParentIndex(BoneIndex);
if (ParentIndex != INDEX_NONE)
{
const int32 MeshParentIndex = Skeleton->GetMeshBoneIndexFromSkeletonBoneIndex(SkelComp->SkeletalMesh, ParentIndex);
if (MeshParentIndex != INDEX_NONE)
{
const FTransform ParentTM = SkelComp->GetBoneTransform(MeshParentIndex);
OutCSTransform = InTransform * ParentTM;
}
else
{
OutCSTransform = InTransform;
}
}
}
break;
case BCS_BoneSpace:
if (BoneIndex != INDEX_NONE)
{
const int32 MeshBoneIndex = Skeleton->GetMeshBoneIndexFromSkeletonBoneIndex(SkelComp->SkeletalMesh, BoneIndex);
if (MeshBoneIndex != INDEX_NONE)
{
const FTransform BoneTM = SkelComp->GetBoneTransform(MeshBoneIndex);
OutCSTransform = InTransform * BoneTM;
}
else
{
OutCSTransform = InTransform;
}
}
break;
default:
if (SkelComp->SkeletalMesh)
{
UE_LOG(LogAnimation, Warning, TEXT("ConvertToComponentSpaceTransform: Unknown BoneSpace %d for Mesh: %s"), (uint8)Space, *SkelComp->SkeletalMesh->GetFName().ToString());
}
else
{
UE_LOG(LogAnimation, Warning, TEXT("ConvertToComponentSpaceTransform: Unknown BoneSpace %d for Skeleton: %s"), (uint8)Space, *Skeleton->GetFName().ToString());
}
break;
}
}
示例5: FactoryCreateText
//.........这里部分代码省略.........
EntitySkeleton->SetPreviewMesh(SkeletalMesh);
// Create the animations
for (const FSpriterAnimation& Animation : Entity.Animations)
{
//@TODO: That thing I said...
const FString TargetAnimationName = Animation.Name;
const FString TargetAnimationPath = LongPackagePath / TEXT("Animations");
UAnimSequence* AnimationAsset = CastChecked<UAnimSequence>(CreateNewAsset(UAnimSequence::StaticClass(), TargetAnimationPath, TargetAnimationName, Flags));
AnimationAsset->SetSkeleton(EntitySkeleton);
// if you have one pose(thus 0.f duration), it still contains animation, so we'll need to consider that as MINIMUM_ANIMATION_LENGTH time length
const float DurationInSeconds = Animation.LengthInMS * 0.001f;
AnimationAsset->SequenceLength = FMath::Max<float>(DurationInSeconds, MINIMUM_ANIMATION_LENGTH);
const bool bSourceDataExists = (AnimationAsset->SourceRawAnimationData.Num() > 0);
TArray<struct FRawAnimSequenceTrack>& RawAnimationData = bSourceDataExists ? AnimationAsset->SourceRawAnimationData : AnimationAsset->RawAnimationData;
int32 TotalNumKeys = 0;
for (const FSpriterTimeline& Timeline : Animation.Timelines)
{
if (Timeline.ObjectType != ESpriterObjectType::Bone)
{
continue;
}
const FName BoneName = Entity.Objects[Timeline.ObjectIndex].ObjectName;
const int32 RefBoneIndex = EntitySkeleton->GetReferenceSkeleton().FindBoneIndex(BoneName);
check(RefBoneIndex != INDEX_NONE);
FRawAnimSequenceTrack RawTrack;
RawTrack.PosKeys.Empty();
RawTrack.RotKeys.Empty();
RawTrack.ScaleKeys.Empty();
int32 NumKeysForTrack = 0;
//@TODO: Quick and dirty resampling code that needs to be replaced (totally ignores curve type, edge cases, etc...)
const float ResampleFPS = 30.0f;
int32 DesiredNumKeys = FMath::CeilToInt(ResampleFPS * DurationInSeconds);
const float TimePerKey = 1.0f / ResampleFPS;
float CurrentSampleTime = 0.0f;
for (int32 FrameIndex = 0; FrameIndex < DesiredNumKeys; ++FrameIndex)
{
int32 LowerKeyIndex = 0;
for (; LowerKeyIndex < Timeline.Keys.Num(); ++LowerKeyIndex)
{
if (Timeline.Keys[LowerKeyIndex].TimeInMS * 0.001f > CurrentSampleTime)
{
--LowerKeyIndex;
break;
}
}
if (LowerKeyIndex >= Timeline.Keys.Num())
{
LowerKeyIndex = Timeline.Keys.Num() - 1;
}
int32 UpperKeyIndex = LowerKeyIndex + 1;