Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MoCapPlugin
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LuFG VR VIS
VR-Group
Unreal-Development
Plugins
MoCapPlugin
Commits
7413bf66
Commit
7413bf66
authored
2 years ago
by
Patrick Nossol
Browse files
Options
Downloads
Patches
Plain Diff
Added scaling of anim and holding hands by set points
parent
10f96efe
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Source/MoCapPlugin/Private/MCController.cpp
+136
-71
136 additions, 71 deletions
Source/MoCapPlugin/Private/MCController.cpp
Source/MoCapPlugin/Public/MCController.h
+9
-2
9 additions, 2 deletions
Source/MoCapPlugin/Public/MCController.h
with
145 additions
and
73 deletions
Source/MoCapPlugin/Private/MCController.cpp
+
136
−
71
View file @
7413bf66
...
@@ -42,7 +42,7 @@ void AMCController::BeginPlay() {
...
@@ -42,7 +42,7 @@ void AMCController::BeginPlay() {
InputComponent
->
BindAction
(
"SetMarker"
,
EInputEvent
::
IE_Pressed
,
this
,
&
AMCController
::
SetMarker
);
InputComponent
->
BindAction
(
"SetMarker"
,
EInputEvent
::
IE_Pressed
,
this
,
&
AMCController
::
SetMarker
);
InputComponent
->
BindAction
(
"StartRecording"
,
EInputEvent
::
IE_Pressed
,
this
,
&
AMCController
::
ToggleRecording
);
InputComponent
->
BindAction
(
"StartRecording"
,
EInputEvent
::
IE_Pressed
,
this
,
&
AMCController
::
ToggleRecording
);
InputComponent
->
BindAction
(
"NextSentence"
,
EInputEvent
::
IE_Pressed
,
this
,
&
AMCController
::
SetMarker
);
InputComponent
->
BindAction
(
"NextSentence"
,
EInputEvent
::
IE_Pressed
,
this
,
&
AMCController
::
SetMarker
);
InputComponent
->
BindAction
(
"SaveAnimation"
,
EInputEvent
::
IE_Pressed
,
this
,
&
AMCController
::
SaveAnimation
);
InputComponent
->
BindAction
(
"SaveAnimation"
,
EInputEvent
::
IE_Pressed
,
this
,
&
AMCController
::
SaveAnimation
Editor
);
}
}
if
(
!
Pawn
||
!
Pawn
->
GetActorLocation
().
Equals
(
FVector
(
0
,
0
,
0
))
||
!
Pawn
->
GetActorRotation
().
Equals
(
FRotator
(
0
,
0
,
0
)))
{
if
(
!
Pawn
||
!
Pawn
->
GetActorLocation
().
Equals
(
FVector
(
0
,
0
,
0
))
||
!
Pawn
->
GetActorRotation
().
Equals
(
FRotator
(
0
,
0
,
0
)))
{
...
@@ -209,9 +209,7 @@ void AMCController::ScaleAnimDataInterval(int start, int end, float DeltaTime) {
...
@@ -209,9 +209,7 @@ void AMCController::ScaleAnimDataInterval(int start, int end, float DeltaTime) {
FProcessedAnimData
Data
;
FProcessedAnimData
Data
;
Data
.
Timestamp
=
StartTime
+
FTimespan
::
FromSeconds
((
float
)
i
*
NewTime
/
(
float
)
NewNrFrames
);
Data
.
Timestamp
=
StartTime
+
FTimespan
::
FromSeconds
((
float
)
i
*
NewTime
/
(
float
)
NewNrFrames
);
//SmoothStop
//SmoothStop
//float TransformedI = 1.f - FMath::Pow(1.f - ((float)i / (float)NewNrFrames), 4);
float
TransformedI
=
1.f
-
FMath
::
Pow
(
1.f
-
((
float
)
i
/
(
float
)
NewNrFrames
),
GestureHoldExcessEasingExponent
);
//SmoothStart
float
TransformedI
=
FMath
::
Pow
(((
float
)
i
/
(
float
)
NewNrFrames
),
4
);
FTimespan
OldTimestamp
=
StartTime
+
FTimespan
::
FromSeconds
(
TransformedI
*
OldTime
);
FTimespan
OldTimestamp
=
StartTime
+
FTimespan
::
FromSeconds
(
TransformedI
*
OldTime
);
bool
stop
=
false
;
bool
stop
=
false
;
...
@@ -287,7 +285,7 @@ void AMCController::ScaleAnimDataInterval(int start, int end, float DeltaTime) {
...
@@ -287,7 +285,7 @@ void AMCController::ScaleAnimDataInterval(int start, int end, float DeltaTime) {
}
}
bool
AMCController
::
PreprocessRecording
()
{
bool
AMCController
::
PreprocessRecording
(
const
TArray
<
float
>&
HaltingPoints
)
{
UMCAnimInstance
*
AI
=
AnimSaveState
.
Pawn
->
GetAnimInstance
();
UMCAnimInstance
*
AI
=
AnimSaveState
.
Pawn
->
GetAnimInstance
();
...
@@ -528,7 +526,9 @@ bool AMCController::PreprocessRecording() {
...
@@ -528,7 +526,9 @@ bool AMCController::PreprocessRecording() {
//---find last slow part of the gesture and scale it up---
//---find last slow part of the gesture and scale it up---
TArray
<
float
>
GestureSpeed
;
TArray
<
float
>
GestureSpeed
;
bool
newMethod
=
true
;
if
(
!
newMethod
)
{
if
(
GestureHoldExcessTime
>
0.f
)
{
if
(
GestureHoldExcessTime
>
0.f
)
{
for
(
int
i
=
1
;
i
<
AnimSaveState
.
AnimData
.
Num
();
i
++
)
{
for
(
int
i
=
1
;
i
<
AnimSaveState
.
AnimData
.
Num
();
i
++
)
{
...
@@ -622,6 +622,64 @@ bool AMCController::PreprocessRecording() {
...
@@ -622,6 +622,64 @@ bool AMCController::PreprocessRecording() {
ScaleAnimDataInterval
(
ScaleStart
,
AnimSaveState
.
AnimData
.
Num
()
-
2
,
GestureHoldExcessTime
);
ScaleAnimDataInterval
(
ScaleStart
,
AnimSaveState
.
AnimData
.
Num
()
-
2
,
GestureHoldExcessTime
);
}
}
}
else
{
if
(
HaltingPoints
.
Num
()
>
0
)
{
FTimespan
Start
;
bool
StartTimeInitialized
=
false
;
bool
hold
=
false
;
int
holdStartingIndex
=
-
1
;
for
(
int
i
=
1
;
i
<
AnimSaveState
.
AnimData
.
Num
();
i
++
)
{
FProcessedAnimData
&
AnimData
=
AnimSaveState
.
AnimData
[
i
];
if
(
AnimData
.
IsMarker
||
AnimData
.
IsEnd
)
{
continue
;
}
if
(
!
StartTimeInitialized
)
{
StartTimeInitialized
=
true
;
Start
=
AnimData
.
Timestamp
;
}
//process sensor data
FSensorData
&
SensorData
=
AnimData
.
SensorData
;
for
(
int
j
=
0
;
j
<
EBodyPart
::
LAST
;
j
++
)
{
EBodyPart
Type
=
EBodyPart
(
j
);
FSensorDataEntry
*
Entry
=
SensorData
.
GetEntry
(
Type
);
if
(
Type
==
EBodyPart
::
HandL
||
Type
==
EBodyPart
::
HandR
||
Type
==
EBodyPart
::
LowerArmL
||
Type
==
EBodyPart
::
LowerArmR
)
{
if
(
DoHolding
&&
hold
)
{
if
(
Type
==
EBodyPart
::
HandL
||
Type
==
EBodyPart
::
HandR
)
{
Entry
->
Pos
=
AnimSaveState
.
AnimData
[
i
-
1
].
SensorData
.
GetEntry
(
Type
)
->
Pos
;
}
Entry
->
Rot
=
AnimSaveState
.
AnimData
[
i
-
1
].
SensorData
.
GetEntry
(
Type
)
->
Rot
;
}
}
}
//or time unit?
if
(
!
hold
&&
HaltingPoints
[
0
]
<=
(
AnimData
.
Timestamp
-
Start
).
GetTotalSeconds
())
{
hold
=
true
;
holdStartingIndex
=
i
;
}
}
if
(
hold
&&
GestureHoldExcessTime
>
0.f
)
{
ScaleAnimDataInterval
(
holdStartingIndex
,
AnimSaveState
.
AnimData
.
Num
()
-
2
,
GestureHoldExcessTime
);
}
}
}
//---adjust feet position so that they are located at the green foot indicators---
//---adjust feet position so that they are located at the green foot indicators---
...
@@ -1169,7 +1227,11 @@ void AMCController::SetMarker() {
...
@@ -1169,7 +1227,11 @@ void AMCController::SetMarker() {
}
}
}
}
void
AMCController
::
SaveAnimation
()
{
void
AMCController
::
SaveAnimationEditor
()
{
SaveAnimation
({},
false
);
}
void
AMCController
::
SaveAnimation
(
const
TArray
<
float
>&
HaltingPoints
,
bool
skipTranslation
)
{
if
(
IsSavingToAnim
)
{
if
(
IsSavingToAnim
)
{
return
;
return
;
...
@@ -1239,14 +1301,17 @@ void AMCController::SaveAnimation() {
...
@@ -1239,14 +1301,17 @@ void AMCController::SaveAnimation() {
AnimSaveState
.
FPS
=
FramesPerSecond
;
AnimSaveState
.
FPS
=
FramesPerSecond
;
AnimSaveState
.
SPF
=
1.f
/
((
float
)
AnimSaveState
.
FPS
);
AnimSaveState
.
SPF
=
1.f
/
((
float
)
AnimSaveState
.
FPS
);
IsSavingToAnim
=
true
;
IsSavingToAnim
=
!
skipTranslation
;
if
(
skipTranslation
)
{
return
;
}
if
(
!
EditOffsetMode
)
{
if
(
!
EditOffsetMode
)
{
AnimSaveState
.
WaitForAnimInstance
=
true
;
AnimSaveState
.
WaitForAnimInstance
=
true
;
}
}
AnimSaveState
.
Pawn
->
GetAnimInstance
()
->
AdditionalOffsets
=
AdditionalOffsets
;
AnimSaveState
.
Pawn
->
GetAnimInstance
()
->
AdditionalOffsets
=
AdditionalOffsets
;
bool
isValid
=
PreprocessRecording
();
bool
isValid
=
PreprocessRecording
(
HaltingPoints
);
if
(
!
isValid
)
{
if
(
!
isValid
)
{
IsSavingToAnim
=
false
;
IsSavingToAnim
=
false
;
return
;
return
;
...
...
This diff is collapsed.
Click to expand it.
Source/MoCapPlugin/Public/MCController.h
+
9
−
2
View file @
7413bf66
...
@@ -79,7 +79,7 @@ public:
...
@@ -79,7 +79,7 @@ public:
void
SetMarker
();
void
SetMarker
();
UFUNCTION
(
BlueprintCallable
)
UFUNCTION
(
BlueprintCallable
)
void
SaveAnimation
();
void
SaveAnimation
Editor
();
UFUNCTION
(
BlueprintCallable
)
UFUNCTION
(
BlueprintCallable
)
void
NextEditFrame
();
void
NextEditFrame
();
...
@@ -96,9 +96,10 @@ protected:
...
@@ -96,9 +96,10 @@ protected:
void
SaveToAnimMode
();
void
SaveToAnimMode
();
void
ScaleAnimDataInterval
(
int
start
,
int
end
,
float
DeltaTime
);
void
ScaleAnimDataInterval
(
int
start
,
int
end
,
float
DeltaTime
);
bool
PreprocessRecording
();
bool
PreprocessRecording
(
const
TArray
<
float
>&
HaltingPoints
);
void
InputNextFrame
();
void
InputNextFrame
();
void
SaveAnimation
(
const
TArray
<
float
>&
HaltingPoints
,
bool
skipTranslation
=
false
);
void
SaveAnimSnapshots
();
void
SaveAnimSnapshots
();
UAnimSequence
*
SaveAsAnimSequence
(
const
FSnapshotAnimations
&
Recording
,
const
FString
&
AnimName
,
const
FString
&
FolderName
);
UAnimSequence
*
SaveAsAnimSequence
(
const
FSnapshotAnimations
&
Recording
,
const
FString
&
AnimName
,
const
FString
&
FolderName
);
void
SetBonesAnimationInAnimSeq
(
const
FSnapshotAnimations
&
Recording
,
UAnimSequence
*
AnimSequence
);
void
SetBonesAnimationInAnimSeq
(
const
FSnapshotAnimations
&
Recording
,
UAnimSequence
*
AnimSequence
);
...
@@ -162,9 +163,15 @@ public:
...
@@ -162,9 +163,15 @@ public:
UPROPERTY
(
EditAnywhere
,
meta
=
(
DisplayName
=
"Frames per Second"
,
Category
=
"MotionCapture Anim"
))
UPROPERTY
(
EditAnywhere
,
meta
=
(
DisplayName
=
"Frames per Second"
,
Category
=
"MotionCapture Anim"
))
int
FramesPerSecond
=
60
;
int
FramesPerSecond
=
60
;
UPROPERTY
(
EditAnywhere
,
meta
=
(
DisplayName
=
"Gesture Do Holding"
,
Category
=
"MotionCapture Anim"
))
bool
DoHolding
=
false
;
UPROPERTY
(
EditAnywhere
,
meta
=
(
DisplayName
=
"Gesture Hold Scale Excess Time"
,
Category
=
"MotionCapture Anim"
))
UPROPERTY
(
EditAnywhere
,
meta
=
(
DisplayName
=
"Gesture Hold Scale Excess Time"
,
Category
=
"MotionCapture Anim"
))
float
GestureHoldExcessTime
=
0.f
;
float
GestureHoldExcessTime
=
0.f
;
UPROPERTY
(
EditAnywhere
,
meta
=
(
DisplayName
=
"Gesture Hold Excess Easing Exponent"
,
Category
=
"MotionCapture Anim"
))
float
GestureHoldExcessEasingExponent
=
2.f
;
UPROPERTY
(
EditAnywhere
,
meta
=
(
DisplayName
=
"Nr of Leg Smoothing Iterations"
,
Category
=
"MotionCapture Anim"
))
UPROPERTY
(
EditAnywhere
,
meta
=
(
DisplayName
=
"Nr of Leg Smoothing Iterations"
,
Category
=
"MotionCapture Anim"
))
int
LegSmoothTimes
=
5
;
int
LegSmoothTimes
=
5
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment