本文整理汇总了C++中FTransform::GetLocation方法的典型用法代码示例。如果您正苦于以下问题:C++ FTransform::GetLocation方法的具体用法?C++ FTransform::GetLocation怎么用?C++ FTransform::GetLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FTransform
的用法示例。
在下文中一共展示了FTransform::GetLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawTargetLocation
void UAnimGraphNode_TwoBoneIK::DrawTargetLocation(FPrimitiveDrawInterface* PDI, USkeletalMeshComponent* SkelComp, USkeleton * Skeleton, EBoneControlSpace SpaceBase, FName SpaceBoneName, const FVector & TargetLocation, const FColor & TargetColor, const FColor & BoneColor) const
{
const bool bInBoneSpace = (SpaceBase == BCS_ParentBoneSpace) || (SpaceBase == BCS_BoneSpace);
const int32 SpaceBoneIndex = bInBoneSpace ? Skeleton->GetReferenceSkeleton().FindBoneIndex(SpaceBoneName) : INDEX_NONE;
// Transform EffectorLocation from EffectorLocationSpace to ComponentSpace.
FTransform TargetTransform = FTransform (TargetLocation);
FTransform CSTransform;
ConvertToComponentSpaceTransform(SkelComp, TargetTransform, CSTransform, SpaceBoneIndex, SpaceBase);
FTransform WorldTransform = CSTransform * SkelComp->ComponentToWorld;
#if 0 // @TODO : remove this code because this doesn't show correct target location
DrawCoordinateSystem( PDI, WorldTransform.GetLocation(), WorldTransform.GetRotation().Rotator(), 20.f, SDPG_Foreground );
DrawWireDiamond( PDI, WorldTransform.ToMatrixWithScale(), 2.f, TargetColor, SDPG_Foreground );
#endif
if (bInBoneSpace)
{
ConvertToComponentSpaceTransform(SkelComp, FTransform::Identity, CSTransform, SpaceBoneIndex, SpaceBase);
WorldTransform = CSTransform * SkelComp->ComponentToWorld;
DrawCoordinateSystem( PDI, WorldTransform.GetLocation(), WorldTransform.GetRotation().Rotator(), 20.f, SDPG_Foreground );
DrawWireDiamond( PDI, WorldTransform.ToMatrixWithScale(), 2.f, BoneColor, SDPG_Foreground );
}
}
示例2: 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);
}
}
示例3: TeleportMoveGrippedActor
bool UGripMotionControllerComponent::TeleportMoveGrippedActor(AActor * GrippedActorToMove)
{
if (!GrippedActorToMove || !GrippedActors.Num())
return false;
FTransform WorldTransform;
FTransform InverseTransform = this->GetComponentTransform().Inverse();
for (int i = GrippedActors.Num() - 1; i >= 0; --i)
{
if (GrippedActors[i].Actor == GrippedActorToMove)
{
// GetRelativeTransformReverse had some serious fucking floating point errors associated with it that was fucking everything up
// Not sure whats wrong with the function but I might want to push a patch out eventually
WorldTransform = GrippedActors[i].RelativeTransform.GetRelativeTransform(InverseTransform);
// Need to use WITH teleport for this function so that the velocity isn't updated and without sweep so that they don't collide
GrippedActors[i].Actor->SetActorTransform(WorldTransform, false, NULL, ETeleportType::TeleportPhysics);
FBPActorPhysicsHandleInformation * Handle = GetPhysicsGrip(GrippedActors[i]);
if (Handle && Handle->KinActorData)
{
{
PxScene* PScene = GetPhysXSceneFromIndex(Handle->SceneIndex);
if (PScene)
{
SCOPED_SCENE_WRITE_LOCK(PScene);
Handle->KinActorData->setKinematicTarget(PxTransform(U2PVector(WorldTransform.GetLocation()), Handle->KinActorData->getGlobalPose().q));
Handle->KinActorData->setGlobalPose(PxTransform(U2PVector(WorldTransform.GetLocation()), Handle->KinActorData->getGlobalPose().q));
}
}
//Handle->KinActorData->setGlobalPose(PxTransform(U2PVector(WorldTransform.GetLocation()), Handle->KinActorData->getGlobalPose().q));
UPrimitiveComponent *root = Cast<UPrimitiveComponent>(GrippedActors[i].Actor->GetRootComponent());
if (root)
{
FBodyInstance * body = root->GetBodyInstance();
if (body)
{
body->SetBodyTransform(WorldTransform, ETeleportType::TeleportPhysics);
}
}
}
return true;
}
}
return false;
}
示例4: GetWidgetLocation
FVector FEdMode::GetWidgetLocation() const
{
if(UsesPropertyWidgets())
{
AActor* SelectedActor = GetFirstSelectedActorInstance();
if(SelectedActor != NULL)
{
if(EditedPropertyName != TEXT(""))
{
FVector LocalPos = FVector::ZeroVector;
if(bEditedPropertyIsTransform)
{
FTransform LocalTM = GetPropertyValueByName<FTransform>(SelectedActor, EditedPropertyName, EditedPropertyIndex);
LocalPos = LocalTM.GetLocation();
}
else
{
LocalPos = GetPropertyValueByName<FVector>(SelectedActor, EditedPropertyName, EditedPropertyIndex);
}
FTransform ActorToWorld = SelectedActor->ActorToWorld();
FVector WorldPos = ActorToWorld.TransformPosition(LocalPos);
return WorldPos;
}
}
}
//UE_LOG(LogEditorModes, Log, TEXT("In FEdMode::GetWidgetLocation"));
return Owner->PivotLocation;
}
示例5: CalcBounds
FBoxSphereBounds UPaperFlipbookComponent::CalcBounds(const FTransform& LocalToWorld) const
{
if (SourceFlipbook != nullptr)
{
// Graphics bounds.
FBoxSphereBounds NewBounds = SourceFlipbook->GetRenderBounds().TransformBy(LocalToWorld);
// Add bounds of collision geometry (if present).
if (CachedBodySetup != nullptr)
{
const FBox AggGeomBox = CachedBodySetup->AggGeom.CalcAABB(LocalToWorld);
if (AggGeomBox.IsValid)
{
NewBounds = Union(NewBounds, FBoxSphereBounds(AggGeomBox));
}
}
// Apply bounds scale
NewBounds.BoxExtent *= BoundsScale;
NewBounds.SphereRadius *= BoundsScale;
return NewBounds;
}
else
{
return FBoxSphereBounds(LocalToWorld.GetLocation(), FVector::ZeroVector, 0.f);
}
}
示例6: OnFocusViewportToSelection
void SStaticMeshEditorViewport::OnFocusViewportToSelection()
{
// If we have selected sockets, focus on them
UStaticMeshSocket* SelectedSocket = StaticMeshEditorPtr.Pin()->GetSelectedSocket();
if( SelectedSocket && PreviewMeshComponent )
{
FTransform SocketTransform;
SelectedSocket->GetSocketTransform( SocketTransform, PreviewMeshComponent );
const FVector Extent(30.0f);
const FVector Origin = SocketTransform.GetLocation();
const FBox Box(Origin - Extent, Origin + Extent);
EditorViewportClient->FocusViewportOnBox( Box );
return;
}
// If we have selected primitives, focus on them
FBox Box(0);
const bool bSelectedPrim = StaticMeshEditorPtr.Pin()->CalcSelectedPrimsAABB(Box);
if (bSelectedPrim)
{
EditorViewportClient->FocusViewportOnBox(Box);
return;
}
// Fallback to focusing on the mesh, if nothing else
if( PreviewMeshComponent )
{
EditorViewportClient->FocusViewportOnBox( PreviewMeshComponent->Bounds.GetBox() );
return;
}
}
示例7: GetMovementBaseTransform
bool GetMovementBaseTransform(const UPrimitiveComponent* MovementBase, const FName BoneName, FVector& OutLocation, FQuat& OutQuat)
{
if (MovementBase)
{
if (BoneName != NAME_None)
{
const USkeletalMeshComponent* SkeletalBase = Cast<USkeletalMeshComponent>(MovementBase);
if (SkeletalBase)
{
const int32 BoneIndex = SkeletalBase->GetBoneIndex(BoneName);
if (BoneIndex != INDEX_NONE)
{
const FTransform BoneTransform = SkeletalBase->GetBoneTransform(BoneIndex);
OutLocation = BoneTransform.GetLocation();
OutQuat = BoneTransform.GetRotation();
return true;
}
UE_LOG(LogCharacter, Warning, TEXT("GetMovementBaseTransform(): Invalid bone '%s' for SkeletalMeshComponent base %s"), *BoneName.ToString(), *GetPathNameSafe(MovementBase));
return false;
}
// TODO: warn if not a skeletal mesh but providing bone index.
}
// No bone supplied
OutLocation = MovementBase->GetComponentLocation();
OutQuat = MovementBase->GetComponentQuat();
return true;
}
// NULL MovementBase
OutLocation = FVector::ZeroVector;
OutQuat = FQuat::Identity;
return false;
}
示例8: DoCreatureMeshUpdate
void UCreatureMeshComponent::DoCreatureMeshUpdate(int render_packet_idx)
{
// Update Mesh
SetBoundsScale(creature_bounds_scale);
SetBoundsOffset(creature_bounds_offset);
SetExtraXForm(GetComponentToWorld());
ForceAnUpdate(render_packet_idx);
// Debug
if (creature_debug_draw) {
FSphere debugSphere = GetDebugBoundsSphere();
DrawDebugSphere(
GetWorld(),
debugSphere.Center,
debugSphere.W,
32,
FColor(255, 0, 0)
);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Sphere pos is: (%f, %f, %f)"), debugSphere.Center.X, debugSphere.Center.Y, debugSphere.Center.Z));
FTransform wTransform = GetComponentToWorld();
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Walk pos is: (%f, %f, %f)"), wTransform.GetLocation().X,
wTransform.GetLocation().Y,
wTransform.GetLocation().Z));
}
}
示例9: CalcBounds
FBoxSphereBounds UPaperGroupedSpriteComponent::CalcBounds(const FTransform& BoundTransform) const
{
bool bHadAnyBounds = false;
FBoxSphereBounds NewBounds(ForceInit);
if (PerInstanceSpriteData.Num() > 0)
{
const FMatrix BoundTransformMatrix = BoundTransform.ToMatrixWithScale();
for (const FSpriteInstanceData& InstanceData : PerInstanceSpriteData)
{
if (InstanceData.SourceSprite != nullptr)
{
const FBoxSphereBounds RenderBounds = InstanceData.SourceSprite->GetRenderBounds();
const FBoxSphereBounds InstanceBounds = RenderBounds.TransformBy(InstanceData.Transform * BoundTransformMatrix);
if (bHadAnyBounds)
{
NewBounds = NewBounds + InstanceBounds;
}
else
{
NewBounds = InstanceBounds;
bHadAnyBounds = true;
}
}
}
}
return bHadAnyBounds ? NewBounds : FBoxSphereBounds(BoundTransform.GetLocation(), FVector::ZeroVector, 0.f);
}
示例10: DrawElemWire
// NB: ElemTM is assumed to have no scaling in it!
void FKSphylElem::DrawElemWire(FPrimitiveDrawInterface* PDI, const FTransform& ElemTM, float Scale, const FColor Color)
{
FVector Origin = ElemTM.GetLocation();
FVector XAxis = ElemTM.GetScaledAxis( EAxis::X );
FVector YAxis = ElemTM.GetScaledAxis( EAxis::Y );
FVector ZAxis = ElemTM.GetScaledAxis( EAxis::Z );
// Draw top and bottom circles
FVector TopEnd = Origin + Scale*0.5f*Length*ZAxis;
FVector BottomEnd = Origin - Scale*0.5f*Length*ZAxis;
DrawCircle(PDI,TopEnd, XAxis, YAxis, Color, Scale*Radius, DrawCollisionSides, SDPG_World);
DrawCircle(PDI,BottomEnd, XAxis, YAxis, Color, Scale*Radius, DrawCollisionSides, SDPG_World);
// Draw domed caps
DrawHalfCircle(PDI, TopEnd, YAxis, ZAxis, Color,Scale* Radius);
DrawHalfCircle(PDI, TopEnd, XAxis, ZAxis, Color, Scale*Radius);
FVector NegZAxis = -ZAxis;
DrawHalfCircle(PDI, BottomEnd, YAxis, NegZAxis, Color, Scale*Radius);
DrawHalfCircle(PDI, BottomEnd, XAxis, NegZAxis, Color, Scale*Radius);
// Draw connecty lines
PDI->DrawLine(TopEnd + Scale*Radius*XAxis, BottomEnd + Scale*Radius*XAxis, Color, SDPG_World);
PDI->DrawLine(TopEnd - Scale*Radius*XAxis, BottomEnd - Scale*Radius*XAxis, Color, SDPG_World);
PDI->DrawLine(TopEnd + Scale*Radius*YAxis, BottomEnd + Scale*Radius*YAxis, Color, SDPG_World);
PDI->DrawLine(TopEnd - Scale*Radius*YAxis, BottomEnd - Scale*Radius*YAxis, Color, SDPG_World);
}
示例11: GetTransformMatrix
FMatrix USkeletalMeshComponent::GetTransformMatrix() const
{
FTransform RootTransform = GetBoneTransform(0);
FVector Translation;
FQuat Rotation;
// if in editor, it should always use localToWorld
// if root motion is ignored, use root transform
if( GetWorld()->IsGameWorld() || !SkeletalMesh )
{
// add root translation info
Translation = RootTransform.GetLocation();
}
else
{
Translation = ComponentToWorld.TransformPosition(SkeletalMesh->RefSkeleton.GetRefBonePose()[0].GetTranslation());
}
// if root rotation is ignored, use root transform rotation
Rotation = RootTransform.GetRotation();
// now I need to get scale
// only LocalToWorld will have scale
FVector ScaleVector = ComponentToWorld.GetScale3D();
Rotation.Normalize();
return FScaleMatrix(ScaleVector)*FQuatRotationTranslationMatrix(Rotation, Translation);
}
示例12: RescaleSimpleCollision
void UBodySetup::RescaleSimpleCollision( FVector BuildScale )
{
if( BuildScale3D != BuildScale )
{
// Back out the old scale when applying the new scale
const FVector ScaleMultiplier3D = (BuildScale / BuildScale3D);
for (int32 i = 0; i < AggGeom.ConvexElems.Num(); i++)
{
FKConvexElem* ConvexElem = &(AggGeom.ConvexElems[i]);
FTransform ConvexTrans = ConvexElem->GetTransform();
FVector ConvexLoc = ConvexTrans.GetLocation();
ConvexLoc *= ScaleMultiplier3D;
ConvexTrans.SetLocation(ConvexLoc);
ConvexElem->SetTransform(ConvexTrans);
TArray<FVector>& Vertices = ConvexElem->VertexData;
for (int32 VertIndex = 0; VertIndex < Vertices.Num(); ++VertIndex)
{
Vertices[VertIndex] *= ScaleMultiplier3D;
}
ConvexElem->UpdateElemBox();
}
// @todo Deal with non-vector properties by just applying the max value for the time being
const float ScaleMultiplier = ScaleMultiplier3D.GetMax();
for (int32 i = 0; i < AggGeom.SphereElems.Num(); i++)
{
FKSphereElem* SphereElem = &(AggGeom.SphereElems[i]);
SphereElem->Center *= ScaleMultiplier3D;
SphereElem->Radius *= ScaleMultiplier;
}
for (int32 i = 0; i < AggGeom.BoxElems.Num(); i++)
{
FKBoxElem* BoxElem = &(AggGeom.BoxElems[i]);
BoxElem->Center *= ScaleMultiplier3D;
BoxElem->X *= ScaleMultiplier3D.X;
BoxElem->Y *= ScaleMultiplier3D.Y;
BoxElem->Z *= ScaleMultiplier3D.Z;
}
for (int32 i = 0; i < AggGeom.SphylElems.Num(); i++)
{
FKSphylElem* SphylElem = &(AggGeom.SphylElems[i]);
SphylElem->Center *= ScaleMultiplier3D;
SphylElem->Radius *= ScaleMultiplier;
SphylElem->Length *= ScaleMultiplier;
}
BuildScale3D = BuildScale;
}
}
示例13: OnEndCrouch
void ANimModCharacter::OnEndCrouch(float HalfHeightAdjust, float ScaledHalfHeightAdjust)
{
Super::OnEndCrouch(HalfHeightAdjust, ScaledHalfHeightAdjust);
FTransform currentTransform = Mesh1P->GetRelativeTransform();
FVector origin = currentTransform.GetLocation();
origin.Z += (DefaultBaseEyeHeight - CrouchedEyeHeight);// HalfHeightAdjust; //This is different than the one passed in in OnStartCrouch...
FRotator rotation = currentTransform.GetRotation().Rotator();
Mesh1P->SetRelativeLocationAndRotation(origin, rotation, false, nullptr, ETeleportType::TeleportPhysics);
}
示例14: U2PTransform
PxTransform U2PTransform(const FTransform& UTransform)
{
PxQuat PQuat = U2PQuat(UTransform.GetRotation());
PxVec3 PPos = U2PVector(UTransform.GetLocation());
PxTransform Result(PPos, PQuat);
return Result;
}
示例15: SerializeInstancedMeshes
void UTerrainZoneComponent::SerializeInstancedMeshes(FBufferArchive& BinaryData) {
int32 MeshCount = InstancedMeshMap.Num();
BinaryData << MeshCount;
for (auto& Elem : InstancedMeshMap) {
UHierarchicalInstancedStaticMeshComponent* InstancedStaticMeshComponent = Elem.Value;
int32 MeshTypeId = Elem.Key;
int32 MeshInstanceCount = InstancedStaticMeshComponent->GetInstanceCount();
BinaryData << MeshTypeId;
BinaryData << MeshInstanceCount;
for (int32 InstanceIdx = 0; InstanceIdx < MeshInstanceCount; InstanceIdx++) {
FTransform InstanceTransform;
InstancedStaticMeshComponent->GetInstanceTransform(InstanceIdx, InstanceTransform, true);
float X = InstanceTransform.GetLocation().X;
float Y = InstanceTransform.GetLocation().Y;
float Z = InstanceTransform.GetLocation().Z;
float Roll = InstanceTransform.Rotator().Roll;
float Pitch = InstanceTransform.Rotator().Pitch;
float Yaw = InstanceTransform.Rotator().Yaw;
float ScaleX = InstanceTransform.GetScale3D().X;
float ScaleY = InstanceTransform.GetScale3D().Y;
float ScaleZ = InstanceTransform.GetScale3D().Z;
BinaryData << X;
BinaryData << Y;
BinaryData << Z;
BinaryData << Roll;
BinaryData << Pitch;
BinaryData << Yaw;
BinaryData << ScaleX;
BinaryData << ScaleY;
BinaryData << ScaleZ;
}
}
}