diff --git a/Source/CharacterPlugin/Private/VHFacialExpressions.cpp b/Source/CharacterPlugin/Private/VHFacialExpressions.cpp index 0a62ad8ef52caf95cc25b310fafc109188ac2473..8eb9c5de48aca19b24910f79bbeb57e736721b88 100644 --- a/Source/CharacterPlugin/Private/VHFacialExpressions.cpp +++ b/Source/CharacterPlugin/Private/VHFacialExpressions.cpp @@ -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; } diff --git a/Source/CharacterPlugin/Private/VHOVRBridge.cpp b/Source/CharacterPlugin/Private/VHOVRBridge.cpp index 161629878f55cdb5b715868ad55416c616158af3..c1491122a2f2929eabd6178358d22c3ce7df25ea 100644 --- a/Source/CharacterPlugin/Private/VHOVRBridge.cpp +++ b/Source/CharacterPlugin/Private/VHOVRBridge.cpp @@ -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; diff --git a/Source/CharacterPlugin/Private/VHSaccades.cpp b/Source/CharacterPlugin/Private/VHSaccades.cpp index db647a331c6bb496d8b23bf1d3bc4dfcd066813c..897dacf9125daef57364f28e158e583dcba686a3 100644 --- a/Source/CharacterPlugin/Private/VHSaccades.cpp +++ b/Source/CharacterPlugin/Private/VHSaccades.cpp @@ -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) diff --git a/Source/CharacterPlugin/Public/VHFacialExpressions.h b/Source/CharacterPlugin/Public/VHFacialExpressions.h index a9e6cd5726bebe14f73168a3d6b26429ea4d2f02..20147e27f06f662ca0e76ecbef0c58f5561a1c03 100644 --- a/Source/CharacterPlugin/Public/VHFacialExpressions.h +++ b/Source/CharacterPlugin/Public/VHFacialExpressions.h @@ -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; }; diff --git a/Source/CharacterPlugin/Public/VHSaccades.h b/Source/CharacterPlugin/Public/VHSaccades.h index 5113c360188e2c3731d667ab458f12d82cd7ec9b..7763065a74d7105c2811572d82d3df0d0b9eccdb 100644 --- a/Source/CharacterPlugin/Public/VHSaccades.h +++ b/Source/CharacterPlugin/Public/VHSaccades.h @@ -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;