From 5bfb0cebebaf58d39187b5e415880cc3e6b82d0a Mon Sep 17 00:00:00 2001 From: Jonathan Ehret <jonathan.ehret@rwth-aachen.de> Date: Thu, 6 Jul 2023 09:55:20 +0200 Subject: [PATCH] Debug output cave tracking --- .../Private/SoundSource/VASoundSource.cpp | 5 ++-- Source/VAPlugin/Private/VAReceiverActor.cpp | 25 +++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Source/VAPlugin/Private/SoundSource/VASoundSource.cpp b/Source/VAPlugin/Private/SoundSource/VASoundSource.cpp index 4398f16..f18c619 100644 --- a/Source/VAPlugin/Private/SoundSource/VASoundSource.cpp +++ b/Source/VAPlugin/Private/SoundSource/VASoundSource.cpp @@ -8,6 +8,7 @@ #include "SoundSource/VASoundSourceRepresentation.h" #include "Engine/World.h" +#include "Utility/VirtualRealityUtilities.h" // ****************************************************************** // @@ -73,7 +74,7 @@ void FVASoundSource::SetPosition(const FVector NewPosition) { Position = NewPosition; - if (!FVAPlugin::SetSoundSourcePosition(SoundSourceID, Position)) + if (!FVAPlugin::SetSoundSourcePosition(SoundSourceID, Position) && UVirtualRealityUtilities::IsMaster()) { FVAUtils::LogStuff("[FVASoundSource::SetPosition()]:" + FString(" Could not set sound source position in VA. Position of visual and auditive representation might mismatch now."), true); @@ -86,7 +87,7 @@ void FVASoundSource::SetRotation(const FRotator NewRotation) { Rotation = NewRotation; - if (!FVAPlugin::SetSoundSourceRotation(SoundSourceID, Rotation)) + if (!FVAPlugin::SetSoundSourceRotation(SoundSourceID, Rotation) && UVirtualRealityUtilities::IsMaster()) { FVAUtils::LogStuff("[FVASoundSource::SetRotation()]:" + FString(" Could not set sound source rotation in VA. Orientation of visual and auditive representation might mismatch now."), true); diff --git a/Source/VAPlugin/Private/VAReceiverActor.cpp b/Source/VAPlugin/Private/VAReceiverActor.cpp index 467a79f..3505eda 100644 --- a/Source/VAPlugin/Private/VAReceiverActor.cpp +++ b/Source/VAPlugin/Private/VAReceiverActor.cpp @@ -257,13 +257,28 @@ bool AVAReceiverActor::UpdateVirtualWorldPose() if(TrackingSource == ETrackingSource::VirtualRealityPawn) { - // Auralization Pose is coppled to the Virtual Reality Pawn, e.g, HMD, CAVE - FVector ViewPos; - FRotator ViewRot; - GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(ViewPos, ViewRot); + // Auralization Pose is coupled to the Virtual Reality Pawn, e.g, HMD, CAVE + + AVirtualRealityPawn* VirtualRealityPawn = Cast<AVirtualRealityPawn>(GetWorld()->GetFirstPlayerController()->AcknowledgedPawn); + if (VirtualRealityPawn == nullptr) + { + return false; + } + + USceneComponent* Head = VirtualRealityPawn->Head; + + if (!Head) + { + return false; + } + + FVector ViewPos = Head->GetComponentLocation(); + FRotator ViewRot = Head->GetComponentRotation(); + //Offset from ViewPoint (between eyes) to head center, rotate according to view rotation + ViewPos += ViewRot.RotateVector(ViewpointToHeadcenterOffset); bool bResult = true; - bResult &= FVAPlugin::SetSoundReceiverPosition(ReceiverID, ViewPos + ViewRot.RotateVector(ViewpointToHeadcenterOffset)); //Offset from ViewPoint (between eyes) to head center, rotate according to view rotation + bResult &= FVAPlugin::SetSoundReceiverPosition(ReceiverID, ViewPos); bResult &= FVAPlugin::SetSoundReceiverRotation(ReceiverID, ViewRot); return bResult; } -- GitLab