Skip to content
Snippets Groups Projects
Commit b309dcc2 authored by Patrick Nossol's avatar Patrick Nossol
Browse files

added chest control

parent 49fa19d0
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
...@@ -380,13 +380,6 @@ bool AMCController::PreprocessRecording(float StartHaltingPoint, float EndHaltin ...@@ -380,13 +380,6 @@ bool AMCController::PreprocessRecording(float StartHaltingPoint, float EndHaltin
return false; return false;
} }
//found no end -> add one
/*if (!AnimSaveState.AnimData.Last().IsEnd) {
AnimSaveState.AnimData.Push(FProcessedAnimData());
AnimSaveState.AnimData.Last().Timestamp = LastStamp + FTimespan::FromMilliseconds(10);
AnimSaveState.AnimData.Last().IsEnd = true;
}*/
//----process the anim data---- //----process the anim data----
//---Sensor turned off -> interpolate //---Sensor turned off -> interpolate
...@@ -577,10 +570,70 @@ bool AMCController::PreprocessRecording(float StartHaltingPoint, float EndHaltin ...@@ -577,10 +570,70 @@ bool AMCController::PreprocessRecording(float StartHaltingPoint, float EndHaltin
} }
} }
//---return to default pose at start and end--- //---Controlling Chest Position---
if (ChestControlFactor > 0.f) {
FVector AvgChestPos;
FVector AvgHipPos;
FVector MoveChest;
for (int i = 0; i < AnimSaveState.AnimData.Num(); i++) {
FProcessedAnimData& AnimData = AnimSaveState.AnimData[i];
if (AnimData.IsMarker || AnimData.IsEnd) {
//average chest position
AvgChestPos = FVector::ZeroVector;
int Num = 0;
for (int j = i + 1; j < AnimSaveState.AnimData.Num(); j++) {
if (AnimSaveState.AnimData[j].IsMarker || AnimSaveState.AnimData[j].IsEnd) {
break;
}
Num++;
}
for (int j = i + 1; j <= i + Num; j++) {
AvgChestPos += AnimSaveState.AnimData[j].SensorData.GetEntry(EBodyPart::UpperBody)->Pos / (float)Num;
}
//average hip position
AvgHipPos = FVector::ZeroVector;
for (int j = i + 1; j <= i + Num; j++) {
AvgHipPos += AnimSaveState.AnimData[j].SensorData.GetEntry(EBodyPart::LowerBody)->Pos / (float)Num;
}
MoveChest = ChestControlFactor * (AvgHipPos + ChestControlCenter - AvgChestPos);
MoveChest.X = 0.f;
MoveChest.Z = 0.f;
continue;
}
FSensorData& SensorData = AnimData.SensorData;
//move chest
FSensorDataEntry* ChestEntry = SensorData.GetEntry(EBodyPart::UpperBody);
ChestEntry->Pos += MoveChest;
if (ChestKeepLength) {
FSensorDataEntry* HipEntry = SensorData.GetEntry(EBodyPart::LowerBody);
FVector OldPos = ChestEntry->Pos;
ChestEntry->Pos = HipEntry->Pos + (AvgHipPos - AvgChestPos).Size() * (ChestEntry->Pos - HipEntry->Pos).Normalize();
MoveChest += ChestEntry->Pos - OldPos;
}
//move upper body parts to fit chest
for (int j = 0; j < EBodyPart::LAST; j++) {
EBodyPart Type = EBodyPart(j);
if (Type == EBodyPart::UpperBody || Type == EBodyPart::LowerBody || Type == EBodyPart::FootL || Type == EBodyPart::FootR) {
continue;
}
FSensorDataEntry* Entry = SensorData.GetEntry(Type);
Entry->Pos += MoveChest;
}
}
}
//---return to default pose at start and end---
FSensorData DefaultPose; FSensorData DefaultPose;
//float DefaultPoseTakingTime = 0.3f;
if (ReturnToDefaultPose) { if (ReturnToDefaultPose) {
//Take default pose from time or file //Take default pose from time or file
......
...@@ -203,6 +203,15 @@ public: ...@@ -203,6 +203,15 @@ public:
UPROPERTY(EditAnywhere, meta = (DisplayName = "Default Pose Time To Interpolate To It", Category = "MotionCapture Anim")) UPROPERTY(EditAnywhere, meta = (DisplayName = "Default Pose Time To Interpolate To It", Category = "MotionCapture Anim"))
float DefaultPoseTakingTime = 0.6f; float DefaultPoseTakingTime = 0.6f;
UPROPERTY(EditAnywhere, meta = (DisplayName = "Chest Control Center", Category = "MotionCapture Anim"))
FVector ChestControlCenter;
UPROPERTY(EditAnywhere, meta = (DisplayName = "Chest Control Factor", Category = "MotionCapture Anim"))
float ChestControlFactor = 0.0;
//UPROPERTY(EditAnywhere, meta = (DisplayName = "Chest Control Keep Length", Category = "MotionCapture Anim"))
bool ChestKeepLength = false;
UPROPERTY(EditAnywhere, meta = (DisplayName = "Hip Reducing Center", Category = "MotionCapture Anim")) UPROPERTY(EditAnywhere, meta = (DisplayName = "Hip Reducing Center", Category = "MotionCapture Anim"))
FVector HipReducingCenter; FVector HipReducingCenter;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment