Skip to content
Snippets Groups Projects
Commit 9e168acb authored by Denys Kuznietsov's avatar Denys Kuznietsov
Browse files

OVRBridge now supports MetaHuman Models

parent b338f5c4
No related branches found
No related tags found
No related merge requests found
......@@ -269,7 +269,7 @@ bool UVHFacialExpressions::UpdateFACS(Emotions Emotion, float DeltaTime)
return isInterpolationFinished;
}
const TMap<FName, float>& UVHFacialExpressions::GetCurrentAnimationValues() const
TMap<FName, float>& UVHFacialExpressions::GetCurrentAnimationValues()
{
return CurrentAnimationValues;
}
......
......@@ -41,6 +41,8 @@ void UVHOVRBridge::SetPredictions(TArray<float> PredictedVisemeWeights)
TArray<FSmartName> BlendshapeNames = Mapping->GetCurveNames();
TArray<TArray<float>> BlendshapeValues;
TArray<float> TargetBlendshapeValues;
if(owner->GetComponentByClass(UVHFacialExpressions::StaticClass())!=nullptr)
UVHFacialExpressions *FacialExpressions = Cast<UVHFacialExpressions>(owner->GetComponentByClass(UVHFacialExpressions::StaticClass()));
for(FSmartName PoseName : Mapping->GetPoseNames())
{
BlendshapeValues.Add(Mapping->GetCurveValues(Mapping->GetPoseIndexByName(PoseName.DisplayName)));
......@@ -67,7 +69,11 @@ void UVHOVRBridge::SetPredictions(TArray<float> PredictedVisemeWeights)
for (int i = 0; i < BlendshapeNames.Num(); ++i) {
// SetMorphTarget
if(owner->GetBodyType()==BodyType::CC3) AnimInstance->SetMorphTarget(BlendshapeNames[i].DisplayName, TargetBlendshapeValues[i]);
else if(owner->GetBodyType()==BodyType::MetaHuman) AnimInstance->SetMorphTarget(BlendshapeNames[i].DisplayName, TargetBlendshapeValues[i]);
else if(owner->GetBodyType()==BodyType::MetaHuman && owner->GetComponentByClass(USkeletalMeshComponent::StaticClass())!=nullptr)
{
UVHFacialExpressions *FacialExpressions = Cast<UVHFacialExpressions>(owner->GetComponentByClass(UVHFacialExpressions::StaticClass()));
FacialExpressions->GetCurrentAnimationValues().Emplace(BlendshapeNames[i].DisplayName, TargetBlendshapeValues[i]);
}
}
// OUT: accumulate all values from all weighted poses and apply them on mesh;
......
......@@ -77,21 +77,21 @@ void UVHSaccades::TickComponent(float DeltaTime, ELevelTick TickType, FActorComp
// UE_LOG(LogTemp, Display, TEXT("[Blinking]: Start blinking"));
// UE_LOG(LogTemp, Display, TEXT("[Blinking]: Current blendshape value %f"), cur_value);
// UE_LOG(LogTemp, Display, TEXT("[Blinking]: BlinkAnimationTimerValue %i"), BlinkAnimationTimer);
if(cur_value<=1.0 && !bEyesClosed)
if(BlinkValue<=1.0 && !bEyesClosed)
{
UE_LOG(LogTemp, Display, TEXT("[Blinking]: closing"));
cur_value = FMath::FInterpConstantTo(cur_value, 1.0, DeltaTime, 8);
BlinkValue = FMath::FInterpConstantTo(BlinkValue, 1.0, DeltaTime, 8);
// if(owner->GetBodyType()==BodyType::CC3) AnimInstance->SetMorphTarget(FName("Eye_Blink"), cur_value);
// else AnimInstance->EyeBlink = cur_value;
if(cur_value==1.0) bEyesClosed = true;
if(BlinkValue==1.0) bEyesClosed = true;
}
else
{
UE_LOG(LogTemp, Display, TEXT("[Blinking]: opening"));
cur_value = FMath::FInterpConstantTo(cur_value, 0.0, DeltaTime, 8);
BlinkValue = FMath::FInterpConstantTo(BlinkValue, 0.0, DeltaTime, 8);
// if(owner->GetBodyType()==BodyType::CC3) AnimInstance->SetMorphTarget(FName("Eye_Blink"), cur_value);
// else AnimInstance->EyeBlink = cur_value;
if(cur_value==0)
if(BlinkValue==0)
{
UE_LOG(LogTemp, Display, TEXT("[Blinking]: done"));
std::normal_distribution<float> gBlink(intervalBlink, intervalBlinkStD);
......@@ -104,8 +104,13 @@ void UVHSaccades::TickComponent(float DeltaTime, ELevelTick TickType, FActorComp
}
}
if(owner->GetBodyType()==BodyType::CC3) AnimInstance->SetMorphTarget(FName("Eye_Blink"), cur_value);
else AnimInstance->EyeBlink = cur_value;
if(owner->GetBodyType()==BodyType::CC3)
{
AnimInstance->SetMorphTarget(FName("Eye_Blink"), BlinkValue);
// change brow values accordingly
// AnimInstance->SetMorphTarget(FName("Eye_Blink"), BrowValue);
}
else AnimInstance->EyeBlink = BlinkValue;
}
if(timeInState%15==0)
......
......@@ -93,7 +93,7 @@ public:
// Used to "call" an update of already selected pose on demand
UPROPERTY(BlueprintReadWrite,EditAnywhere)
bool isPoseDirty = false;
const TMap<FName, float>& GetCurrentAnimationValues() const;
TMap<FName, float>& GetCurrentAnimationValues();
protected:
virtual void BeginPlay() override;
......@@ -113,5 +113,7 @@ private:
TMap<Emotions, TArray<FACSValue>> FACSExpressionsLibrary;
TMap<int, FAUPose> AUPoses;
TMap<FName, float> CurrentAnimationValues;
private:
TSet<FString> EvaluatedNames;
};
......@@ -45,7 +45,8 @@ private:
const float intervalBlink = 3.4; //in ms
const float intervalBlinkStD = 0.8; //in ms
float nextBlink = 0; //ms
float cur_value = 0;
float BlinkValue = 0;
float BrowValue = 0;
bool bEyesClosed = false;
FRotator EyeOrientation;
AVirtualHuman* owner = nullptr;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment