本文整理汇总了C++中FTransform::Inverse方法的典型用法代码示例。如果您正苦于以下问题:C++ FTransform::Inverse方法的具体用法?C++ FTransform::Inverse怎么用?C++ FTransform::Inverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FTransform
的用法示例。
在下文中一共展示了FTransform::Inverse方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PreTick
void UVREditorMode::PreTick( const float DeltaTime )
{
if( !bIsFullyInitialized || !bIsActive || bWantsToExitMode )
{
return;
}
//Setting the initial position and rotation based on the editor viewport when going into VR mode
if( bFirstTick && bActuallyUsingVR )
{
const FTransform RoomToWorld = GetRoomTransform();
const FTransform WorldToRoom = RoomToWorld.Inverse();
FTransform ViewportToWorld = FTransform( SavedEditorState.ViewRotation, SavedEditorState.ViewLocation );
FTransform ViewportToRoom = ( ViewportToWorld * WorldToRoom );
FTransform ViewportToRoomYaw = ViewportToRoom;
ViewportToRoomYaw.SetRotation( FQuat( FRotator( 0.0f, ViewportToRoomYaw.GetRotation().Rotator().Yaw, 0.0f ) ) );
FTransform HeadToRoomYaw = GetRoomSpaceHeadTransform();
HeadToRoomYaw.SetRotation( FQuat( FRotator( 0.0f, HeadToRoomYaw.GetRotation().Rotator().Yaw, 0.0f ) ) );
FTransform RoomToWorldYaw = RoomToWorld;
RoomToWorldYaw.SetRotation( FQuat( FRotator( 0.0f, RoomToWorldYaw.GetRotation().Rotator().Yaw, 0.0f ) ) );
FTransform ResultToWorld = ( HeadToRoomYaw.Inverse() * ViewportToRoomYaw ) * RoomToWorldYaw;
SetRoomTransform( ResultToWorld );
}
}
示例2: ConvertCSRotationToBoneSpace
FQuat UAnimGraphNode_SkeletalControlBase::ConvertCSRotationToBoneSpace(const USkeletalMeshComponent* SkelComp, FRotator& InCSRotator, FA2CSPose& MeshBases, const FName& BoneName, const EBoneControlSpace Space)
{
FQuat OutQuat = FQuat::Identity;
if (MeshBases.IsValid())
{
int32 MeshBoneIndex = SkelComp->GetBoneIndex(BoneName);
FVector RotAxis;
float RotAngle;
InCSRotator.Quaternion().ToAxisAndAngle(RotAxis, RotAngle);
switch (Space)
{
// World Space, no change in preview window
case BCS_WorldSpace:
case BCS_ComponentSpace:
// Component Space, no change.
OutQuat = InCSRotator.Quaternion();
break;
case BCS_ParentBoneSpace:
{
const int32 ParentIndex = MeshBases.GetParentBoneIndex(MeshBoneIndex);
if (ParentIndex != INDEX_NONE)
{
FTransform ParentTM = MeshBases.GetComponentSpaceTransform(ParentIndex);
ParentTM = ParentTM.Inverse();
//Calculate the new delta rotation
FVector4 BoneSpaceAxis = ParentTM.TransformVector(RotAxis);
FQuat DeltaQuat(BoneSpaceAxis, RotAngle);
DeltaQuat.Normalize();
OutQuat = DeltaQuat;
}
}
break;
case BCS_BoneSpace:
{
FTransform BoneTM = MeshBases.GetComponentSpaceTransform(MeshBoneIndex);
BoneTM = BoneTM.Inverse();
FVector4 BoneSpaceAxis = BoneTM.TransformVector(RotAxis);
//Calculate the new delta rotation
FQuat DeltaQuat(BoneSpaceAxis, RotAngle);
DeltaQuat.Normalize();
OutQuat = DeltaQuat;
}
break;
}
}
return OutQuat;
}
示例3: AdjustComponentDelta
void FComponentEditorUtils::AdjustComponentDelta(USceneComponent* Component, FVector& Drag, FRotator& Rotation)
{
USceneComponent* ParentSceneComp = Component->GetAttachParent();
if (ParentSceneComp)
{
const FTransform ParentToWorldSpace = ParentSceneComp->GetSocketTransform(Component->AttachSocketName);
if (!Component->bAbsoluteLocation)
{
Drag = ParentToWorldSpace.Inverse().TransformVector(Drag);
}
if (!Component->bAbsoluteRotation)
{
Rotation = ( ParentToWorldSpace.Inverse().GetRotation() * Rotation.Quaternion() * ParentToWorldSpace.GetRotation() ).Rotator();
}
}
}
示例4: AdjustComponentDelta
void FComponentEditorUtils::AdjustComponentDelta(USceneComponent* Component, FVector& Drag, FRotator& Rotation)
{
USceneComponent* ParentSceneComp = Component->GetAttachParent();
if (ParentSceneComp)
{
const FTransform ParentToWorldSpace = ParentSceneComp->GetSocketTransform(Component->AttachSocketName);
if (!Component->bAbsoluteLocation)
{
//transform the drag vector in relative to the parent transform
Drag = ParentToWorldSpace.InverseTransformVectorNoScale(Drag);
//Now that we have a global drag we can apply the parent scale
Drag = Drag * ParentToWorldSpace.Inverse().GetScale3D();
}
if (!Component->bAbsoluteRotation)
{
Rotation = ( ParentToWorldSpace.Inverse().GetRotation() * Rotation.Quaternion() * ParentToWorldSpace.GetRotation() ).Rotator();
}
}
}
示例5: ScopeLock
//=============================================================================
void UGripMotionControllerComponent::FViewExtension::PreRenderViewFamily_RenderThread(FRHICommandListImmediate& RHICmdList, FSceneViewFamily& InViewFamily)
{
if (!MotionControllerComponent)
{
return;
}
FScopeLock ScopeLock(&CritSect);
if (MotionControllerComponent->bDisableLowLatencyUpdate || !CVarEnableMotionControllerLateUpdate->GetValueOnRenderThread())
{
return;
}
// Poll state for the most recent controller transform
FVector Position;
FRotator Orientation;
//bool bRenderTracked = bRenderTracked = MotionControllerComponent->PollControllerState(Position, Orientation);
if (!MotionControllerComponent->PollControllerState(Position, Orientation))
{
return;
}
if (LateUpdatePrimitives.Num())
{
// Calculate the late update transform that will rebase all children proxies within the frame of reference
FTransform OldLocalToWorldTransform = MotionControllerComponent->CalcNewComponentToWorld(MotionControllerComponent->GetRelativeTransform());
FTransform NewLocalToWorldTransform = MotionControllerComponent->CalcNewComponentToWorld(FTransform(Orientation, Position));
FMatrix LateUpdateTransform = (OldLocalToWorldTransform.Inverse() * NewLocalToWorldTransform).ToMatrixWithScale();
FPrimitiveSceneInfo* RetrievedSceneInfo;
FPrimitiveSceneInfo* CachedSceneInfo;
// Apply delta to the affected scene proxies
for (auto PrimitiveInfo : LateUpdatePrimitives)
{
RetrievedSceneInfo = InViewFamily.Scene->GetPrimitiveSceneInfo(*PrimitiveInfo.IndexAddress);
CachedSceneInfo = PrimitiveInfo.SceneInfo;
// If the retrieved scene info is different than our cached scene info then the primitive was removed from the scene
if (CachedSceneInfo == RetrievedSceneInfo && CachedSceneInfo->Proxy)
{
CachedSceneInfo->Proxy->ApplyLateUpdateTransform(LateUpdateTransform);
}
}
LateUpdatePrimitives.Reset();
}
}
示例6: ApplyLateUpdate
void IHeadMountedDisplay::ApplyLateUpdate(FSceneInterface* Scene, const FTransform& OldRelativeTransform, const FTransform& NewRelativeTransform)
{
if (!LateUpdatePrimitives.Num())
{
return;
}
const FTransform OldCameraTransform = OldRelativeTransform * LateUpdateParentToWorld;
const FTransform NewCameraTransform = NewRelativeTransform * LateUpdateParentToWorld;
const FMatrix LateUpdateTransform = (OldCameraTransform.Inverse() * NewCameraTransform).ToMatrixWithScale();
// Apply delta to the affected scene proxies
for (auto PrimitiveInfo : LateUpdatePrimitives)
{
FPrimitiveSceneInfo* RetrievedSceneInfo = Scene->GetPrimitiveSceneInfo(*PrimitiveInfo.IndexAddress);
FPrimitiveSceneInfo* CachedSceneInfo = PrimitiveInfo.SceneInfo;
// If the retrieved scene info is different than our cached scene info then the primitive was removed from the scene
if (CachedSceneInfo == RetrievedSceneInfo && CachedSceneInfo->Proxy)
{
CachedSceneInfo->Proxy->ApplyLateUpdateTransform(LateUpdateTransform);
}
}
LateUpdatePrimitives.Reset();
}
示例7: StartManipulating
void FPhATEdPreviewViewportClient::StartManipulating(EAxisList::Type Axis, const FViewportClick& Click, const FMatrix& WorldToCamera)
{
check(!SharedData->bManipulating);
if (SharedData->EditingMode == FPhATSharedData::PEM_BodyEdit && SharedData->SelectedBodies.Num())
{
GEditor->BeginTransaction( NSLOCTEXT("UnrealEd", "MoveElement", "Move Element") );
for(int32 i=0; i<SharedData->SelectedBodies.Num(); ++i)
{
SharedData->PhysicsAsset->SkeletalBodySetups[SharedData->SelectedBodies[i].Index]->Modify();
SharedData->SelectedBodies[i].ManipulateTM = FTransform::Identity;
}
SharedData->bManipulating = true;
}
else if( SharedData->GetSelectedConstraint())
{
GEditor->BeginTransaction( NSLOCTEXT("UnrealEd", "MoveConstraint", "Move Constraint") );
for(int32 i=0; i<SharedData->SelectedConstraints.Num(); ++i)
{
SharedData->PhysicsAsset->ConstraintSetup[SharedData->SelectedConstraints[i].Index]->Modify();
SharedData->SelectedConstraints[i].ManipulateTM = FTransform::Identity;
}
const FTransform WParentFrame = SharedData->GetConstraintWorldTM(SharedData->GetSelectedConstraint(), EConstraintFrame::Frame2);
const FTransform WChildFrame = SharedData->GetConstraintWorldTM(SharedData->GetSelectedConstraint(), EConstraintFrame::Frame1);
StartManRelConTM = WChildFrame * WParentFrame.Inverse();
UPhysicsConstraintTemplate* Setup = SharedData->PhysicsAsset->ConstraintSetup[SharedData->GetSelectedConstraint()->Index];
StartManParentConTM = Setup->DefaultInstance.GetRefFrame(EConstraintFrame::Frame2);
StartManChildConTM = Setup->DefaultInstance.GetRefFrame(EConstraintFrame::Frame1);
SharedData->bManipulating = true;
}
}
示例8: GripComponent
bool UGripMotionControllerComponent::GripComponent(
UPrimitiveComponent* ComponentToGrip,
const FTransform &WorldOffset,
bool bWorldOffsetIsRelative,
FName OptionalSnapToSocketName,
TEnumAsByte<EGripCollisionType> GripCollisionType,
bool bAllowSetMobility,
float GripStiffness,
float GripDamping,
bool bTurnOffLateUpdateWhenColliding
)
{
if (!bIsServer || !ComponentToGrip)
{
UE_LOG(LogTemp, Warning, TEXT("VRGripMotionController grab function was passed an invalid or already gripped component"));
return false;
}
// Has to be movable to work
if (ComponentToGrip->Mobility != EComponentMobility::Movable)
{
if (bAllowSetMobility)
ComponentToGrip->SetMobility(EComponentMobility::Movable);
else
{
UE_LOG(LogTemp, Warning, TEXT("VRGripMotionController tried to grip a component set to static mobility and bAllowSetMobility is false"));
return false; // It is not movable, can't grip it
}
}
ComponentToGrip->IgnoreActorWhenMoving(this->GetOwner(), true);
// So that events caused by sweep and the like will trigger correctly
ComponentToGrip->AddTickPrerequisiteComponent(this);
FBPActorGripInformation newActorGrip;
newActorGrip.GripCollisionType = GripCollisionType;
newActorGrip.Component = ComponentToGrip;
if(ComponentToGrip->GetOwner())
newActorGrip.bOriginalReplicatesMovement = ComponentToGrip->GetOwner()->bReplicateMovement;
newActorGrip.Stiffness = GripStiffness;
newActorGrip.Damping = GripDamping;
newActorGrip.bTurnOffLateUpdateWhenColliding = bTurnOffLateUpdateWhenColliding;
if (OptionalSnapToSocketName.IsValid() && ComponentToGrip->DoesSocketExist(OptionalSnapToSocketName))
{
// I inverse it so that laying out the sockets makes sense
FTransform sockTrans = ComponentToGrip->GetSocketTransform(OptionalSnapToSocketName, ERelativeTransformSpace::RTS_Component);
newActorGrip.RelativeTransform = sockTrans.Inverse();
newActorGrip.RelativeTransform.SetScale3D(ComponentToGrip->GetComponentScale());
}
else if (bWorldOffsetIsRelative)
newActorGrip.RelativeTransform = WorldOffset;
else
newActorGrip.RelativeTransform = WorldOffset.GetRelativeTransform(this->GetComponentTransform());
NotifyGrip(newActorGrip);
GrippedActors.Add(newActorGrip);
return true;
}
示例9: InputWidgetDelta
bool FSCSEditorViewportClient::InputWidgetDelta( FViewport* Viewport, EAxisList::Type CurrentAxis, FVector& Drag, FRotator& Rot, FVector& Scale )
{
bool bHandled = false;
if(bIsManipulating && CurrentAxis != EAxisList::None)
{
bHandled = true;
AActor* PreviewActor = GetPreviewActor();
if(PreviewActor)
{
TArray<FSCSEditorTreeNodePtrType> SelectedNodes = BlueprintEditorPtr.Pin()->GetSelectedSCSEditorTreeNodes();
if(SelectedNodes.Num() > 0)
{
FVector ModifiedScale = Scale;
if( GEditor->UsePercentageBasedScaling() )
{
ModifiedScale = Scale * ((GEditor->GetScaleGridSize() / 100.0f) / GEditor->GetGridSize());
}
TSet<USceneComponent*> UpdatedComponents;
for(auto It(SelectedNodes.CreateIterator());It;++It)
{
FSCSEditorTreeNodePtrType SelectedNodePtr = *It;
// Don't allow editing of a root node, inherited SCS node or child node that also has a movable (non-root) parent node selected
const bool bCanEdit = !SelectedNodePtr->IsRoot() && !SelectedNodePtr->IsInherited()
&& !IsMovableParentNodeSelected(SelectedNodePtr, SelectedNodes);
if(bCanEdit)
{
USceneComponent* SceneComp = Cast<USceneComponent>(SelectedNodePtr->FindComponentInstanceInActor(PreviewActor, true));
USceneComponent* SelectedTemplate = Cast<USceneComponent>(SelectedNodePtr->GetComponentTemplate());
if(SceneComp != NULL && SelectedTemplate != NULL)
{
// Cache the current default values for propagation
FVector OldRelativeLocation = SelectedTemplate->RelativeLocation;
FRotator OldRelativeRotation = SelectedTemplate->RelativeRotation;
FVector OldRelativeScale3D = SelectedTemplate->RelativeScale3D;
USceneComponent* ParentSceneComp = SceneComp->GetAttachParent();
if( ParentSceneComp )
{
const FTransform ParentToWorldSpace = ParentSceneComp->GetSocketTransform(SceneComp->AttachSocketName);
if(!SceneComp->bAbsoluteLocation)
{
Drag = ParentToWorldSpace.Inverse().TransformVector(Drag);
}
if(!SceneComp->bAbsoluteRotation)
{
Rot = (ParentToWorldSpace.Inverse().GetRotation() * Rot.Quaternion() * ParentToWorldSpace.GetRotation()).Rotator();
}
}
FComponentEditorUtils::FTransformData OldDefaultTransform(*SelectedTemplate);
TSharedPtr<ISCSEditorCustomization> Customization = BlueprintEditorPtr.Pin()->CustomizeSCSEditor(SceneComp);
if(Customization.IsValid() && Customization->HandleViewportDrag(SceneComp, SelectedTemplate, Drag, Rot, ModifiedScale, GetWidgetLocation()))
{
UpdatedComponents.Add(SceneComp);
UpdatedComponents.Add(SelectedTemplate);
}
else
{
// Apply delta to the preview actor's scene component
GEditor->ApplyDeltaToComponent(
SceneComp,
true,
&Drag,
&Rot,
&ModifiedScale,
SceneComp->RelativeLocation );
UpdatedComponents.Add(SceneComp);
// Apply delta to the template component object
GEditor->ApplyDeltaToComponent(
SelectedTemplate,
true,
&Drag,
&Rot,
&ModifiedScale,
SelectedTemplate->RelativeLocation );
UpdatedComponents.Add(SelectedTemplate);
}
FComponentEditorUtils::FTransformData NewDefaultTransform(*SelectedTemplate);
if (SelectedNodePtr->IsNative())
{
if (ensure(SelectedTemplate->HasAnyFlags(RF_DefaultSubObject)))
{
FComponentEditorUtils::PropagateTransformPropertyChange(SelectedTemplate, OldDefaultTransform, NewDefaultTransform, UpdatedComponents);
}
}
if(PreviewBlueprint != NULL)
{
// Like PostEditMove(), but we only need to re-run construction scripts
if(PreviewBlueprint && PreviewBlueprint->bRunConstructionScriptOnDrag)
{
//.........这里部分代码省略.........