Skip to content

Commit

Permalink
Merge pull request #15 from qualisys/fix_skeleton_mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilRosenquist authored Dec 11, 2020
2 parents b87769e + 2305d73 commit d1a5950
Show file tree
Hide file tree
Showing 18 changed files with 16 additions and 14 deletions.
Binary file modified Example Project/Content/BackFlip.umap
Binary file not shown.
Binary file modified Example Project/Content/BackFlip_BuiltData.uasset
Binary file not shown.
Binary file modified Example Project/Content/QAvatar/Body_D_red.uasset
Binary file not shown.
Binary file modified Example Project/Content/QAvatar/Body_R.uasset
Binary file not shown.
Binary file modified Example Project/Content/QAvatar/Mask_D.uasset
Binary file not shown.
Binary file modified Example Project/Content/QAvatar/QAFace.uasset
Binary file not shown.
Binary file modified Example Project/Content/QAvatar/QAMask.uasset
Binary file not shown.
Binary file modified Example Project/Content/QAvatar/QASuit_B.uasset
Binary file not shown.
Binary file modified Example Project/Content/QAvatar/QAvatar.uasset
Binary file not shown.
Binary file modified Example Project/Content/QAvatar/QAvatar_PhysicsAsset.uasset
Binary file not shown.
Binary file modified Example Project/Content/QAvatar/QAvatar_Skeleton.uasset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Example Project/Content/QAvatar/face_D.uasset
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -466,22 +466,20 @@ uint32 FQTMConnectLiveLinkSource::Run()

CRTPacket::SSkeletonSegment segment;
packet->GetSkeletonSegment(skeletonIndex, segmentIndex, segment);

auto segmentRotation = FQuat(-segment.rotationX, segment.rotationY, -segment.rotationZ, segment.rotationW) * FQuat(-settings.rotationX, settings.rotationY, -settings.rotationZ, settings.rotationW).Inverse();

auto segmentRotation = FQuat(0, 0, 0, 1);
auto segmentLocation = FVector(0, 0, 0);
while (settings.parentIndex != -1)
{
mRTProtocol->GetSkeletonSegment(skeletonIndex, settings.parentIndex, &settings);

auto ancestorRotation = FQuat(-settings.rotationX, settings.rotationY, -settings.rotationZ, settings.rotationW);

if (settings.parentIndex == -1)
{
segmentRotation = FQuat(segment.rotationX, -segment.rotationY, segment.rotationZ, -segment.rotationW);
segmentLocation = FVector(segment.positionX, -segment.positionY, segment.positionZ) * positionScalingFactor;
}
else
{
segmentRotation = FQuat(-segment.rotationX, segment.rotationY, -segment.rotationZ, segment.rotationW);
segmentLocation = FVector(segment.positionX, -segment.positionY, segment.positionZ) * positionScalingFactor;
segmentRotation = ancestorRotation * segmentRotation * ancestorRotation.Inverse();
}

const auto segmentLocation = FVector(segment.positionX, -segment.positionY, segment.positionZ) * positionScalingFactor;

const auto segmentScale = FVector(1.0, 1.0, 1.0);

transforms[segmentIndex] = FTransform(segmentRotation, segmentLocation, segmentScale);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ void UQualisysLiveLinkRetargetAsset::BuildPoseFromAnimationData(float DeltaTime,
for (int32 i = 0; i < TargetBoneNames.Num(); ++i)
{
const auto& BoneName = TargetBoneNames[i];
const auto& BoneTransform = InFrameData->Transforms[i];
auto BoneTransform = InFrameData->Transforms[i];
const auto& location = BoneTransform.GetLocation();
const auto& rotation = BoneTransform.GetRotation();
BoneTransform.SetLocation(FVector(-location.X, -location.Y, location.Z));
BoneTransform.SetRotation(FQuat(-rotation.X, -rotation.Y, rotation.Z, rotation.W));

const auto BoneIndex = GetCompactPoseBoneIndex(BoneName, OutPose);

Expand Down Expand Up @@ -229,7 +233,7 @@ void UQualisysLiveLinkRetargetAsset::BuildPoseFromAnimationData(float DeltaTime,
const auto ChildActualDir = (ChildRefPose.GetTranslation() - WorldRefPose.GetTranslation()).GetSafeNormal();
const auto ChildTargetDir = GetTargetBoneDir(SourceBoneNames[i]);

LocalPoseCorrections[i] = FQuat::MakeFromEuler(FVector(0, 0, 0));
LocalPoseCorrections[i] = FQuat::FindBetween(WorldToLocal.RotateVector(ChildActualDir), WorldToLocal.RotateVector(ChildTargetDir));
}
}
}
Expand All @@ -242,7 +246,7 @@ void UQualisysLiveLinkRetargetAsset::BuildPoseFromAnimationData(float DeltaTime,
const auto OriginalPose = GetRefPose(OutPose, BoneIndex, false);
const auto CorrectedPose = GetRefPose(OutPose, BoneIndex, true);

LocalPoseCorrections[i] = FQuat::MakeFromEuler(FVector(0, 0, 0));
LocalPoseCorrections[i] = (CorrectedPose.GetRotation().Inverse() * OriginalPose.GetRotation());
}

auto Pose = FTransform::Identity;
Expand Down
Binary file not shown.

0 comments on commit d1a5950

Please sign in to comment.