Skip to content
Snippets Groups Projects
Commit ccc9404e authored by Jonathan Ehret's avatar Jonathan Ehret
Browse files

Merge branch 'feature/sound_source_explicit_renderer' into '4.26'

VA Sound Source: Added setting to create renderer explicit sources

See merge request !7
parents b3ccceaf a87463a8
No related branches found
No related tags found
1 merge request!7VA Sound Source: Added setting to create renderer explicit sources
...@@ -29,7 +29,7 @@ FVAImageSourceModel::FVAImageSourceModel(UWorld* World, TSharedRef<FVASoundSourc ...@@ -29,7 +29,7 @@ FVAImageSourceModel::FVAImageSourceModel(UWorld* World, TSharedRef<FVASoundSourc
const float R = Wall->GetReflectionValueR(); const float R = Wall->GetReflectionValueR();
const float PowerR = ParentSource->GetPower() * R * R; 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, ...@@ -179,8 +179,9 @@ FRotator FVAImageSourceModel::ComputeReflectedRot(const AVAReflectionWall* Wall,
// ******* Image Source Class *************************************** // // ******* 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 */) FVAImageSourceModel::FVAImageSource::FVAImageSource(AVAReflectionWall* Wall, UWorld* World, const FVector& Position, const FRotator& Rotation, float Power,
: FVASoundSource(World, Position, Rotation, Power, Name, Directivity) const std::string& Name, const std::string& RendererID /* = "" */, TSharedPtr<FVADirectivity> Directivity /* = nullptr */)
: FVASoundSource(World, Position, Rotation, Power, Name, RendererID, Directivity)
, Wall(Wall) , Wall(Wall)
{ {
if (Wall == nullptr) if (Wall == nullptr)
......
...@@ -56,7 +56,7 @@ private: ...@@ -56,7 +56,7 @@ private:
class FVAImageSource : public FVASoundSource class FVAImageSource : public FVASoundSource
{ {
public: 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(); AVAReflectionWall* GetWall();
private: private:
AVAReflectionWall* Wall; AVAReflectionWall* Wall;
......
...@@ -150,8 +150,10 @@ void UVAAbstractSourceComponent::Initialize() ...@@ -150,8 +150,10 @@ void UVAAbstractSourceComponent::Initialize()
SpawnPosition = GetOwner()->GetTransform().GetLocation(); SpawnPosition = GetOwner()->GetTransform().GetLocation();
SpawnRotation = GetOwner()->GetTransform().GetRotation().Rotator(); 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()) ); 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()) if (UVirtualRealityUtilities::IsMaster())
{ {
......
...@@ -14,9 +14,11 @@ ...@@ -14,9 +14,11 @@
// ******* Initialization ******************************************* // // ******* 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) : SoundSourceID(VA_INVALID_ID)
, Name(Name) , Name(Name)
, RendererID(RendererID)
, Position(Position) , Position(Position)
, Rotation(Rotation) , Rotation(Rotation)
, bShowCones(false) , bShowCones(false)
...@@ -26,7 +28,7 @@ FVASoundSource::FVASoundSource(UWorld* World, const FVector& Position, const FRo ...@@ -26,7 +28,7 @@ FVASoundSource::FVASoundSource(UWorld* World, const FVector& Position, const FRo
{ {
bShowCones = FVAPlugin::GetDebugMode(); bShowCones = FVAPlugin::GetDebugMode();
SoundSourceID = FVAPlugin::CreateNewSoundSource(Name, Position, Rotation, Power); SoundSourceID = FVAPlugin::CreateNewSoundSource(Name, Position, Rotation, Power, RendererID);
if (SoundSourceID == VA_INVALID_ID) if (SoundSourceID == VA_INVALID_ID)
{ {
FVAUtils::LogStuff("[FVASoundSource::FVASoundSource()]: Error initializing VA sound source", true); FVAUtils::LogStuff("[FVASoundSource::FVASoundSource()]: Error initializing VA sound source", true);
...@@ -182,6 +184,11 @@ const std::string& FVASoundSource::GetSoundSourceName() const ...@@ -182,6 +184,11 @@ const std::string& FVASoundSource::GetSoundSourceName() const
return Name; return Name;
} }
const std::string& FVASoundSource::GetExplicitRendererID() const
{
return RendererID;
}
FVector FVASoundSource::GetPosition() const FVector FVASoundSource::GetPosition() const
{ {
return Position; return Position;
......
...@@ -17,7 +17,7 @@ class FVASoundSource ...@@ -17,7 +17,7 @@ class FVASoundSource
public: public:
// Initialization // 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(); virtual ~FVASoundSource();
// Setter // Setter
...@@ -39,6 +39,7 @@ public: ...@@ -39,6 +39,7 @@ public:
// Getter // Getter
int GetSoundSourceID() const; int GetSoundSourceID() const;
const std::string& GetSoundSourceName() const; const std::string& GetSoundSourceName() const;
const std::string& GetExplicitRendererID() const;
FVector GetPosition() const; FVector GetPosition() const;
FRotator GetRotation() const; FRotator GetRotation() const;
...@@ -54,6 +55,7 @@ private: ...@@ -54,6 +55,7 @@ private:
int SoundSourceID; int SoundSourceID;
std::string Name; std::string Name;
std::string RendererID;
FVector Position; FVector Position;
FRotator Rotation; FRotator Rotation;
......
...@@ -635,7 +635,7 @@ bool FVAPlugin::SetJetEngineRMP(const std::string& SignalSourceID, float fRPM) ...@@ -635,7 +635,7 @@ bool FVAPlugin::SetJetEngineRMP(const std::string& SignalSourceID, float fRPM)
// ******* Sound Sources ******************************************** // // ******* 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()) if (!ShouldInteractWithServer())
{ {
...@@ -660,7 +660,11 @@ int FVAPlugin::CreateNewSoundSource(const std::string& Name, FVector Pos, FRotat ...@@ -660,7 +660,11 @@ int FVAPlugin::CreateNewSoundSource(const std::string& Name, FVector Pos, FRotat
try 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); VAServer->SetSoundSourcePose(SoundSourceID, *TmpVAVec3, *TmpVAQuat);
......
...@@ -86,7 +86,7 @@ public: ...@@ -86,7 +86,7 @@ public:
// ******* Sound Sources ******* // // ******* Sound Sources ******* //
static int CreateNewSoundSource(const std::string& Name, FVector Pos = FVector(0, 0, 0), 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! // Deletes a sound source with given ID. Use with great care!
static bool DeleteSoundSource(int SoundSourceID); static bool DeleteSoundSource(int SoundSourceID);
static bool SetSoundSourcePosition(int SoundSourceID, FVector Pos); static bool SetSoundSourcePosition(int SoundSourceID, FVector Pos);
......
...@@ -35,6 +35,14 @@ protected: ...@@ -35,6 +35,14 @@ protected:
ClampMin = "0.0", ClampMax = "100.0", UIMin = "0.0", UIMax = "100.0")) ClampMin = "0.0", ClampMax = "100.0", UIMin = "0.0", UIMax = "100.0"))
float SoundPower = 0.0316227749f; 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 // Decide whether to use manual Transform (below) or use Transform / Movement of Actor
UPROPERTY(EditAnywhere, meta = (DisplayName = "Position Settings", Category = "Position", UPROPERTY(EditAnywhere, meta = (DisplayName = "Position Settings", Category = "Position",
CustomStructureParam = "Move With the Object, At Object Spawn Point (unmovable, also reflections), Attatch to a Bone")) CustomStructureParam = "Move With the Object, At Object Spawn Point (unmovable, also reflections), Attatch to a Bone"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment