diff --git a/Source/VAPlugin/Private/ImageSourceModel/VAImageSourceModel.cpp b/Source/VAPlugin/Private/ImageSourceModel/VAImageSourceModel.cpp index 2d5802dd53372bc9df9989b5053b363cda988a3d..975124424209060a0df5dbc5e761bc3c1065673f 100644 --- a/Source/VAPlugin/Private/ImageSourceModel/VAImageSourceModel.cpp +++ b/Source/VAPlugin/Private/ImageSourceModel/VAImageSourceModel.cpp @@ -29,7 +29,7 @@ FVAImageSourceModel::FVAImageSourceModel(UWorld* World, TSharedRef<FVASoundSourc const float R = Wall->GetReflectionValueR(); const float PowerR = ParentSource->GetPower() * R * R; - ImageSources.Add( MakeShared<FVAImageSource>(Wall, World, ParentSource->GetPosition(), ParentSource->GetRotation(), PowerR, ISName, ParentSource->GetDirectivity()) ); + ImageSources.Add( MakeShared<FVAImageSource>(Wall, World, ParentSource->GetPosition(), ParentSource->GetRotation(), PowerR, ISName, ParentSource->GetExplicitRendererID(), ParentSource->GetDirectivity()) ); } } @@ -179,8 +179,9 @@ FRotator FVAImageSourceModel::ComputeReflectedRot(const AVAReflectionWall* Wall, // ******* Image Source Class *************************************** // // ****************************************************************** // -FVAImageSourceModel::FVAImageSource::FVAImageSource(AVAReflectionWall* Wall, UWorld* World, const FVector& Position, const FRotator& Rotation, float Power, const std::string& Name, TSharedPtr<FVADirectivity> Directivity /* = nullptr */) - : FVASoundSource(World, Position, Rotation, Power, Name, Directivity) +FVAImageSourceModel::FVAImageSource::FVAImageSource(AVAReflectionWall* Wall, UWorld* World, const FVector& Position, const FRotator& Rotation, float Power, + const std::string& Name, const std::string& RendererID /* = "" */, TSharedPtr<FVADirectivity> Directivity /* = nullptr */) + : FVASoundSource(World, Position, Rotation, Power, Name, RendererID, Directivity) , Wall(Wall) { if (Wall == nullptr) diff --git a/Source/VAPlugin/Private/ImageSourceModel/VAImageSourceModel.h b/Source/VAPlugin/Private/ImageSourceModel/VAImageSourceModel.h index ac62ea18bb4cdf3257e4c6919a9fd41bce4a1457..c8c7c9b9ff605643168b77ac2a8e43fe1b856adc 100644 --- a/Source/VAPlugin/Private/ImageSourceModel/VAImageSourceModel.h +++ b/Source/VAPlugin/Private/ImageSourceModel/VAImageSourceModel.h @@ -56,7 +56,7 @@ private: class FVAImageSource : public FVASoundSource { public: - FVAImageSource(AVAReflectionWall* Wall, UWorld* World, const FVector& PosN, const FRotator& RotN, float PowerN, const std::string& NameN, TSharedPtr<FVADirectivity> Directivity = nullptr); + FVAImageSource(AVAReflectionWall* Wall, UWorld* World, const FVector& PosN, const FRotator& RotN, float PowerN, const std::string& NameN, const std::string& RendererID = "", TSharedPtr<FVADirectivity> Directivity = nullptr); AVAReflectionWall* GetWall(); private: AVAReflectionWall* Wall; diff --git a/Source/VAPlugin/Private/SoundSource/VAAbstractSourceComponent.cpp b/Source/VAPlugin/Private/SoundSource/VAAbstractSourceComponent.cpp index 0639a3eea626ab02f3b87b49a422c33a19057ae4..a85a86d318f62be9593143c2736223decfd9b4b5 100644 --- a/Source/VAPlugin/Private/SoundSource/VAAbstractSourceComponent.cpp +++ b/Source/VAPlugin/Private/SoundSource/VAAbstractSourceComponent.cpp @@ -150,8 +150,10 @@ void UVAAbstractSourceComponent::Initialize() SpawnPosition = GetOwner()->GetTransform().GetLocation(); SpawnRotation = GetOwner()->GetTransform().GetRotation().Rotator(); + + const std::string ExplicitRendererID = bRendererExplicit ? std::string( TCHAR_TO_UTF8(*RendererID) ): ""; // Empty ID => general source const std::string SoundSourceName = std::string( TCHAR_TO_UTF8(*GetName()) ); - SoundSource = MakeShared<FVASoundSource>(GetWorld(), GetPosition(), GetRotation(), SoundPower, SoundSourceName); + SoundSource = MakeShared<FVASoundSource>(GetWorld(), GetPosition(), GetRotation(), SoundPower, SoundSourceName, ExplicitRendererID); if (UVirtualRealityUtilities::IsMaster()) { diff --git a/Source/VAPlugin/Private/SoundSource/VASoundSource.cpp b/Source/VAPlugin/Private/SoundSource/VASoundSource.cpp index 28f797981774fa15bdea38a68082a1f143788dbd..4398f169da874689f1d920935296e7359c4bde1a 100644 --- a/Source/VAPlugin/Private/SoundSource/VASoundSource.cpp +++ b/Source/VAPlugin/Private/SoundSource/VASoundSource.cpp @@ -14,9 +14,11 @@ // ******* Initialization ******************************************* // // ****************************************************************** // -FVASoundSource::FVASoundSource(UWorld* World, const FVector& Position, const FRotator& Rotation, float Power, const std::string& Name /* = "" */, TSharedPtr<FVADirectivity> Directivity /* = nullptr */) +FVASoundSource::FVASoundSource(UWorld* World, const FVector& Position, const FRotator& Rotation, float Power, const std::string& Name, + const std::string& RendererID /* = "" */, TSharedPtr<FVADirectivity> Directivity /* = nullptr */) : SoundSourceID(VA_INVALID_ID) , Name(Name) + , RendererID(RendererID) , Position(Position) , Rotation(Rotation) , bShowCones(false) @@ -26,7 +28,7 @@ FVASoundSource::FVASoundSource(UWorld* World, const FVector& Position, const FRo { bShowCones = FVAPlugin::GetDebugMode(); - SoundSourceID = FVAPlugin::CreateNewSoundSource(Name, Position, Rotation, Power); + SoundSourceID = FVAPlugin::CreateNewSoundSource(Name, Position, Rotation, Power, RendererID); if (SoundSourceID == VA_INVALID_ID) { FVAUtils::LogStuff("[FVASoundSource::FVASoundSource()]: Error initializing VA sound source", true); @@ -182,6 +184,11 @@ const std::string& FVASoundSource::GetSoundSourceName() const return Name; } +const std::string& FVASoundSource::GetExplicitRendererID() const +{ + return RendererID; +} + FVector FVASoundSource::GetPosition() const { return Position; diff --git a/Source/VAPlugin/Private/SoundSource/VASoundSource.h b/Source/VAPlugin/Private/SoundSource/VASoundSource.h index a007878660487f55932d72df86b7d5ac138c0c1c..a5f7210b901ae47bc32f9ec372e01bc9f8150888 100644 --- a/Source/VAPlugin/Private/SoundSource/VASoundSource.h +++ b/Source/VAPlugin/Private/SoundSource/VASoundSource.h @@ -17,7 +17,7 @@ class FVASoundSource public: // Initialization - FVASoundSource(UWorld* World, const FVector& PosN, const FRotator& RotN, float PowerN, const std::string& NameN = "", TSharedPtr<FVADirectivity> DirectivityID = nullptr); + FVASoundSource(UWorld* World, const FVector& PosN, const FRotator& RotN, float PowerN, const std::string& NameN, const std::string& RendererID = "", TSharedPtr<FVADirectivity> DirectivityID = nullptr); virtual ~FVASoundSource(); // Setter @@ -39,6 +39,7 @@ public: // Getter int GetSoundSourceID() const; const std::string& GetSoundSourceName() const; + const std::string& GetExplicitRendererID() const; FVector GetPosition() const; FRotator GetRotation() const; @@ -54,6 +55,7 @@ private: int SoundSourceID; std::string Name; + std::string RendererID; FVector Position; FRotator Rotation; diff --git a/Source/VAPlugin/Private/VAPlugin.cpp b/Source/VAPlugin/Private/VAPlugin.cpp index d0f3ba5302931dee1b9e530f5312b86ddd82856c..87eeda9c65b1cfa9c59396ea1fcd459990c90bc9 100644 --- a/Source/VAPlugin/Private/VAPlugin.cpp +++ b/Source/VAPlugin/Private/VAPlugin.cpp @@ -635,7 +635,7 @@ bool FVAPlugin::SetJetEngineRMP(const std::string& SignalSourceID, float fRPM) // ******* Sound Sources ******************************************** // // ****************************************************************** // -int FVAPlugin::CreateNewSoundSource(const std::string& Name, FVector Pos, FRotator Rot, const float Power, const std::string& SignalSourceID) +int FVAPlugin::CreateNewSoundSource(const std::string& Name, FVector Pos, FRotator Rot, const float Power, const std::string& RendererID, const std::string& SignalSourceID) { if (!ShouldInteractWithServer()) { @@ -660,7 +660,11 @@ int FVAPlugin::CreateNewSoundSource(const std::string& Name, FVector Pos, FRotat try { - const int SoundSourceID = VAServer->CreateSoundSource(Name); + int SoundSourceID; + if ( RendererID.empty() ) + SoundSourceID = VAServer->CreateSoundSource(Name); + else + SoundSourceID = VAServer->CreateSoundSourceExplicitRenderer(RendererID, Name); VAServer->SetSoundSourcePose(SoundSourceID, *TmpVAVec3, *TmpVAQuat); diff --git a/Source/VAPlugin/Private/VAPlugin.h b/Source/VAPlugin/Private/VAPlugin.h index 48cb7eacda4d83ff14e6a8f66bcd25d9cbe9559d..9fa2bcf31aeff46e6841c4f23cdbecf26fd9adf4 100644 --- a/Source/VAPlugin/Private/VAPlugin.h +++ b/Source/VAPlugin/Private/VAPlugin.h @@ -86,7 +86,7 @@ public: // ******* Sound Sources ******* // static int CreateNewSoundSource(const std::string& Name, FVector Pos = FVector(0, 0, 0), - FRotator Rot = FRotator(0, 0, 0), float Power = -1.0f, const std::string& SignalSourceID = ""); + FRotator Rot = FRotator(0, 0, 0), float Power = -1.0f, const std::string& RendererID = "", const std::string & SignalSourceID = ""); // Deletes a sound source with given ID. Use with great care! static bool DeleteSoundSource(int SoundSourceID); static bool SetSoundSourcePosition(int SoundSourceID, FVector Pos); diff --git a/Source/VAPlugin/Public/SoundSource/VAAbstractSourceComponent.h b/Source/VAPlugin/Public/SoundSource/VAAbstractSourceComponent.h index 0a9176ffab3d4b9d6b5508a57e528b6bdf1048f3..fdc43f488dd05293d47550c73553acaa907aa0c0 100644 --- a/Source/VAPlugin/Public/SoundSource/VAAbstractSourceComponent.h +++ b/Source/VAPlugin/Public/SoundSource/VAAbstractSourceComponent.h @@ -35,6 +35,14 @@ protected: ClampMin = "0.0", ClampMax = "100.0", UIMin = "0.0", UIMax = "100.0")) float SoundPower = 0.0316227749f; + // Enable to make this sound source only available to a specific VA renderer + UPROPERTY(EditAnywhere, meta = (DisplayName = "Renderer explicit", Category = "General Settings") ) + bool bRendererExplicit; + + // VA Renderer ID for using specific renderer. An empty string refers to a general source. + UPROPERTY(EditAnywhere, meta = (DisplayName = "Renderer ID", Category = "General Settings", EditCondition = "bRendererExplicit") ) + FString RendererID = ""; + // Decide whether to use manual Transform (below) or use Transform / Movement of Actor UPROPERTY(EditAnywhere, meta = (DisplayName = "Position Settings", Category = "Position", CustomStructureParam = "Move With the Object, At Object Spawn Point (unmovable, also reflections), Attatch to a Bone"))