even more optimal fxrmotioncontroller data calculations that considers mesh when outputting senseglove data
This commit is contained in:
@@ -46,8 +46,7 @@ FSGVirtualHandTrackingSettings::FSGVirtualHandTrackingSettings()
|
||||
2.4f,
|
||||
2.4f,
|
||||
2.4f,
|
||||
FRotator{0.0f, -90.0f, 0.0f},
|
||||
FRotator{0.0f, 180.0f, 90.0f})
|
||||
FRotator{0.0f, -90.0f, 0.0f})
|
||||
{
|
||||
}
|
||||
|
||||
@@ -59,8 +58,7 @@ FSGVirtualHandTrackingSettings::FSGVirtualHandTrackingSettings(
|
||||
const float InMiddleDistalPhalanxLength,
|
||||
const float InRingDistalPhalanxLength,
|
||||
const float InLittleDistalPhalanxLength,
|
||||
const FRotator& InHandMeshToOpenXRRootBoneRotationCorrection,
|
||||
const FRotator& InHandMeshToSenseGloveRootBoneRotationCorrection)
|
||||
const FRotator& InRootBoneRotationCorrection)
|
||||
: LeftHandReferenceMesh(InLeftHandReferenceMesh),
|
||||
RightHandReferenceMesh(InRightHandReferenceMesh),
|
||||
ThumbDistalPhalanxLength(InThumbDistalPhalanxLength),
|
||||
@@ -68,8 +66,7 @@ FSGVirtualHandTrackingSettings::FSGVirtualHandTrackingSettings(
|
||||
MiddleDistalPhalanxLength(InMiddleDistalPhalanxLength),
|
||||
RingDistalPhalanxLength(InRingDistalPhalanxLength),
|
||||
LittleDistalPhalanxLength(InLittleDistalPhalanxLength),
|
||||
HandMeshToOpenXRRootBoneRotationCorrection(InHandMeshToOpenXRRootBoneRotationCorrection),
|
||||
HandMeshToSenseGloveRootBoneRotationCorrection(InHandMeshToSenseGloveRootBoneRotationCorrection),
|
||||
RootBoneRotationCorrection(InRootBoneRotationCorrection),
|
||||
LeftHandDefaultReferenceBoneTransforms{
|
||||
TPair<FName, FTransform>{
|
||||
FName{TEXT("hand_l")},
|
||||
|
||||
@@ -73,10 +73,7 @@ public:
|
||||
float LittleDistalPhalanxLength;
|
||||
|
||||
UPROPERTY(Config, EditDefaultsOnly, Category="Virtual Hand")
|
||||
FRotator HandMeshToOpenXRRootBoneRotationCorrection;
|
||||
|
||||
UPROPERTY(Config, EditDefaultsOnly, Category="Virtual Hand")
|
||||
FRotator HandMeshToSenseGloveRootBoneRotationCorrection;
|
||||
FRotator RootBoneRotationCorrection;
|
||||
|
||||
UPROPERTY(Config, VisibleDefaultsOnly, Category="Virtual Hand")
|
||||
TMap<FName, FTransform> LeftHandDefaultReferenceBoneTransforms;
|
||||
@@ -101,7 +98,5 @@ public:
|
||||
float InMiddleDistalPhalanxLength,
|
||||
float InRingDistalPhalanxLength,
|
||||
float InLittleDistalPhalanxLength,
|
||||
const FRotator& InHandMeshToOpenXRRootBoneRotationCorrection,
|
||||
const FRotator& InHandMeshToSenseGloveRootBoneRotationCorrection);
|
||||
|
||||
const FRotator& InRootBoneRotationCorrection);
|
||||
};
|
||||
@@ -210,6 +210,7 @@ struct FSGXRTracker::FImpl
|
||||
float DistalPhalanxLength);
|
||||
|
||||
static TArray<TArray<float>> GetFingerLengths(bool bRight);
|
||||
static TArray<FTransform> GetFingerStartTransforms(bool bRight);
|
||||
static TArray<FVector> GetFingerStartPositions(bool bRight);
|
||||
static TArray<FQuat> GetFingerStartRotations(bool bRight);
|
||||
static USGBasicHandModel* GetHandModel(bool bRight);
|
||||
@@ -280,126 +281,128 @@ struct FSGXRTracker::FImpl
|
||||
return Name;
|
||||
}
|
||||
|
||||
static const FTransform& GetRawMeshBoneRefTransform(bool bRight, const FName& BoneName);
|
||||
static const FTransform& GetMeshRawBoneRefTransform(bool bRight, const FName& BoneName);
|
||||
|
||||
FORCEINLINE static const FTransform& GetRawMeshBoneRefTransform(const bool bRight, const int32 JointIndex)
|
||||
FORCEINLINE static const FTransform& GetMeshRawBoneRefTransform(const bool bRight, const int32 JointIndex)
|
||||
{
|
||||
const FName& BoneName{GetMeshBoneName(bRight, JointIndex)};
|
||||
const FTransform& Transform{GetRawMeshBoneRefTransform(bRight, BoneName)};
|
||||
const FTransform& Transform{GetMeshRawBoneRefTransform(bRight, BoneName)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
FORCEINLINE static const FTransform& GetRawMeshBoneRefTransform(const bool bRight, const EHandKeypoint Keypoint)
|
||||
FORCEINLINE static const FTransform& GetMeshRawBoneRefTransform(const bool bRight, const EHandKeypoint Keypoint)
|
||||
{
|
||||
const FName& BoneName{GetMeshBoneName(bRight, Keypoint)};
|
||||
const FTransform& Transform{GetRawMeshBoneRefTransform(bRight, BoneName)};
|
||||
const FTransform& Transform{GetMeshRawBoneRefTransform(bRight, BoneName)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
FORCEINLINE static const FTransform& GetRawMeshBoneRefTransform(const EControllerHand Hand, const FName& BoneName)
|
||||
FORCEINLINE static const FTransform& GetMeshRawBoneRefTransform(const EControllerHand Hand, const FName& BoneName)
|
||||
{
|
||||
const bool bRight = Hand == EControllerHand::Right;
|
||||
const FTransform& Transform{GetRawMeshBoneRefTransform(bRight, BoneName)};
|
||||
const FTransform& Transform{GetMeshRawBoneRefTransform(bRight, BoneName)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
FORCEINLINE static const FTransform& GetRawMeshBoneRefTransform(const EControllerHand Hand, const int32 JointIndex)
|
||||
FORCEINLINE static const FTransform& GetMeshRawBoneRefTransform(const EControllerHand Hand, const int32 JointIndex)
|
||||
{
|
||||
const bool bRight = Hand == EControllerHand::Right;
|
||||
const FName& BoneName{GetMeshBoneName(bRight, JointIndex)};
|
||||
const FTransform& Transform{GetRawMeshBoneRefTransform(bRight, BoneName)};
|
||||
const FTransform& Transform{GetMeshRawBoneRefTransform(bRight, BoneName)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
FORCEINLINE static const FTransform& GetRawMeshBoneRefTransform(
|
||||
FORCEINLINE static const FTransform& GetMeshRawBoneRefTransform(
|
||||
const EControllerHand Hand, const EHandKeypoint Keypoint)
|
||||
{
|
||||
const bool bRight = Hand == EControllerHand::Right;
|
||||
const FName& BoneName{GetMeshBoneName(bRight, Keypoint)};
|
||||
const FTransform& Transform{GetRawMeshBoneRefTransform(bRight, BoneName)};
|
||||
const FTransform& Transform{GetMeshRawBoneRefTransform(bRight, BoneName)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
static FTransform GetOpenXRMeshBoneRefTransform(bool bRight, const FName& BoneName);
|
||||
static FTransform GetMeshWristChildBoneRefTransform(bool bRight, const FName& BoneName);
|
||||
|
||||
FORCEINLINE static FTransform GetOpenXRMeshBoneRefTransform(const bool bRight, const int32 JointIndex)
|
||||
{
|
||||
const FName& BoneName{GetMeshBoneName(bRight, JointIndex)};
|
||||
const FTransform Transform{GetOpenXRMeshBoneRefTransform(bRight, BoneName)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
FORCEINLINE static FTransform GetOpenXRMeshBoneRefTransform(
|
||||
const bool bRight, const EHandKeypoint Keypoint)
|
||||
{
|
||||
const FName& BoneName{GetMeshBoneName(bRight, Keypoint)};
|
||||
const FTransform Transform{GetOpenXRMeshBoneRefTransform(bRight, BoneName)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
FORCEINLINE static FTransform GetOpenXRMeshBoneRefTransform(
|
||||
const EControllerHand Hand, const FName& BoneName)
|
||||
{
|
||||
const bool bRight = Hand == EControllerHand::Right;
|
||||
const FTransform Transform{GetOpenXRMeshBoneRefTransform(bRight, BoneName)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
FORCEINLINE static FTransform GetOpenXRMeshBoneRefTransform(
|
||||
const EControllerHand Hand, const int32 JointIndex)
|
||||
{
|
||||
const bool bRight = Hand == EControllerHand::Right;
|
||||
const FTransform Transform{GetOpenXRMeshBoneRefTransform(bRight, JointIndex)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
FORCEINLINE static FTransform GetOpenXRMeshBoneRefTransform(
|
||||
const EControllerHand Hand, const EHandKeypoint Keypoint)
|
||||
{
|
||||
const bool bRight = Hand == EControllerHand::Right;
|
||||
const FTransform Transform{GetOpenXRMeshBoneRefTransform(bRight, Keypoint)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
static FTransform GetSGMeshMetacarpalBoneRefTransform(bool bRight, const FName& BoneName);
|
||||
|
||||
FORCEINLINE static FTransform GetSGMeshMetacarpalBoneRefTransform(
|
||||
FORCEINLINE static FTransform GetMeshWristChildBoneRefTransform(
|
||||
const bool bRight, const int32 JointIndex)
|
||||
{
|
||||
const FName& BoneName{GetMeshBoneName(bRight, JointIndex)};
|
||||
const FTransform Transform{GetSGMeshMetacarpalBoneRefTransform(bRight, BoneName)};
|
||||
const FTransform Transform{GetMeshWristChildBoneRefTransform(bRight, BoneName)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
FORCEINLINE static FTransform GetSGMeshMetacarpalBoneRefTransform(
|
||||
FORCEINLINE static FTransform GetMeshWristChildBoneRefTransform(
|
||||
const bool bRight, const EHandKeypoint Keypoint)
|
||||
{
|
||||
const FName& BoneName{GetMeshBoneName(bRight, Keypoint)};
|
||||
const FTransform Transform{GetSGMeshMetacarpalBoneRefTransform(bRight, BoneName)};
|
||||
const FTransform Transform{GetMeshWristChildBoneRefTransform(bRight, BoneName)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
FORCEINLINE static FTransform GetSGMeshMetacarpalBoneRefTransform(
|
||||
FORCEINLINE static FTransform GetMeshWristChildBoneRefTransform(
|
||||
const EControllerHand Hand, const FName& BoneName)
|
||||
{
|
||||
const bool bRight = Hand == EControllerHand::Right;
|
||||
const FTransform Transform{GetSGMeshMetacarpalBoneRefTransform(bRight, BoneName)};
|
||||
const FTransform Transform{GetMeshWristChildBoneRefTransform(bRight, BoneName)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
FORCEINLINE static FTransform GetSGMeshMetacarpalBoneRefTransform(
|
||||
FORCEINLINE static FTransform GetMeshWristChildBoneRefTransform(
|
||||
const EControllerHand Hand, const int32 JointIndex)
|
||||
{
|
||||
const bool bRight = Hand == EControllerHand::Right;
|
||||
const FTransform Transform{GetSGMeshMetacarpalBoneRefTransform(bRight, JointIndex)};
|
||||
const FTransform Transform{GetMeshWristChildBoneRefTransform(bRight, JointIndex)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
FORCEINLINE static FTransform GetSGMeshMetacarpalBoneRefTransform(
|
||||
FORCEINLINE static FTransform GetMeshWristChildBoneRefTransform(
|
||||
const EControllerHand Hand, const EHandKeypoint Keypoint)
|
||||
{
|
||||
const bool bRight = Hand == EControllerHand::Right;
|
||||
const FTransform Transform{GetSGMeshMetacarpalBoneRefTransform(bRight, Keypoint)};
|
||||
const FTransform Transform{GetMeshWristChildBoneRefTransform(bRight, Keypoint)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
static FTransform GetMeshFingerStartBoneRefTransform(
|
||||
bool bRight, EHandKeypoint Parent, const FName& BoneName);
|
||||
|
||||
FORCEINLINE static FTransform GetMeshFingerStartBoneRefTransform(
|
||||
const bool bRight, const EHandKeypoint Parent, const int32 JointIndex)
|
||||
{
|
||||
const FName& BoneName{GetMeshBoneName(bRight, JointIndex)};
|
||||
const FTransform Transform{GetMeshFingerStartBoneRefTransform(bRight, Parent, BoneName)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
FORCEINLINE static FTransform GetMeshFingerStartBoneRefTransform(
|
||||
const bool bRight, const EHandKeypoint Parent, const EHandKeypoint Keypoint)
|
||||
{
|
||||
const FName& BoneName{GetMeshBoneName(bRight, Keypoint)};
|
||||
const FTransform Transform{GetMeshFingerStartBoneRefTransform(bRight, Parent, BoneName)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
FORCEINLINE static FTransform GetMeshFingerStartBoneRefTransform(
|
||||
const EControllerHand Hand, const EHandKeypoint Parent, const FName& BoneName)
|
||||
{
|
||||
const bool bRight = Hand == EControllerHand::Right;
|
||||
const FTransform Transform{GetMeshFingerStartBoneRefTransform(bRight, Parent, BoneName)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
FORCEINLINE static FTransform GetMeshFingerStartBoneRefTransform(
|
||||
const EControllerHand Hand, const EHandKeypoint Parent, const int32 JointIndex)
|
||||
{
|
||||
const bool bRight = Hand == EControllerHand::Right;
|
||||
const FTransform Transform{GetMeshFingerStartBoneRefTransform(bRight, Parent, JointIndex)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
FORCEINLINE static FTransform GetMeshFingerStartBoneRefTransform(
|
||||
const EControllerHand Hand, const EHandKeypoint Parent, const EHandKeypoint Keypoint)
|
||||
{
|
||||
const bool bRight = Hand == EControllerHand::Right;
|
||||
const FTransform Transform{GetMeshFingerStartBoneRefTransform(bRight, Parent, Keypoint)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
@@ -637,9 +640,9 @@ TArray<float> FSGXRTracker::FImpl::GetFingerLengths(
|
||||
const EHandKeypoint Joint2nd, const EHandKeypoint Joint3rd,
|
||||
const float DistalPhalanxLength)
|
||||
{
|
||||
const FTransform& Joint2ndTransform{GetOpenXRMeshBoneRefTransform(bRight, Joint2nd)};
|
||||
const FTransform& Joint2ndTransform{GetMeshRawBoneRefTransform(bRight, Joint2nd)};
|
||||
const FVector& Joint2ndLocation{Joint2ndTransform.GetLocation()};
|
||||
const FTransform& Joint3rdTransform{GetOpenXRMeshBoneRefTransform(bRight, Joint3rd)};
|
||||
const FTransform& Joint3rdTransform{GetMeshRawBoneRefTransform(bRight, Joint3rd)};
|
||||
const FVector& Joint3rdLocation{Joint3rdTransform.GetLocation()};
|
||||
|
||||
const float PhalanxLength1st = static_cast<float>(Joint2ndLocation.Size());
|
||||
@@ -684,74 +687,51 @@ TArray<TArray<float>> FSGXRTracker::FImpl::GetFingerLengths(const bool bRight)
|
||||
return Lengths;
|
||||
}
|
||||
|
||||
TArray<FTransform> FSGXRTracker::FImpl::GetFingerStartTransforms(const bool bRight)
|
||||
{
|
||||
FTransform ThumbStartTransform{
|
||||
GetMeshWristChildBoneRefTransform(bRight, EHandKeypoint::ThumbMetacarpal).GetLocation()
|
||||
};
|
||||
|
||||
FTransform IndexStartTransform{
|
||||
GetMeshFingerStartBoneRefTransform(bRight, EHandKeypoint::IndexMetacarpal, EHandKeypoint::IndexProximal)
|
||||
};
|
||||
|
||||
FTransform MiddleStartTransform{
|
||||
GetMeshFingerStartBoneRefTransform(bRight, EHandKeypoint::MiddleMetacarpal, EHandKeypoint::MiddleProximal)
|
||||
};
|
||||
|
||||
FTransform RingStartTransform{
|
||||
GetMeshFingerStartBoneRefTransform(bRight, EHandKeypoint::RingMetacarpal, EHandKeypoint::RingProximal)
|
||||
};
|
||||
|
||||
FTransform LittleStartTransform{
|
||||
GetMeshFingerStartBoneRefTransform(bRight, EHandKeypoint::LittleMetacarpal, EHandKeypoint::LittleProximal)
|
||||
};
|
||||
|
||||
TArray<FTransform> Transforms{
|
||||
MoveTemp(ThumbStartTransform),
|
||||
MoveTemp(IndexStartTransform),
|
||||
MoveTemp(MiddleStartTransform),
|
||||
MoveTemp(RingStartTransform),
|
||||
MoveTemp(LittleStartTransform),
|
||||
};
|
||||
|
||||
return Transforms;
|
||||
}
|
||||
|
||||
TArray<FVector> FSGXRTracker::FImpl::GetFingerStartPositions(const bool bRight)
|
||||
{
|
||||
const FVector WristPosition{GetRawMeshBoneRefTransform(bRight, EHandKeypoint::Wrist).GetLocation()};
|
||||
|
||||
const FQuat RootRotationCorrection{
|
||||
GetVirtualHandTrackingSettings().HandMeshToOpenXRRootBoneRotationCorrection.Quaternion()
|
||||
};
|
||||
FTransform RootBoneRefTransform{GetRawMeshBoneRefTransform(bRight, EHandKeypoint::Wrist)};
|
||||
RootBoneRefTransform.SetRotation(RootRotationCorrection * RootBoneRefTransform.GetRotation());
|
||||
|
||||
|
||||
FVector ThumbStartPosition{
|
||||
GetRawMeshBoneRefTransform(bRight, EHandKeypoint::ThumbMetacarpal).GetLocation()
|
||||
};
|
||||
|
||||
FTransform IndexMetacarpalTransform{
|
||||
GetRawMeshBoneRefTransform(bRight, EHandKeypoint::IndexMetacarpal)
|
||||
};
|
||||
FTransform IndexStartTransform{
|
||||
GetRawMeshBoneRefTransform(bRight, EHandKeypoint::IndexProximal)
|
||||
};
|
||||
|
||||
FVector IndexStartPositionUncorrected = IndexMetacarpalTransform.GetLocation() + (IndexMetacarpalTransform.
|
||||
GetRotation() * IndexStartTransform.GetLocation());
|
||||
FVector IndexStartPosition = RootBoneRefTransform.GetRotation() * IndexStartPositionUncorrected;
|
||||
|
||||
FTransform MiddleMetacarpalTransform{
|
||||
GetRawMeshBoneRefTransform(bRight, EHandKeypoint::MiddleMetacarpal)
|
||||
};
|
||||
FTransform MiddleStartTransform{
|
||||
GetRawMeshBoneRefTransform(bRight, EHandKeypoint::MiddleProximal)
|
||||
};
|
||||
|
||||
FVector MiddleStartPositionUncorrected = MiddleMetacarpalTransform.GetLocation() + (MiddleMetacarpalTransform.
|
||||
GetRotation() * MiddleStartTransform.GetLocation());
|
||||
FVector MiddleStartPosition = RootBoneRefTransform.GetRotation() * MiddleStartPositionUncorrected;
|
||||
|
||||
|
||||
FTransform RingMetacarpalTransform{
|
||||
GetRawMeshBoneRefTransform(bRight, EHandKeypoint::RingMetacarpal)
|
||||
};
|
||||
FTransform RingStartTransform{
|
||||
GetRawMeshBoneRefTransform(bRight, EHandKeypoint::RingProximal)
|
||||
};
|
||||
|
||||
FVector RingStartPositionUncorrected = RingMetacarpalTransform.GetLocation() + (RingMetacarpalTransform.
|
||||
GetRotation() * RingStartTransform.GetLocation());
|
||||
FVector RingStartPosition = RootBoneRefTransform.GetRotation() * RingStartPositionUncorrected;
|
||||
|
||||
|
||||
FTransform LittleMetacarpalTransform{
|
||||
GetRawMeshBoneRefTransform(bRight, EHandKeypoint::LittleMetacarpal)
|
||||
};
|
||||
FTransform LittleStartTransform{
|
||||
GetRawMeshBoneRefTransform(bRight, EHandKeypoint::LittleProximal)
|
||||
};
|
||||
|
||||
FVector LittleStartPositionUncorrected = LittleMetacarpalTransform.GetLocation() + (LittleMetacarpalTransform.
|
||||
GetRotation() * LittleStartTransform.GetLocation());
|
||||
FVector LittleStartPosition = RootBoneRefTransform.GetRotation() * LittleStartPositionUncorrected;
|
||||
const TArray<FTransform> StartTransforms{GetFingerStartTransforms(bRight)};
|
||||
|
||||
ensureAlwaysMsgf(StartTransforms.Num() == 5, TEXT("Invalid number of finger start transforms!"));
|
||||
|
||||
const TArray<FVector> StartPositions{
|
||||
ThumbStartPosition,
|
||||
IndexStartPosition,
|
||||
MiddleStartPosition,
|
||||
RingStartPosition,
|
||||
LittleStartPosition,
|
||||
StartTransforms[0].GetLocation(),
|
||||
StartTransforms[1].GetLocation(),
|
||||
StartTransforms[2].GetLocation(),
|
||||
StartTransforms[3].GetLocation(),
|
||||
StartTransforms[4].GetLocation(),
|
||||
};
|
||||
|
||||
return StartPositions;
|
||||
@@ -759,78 +739,16 @@ TArray<FVector> FSGXRTracker::FImpl::GetFingerStartPositions(const bool bRight)
|
||||
|
||||
TArray<FQuat> FSGXRTracker::FImpl::GetFingerStartRotations(const bool bRight)
|
||||
{
|
||||
// const FQuat ThumbStartRotation{
|
||||
// GetSGMeshMetacarpalBoneRefTransform(bRight, EHandKeypoint::ThumbMetacarpal).GetRotation()
|
||||
// };
|
||||
//
|
||||
// const FQuat IndexMetacarpalRotation{
|
||||
// GetSGMeshMetacarpalBoneRefTransform(bRight, EHandKeypoint::IndexMetacarpal).GetRotation()
|
||||
// };
|
||||
// const FQuat IndexStartRotation{
|
||||
// GetRawMeshBoneRefTransform(bRight, EHandKeypoint::IndexProximal).GetRotation() * IndexMetacarpalRotation
|
||||
// };
|
||||
//
|
||||
// const FQuat MiddleMetacarpalRotation{
|
||||
// GetSGMeshMetacarpalBoneRefTransform(bRight, EHandKeypoint::MiddleMetacarpal).GetRotation()
|
||||
// };
|
||||
// const FQuat MiddleStartRotation{
|
||||
// GetRawMeshBoneRefTransform(bRight, EHandKeypoint::MiddleProximal).GetRotation() * MiddleMetacarpalRotation
|
||||
// };
|
||||
//
|
||||
// const FQuat RingMetacarpalRotation{
|
||||
// GetSGMeshMetacarpalBoneRefTransform(bRight, EHandKeypoint::RingMetacarpal).GetRotation()
|
||||
// };
|
||||
// const FQuat RingStartRotation{
|
||||
// GetRawMeshBoneRefTransform(bRight, EHandKeypoint::RingProximal).GetRotation() * RingMetacarpalRotation
|
||||
// };
|
||||
//
|
||||
// const FQuat LittleMetacarpalRotation{
|
||||
// GetSGMeshMetacarpalBoneRefTransform(bRight, EHandKeypoint::LittleMetacarpal).GetRotation()
|
||||
// };
|
||||
// const FQuat LittleStartRotation{
|
||||
// GetRawMeshBoneRefTransform(bRight, EHandKeypoint::LittleProximal).GetRotation() * LittleMetacarpalRotation
|
||||
// };
|
||||
|
||||
const FQuat ThumbStartRotation{
|
||||
GetRawMeshBoneRefTransform(bRight, EHandKeypoint::ThumbMetacarpal).GetRotation()
|
||||
};
|
||||
|
||||
const FQuat RootRotationCorrection{
|
||||
GetVirtualHandTrackingSettings().HandMeshToSenseGloveRootBoneRotationCorrection.Quaternion()
|
||||
};
|
||||
FTransform RootBoneRefTransform{GetRawMeshBoneRefTransform(bRight, EHandKeypoint::Wrist)};
|
||||
RootBoneRefTransform.SetRotation(RootRotationCorrection * RootBoneRefTransform.GetRotation());
|
||||
|
||||
const FTransform IndexMetacarpalTransform{
|
||||
GetRawMeshBoneRefTransform(bRight, EHandKeypoint::IndexMetacarpal)
|
||||
};
|
||||
const FTransform IndexProximalTransform{
|
||||
GetRawMeshBoneRefTransform(bRight, EHandKeypoint::IndexProximal)
|
||||
};
|
||||
|
||||
const FQuat IndexStartRotation{IndexProximalTransform.GetRotation() * RootBoneRefTransform.GetRotation()};
|
||||
|
||||
|
||||
|
||||
const FQuat MiddleStartRotation{
|
||||
GetRawMeshBoneRefTransform(bRight, EHandKeypoint::MiddleProximal).GetRotation()
|
||||
};
|
||||
|
||||
const FQuat RingStartRotation{
|
||||
GetRawMeshBoneRefTransform(bRight, EHandKeypoint::RingProximal).GetRotation()
|
||||
};
|
||||
|
||||
const FQuat LittleStartRotation{
|
||||
GetRawMeshBoneRefTransform(bRight, EHandKeypoint::LittleProximal).GetRotation()
|
||||
};
|
||||
const TArray<FTransform> StartTransforms{GetFingerStartTransforms(bRight)};
|
||||
|
||||
ensureAlwaysMsgf(StartTransforms.Num() == 5, TEXT("Invalid number of finger start transforms!"));
|
||||
|
||||
const TArray<FQuat> StartRotations{
|
||||
// ThumbStartRotation,
|
||||
// IndexStartRotation,
|
||||
// MiddleStartRotation,
|
||||
// RingStartRotation,
|
||||
// LittleStartRotation,
|
||||
// StartTransforms[0].GetRotation(),
|
||||
// StartTransforms[1].GetRotation(),
|
||||
// StartTransforms[2].GetRotation(),
|
||||
// StartTransforms[3].GetRotation(),
|
||||
// StartTransforms[4].GetRotation(),
|
||||
FQuat::Identity,
|
||||
FQuat::Identity,
|
||||
FQuat::Identity,
|
||||
@@ -877,7 +795,7 @@ USGHandPose* FSGXRTracker::FImpl::GetHandPose(const bool bRight)
|
||||
return HandPose;
|
||||
}
|
||||
|
||||
const FTransform& FSGXRTracker::FImpl::GetRawMeshBoneRefTransform(const bool bRight, const FName& BoneName)
|
||||
const FTransform& FSGXRTracker::FImpl::GetMeshRawBoneRefTransform(const bool bRight, const FName& BoneName)
|
||||
{
|
||||
const TSoftObjectPtr<USkeletalMesh>& HandMesh{
|
||||
bRight
|
||||
@@ -919,30 +837,37 @@ const FTransform& FSGXRTracker::FImpl::GetRawMeshBoneRefTransform(const bool bRi
|
||||
return Transform;
|
||||
}
|
||||
|
||||
FTransform FSGXRTracker::FImpl::GetOpenXRMeshBoneRefTransform(
|
||||
const bool bRight, const FName& BoneName)
|
||||
FTransform FSGXRTracker::FImpl::GetMeshWristChildBoneRefTransform(const bool bRight, const FName& BoneName)
|
||||
{
|
||||
const FQuat RootRotationCorrection{
|
||||
GetVirtualHandTrackingSettings().HandMeshToOpenXRRootBoneRotationCorrection.Quaternion()
|
||||
FQuat RootRotationCorrection{
|
||||
GetVirtualHandTrackingSettings().RootBoneRotationCorrection
|
||||
};
|
||||
const FTransform& RootBoneRefTransform{GetMeshRawBoneRefTransform(bRight, EHandKeypoint::Wrist)};
|
||||
const FTransform& RawTransform{GetMeshRawBoneRefTransform(bRight, BoneName)};
|
||||
FQuat CorrectedRootBoneRefRotation{MoveTemp(RootRotationCorrection) * RootBoneRefTransform.GetRotation()};
|
||||
FVector CorrectedLocation{MoveTemp(CorrectedRootBoneRefRotation) * RawTransform.GetLocation()};
|
||||
|
||||
FTransform RootBoneRefTransform{GetRawMeshBoneRefTransform(bRight, EHandKeypoint::Wrist)};
|
||||
RootBoneRefTransform.SetRotation(RootRotationCorrection * RootBoneRefTransform.GetRotation());
|
||||
const FTransform Transform{GetRawMeshBoneRefTransform(bRight, BoneName) * RootBoneRefTransform};
|
||||
|
||||
const FTransform Transform{RawTransform.GetRotation(), MoveTemp(CorrectedLocation)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
FTransform FSGXRTracker::FImpl::GetSGMeshMetacarpalBoneRefTransform(const bool bRight, const FName& BoneName)
|
||||
FTransform FSGXRTracker::FImpl::GetMeshFingerStartBoneRefTransform(
|
||||
const bool bRight, const EHandKeypoint Parent, const FName& BoneName)
|
||||
{
|
||||
const FQuat RootRotationCorrection{
|
||||
GetVirtualHandTrackingSettings().HandMeshToSenseGloveRootBoneRotationCorrection.Quaternion()
|
||||
FQuat RootRotationCorrection{
|
||||
GetVirtualHandTrackingSettings().RootBoneRotationCorrection
|
||||
};
|
||||
const FTransform& RootBoneRefTransform{GetMeshRawBoneRefTransform(bRight, EHandKeypoint::Wrist)};
|
||||
FQuat CorrectedRootBoneRefRotation{MoveTemp(RootRotationCorrection) * RootBoneRefTransform.GetRotation()};
|
||||
FTransform CorrectedRootBoneRefTransform {
|
||||
MoveTemp(CorrectedRootBoneRefRotation), RootBoneRefTransform.GetLocation()
|
||||
};
|
||||
|
||||
FTransform RootBoneRefTransform{GetRawMeshBoneRefTransform(bRight, EHandKeypoint::Wrist)};
|
||||
RootBoneRefTransform.SetRotation(RootRotationCorrection * RootBoneRefTransform.GetRotation());
|
||||
const FTransform Transform{RootBoneRefTransform * GetRawMeshBoneRefTransform(bRight, BoneName)};
|
||||
FTransform ParentBoneRefTransform{
|
||||
GetMeshRawBoneRefTransform(bRight, Parent) * MoveTemp(CorrectedRootBoneRefTransform)
|
||||
};
|
||||
|
||||
const FTransform Transform{GetMeshRawBoneRefTransform(bRight, BoneName) * MoveTemp(ParentBoneRefTransform)};
|
||||
return Transform;
|
||||
}
|
||||
|
||||
@@ -1852,11 +1777,9 @@ bool FSGXRTracker::FImpl::UpdateSGPalmJointData(
|
||||
return false;
|
||||
}
|
||||
|
||||
const FTransform JointTransform{GetOpenXRMeshBoneRefTransform(DeviceHand, EHandKeypoint::Palm)};
|
||||
// FVector JointLocation{JointTransform.GetLocation()};
|
||||
// FQuat JointRotation{JointTransform.GetRotation()};
|
||||
FVector JointLocation{4.967f, 0.090f, -0.132f};
|
||||
FQuat JointRotation{0.000000000f, 0.000000000f, 0.000000000f, 0.999999829f};
|
||||
const FTransform JointTransform{GetMeshWristChildBoneRefTransform(DeviceHand, EHandKeypoint::Palm)};
|
||||
FVector JointLocation{JointTransform.GetLocation()};
|
||||
FQuat JointRotation{JointTransform.GetRotation()};
|
||||
|
||||
if (!UpdateSGJointData(OutHandState, EHandKeypoint::Palm,
|
||||
MoveTemp(JointLocation), MoveTemp(JointRotation), WristLocation, WristRotation,
|
||||
@@ -1945,12 +1868,10 @@ bool FSGXRTracker::FImpl::UpdateSGIndexJointData(
|
||||
static constexpr int32 IndexTipJointIndex = 3;
|
||||
|
||||
const FTransform& IndexMetacarpalTransform{
|
||||
GetOpenXRMeshBoneRefTransform(DeviceHand, EHandKeypoint::IndexMetacarpal)
|
||||
GetMeshWristChildBoneRefTransform(DeviceHand, EHandKeypoint::IndexMetacarpal)
|
||||
};
|
||||
// FVector IndexMetacarpalLocation{IndexMetacarpalTransform.GetLocation()};
|
||||
// FQuat IndexMetacarpalRotation{IndexMetacarpalTransform.GetRotation()};
|
||||
FVector IndexMetacarpalLocation{3.759f, 2.089f, -0.932f};
|
||||
FQuat IndexMetacarpalRotation{0.000000000f, 0.000000000f, 0.000000000f, 0.999999829f};
|
||||
FVector IndexMetacarpalLocation{IndexMetacarpalTransform.GetLocation()};
|
||||
FQuat IndexMetacarpalRotation{IndexMetacarpalTransform.GetRotation()};
|
||||
|
||||
const FVector& IndexProximalLocation{JointLocations[IndexFingerIndex][IndexProximalJointIndex]};
|
||||
const FVector& IndexIntermediateLocation{JointLocations[IndexFingerIndex][IndexIntermediateJointIndex]};
|
||||
@@ -2026,12 +1947,10 @@ bool FSGXRTracker::FImpl::UpdateSGMiddleJointData(
|
||||
static constexpr int32 MiddleTipJointMiddle = 3;
|
||||
|
||||
const FTransform& MiddleMetacarpalTransform{
|
||||
GetOpenXRMeshBoneRefTransform(DeviceHand, EHandKeypoint::MiddleMetacarpal)
|
||||
GetMeshWristChildBoneRefTransform(DeviceHand, EHandKeypoint::MiddleMetacarpal)
|
||||
};
|
||||
// FVector MiddleMetacarpalLocation{MiddleMetacarpalTransform.GetLocation()};
|
||||
// FQuat MiddleMetacarpalRotation{MiddleMetacarpalTransform.GetRotation()};
|
||||
FVector MiddleMetacarpalLocation{3.534f, 0.405f, -0.767f};
|
||||
FQuat MiddleMetacarpalRotation{0.000000000f, 0.000000000f, 0.000000000f, 0.999999829f};
|
||||
FVector MiddleMetacarpalLocation{MiddleMetacarpalTransform.GetLocation()};
|
||||
FQuat MiddleMetacarpalRotation{MiddleMetacarpalTransform.GetRotation()};
|
||||
|
||||
const FVector& MiddleProximalLocation{JointLocations[MiddleFingerMiddle][MiddleProximalJointMiddle]};
|
||||
const FVector& MiddleIntermediateLocation{JointLocations[MiddleFingerMiddle][MiddleIntermediateJointMiddle]};
|
||||
@@ -2107,12 +2026,10 @@ bool FSGXRTracker::FImpl::UpdateSGRingJointData(
|
||||
static constexpr int32 RingTipJointRing = 3;
|
||||
|
||||
const FTransform& RingMetacarpalTransform{
|
||||
GetOpenXRMeshBoneRefTransform(DeviceHand, EHandKeypoint::RingMetacarpal)
|
||||
GetMeshWristChildBoneRefTransform(DeviceHand, EHandKeypoint::RingMetacarpal)
|
||||
};
|
||||
// FVector RingMetacarpalLocation{RingMetacarpalTransform.GetLocation()};
|
||||
// FQuat RingMetacarpalRotation{RingMetacarpalTransform.GetRotation()};
|
||||
FVector RingMetacarpalLocation{3.612f, -1.557f, -0.625f};
|
||||
FQuat RingMetacarpalRotation{0.000000000f, 0.000000000f, 0.000000000f, 0.999999829f};
|
||||
FVector RingMetacarpalLocation{RingMetacarpalTransform.GetLocation()};
|
||||
FQuat RingMetacarpalRotation{RingMetacarpalTransform.GetRotation()};
|
||||
|
||||
const FVector& RingProximalLocation{JointLocations[RingFingerRing][RingProximalJointRing]};
|
||||
const FVector& RingIntermediateLocation{JointLocations[RingFingerRing][RingIntermediateJointRing]};
|
||||
@@ -2188,12 +2105,10 @@ bool FSGXRTracker::FImpl::UpdateSGLittleJointData(
|
||||
static constexpr int32 LittleTipJointLittle = 3;
|
||||
|
||||
const FTransform& LittleMetacarpalTransform{
|
||||
GetOpenXRMeshBoneRefTransform(DeviceHand, EHandKeypoint::LittleMetacarpal)
|
||||
GetMeshWristChildBoneRefTransform(DeviceHand, EHandKeypoint::LittleMetacarpal)
|
||||
};
|
||||
// FVector LittleMetacarpalLocation{LittleMetacarpalTransform.GetLocation()};
|
||||
// FQuat LittleMetacarpalRotation{LittleMetacarpalTransform.GetRotation()};
|
||||
FVector LittleMetacarpalLocation{3.539f, -2.389f, -0.978f};
|
||||
FQuat LittleMetacarpalRotation{0.207036002f, 0.018311810f, -0.140342834f, 0.968041580f};
|
||||
FVector LittleMetacarpalLocation{LittleMetacarpalTransform.GetLocation()};
|
||||
FQuat LittleMetacarpalRotation{LittleMetacarpalTransform.GetRotation()};
|
||||
|
||||
const FVector& LittleProximalLocation{JointLocations[LittleFingerLittle][LittleProximalJointLittle]};
|
||||
const FVector& LittleIntermediateLocation{JointLocations[LittleFingerLittle][LittleIntermediateJointLittle]};
|
||||
|
||||
Reference in New Issue
Block a user