本文整理汇总了C++中FTransform::GetTranslation方法的典型用法代码示例。如果您正苦于以下问题:C++ FTransform::GetTranslation方法的具体用法?C++ FTransform::GetTranslation怎么用?C++ FTransform::GetTranslation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FTransform
的用法示例。
在下文中一共展示了FTransform::GetTranslation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void UAnimGraphNode_BoneDrivenController::Draw(FPrimitiveDrawInterface* PDI, USkeletalMeshComponent* SkelMeshComp) const
{
static const float ArrowHeadWidth = 5.0f;
static const float ArrowHeadHeight = 8.0f;
const int32 SourceIdx = SkelMeshComp->GetBoneIndex(Node.SourceBone.BoneName);
const int32 TargetIdx = SkelMeshComp->GetBoneIndex(Node.TargetBone.BoneName);
if ((SourceIdx != INDEX_NONE) && (TargetIdx != INDEX_NONE))
{
const FTransform SourceTM = SkelMeshComp->GetSpaceBases()[SourceIdx] * SkelMeshComp->ComponentToWorld;
const FTransform TargetTM = SkelMeshComp->GetSpaceBases()[TargetIdx] * SkelMeshComp->ComponentToWorld;
PDI->DrawLine(TargetTM.GetLocation(), SourceTM.GetLocation(), FLinearColor(0.0f, 0.0f, 1.0f), SDPG_Foreground, 0.5f);
const FVector ToTarget = TargetTM.GetTranslation() - SourceTM.GetTranslation();
const FVector UnitToTarget = ToTarget.GetSafeNormal();
FVector Midpoint = SourceTM.GetTranslation() + 0.5f * ToTarget + 0.5f * UnitToTarget * ArrowHeadHeight;
FVector YAxis;
FVector ZAxis;
UnitToTarget.FindBestAxisVectors(YAxis, ZAxis);
const FMatrix ArrowMatrix(UnitToTarget, YAxis, ZAxis, Midpoint);
DrawConnectedArrow(PDI, ArrowMatrix, FLinearColor(0.0f, 1.0f, 0.0), ArrowHeadHeight, ArrowHeadWidth, SDPG_Foreground);
PDI->DrawPoint(SourceTM.GetTranslation(), FLinearColor(0.8f, 0.8f, 0.2f), 5.0f, SDPG_Foreground);
PDI->DrawPoint(SourceTM.GetTranslation() + ToTarget, FLinearColor(0.8f, 0.8f, 0.2f), 5.0f, SDPG_Foreground);
}
}
示例2: SetRefFrame
void FConstraintInstance::SetRefFrame(EConstraintFrame::Type Frame, const FTransform& RefFrame)
{
#if WITH_PHYSX
PxJointActorIndex::Enum PxFrame = U2PConstraintFrame(Frame);
#endif
if(Frame == EConstraintFrame::Frame1)
{
Pos1 = RefFrame.GetTranslation();
PriAxis1 = RefFrame.GetUnitAxis( EAxis::X );
SecAxis1 = RefFrame.GetUnitAxis( EAxis::Y );
}
else
{
Pos2 = RefFrame.GetTranslation();
PriAxis2 = RefFrame.GetUnitAxis( EAxis::X );
SecAxis2 = RefFrame.GetUnitAxis( EAxis::Y );
}
#if WITH_PHYSX
if (PxD6Joint* Joint = GetUnbrokenJoint())
{
PxTransform PxRefFrame = U2PTransform(RefFrame);
Joint->setLocalPose(PxFrame, PxRefFrame);
}
#endif
}
示例3: EvaluateBoneTransforms
void FAnimNode_HandIKRetargeting::EvaluateBoneTransforms(USkeletalMeshComponent* SkelComp, const FBoneContainer& RequiredBones, FA2CSPose& MeshBases, TArray<FBoneTransform>& OutBoneTransforms)
{
checkSlow(OutBoneTransforms.Num() == 0);
// Get component space transforms for all of our IK and FK bones.
FTransform const RightHandFKTM = MeshBases.GetComponentSpaceTransform(RightHandFK.BoneIndex);
FTransform const LeftHandFKTM = MeshBases.GetComponentSpaceTransform(LeftHandFK.BoneIndex);
FTransform const RightHandIKTM = MeshBases.GetComponentSpaceTransform(RightHandIK.BoneIndex);
FTransform const LeftHandIKTM = MeshBases.GetComponentSpaceTransform(LeftHandIK.BoneIndex);
// Compute weight FK and IK hand location. And translation from IK to FK.
FVector const FKLocation = FMath::Lerp<FVector>(LeftHandFKTM.GetTranslation(), RightHandFKTM.GetTranslation(), HandFKWeight);
FVector const IKLocation = FMath::Lerp<FVector>(LeftHandIKTM.GetTranslation(), RightHandIKTM.GetTranslation(), HandFKWeight);
FVector const IK_To_FK_Translation = FKLocation - IKLocation;
// If we're not translating, don't send any bones to update.
if (!IK_To_FK_Translation.IsNearlyZero())
{
// Move desired bones
for (int32 BoneIndex = 0; BoneIndex < IKBonesToMove.Num(); BoneIndex++)
{
FBoneReference const & BoneReference = IKBonesToMove[BoneIndex];
if (BoneReference.IsValid(RequiredBones))
{
FTransform BoneTransform = MeshBases.GetComponentSpaceTransform(BoneReference.BoneIndex);
BoneTransform.AddToTranslation(IK_To_FK_Translation);
OutBoneTransforms.Add(FBoneTransform(BoneReference.BoneIndex, BoneTransform));
}
}
}
}
示例4: ConsumeRootMotion
void UDebugSkelMeshComponent::ConsumeRootMotion(const FVector& FloorMin, const FVector& FloorMax)
{
if (bPreviewRootMotion)
{
if (UAnimInstance* AnimInst = GetAnimInstance())
{
FRootMotionMovementParams ExtractedRootMotion = AnimInst->ConsumeExtractedRootMotion();
if (ExtractedRootMotion.bHasRootMotion)
{
AddLocalTransform(ExtractedRootMotion.RootMotionTransform);
//Handle moving component so that it stays within the editor floor
FTransform CurrentTransform = GetRelativeTransform();
FVector Trans = CurrentTransform.GetTranslation();
Trans.X = WrapInRange(Trans.X, FloorMin.X, FloorMax.X);
Trans.Y = WrapInRange(Trans.Y, FloorMin.Y, FloorMax.Y);
CurrentTransform.SetTranslation(Trans);
SetRelativeTransform(CurrentTransform);
}
}
}
else
{
SetWorldTransform(FTransform());
}
}
示例5: EvaluateBoneTransforms
void FAnimNode_CopyBone::EvaluateBoneTransforms(USkeletalMeshComponent* SkelComp, const FBoneContainer & RequiredBones, FA2CSPose& MeshBases, TArray<FBoneTransform>& OutBoneTransforms)
{
check(OutBoneTransforms.Num() == 0);
// Pass through if we're not doing anything.
if( !bCopyTranslation && !bCopyRotation && !bCopyScale )
{
return;
}
// Get component space transform for source and current bone.
FTransform SourceBoneTM = MeshBases.GetComponentSpaceTransform(SourceBone.BoneIndex);
FTransform CurrentBoneTM = MeshBases.GetComponentSpaceTransform(TargetBone.BoneIndex);
// Copy individual components
if (bCopyTranslation)
{
CurrentBoneTM.SetTranslation( SourceBoneTM.GetTranslation() );
}
if (bCopyRotation)
{
CurrentBoneTM.SetRotation( SourceBoneTM.GetRotation() );
}
if (bCopyScale)
{
CurrentBoneTM.SetScale3D( SourceBoneTM.GetScale3D() );
}
// Output new transform for current bone.
OutBoneTransforms.Add( FBoneTransform(TargetBone.BoneIndex, CurrentBoneTM) );
}
示例6: StartPlay
void AProjectTapGameMode::StartPlay()
{
Super::StartPlay();
auto gameState = GetGameState<AProjectTapGameState>();
ABallPawn* ball = nullptr;
if ( UWorld* world = GetWorld() )
{
AActor* playerStart = FindPlayerStart( 0 , FString( "Player" ) );
FTransform playerTransform = playerStart->GetTransform();
if ( ABallPlayerStart* realPlayerStart = Cast<ABallPlayerStart>( playerStart ) )
{
auto possibleCamera = realPlayerStart->camera == nullptr ? nullptr : Cast<UProjectTapCameraComponent>( realPlayerStart->camera->GetComponentByClass( UProjectTapCameraComponent::StaticClass() ) );
FActorSpawnParameters params;
ball = world->SpawnActor<ABallPawn>(
ABallPawn::StaticClass() ,
playerTransform.GetTranslation() ,
FRotator( playerTransform.GetRotation() ) ,
params );
if ( ball != nullptr )
{
ball->AddVelocity( realPlayerStart->initialVelocity , realPlayerStart->GetActorLocation() );
if ( possibleCamera != nullptr && realPlayerStart->followPlayer )
{
ball->setCamera( realPlayerStart );
possibleCamera = ball->GetCamera();
}
}
gameState->SetCamera( possibleCamera );
isMenu = realPlayerStart->GameMode == CustomGameMode::GAME_MODE_MAIN_MENU;
if ( realPlayerStart->music != nullptr )musicPlayer->SetSound( realPlayerStart->music );
}
else
{
FActorSpawnParameters params;
ball = world->SpawnActor<ABallPawn>( ABallPawn::StaticClass() , playerTransform.GetTranslation() , FRotator( playerTransform.GetRotation() ) , params );
}
gameState->SetPlayer(ball);
}
musicPlayer->Play();
musicPlayer->SetVolumeMultiplier( 0 );
gameState->SetGameState( CustomGameState::GAME_STATE_PLAYING );
if ( isMenu ) gameState->SetGameMode( CustomGameMode::GAME_MODE_MAIN_MENU );
}
示例7: ExtractAngle
FQuat FAnimNode_RotationMultiplier::ExtractAngle(const FTransform& RefPoseTransform, const FTransform& LocalBoneTransform, const EBoneAxis Axis)
{
// local bone transform with reference rotation
FTransform ReferenceBoneTransform = RefPoseTransform;
ReferenceBoneTransform.SetTranslation(LocalBoneTransform.GetTranslation());
// find delta angle between the two quaternions X Axis.
const FVector RotationAxis = GetAxisVector(Axis);
const FVector LocalRotationVector = LocalBoneTransform.GetRotation().RotateVector(RotationAxis);
const FVector ReferenceRotationVector = ReferenceBoneTransform.GetRotation().RotateVector(RotationAxis);
const FQuat LocalToRefQuat = FQuat::FindBetween(LocalRotationVector, ReferenceRotationVector);
checkSlow( LocalToRefQuat.IsNormalized() );
// Rotate parent bone atom from position in local space to reference skeleton
// Since our rotation rotates both vectors with shortest arc
// we're essentially left with a quaternion that has angle difference with reference skeleton version
const FQuat BoneQuatAligned = LocalToRefQuat* LocalBoneTransform.GetRotation();
checkSlow( BoneQuatAligned.IsNormalized() );
// Find that delta angle
const FQuat DeltaQuat = (ReferenceBoneTransform.GetRotation().Inverse()) * BoneQuatAligned;
checkSlow( DeltaQuat.IsNormalized() );
#if 0 //DEBUG_TWISTBONECONTROLLER
UE_LOG(LogSkeletalControl, Log, TEXT("\t ExtractAngle, Bone: %s"),
*SourceBone.BoneName.ToString());
UE_LOG(LogSkeletalControl, Log, TEXT("\t\t Bone Quat: %s, Rot: %s, AxisX: %s"), *LocalBoneTransform.GetRotation().ToString(), *LocalBoneTransform.GetRotation().Rotator().ToString(), *LocalRotationVector.ToString() );
UE_LOG(LogSkeletalControl, Log, TEXT("\t\t BoneRef Quat: %s, Rot: %s, AxisX: %s"), *ReferenceBoneTransform.GetRotation().ToString(), *ReferenceBoneTransform.GetRotation().Rotator().ToString(), *ReferenceRotationVector.ToString() );
UE_LOG(LogSkeletalControl, Log, TEXT("\t\t LocalToRefQuat Quat: %s, Rot: %s"), *LocalToRefQuat.ToString(), *LocalToRefQuat.Rotator().ToString() );
const FVector BoneQuatAlignedX = LocalBoneTransform.GetRotation().RotateVector(RotationAxis);
UE_LOG(LogSkeletalControl, Log, TEXT("\t\t BoneQuatAligned Quat: %s, Rot: %s, AxisX: %s"), *BoneQuatAligned.ToString(), *BoneQuatAligned.Rotator().ToString(), *BoneQuatAlignedX.ToString() );
UE_LOG(LogSkeletalControl, Log, TEXT("\t\t DeltaQuat Quat: %s, Rot: %s"), *DeltaQuat.ToString(), *DeltaQuat.Rotator().ToString() );
FTransform BoneAtomAligned(BoneQuatAligned, ReferenceBoneTransform.GetTranslation());
const FQuat DeltaQuatAligned = FQuat::FindBetween(BoneAtomAligned.GetScaledAxis( EAxis::X ), ReferenceBoneTransform.GetScaledAxis( EAxis::X ));
UE_LOG(LogSkeletalControl, Log, TEXT("\t\t DeltaQuatAligned Quat: %s, Rot: %s"), *DeltaQuatAligned.ToString(), *DeltaQuatAligned.Rotator().ToString() );
FVector DeltaAxis;
float DeltaAngle;
DeltaQuat.ToAxisAndAngle(DeltaAxis, DeltaAngle);
UE_LOG(LogSkeletalControl, Log, TEXT("\t\t DeltaAxis: %s, DeltaAngle: %f"), *DeltaAxis.ToString(), DeltaAngle );
#endif
return DeltaQuat;
}
示例8: ConvertLocalRootMotionToWorld
FTransform USkeletalMeshComponent::ConvertLocalRootMotionToWorld(const FTransform & InTransform)
{
// Make sure component to world is up to date
if (!bWorldToComponentUpdated)
{
UpdateComponentToWorld();
}
const FTransform NewWorldTransform = InTransform * ComponentToWorld;
const FVector DeltaWorldTranslation = NewWorldTransform.GetTranslation() - ComponentToWorld.GetTranslation();
const FQuat DeltaWorldRotation = ComponentToWorld.GetRotation().Inverse() * NewWorldTransform.GetRotation();
const FTransform DeltaWorldTransform(DeltaWorldRotation, DeltaWorldTranslation);
UE_LOG(LogRootMotion, Log, TEXT("ConvertLocalRootMotionToWorld LocalT: %s, LocalR: %s, WorldT: %s, WorldR: %s."),
*InTransform.GetTranslation().ToCompactString(), *InTransform.GetRotation().Rotator().ToCompactString(),
*DeltaWorldTransform.GetTranslation().ToCompactString(), *DeltaWorldTransform.GetRotation().Rotator().ToCompactString() );
return DeltaWorldTransform;
}
示例9: CalcAABB
FBox FKSphereElem::CalcAABB(const FTransform& BoneTM, float Scale) const
{
FTransform ElemTM = GetTransform();
ElemTM.ScaleTranslation( FVector(Scale) );
ElemTM *= BoneTM;
const FVector BoxCenter = ElemTM.GetTranslation();
const FVector BoxExtents(Radius * Scale);
return FBox(BoxCenter - BoxExtents, BoxCenter + BoxExtents);
}
示例10: EditorApplyTranslation
void AActor::EditorApplyTranslation(const FVector& DeltaTranslation, bool bAltDown, bool bShiftDown, bool bCtrlDown)
{
if( RootComponent != NULL )
{
FTransform NewTransform = GetRootComponent()->GetComponentTransform();
NewTransform.SetTranslation(NewTransform.GetTranslation() + DeltaTranslation);
GetRootComponent()->SetWorldTransform(NewTransform);
}
else
{
UE_LOG(LogActor, Warning, TEXT("WARNING: EditorApplyTranslation %s has no root component"), *GetName() );
}
}
示例11: AttenuationEvalCapsule
float FAttenuationSettings::AttenuationEvalCapsule(const FTransform& SoundTransform, const FVector ListenerLocation, const float DistanceScale) const
{
float Distance = 0.f;
const float CapsuleHalfHeight = AttenuationShapeExtents.X;
const float CapsuleRadius = AttenuationShapeExtents.Y;
// Capsule devolves to a sphere if HalfHeight <= Radius
if (CapsuleHalfHeight <= CapsuleRadius )
{
Distance = FMath::Max(FVector::Dist( SoundTransform.GetTranslation(), ListenerLocation ) - CapsuleRadius, 0.f);
}
else
{
const FVector PointOffset = (CapsuleHalfHeight - CapsuleRadius) * SoundTransform.GetUnitAxis( EAxis::Z );
const FVector StartPoint = SoundTransform.GetTranslation() + PointOffset;
const FVector EndPoint = SoundTransform.GetTranslation() - PointOffset;
Distance = FMath::PointDistToSegment(ListenerLocation, StartPoint, EndPoint) - CapsuleRadius;
}
return AttenuationEval(Distance, FalloffDistance, DistanceScale);
}
示例12: UpdateOrAddKey
void FTransformCurve::UpdateOrAddKey(const FTransform& NewKey, float CurrentTime)
{
TranslationCurve.UpdateOrAddKey(NewKey.GetTranslation(), CurrentTime);
// pitch, yaw, roll order - please check Evaluate function
FVector RotationAsVector;
FRotator Rotator = NewKey.GetRotation().Rotator();
RotationAsVector.X = Rotator.Roll;
RotationAsVector.Y = Rotator.Pitch;
RotationAsVector.Z = Rotator.Yaw;
RotationCurve.UpdateOrAddKey(RotationAsVector, CurrentTime);
ScaleCurve.UpdateOrAddKey(NewKey.GetScale3D(), CurrentTime);
}
示例13: EvaluateBoneTransforms
void FAnimNode_CopyBone::EvaluateBoneTransforms(USkeletalMeshComponent* SkelComp, FCSPose<FCompactPose>& MeshBases, TArray<FBoneTransform>& OutBoneTransforms)
{
check(OutBoneTransforms.Num() == 0);
// Pass through if we're not doing anything.
if( !bCopyTranslation && !bCopyRotation && !bCopyScale )
{
return;
}
// Get component space transform for source and current bone.
const FBoneContainer& BoneContainer = MeshBases.GetPose().GetBoneContainer();
FCompactPoseBoneIndex SourceBoneIndex = SourceBone.GetCompactPoseIndex(BoneContainer);
FCompactPoseBoneIndex TargetBoneIndex = TargetBone.GetCompactPoseIndex(BoneContainer);
FTransform SourceBoneTM = MeshBases.GetComponentSpaceTransform(SourceBoneIndex);
FTransform CurrentBoneTM = MeshBases.GetComponentSpaceTransform(TargetBoneIndex);
if(ControlSpace != BCS_ComponentSpace)
{
// Convert out to selected space
FAnimationRuntime::ConvertCSTransformToBoneSpace(SkelComp, MeshBases, SourceBoneTM, SourceBoneIndex, ControlSpace);
FAnimationRuntime::ConvertCSTransformToBoneSpace(SkelComp, MeshBases, CurrentBoneTM, TargetBoneIndex, ControlSpace);
}
// Copy individual components
if (bCopyTranslation)
{
CurrentBoneTM.SetTranslation( SourceBoneTM.GetTranslation() );
}
if (bCopyRotation)
{
CurrentBoneTM.SetRotation( SourceBoneTM.GetRotation() );
}
if (bCopyScale)
{
CurrentBoneTM.SetScale3D( SourceBoneTM.GetScale3D() );
}
if(ControlSpace != BCS_ComponentSpace)
{
// Convert back out if we aren't operating in component space
FAnimationRuntime::ConvertBoneSpaceTransformToCS(SkelComp, MeshBases, CurrentBoneTM, TargetBoneIndex, ControlSpace);
}
// Output new transform for current bone.
OutBoneTransforms.Add(FBoneTransform(TargetBoneIndex, CurrentBoneTM));
}
示例14: UpdateHandleTransform
void UPhysicsHandleComponent::UpdateHandleTransform(const FTransform& NewTransform)
{
if(!KinActorData)
{
return;
}
#if WITH_PHYSX
bool bChangedPosition = true;
bool bChangedRotation = true;
PxRigidDynamic* KinActor = KinActorData;
// Check if the new location is worthy of change
PxVec3 PNewLocation = U2PVector(NewTransform.GetTranslation());
PxVec3 PCurrentLocation = KinActor->getGlobalPose().p;
if((PNewLocation - PCurrentLocation).magnitudeSquared() <= 0.01f*0.01f)
{
PNewLocation = PCurrentLocation;
bChangedPosition = false;
}
// Check if the new rotation is worthy of change
PxQuat PNewOrientation = U2PQuat(NewTransform.GetRotation());
PxQuat PCurrentOrientation = KinActor->getGlobalPose().q;
if(!(FMath::Abs(PNewOrientation.dot(PCurrentOrientation)) < (1.f - KINDA_SMALL_NUMBER)))
{
PNewOrientation = PCurrentOrientation;
bChangedRotation = false;
}
// Don't call moveKinematic if it hasn't changed - that will stop bodies from going to sleep.
if (bChangedPosition || bChangedRotation)
{
KinActor->setKinematicTarget(PxTransform(PNewLocation, PNewOrientation));
//LOC_MOD
//PxD6Joint* Joint = (PxD6Joint*) HandleData;
//if(Joint)// && (PNewLocation - PCurrentLocation).magnitudeSquared() > 0.01f*0.01f)
//{
// PxRigidActor* Actor0, *Actor1;
// Joint->getActors(Actor0, Actor1);
// //Joint->setDrivePosition(PxTransform(Actor0->getGlobalPose().transformInv(PNewLocation)));
// Joint->setDrivePosition(PxTransform::createIdentity());
// //Joint->setDriveVelocity(PxVec3(0), PxVec3(0));
//}
}
#endif // WITH_PHYSX
}
示例15: TransformToSteamSpace
//=============================================================================
static void TransformToSteamSpace(const FTransform& In, vr::HmdMatrix34_t& Out, float WorldToMeterScale)
{
const FRotator InRot = In.Rotator();
FRotator OutRot(InRot.Yaw, -InRot.Roll, -InRot.Pitch);
const FVector InPos = In.GetTranslation();
FVector OutPos(InPos.Y, InPos.Z, -InPos.X);
OutPos /= WorldToMeterScale;
const FVector InScale = In.GetScale3D();
FVector OutScale(InScale.Y, InScale.Z, -InScale.X);
OutScale /= WorldToMeterScale;
Out = FSteamVRHMD::ToHmdMatrix34(FTransform(OutRot, OutPos, OutScale).ToMatrixNoScale());
}