本文整理汇总了C++中FTransform::GetScale3D方法的典型用法代码示例。如果您正苦于以下问题:C++ FTransform::GetScale3D方法的具体用法?C++ FTransform::GetScale3D怎么用?C++ FTransform::GetScale3D使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FTransform
的用法示例。
在下文中一共展示了FTransform::GetScale3D方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddConvexElemsToRigidActor_AssumesLocked
void AddConvexElemsToRigidActor_AssumesLocked() const
{
float ContactOffsetFactor, MaxContactOffset;
GetContactOffsetParams(ContactOffsetFactor, MaxContactOffset);
for (int32 i = 0; i < BodySetup->AggGeom.ConvexElems.Num(); i++)
{
const FKConvexElem& ConvexElem = BodySetup->AggGeom.ConvexElems[i];
if (ConvexElem.ConvexMesh)
{
PxTransform PLocalPose;
bool bUseNegX = CalcMeshNegScaleCompensation(Scale3D, PLocalPose);
PxConvexMeshGeometry PConvexGeom;
PConvexGeom.convexMesh = bUseNegX ? ConvexElem.ConvexMeshNegX : ConvexElem.ConvexMesh;
PConvexGeom.scale.scale = U2PVector(Scale3DAbs * ConvexElem.GetTransform().GetScale3D().GetAbs());
FTransform ConvexTransform = ConvexElem.GetTransform();
if (ConvexTransform.GetScale3D().X < 0 || ConvexTransform.GetScale3D().Y < 0 || ConvexTransform.GetScale3D().Z < 0)
{
UE_LOG(LogPhysics, Warning, TEXT("AddConvexElemsToRigidActor: [%s] ConvexElem[%d] has negative scale. Not currently supported"), *GetPathNameSafe(BodySetup->GetOuter()), i);
}
if (ConvexTransform.IsValid())
{
PxTransform PElementTransform = U2PTransform(ConvexTransform * RelativeTM);
PLocalPose.q *= PElementTransform.q;
PLocalPose.p = PElementTransform.p;
PLocalPose.p.x *= Scale3D.X;
PLocalPose.p.y *= Scale3D.Y;
PLocalPose.p.z *= Scale3D.Z;
if (PConvexGeom.isValid())
{
PxVec3 PBoundsExtents = PConvexGeom.convexMesh->getLocalBounds().getExtents();
ensure(PLocalPose.isValid());
{
const float ContactOffset = FMath::Min(MaxContactOffset, ContactOffsetFactor * PBoundsExtents.minElement());
AttachShape_AssumesLocked(PConvexGeom, PLocalPose, ContactOffset);
}
}
else
{
UE_LOG(LogPhysics, Warning, TEXT("AddConvexElemsToRigidActor: [%s] ConvexElem[%d] invalid"), *GetPathNameSafe(BodySetup->GetOuter()), i);
}
}
else
{
UE_LOG(LogPhysics, Warning, TEXT("AddConvexElemsToRigidActor: [%s] ConvexElem[%d] has invalid transform"), *GetPathNameSafe(BodySetup->GetOuter()), i);
}
}
else
{
UE_LOG(LogPhysics, Warning, TEXT("AddConvexElemsToRigidActor: ConvexElem is missing ConvexMesh (%d: %s)"), i, *BodySetup->GetPathName());
}
}
}
示例2: 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) );
}
示例3: GetWidgetLocation
FVector FPhATEdPreviewViewportClient::GetWidgetLocation() const
{
if (SharedData->EditingMode == FPhATSharedData::PEM_BodyEdit) /// BODY EDITING ///
{
// Don't draw widget if nothing selected.
if (!SharedData->GetSelectedBody())
{
return FVector::ZeroVector;
}
int32 BoneIndex = SharedData->EditorSkelComp->GetBoneIndex(SharedData->PhysicsAsset->SkeletalBodySetups[SharedData->GetSelectedBody()->Index]->BoneName);
FTransform BoneTM = SharedData->EditorSkelComp->GetBoneTransform(BoneIndex);
const float Scale = BoneTM.GetScale3D().GetAbsMax();
BoneTM.RemoveScaling();
return SharedData->EditorSkelComp->GetPrimitiveTransform(BoneTM, SharedData->GetSelectedBody()->Index, SharedData->GetSelectedBody()->PrimitiveType, SharedData->GetSelectedBody()->PrimitiveIndex, Scale).GetTranslation();
}
else /// CONSTRAINT EDITING ///
{
if (!SharedData->GetSelectedConstraint())
{
return FVector::ZeroVector;
}
return SharedData->GetConstraintMatrix(SharedData->GetSelectedConstraint()->Index, EConstraintFrame::Frame2, 1.f).GetTranslation();
}
}
示例4: 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;
}
}
}
示例5: 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);
}
示例6: 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));
}
示例7: 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());
}
示例8: AddShapesToRigidActor
void UBodySetup::AddShapesToRigidActor(PxRigidActor* PDestActor, FVector& Scale3D, const FTransform& RelativeTM /* = FTransform::Identity */, TArray<physx::PxShape*>* NewShapes /* = NULL */ )
{
#if WITH_RUNTIME_PHYSICS_COOKING || WITH_EDITOR
// in editor, there are a lot of things relying on body setup to create physics meshes
CreatePhysicsMeshes();
#endif
float MinScale;
float MinScaleAbs;
FVector Scale3DAbs;
SetupNonUniformHelper(Scale3D, MinScale, MinScaleAbs, Scale3DAbs);
{
float MinScaleRelative;
float MinScaleAbsRelative;
FVector Scale3DAbsRelative;
FVector Scale3DRelative = RelativeTM.GetScale3D();
SetupNonUniformHelper(Scale3DRelative, MinScaleRelative, MinScaleAbsRelative, Scale3DAbsRelative);
MinScaleAbs *= MinScaleAbsRelative;
Scale3DAbs.X *= Scale3DAbsRelative.X;
Scale3DAbs.Y *= Scale3DAbsRelative.Y;
Scale3DAbs.Z *= Scale3DAbsRelative.Z;
}
// Create shapes for simple collision if we do not want to use the complex collision mesh
// for simple queries as well
if (CollisionTraceFlag != ECollisionTraceFlag::CTF_UseComplexAsSimple)
{
AddSpheresToRigidActor(PDestActor, RelativeTM, MinScale, MinScaleAbs, NewShapes);
AddBoxesToRigidActor(PDestActor, RelativeTM, Scale3D, Scale3DAbs, NewShapes);
AddSphylsToRigidActor(PDestActor, RelativeTM, Scale3D, Scale3DAbs, NewShapes);
AddConvexElemsToRigidActor(PDestActor, RelativeTM, Scale3D, Scale3DAbs, NewShapes);
}
// Create tri-mesh shape, when we are not using simple collision shapes for
// complex queries as well
if( CollisionTraceFlag != ECollisionTraceFlag::CTF_UseSimpleAsComplex )
{
AddTriMeshToRigidActor(PDestActor, Scale3D, Scale3DAbs);
}
}
示例9: UpdateInstanceTransform
bool UPaperGroupedSpriteComponent::UpdateInstanceTransform(int32 InstanceIndex, const FTransform& NewInstanceTransform, bool bWorldSpace, bool bMarkRenderStateDirty)
{
if (!PerInstanceSpriteData.IsValidIndex(InstanceIndex))
{
return false;
}
// Request navigation update
UNavigationSystem::UpdateNavOctree(this);
FSpriteInstanceData& InstanceData = PerInstanceSpriteData[InstanceIndex];
// Render data uses local transform of the instance
FTransform LocalTransform = bWorldSpace ? NewInstanceTransform.GetRelativeTransform(ComponentToWorld) : NewInstanceTransform;
InstanceData.Transform = LocalTransform.ToMatrixWithScale();
if (bPhysicsStateCreated)
{
// Physics uses world transform of the instance
const FTransform WorldTransform = bWorldSpace ? NewInstanceTransform : (LocalTransform * ComponentToWorld);
if (FBodyInstance* InstanceBodyInstance = InstanceBodies[InstanceIndex])
{
// Update transform.
InstanceBodyInstance->SetBodyTransform(WorldTransform, ETeleportType::None);
InstanceBodyInstance->UpdateBodyScale(WorldTransform.GetScale3D());
}
}
// Request navigation update
UNavigationSystem::UpdateNavOctree(this);
if (bMarkRenderStateDirty)
{
MarkRenderStateDirty();
}
return true;
}
示例10: CalcAABB
FBox FKAggregateGeom::CalcAABB(const FTransform& Transform) const
{
const FVector Scale3D = Transform.GetScale3D();
FTransform BoneTM = Transform;
BoneTM.RemoveScaling();
FBox Box(0);
// Instead of ignore if not uniform, I'm getting Min of the abs value
// the reason for below function is for negative scale
// say if you have scale of (-1, 2, -3), you'd like to get -1;
const float ScaleFactor = SelectMinScale(Scale3D);
for(int32 i=0; i<SphereElems.Num(); i++)
{
Box += SphereElems[i].CalcAABB(BoneTM, ScaleFactor);
}
for(int32 i=0; i<BoxElems.Num(); i++)
{
Box += BoxElems[i].CalcAABB(BoneTM, ScaleFactor);
}
for(int32 i=0; i<SphylElems.Num(); i++)
{
Box += SphylElems[i].CalcAABB(BoneTM, ScaleFactor);
}
// Accumulate convex element bounding boxes.
for(int32 i=0; i<ConvexElems.Num(); i++)
{
Box += ConvexElems[i].CalcAABB(BoneTM, Scale3D);
}
return Box;
}
示例11: ProcessAnimationTracks
//.........这里部分代码省略.........
}
// if requested, retarget the FBoneAtoms towards the target end effectors
if (bRetarget)
{
if (NumScaleKeys > 0 && ParentBoneIndex != INDEX_NONE)
{
// update our bone table from the current bone through the last end effector we need to test
UpdateWorldBoneTransformRange(
AnimSeq,
BoneData,
RefPose,
PositionTracks,
RotationTracks,
ScaleTracks,
BoneIndex,
HighestTargetBoneIndex,
false,
NewWorldBones);
FScaleTrack& ScaleTrack = ScaleTracks[TrackIndex];
// adjust all translation keys to align better with the destination
for ( int32 KeyIndex = 0; KeyIndex < NumScaleKeys; ++KeyIndex )
{
FVector& Key= ScaleTrack.ScaleKeys[KeyIndex];
const int32 FrameIndex= FMath::Clamp(KeyIndex, 0, LastFrame);
const FTransform& NewWorldParent = NewWorldBones[(ParentBoneIndex*NumFrames) + FrameIndex];
const FTransform& RawWorldChild = RawWorldBones[(BoneIndex*NumFrames) + FrameIndex];
const FTransform& RelTM = (RawWorldChild.GetRelativeTransform(NewWorldParent));
const FTransform Delta = FTransform(RelTM);
Key = Delta.GetScale3D();
}
}
if (NumRotKeys > 0 && ParentBoneIndex != INDEX_NONE)
{
if (HighestTargetBoneIndex == BoneIndex)
{
for ( int32 KeyIndex = 0; KeyIndex < NumRotKeys; ++KeyIndex )
{
FQuat& Key = RotTrack.RotKeys[KeyIndex];
check(ParentBoneIndex != INDEX_NONE);
const int32 FrameIndex = FMath::Clamp(KeyIndex, 0, LastFrame);
FTransform NewWorldParent = NewWorldBones[(ParentBoneIndex*NumFrames) + FrameIndex];
FTransform RawWorldChild = RawWorldBones[(BoneIndex*NumFrames) + FrameIndex];
const FTransform& RelTM = (RawWorldChild.GetRelativeTransform(NewWorldParent));
FQuat Rot = FTransform(RelTM).GetRotation();
const FQuat& AlignedKey = EnforceShortestArc(Key, Rot);
Key = AlignedKey;
}
}
else
{
// update our bone table from the current bone through the last end effector we need to test
UpdateWorldBoneTransformRange(
AnimSeq,
BoneData,
RefPose,
PositionTracks,
RotationTracks,
ScaleTracks,
示例12: BreakTransform
void UKismetMathLibrary::BreakTransform(const FTransform& InTransform, FVector& Translation, FRotator& Rotation, FVector& Scale)
{
Translation = InTransform.GetLocation();
Rotation = InTransform.Rotator();
Scale = InTransform.GetScale3D();
}
示例13: GetBoneScaleByName
FVector UPoseableMeshComponent::GetBoneScaleByName(FName BoneName, EBoneSpaces::Type BoneSpace)
{
FTransform CurrentTransform = GetBoneTransformByName(BoneName, BoneSpace);
return CurrentTransform.GetScale3D();
}
示例14: AddedTransform
//.........这里部分代码省略.........
bSuccess = false;
AddTokenizedErrorMessage(FTokenizedMessage::Create(EMessageSeverity::Error, FText::Format(LOCTEXT("Error_InvalidUnrealTransform",
"Track {0} did not yeild valid transform. Please report this to animation team."), FText::FromName(BoneName))), FFbxErrors::Animation_TransformError);
break;
}
// debug data, including import transformation
FTransform AddedTransform(AddedMatrix);
NewDebugData.SourceGlobalTransform.Add(GlobalTransform * AddedTransform);
FTransform LocalTransform;
if( !bPreserveLocalTransform && LinkParent)
{
// I can't rely on LocalMatrix. I need to recalculate quaternion/scale based on global transform if Parent exists
FbxAMatrix ParentGlobalMatrix = Link->GetParent()->EvaluateGlobalTransform(CurTime);
FTransform ParentGlobalTransform = Converter.ConvertTransform(ParentGlobalMatrix);
LocalTransform = GlobalTransform.GetRelativeTransform(ParentGlobalTransform);
NewDebugData.SourceParentGlobalTransform.Add(ParentGlobalTransform);
}
else
{
FbxAMatrix& LocalMatrix = Link->EvaluateLocalTransform(CurTime);
FbxVector4 NewLocalT = LocalMatrix.GetT();
FbxVector4 NewLocalS = LocalMatrix.GetS();
FbxQuaternion NewLocalQ = LocalMatrix.GetQ();
LocalTransform.SetTranslation(Converter.ConvertPos(NewLocalT));
LocalTransform.SetScale3D(Converter.ConvertScale(NewLocalS));
LocalTransform.SetRotation(Converter.ConvertRotToQuat(NewLocalQ));
NewDebugData.SourceParentGlobalTransform.Add(FTransform::Identity);
}
if(TemplateData && BoneTreeIndex == 0)
{
// If we found template data earlier, apply the import transform matrix to
// the root track.
LocalTransform.SetFromMatrix(LocalTransform.ToMatrixWithScale() * AddedMatrix);
}
if (LocalTransform.ContainsNaN())
{
bSuccess = false;
AddTokenizedErrorMessage(FTokenizedMessage::Create(EMessageSeverity::Error, FText::Format(LOCTEXT("Error_InvalidUnrealLocalTransform",
"Track {0} did not yeild valid local transform. Please report this to animation team."), FText::FromName(BoneName))), FFbxErrors::Animation_TransformError);
break;
}
RawTrack.ScaleKeys.Add(LocalTransform.GetScale3D());
RawTrack.PosKeys.Add(LocalTransform.GetTranslation());
RawTrack.RotKeys.Add(LocalTransform.GetRotation());
NewDebugData.RecalculatedLocalTransform.Add(LocalTransform);
++NumKeysForTrack;
}
if (bSuccess)
{
//add new track
int32 NewTrackIdx = RawAnimationData.Add(RawTrack);
DestSeq->AnimationTrackNames.Add(BoneName);
NewDebugData.SetTrackData(NewTrackIdx, BoneTreeIndex, BoneName);
// add mapping to skeleton bone track
DestSeq->TrackToSkeletonMapTable.Add(FTrackToSkeletonMap(BoneTreeIndex));
TransformDebugData.Add(NewDebugData);
}
}
TotalNumKeys = FMath::Max( TotalNumKeys, NumKeysForTrack );
}
DestSeq->NumFrames = TotalNumKeys;
GWarn->EndSlowTask();
}
// compress animation
{
GWarn->BeginSlowTask( LOCTEXT("BeginCompressAnimation", "Compress Animation"), true);
GWarn->StatusForceUpdate(1, 1, LOCTEXT("CompressAnimation", "Compressing Animation"));
// if source data exists, you should bake it to Raw to apply
if(bSourceDataExists)
{
DestSeq->BakeTrackCurvesToRawAnimation();
}
else
{
// otherwise just compress
DestSeq->PostProcessSequence();
}
// run debug mode
AnimationTransformDebug::OutputAnimationTransformDebugData(TransformDebugData, TotalNumKeys, RefSkeleton);
GWarn->EndSlowTask();
}
return true;
}
示例15: SetFromTransform
void UAnimBone::SetFromTransform(const FTransform& Transform)
{
Orientation = FRotator(Transform.GetRotation());
Position = Transform.GetTranslation();
Scale = Transform.GetScale3D();
}