diff --git a/Source/CharacterPlugin/Private/VHListenerBackchannels.cpp b/Source/CharacterPlugin/Private/VHListenerBackchannels.cpp index c76af24fe101c885cc7164f26f7c1bf315dd9261..8c9ed6d49356d0db73aa7bd7fc66219b964fea02 100644 --- a/Source/CharacterPlugin/Private/VHListenerBackchannels.cpp +++ b/Source/CharacterPlugin/Private/VHListenerBackchannels.cpp @@ -417,8 +417,58 @@ FRotator UVHListenerBackchannels::MyFindLookAtRotaion(FVector Start, FVector Tar void UVHListenerBackchannels::GazeController(FRotator HeadRotation) { + float TimePassed = GetWorld()->GetRealTimeSeconds(); FVector point = GetPlayerLookAtTarget(10000); + if (chameleon) + { + if (in_VH_FieldofView(point, HeadRotation)) + { + EyeMimickQueue.push(point); + } + else + { + EyeMimickQueue.push(FVector(0.0, 0.0, 0.0)); + } + if (TimePassed > mimick_delay) + { + if (EyeMimickQueue.front() == FVector(0.0, 0.0, 0.0)) + { + EyeMimickQueue.pop(); + SetEyeLookAtTarget(Player_vr_pawn->Head->GetComponentLocation(), HeadRotation, true); + SetEyeLookAtTarget(Player_vr_pawn->Head->GetComponentLocation(), HeadRotation, false); + } + else + { + point = EyeMimickQueue.front(); + EyeMimickQueue.pop(); + SetEyeLookAtTarget(point, HeadRotation, true); + SetEyeLookAtTarget(point, HeadRotation, false); + } + } + else + { + SetEyeLookAtTarget(Player_vr_pawn->Head->GetComponentLocation(), HeadRotation, true); + SetEyeLookAtTarget(Player_vr_pawn->Head->GetComponentLocation(), HeadRotation, false); + } + } + else + { + if (in_VH_FieldofView(point, HeadRotation)) + { + SetEyeLookAtTarget(GetPlayerLookAtTarget(10000), HeadRotation, true); + SetEyeLookAtTarget(GetPlayerLookAtTarget(10000), HeadRotation, false); + } + else + { + SetEyeLookAtTarget(Player_vr_pawn->Head->GetComponentLocation(), HeadRotation, true); + SetEyeLookAtTarget(Player_vr_pawn->Head->GetComponentLocation(), HeadRotation, false); + } + } + + +/* + if (in_VH_FieldofView(point,HeadRotation )) { SetEyeLookAtTarget(GetPlayerLookAtTarget(10000), HeadRotation, true); @@ -429,6 +479,7 @@ void UVHListenerBackchannels::GazeController(FRotator HeadRotation) SetEyeLookAtTarget(Player_vr_pawn->Head->GetComponentLocation(), HeadRotation, true); SetEyeLookAtTarget(Player_vr_pawn->Head->GetComponentLocation(), HeadRotation, false); } + */ } @@ -436,6 +487,7 @@ bool UVHListenerBackchannels::in_VH_FieldofView(FVector Point, FRotator HeadRota { FRotator LookAtTargetRot = LookAtTarget(Point); FRotator difference = LookAtTargetRot - HeadRotation; + //if ((abs(difference.Yaw) > 107.0) || (abs(difference.Roll) > 70.0)) if ((abs(difference.Yaw) > 107.0) || (abs(difference.Roll) > 70.0)) { return false; diff --git a/Source/CharacterPlugin/Public/VHListenerBackchannels.h b/Source/CharacterPlugin/Public/VHListenerBackchannels.h index 7a51067e020ba7a558468028cc70c1dfd306f9a6..ac39c7b5362d6de5134a17eb537c77793f9a0fce 100644 --- a/Source/CharacterPlugin/Public/VHListenerBackchannels.h +++ b/Source/CharacterPlugin/Public/VHListenerBackchannels.h @@ -60,8 +60,11 @@ private: float BlinkValue = 0.0; float mimick_delay = 4.0; //in s std::queue<FRotator>MimickQueue; + std::queue<FVector>EyeMimickQueue; std::array<FRotator, 50> a1 = { FRotator(0.0, 0.0, 0.0)}; int counter = 0; + std::array<FVector, 50> a2 = { FVector(0.0, 0.0, 0.0) }; + //int counter2 = 0; FRotator NodRotator = FRotator(0.0f, 0.0f, 0.0f);