AkSpotReflector.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*******************************************************************************
  2. The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
  3. Technology released in source code form as part of the game integration package.
  4. The content of this file may not be used without valid licenses to the
  5. AUDIOKINETIC Wwise Technology.
  6. Note that the use of the game engine is subject to the Unreal(R) Engine End User
  7. License Agreement at https://www.unrealengine.com/en-US/eula/unreal
  8. License Usage
  9. Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
  10. this file in accordance with the end user license agreement provided with the
  11. software or, alternatively, in accordance with the terms contained
  12. in a written agreement between you and Audiokinetic Inc.
  13. Copyright (c) 2023 Audiokinetic Inc.
  14. *******************************************************************************/
  15. /*=============================================================================
  16. AkSpotReflector.h:
  17. =============================================================================*/
  18. #pragma once
  19. #include "AkAudioDevice.h"
  20. #include "AkAcousticTexture.h"
  21. #include "GameFramework/Actor.h"
  22. #include "AkSpotReflector.generated.h"
  23. UCLASS(config = Engine)
  24. class AKAUDIO_API AAkSpotReflector : public AActor
  25. {
  26. GENERATED_BODY()
  27. public:
  28. AAkSpotReflector(const FObjectInitializer& ObjectInitializer);
  29. /**
  30. * Send to an Auxiliary Bus containing the Wwise Reflect plugin for early reflections rendering.
  31. * Leave unassigned to use the Early Reflections Auxiliary Bus that is assigned in the Wwise Authoring Tool.
  32. * Setting a value here will apply only to sounds playing on AK Components with EnableSpotReflectors to true.
  33. */
  34. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AkSpotReflector)
  35. class UAkAuxBus * EarlyReflectionAuxBus = nullptr;
  36. /**
  37. * Send to an Auxiliary Bus containing the Wwise Reflect plugin for early reflections rendering.
  38. * Leave unassigned to use the Early Reflections Auxiliary Bus that is assigned in the Wwise Authoring Tool.
  39. * Setting a value here will apply only to sounds playing on AK Components with EnableSpotReflectors to true.
  40. */
  41. UPROPERTY(EditAnywhere, BlueprintReadWrite, AdvancedDisplay, Category = AkSpotReflector)
  42. FString EarlyReflectionAuxBusName;
  43. /**
  44. * The Acoustic Texture represents sound absorption. It is done by filtering the sound bouncing off the spot reflector.
  45. * If left to None, no filtering will be applied to the sound.
  46. */
  47. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AkSpotReflector)
  48. UAkAcousticTexture* AcousticTexture = nullptr;
  49. /**
  50. * This number scales the distance between the listener and the actual image source, preserving orientation.
  51. * Set to 1 to position the image source at the position of the spot reflector
  52. */
  53. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AkSpotReflector, meta = (ClampMin = "0.0"))
  54. float DistanceScalingFactor = .0f;
  55. /** Game-controlled level for the sound that will emit from the image source. Valid range: (0.0, 4.0)*/
  56. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AkSpotReflector, meta = (ClampMin = "0.0", ClampMax = "4.0"))
  57. float Level = .0f;
  58. /** Make this spot reflector only reflect emitted sounds in the same Spatial Audio Room.*/
  59. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AkSpotReflector)
  60. bool SameRoomOnly = false;
  61. /** Override the room this spot reflector is contained in. If disabled, a containment check will be done to find the room.*/
  62. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AkSpotReflector, meta = (EditCondition = "SameRoomOnly"))
  63. bool EnableRoomOverride = false;
  64. /** The room in which the spot reflector will be virtually placed in. If set to None, the default "Outdoors" room will be used.*/
  65. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AkSpotReflector, meta = (EditCondition = "EnableRoomOverride"))
  66. class AActor* RoomOverride = nullptr;
  67. AkImageSourceID GetImageSourceID() const;
  68. AkAuxBusID GetAuxBusID() const;
  69. virtual void PostInitializeComponents() override;
  70. virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
  71. /**
  72. * Update all spot reflectors in the world for a single ak component.
  73. * All spot reflectors are cleared first, then they are set
  74. * If the spot reflector is set as SameRoomOnly, it will be set only if it is in the same room as the ak component.
  75. */
  76. static void UpdateSpotReflectors(UAkComponent* AkComponent);
  77. const FString GetSpotReflectorName() const;
  78. private:
  79. void SetImageSource(UAkComponent* AkComponent);
  80. void AddToWorld();
  81. void RemoveFromWorld();
  82. #if WITH_EDITORONLY_DATA
  83. /** Editor only component used to display the sprite so as to be able to see the location of the Spot Reflector */
  84. class UBillboardComponent* SpriteComponent;
  85. #endif
  86. typedef TSet<AAkSpotReflector*> SpotReflectorSet;
  87. typedef TMap<UWorld*, SpotReflectorSet> WorldToSpotReflectorsMap;
  88. static WorldToSpotReflectorsMap sWorldToSpotReflectors;
  89. };