本文整理汇总了C++中FTransform类的典型用法代码示例。如果您正苦于以下问题:C++ FTransform类的具体用法?C++ FTransform怎么用?C++ FTransform使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FTransform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawSolidBox
void ULineBatchComponent::DrawSolidBox(const FBox& Box, const FTransform& Xform, const FColor& Color, uint8 DepthPriority, float LifeTime)
{
int32 const NewMeshIdx = BatchedMeshes.Add(FBatchedMesh());
FBatchedMesh& BM = BatchedMeshes[NewMeshIdx];
BM.Color = Color;
BM.DepthPriority = DepthPriority;
BM.RemainingLifeTime = LifeTime;
BM.MeshVerts.AddUninitialized(8);
BM.MeshVerts[0] = Xform.TransformPosition( FVector(Box.Min.X, Box.Min.Y, Box.Max.Z) );
BM.MeshVerts[1] = Xform.TransformPosition( FVector(Box.Max.X, Box.Min.Y, Box.Max.Z) );
BM.MeshVerts[2] = Xform.TransformPosition( FVector(Box.Min.X, Box.Min.Y, Box.Min.Z) );
BM.MeshVerts[3] = Xform.TransformPosition( FVector(Box.Max.X, Box.Min.Y, Box.Min.Z) );
BM.MeshVerts[4] = Xform.TransformPosition( FVector(Box.Min.X, Box.Max.Y, Box.Max.Z) );
BM.MeshVerts[5] = Xform.TransformPosition( FVector(Box.Max.X, Box.Max.Y, Box.Max.Z) );
BM.MeshVerts[6] = Xform.TransformPosition( FVector(Box.Min.X, Box.Max.Y, Box.Min.Z) );
BM.MeshVerts[7] = Xform.TransformPosition( FVector(Box.Max.X, Box.Max.Y, Box.Min.Z) );
// clockwise
BM.MeshIndices.AddUninitialized(36);
int32 const Indices[36] = { 3,2,0,
3,0,1,
7,3,1,
7,1,5,
6,7,5,
6,5,4,
2,6,4,
2,4,0,
1,0,4,
1,4,5,
7,6,2,
7,2,3 };
for (int32 Idx=0; Idx<36; ++Idx)
{
BM.MeshIndices[Idx] = Indices[Idx];
}
MarkRenderStateDirty();
}
示例2: ScopeLock
//=============================================================================
void UMotionControllerComponent::FViewExtension::PreRenderViewFamily_RenderThread(FRHICommandListImmediate& RHICmdList, FSceneViewFamily& InViewFamily)
{
if (!MotionControllerComponent)
{
return;
}
FScopeLock ScopeLock(&CritSect);
if (!MotionControllerComponent || MotionControllerComponent->bDisableLowLatencyUpdate || !CVarEnableMotionControllerLateUpdate.GetValueOnRenderThread())
{
return;
}
// Poll state for the most recent controller transform
FVector Position;
FRotator 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
const FTransform OldLocalToWorldTransform = MotionControllerComponent->CalcNewComponentToWorld(MotionControllerComponent->GetRelativeTransform());
const FTransform NewLocalToWorldTransform = MotionControllerComponent->CalcNewComponentToWorld(FTransform(Orientation, Position, MotionControllerComponent->GetComponentScale()));
const FMatrix LateUpdateTransform = (OldLocalToWorldTransform.Inverse() * NewLocalToWorldTransform).ToMatrixWithScale();
// Apply delta to the affected scene proxies
for (auto PrimitiveInfo : LateUpdatePrimitives)
{
FPrimitiveSceneInfo* RetrievedSceneInfo = InViewFamily.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();
}
}
示例3: UE_LOG
void UPrimitiveComponent::SyncComponentToRBPhysics()
{
if(!IsRegistered())
{
UE_LOG(LogPhysics, Log, TEXT("SyncComponentToRBPhysics : Component not registered (%s)"), *GetPathName());
return;
}
// BodyInstance we are going to sync the component to
FBodyInstance* UseBI = GetBodyInstance();
if(UseBI == NULL || !UseBI->IsValidBodyInstance())
{
UE_LOG(LogPhysics, Log, TEXT("SyncComponentToRBPhysics : Missing or invalid BodyInstance (%s)"), *GetPathName());
return;
}
AActor* Owner = GetOwner();
if(Owner != NULL)
{
if (Owner->IsPendingKill() || !Owner->CheckStillInWorld())
{
return;
}
}
if (IsPendingKill() || !IsSimulatingPhysics())
{
return;
}
// See if the transform is actually different, and if so, move the component to match physics
const FTransform NewTransform = GetComponentTransformFromBodyInstance(UseBI);
if(!NewTransform.EqualsNoScale(ComponentToWorld))
{
const FVector MoveBy = NewTransform.GetLocation() - ComponentToWorld.GetLocation();
const FQuat NewRotation = NewTransform.GetRotation();
//@warning: do not reference BodyInstance again after calling MoveComponent() - events from the move could have made it unusable (destroying the actor, SetPhysics(), etc)
MoveComponent(MoveBy, NewRotation, false, NULL, MOVECOMP_SkipPhysicsMove);
}
}
示例4: Scale3D
FTransform UPhATEdSkeletalMeshComponent::GetPrimitiveTransform(FTransform& BoneTM, int32 BodyIndex, EKCollisionPrimitiveType PrimType, int32 PrimIndex, float Scale)
{
UBodySetup* BodySetup = SharedData->PhysicsAsset->BodySetup[BodyIndex];
FVector Scale3D(Scale);
FTransform ManTM = FTransform::Identity;
if(SharedData->bManipulating && !SharedData->bRunningSimulation && SharedData->EditingMode == FPhATSharedData::PEM_BodyEdit)
{
FPhATSharedData::FSelection Body(BodyIndex, PrimType, PrimIndex);
for(int32 i=0; i<SharedData->SelectedBodies.Num(); ++i)
{
if (Body == SharedData->SelectedBodies[i])
{
ManTM = SharedData->SelectedBodies[i].ManipulateTM;
break;
}
}
}
if (PrimType == KPT_Sphere)
{
FTransform PrimTM = ManTM * BodySetup->AggGeom.SphereElems[PrimIndex].GetTransform();
PrimTM.ScaleTranslation(Scale3D);
return PrimTM * BoneTM;
}
else if (PrimType == KPT_Box)
{
FTransform PrimTM = ManTM * BodySetup->AggGeom.BoxElems[PrimIndex].GetTransform();
PrimTM.ScaleTranslation(Scale3D);
return PrimTM * BoneTM;
}
else if (PrimType == KPT_Sphyl)
{
FTransform PrimTM = ManTM * BodySetup->AggGeom.SphylElems[PrimIndex].GetTransform();
PrimTM.ScaleTranslation(Scale3D);
return PrimTM * BoneTM;
}
else if (PrimType == KPT_Convex)
{
FTransform PrimTM = ManTM * BodySetup->AggGeom.ConvexElems[PrimIndex].GetTransform();
PrimTM.ScaleTranslation(Scale3D);
return PrimTM * BoneTM;
}
// Should never reach here
check(0);
return FTransform::Identity;
}
示例5: FTransform
FTransform FConstraintInstance::GetRefFrame(EConstraintFrame::Type Frame) const
{
FTransform Result;
if(Frame == EConstraintFrame::Frame1)
{
Result = FTransform(PriAxis1, SecAxis1, PriAxis1 ^ SecAxis1, Pos1);
}
else
{
Result = FTransform(PriAxis2, SecAxis2, PriAxis2 ^ SecAxis2, Pos2);
}
float Error = FMath::Abs( Result.GetDeterminant() - 1.0f );
if(Error > 0.01f)
{
UE_LOG(LogPhysics, Warning, TEXT("FConstraintInstance::GetRefFrame : Contained scale."));
}
return Result;
}
示例6: OnFocusViewportToSelection
void SStaticMeshEditorViewport::OnFocusViewportToSelection()
{
UStaticMeshSocket* SelectedSocket = StaticMeshEditorPtr.Pin()->GetSelectedSocket();
if( SelectedSocket && PreviewMeshComponent )
{
FTransform SocketTransform;
SelectedSocket->GetSocketTransform( SocketTransform, PreviewMeshComponent );
FVector Extent(30.0f);
FVector Origin = SocketTransform.GetLocation();
FBox Box( Origin - Extent, Origin + Extent);
EditorViewportClient->FocusViewportOnBox( Box );
}
else if( PreviewMeshComponent )
{
EditorViewportClient->FocusViewportOnBox( PreviewMeshComponent->Bounds.GetBox() );
}
}
示例7: Evaluate
FTransform FTransformCurve::Evaluate(float CurrentTime, float BlendWeight) const
{
FTransform Value;
Value.SetTranslation(TranslationCurve.Evaluate(CurrentTime, BlendWeight));
if (ScaleCurve.DoesContainKey())
{
Value.SetScale3D(ScaleCurve.Evaluate(CurrentTime, BlendWeight));
}
else
{
Value.SetScale3D(FVector(1.f));
}
// blend rotation float curve
FVector RotationAsVector = RotationCurve.Evaluate(CurrentTime, BlendWeight);
// pitch, yaw, roll order - please check AddKey function
FRotator Rotator(RotationAsVector.Y, RotationAsVector.Z, RotationAsVector.X);
Value.SetRotation(FQuat(Rotator));
return Value;
}
示例8: 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();
}
}
}
示例9: GetTargetDataOrigin
FTransform UAbilitySystemBlueprintLibrary::GetTargetDataOrigin(FGameplayAbilityTargetDataHandle TargetData, int32 Index)
{
FGameplayAbilityTargetData* Data = TargetData.Data[Index].Get();
if (Data)
{
if (Data->HasOrigin())
{
return Data->GetOrigin();
}
if (Data->HasHitResult())
{
const FHitResult* HitResultPtr = Data->GetHitResult();
FTransform ReturnTransform;
ReturnTransform.SetLocation(HitResultPtr->TraceStart);
ReturnTransform.SetRotation((HitResultPtr->Location - HitResultPtr->TraceStart).GetSafeNormal().Rotation().Quaternion());
return ReturnTransform;
}
}
return FTransform::Identity;
}
示例10: RenderAxisGizmo
// Render a coordinate system indicator
void USkeletalMeshComponent::RenderAxisGizmo( const FTransform& Transform, UCanvas* Canvas ) const
{
// Display colored coordinate system axes for this joint.
const float AxisLength = 3.75f;
const FVector Origin = Transform.GetLocation();
// Red = X
FVector XAxis = Transform.TransformVector( FVector(1.0f,0.0f,0.0f) );
XAxis.Normalize();
DrawDebugCanvasLine(Canvas, Origin, Origin + XAxis * AxisLength, FLinearColor( 1.f, 0.3f, 0.3f));
// Green = Y
FVector YAxis = Transform.TransformVector( FVector(0.0f,1.0f,0.0f) );
YAxis.Normalize();
DrawDebugCanvasLine(Canvas, Origin, Origin + YAxis * AxisLength, FLinearColor( 0.3f, 1.f, 0.3f));
// Blue = Z
FVector ZAxis = Transform.TransformVector( FVector(0.0f,0.0f,1.0f) );
ZAxis.Normalize();
DrawDebugCanvasLine(Canvas, Origin, Origin + ZAxis * AxisLength, FLinearColor( 0.3f, 0.3f, 1.f));
}
示例11: GetContactOffsetParams
void UBodySetup::AddBoxesToRigidActor(PxRigidActor* PDestActor, const FTransform& RelativeTM, const FVector& Scale3D, const FVector& Scale3DAbs, TArray<PxShape*>* NewShapes) const
{
float ContactOffsetFactor, MaxContactOffset;
GetContactOffsetParams(ContactOffsetFactor, MaxContactOffset);
PxMaterial* PDefaultMat = GetDefaultPhysMaterial();
for (int32 i = 0; i < AggGeom.BoxElems.Num(); i++)
{
const FKBoxElem& BoxElem = AggGeom.BoxElems[i];
PxBoxGeometry PBoxGeom;
PBoxGeom.halfExtents.x = (0.5f * BoxElem.X * Scale3DAbs.X);
PBoxGeom.halfExtents.y = (0.5f * BoxElem.Y * Scale3DAbs.Y);
PBoxGeom.halfExtents.z = (0.5f * BoxElem.Z * Scale3DAbs.Z);
FTransform BoxTransform = BoxElem.GetTransform() * RelativeTM;
if (PBoxGeom.isValid() && BoxTransform.IsValid())
{
PxTransform PLocalPose(U2PTransform(BoxTransform));
PLocalPose.p.x *= Scale3D.X;
PLocalPose.p.y *= Scale3D.Y;
PLocalPose.p.z *= Scale3D.Z;
ensure(PLocalPose.isValid());
PxShape* NewShape = PDestActor->createShape(PBoxGeom, *PDefaultMat, PLocalPose);
if (NewShapes)
{
NewShapes->Add(NewShape);
}
const float ContactOffset = FMath::Min(MaxContactOffset, ContactOffsetFactor * PBoxGeom.halfExtents.minElement());
NewShape->setContactOffset(ContactOffset);
}
else
{
UE_LOG(LogPhysics, Warning, TEXT("AddBoxesToRigidActor: [%s] BoxElems[%d] invalid or has invalid transform"), *GetPathNameSafe(GetOuter()), i);
}
}
}
示例12: check
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));
}
示例13: DrawElemWire
// NB: ElemTM is assumed to have no scaling in it!
void FKBoxElem::DrawElemWire(FPrimitiveDrawInterface* PDI, const FTransform& ElemTM, float Scale, const FColor Color)
{
FVector B[2], P, Q, Radii;
// X,Y,Z member variables are LENGTH not RADIUS
Radii.X = Scale*0.5f*X;
Radii.Y = Scale*0.5f*Y;
Radii.Z = Scale*0.5f*Z;
B[0] = Radii; // max
B[1] = -1.0f * Radii; // min
for( int32 i=0; i<2; i++ )
{
for( int32 j=0; j<2; j++ )
{
P.X=B[i].X; Q.X=B[i].X;
P.Y=B[j].Y; Q.Y=B[j].Y;
P.Z=B[0].Z; Q.Z=B[1].Z;
PDI->DrawLine( ElemTM.TransformPosition(P), ElemTM.TransformPosition(Q), Color, SDPG_World);
P.Y=B[i].Y; Q.Y=B[i].Y;
P.Z=B[j].Z; Q.Z=B[j].Z;
P.X=B[0].X; Q.X=B[1].X;
PDI->DrawLine( ElemTM.TransformPosition(P), ElemTM.TransformPosition(Q), Color, SDPG_World);
P.Z=B[i].Z; Q.Z=B[i].Z;
P.X=B[j].X; Q.X=B[j].X;
P.Y=B[0].Y; Q.Y=B[1].Y;
PDI->DrawLine( ElemTM.TransformPosition(P), ElemTM.TransformPosition(Q), Color, SDPG_World);
}
}
}
示例14: ConvertWidgetLocation
FVector UAnimGraphNode_ModifyBone::GetWidgetLocation(const USkeletalMeshComponent* SkelComp, FAnimNode_SkeletalControlBase* AnimNode)
{
USkeleton* Skeleton = SkelComp->SkeletalMesh->Skeleton;
FVector WidgetLoc = FVector::ZeroVector;
// if the current widget mode is translate, then shows the widget according to translation space
if (CurWidgetMode == FWidget::WM_Translate)
{
FCSPose<FCompactPose>& MeshBases = AnimNode->ForwardedPose;
WidgetLoc = ConvertWidgetLocation(SkelComp, MeshBases, Node.BoneToModify.BoneName, GetNodeValue(FString("Translation"), Node.Translation), Node.TranslationSpace);
if (MeshBases.GetPose().IsValid() && Node.TranslationMode == BMM_Additive)
{
if(Node.TranslationSpace == EBoneControlSpace::BCS_WorldSpace ||
Node.TranslationSpace == EBoneControlSpace::BCS_ComponentSpace)
{
const FMeshPoseBoneIndex MeshBoneIndex(SkelComp->GetBoneIndex(Node.BoneToModify.BoneName));
const FCompactPoseBoneIndex BoneIndex = MeshBases.GetPose().GetBoneContainer().MakeCompactPoseIndex(MeshBoneIndex);
if (BoneIndex != INDEX_NONE)
{
const FTransform& BoneTM = MeshBases.GetComponentSpaceTransform(BoneIndex);
WidgetLoc += BoneTM.GetLocation();
}
}
}
}
else // if the current widget mode is not translate mode, then show the widget on the bone to modify
{
int32 MeshBoneIndex = SkelComp->GetBoneIndex(Node.BoneToModify.BoneName);
if (MeshBoneIndex != INDEX_NONE)
{
const FTransform BoneTM = SkelComp->GetBoneTransform(MeshBoneIndex);
WidgetLoc = BoneTM.GetLocation();
}
}
return WidgetLoc;
}
示例15: DrawElemWire
void FKConvexElem::DrawElemWire(FPrimitiveDrawInterface* PDI, const FTransform& ElemTM, const float Scale, const FColor Color) const
{
#if WITH_PHYSX
PxConvexMesh* Mesh = ConvexMesh;
if(Mesh)
{
// Draw each triangle that makes up the convex hull
PxU32 NbVerts = Mesh->getNbVertices();
const PxVec3* Vertices = Mesh->getVertices();
TArray<FVector> TransformedVerts;
TransformedVerts.AddUninitialized(NbVerts);
for(PxU32 i=0; i<NbVerts; i++)
{
TransformedVerts[i] = ElemTM.TransformPosition(P2UVector(Vertices[i]) * Scale);
}
const PxU8* PIndexBuffer = Mesh->getIndexBuffer();
PxU32 NbPolygons = Mesh->getNbPolygons();
for(PxU32 i=0;i<NbPolygons;i++)
{
PxHullPolygon Data;
bool bStatus = Mesh->getPolygonData(i, Data);
check(bStatus);
const PxU8* PIndices = PIndexBuffer + Data.mIndexBase;
for(PxU16 j=0;j<Data.mNbVerts;j++)
{
// Get the verts that make up this line.
int32 I0 = PIndices[j];
int32 I1 = PIndices[j+1];
// Loop back last and first vertices
if(j==Data.mNbVerts - 1)
{
I1 = PIndices[0];
}
PDI->DrawLine( TransformedVerts[I0], TransformedVerts[I1], Color, SDPG_World );
}
}
}
else
{
UE_LOG(LogPhysics, Log, TEXT("FKConvexElem::DrawElemWire : No ConvexMesh, so unable to draw."));
}
#endif // WITH_PHYSX
}