AkAcousticTextureSetComponent.h 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. #pragma once
  16. #include "AkInclude.h"
  17. #include "AkSettings.h"
  18. #include "AkAcousticTexture.h"
  19. #include "Components/SceneComponent.h"
  20. #include "AkAcousticTextureSetComponent.generated.h"
  21. struct FAkReverbDescriptor;
  22. UCLASS(ClassGroup = Audiokinetic, abstract)
  23. class AKAUDIO_API UAkAcousticTextureSetComponent : public USceneComponent
  24. {
  25. GENERATED_BODY()
  26. public:
  27. UAkAcousticTextureSetComponent(const class FObjectInitializer& ObjectInitializer);
  28. virtual void GetTexturesAndSurfaceAreas(TArray<FAkAcousticTextureParams>& textures, TArray<float>& surfaceAreas) const { check(0 && "This function must be overidden"); }
  29. void SetReverbDescriptor(FAkReverbDescriptor* reverbDescriptor);
  30. virtual void OnRegister() override;
  31. virtual void OnUnregister() override;
  32. virtual void BeginPlay() override;
  33. virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
  34. virtual AkGeometrySetID GetGeometrySetID() const { return AkGeometrySetID(this); }
  35. virtual bool GetGeometryHasBeenSent() const { return GeometryHasBeenSent; }
  36. virtual bool GetGeometryInstanceHasBeenSent() const { return GeometryInstanceHasBeenSent; }
  37. protected:
  38. void RecalculateHFDamping();
  39. #if WITH_EDITOR
  40. virtual void BeginDestroy() override;
  41. virtual void HandleObjectsReplaced(const TMap<UObject*, UObject*>& ReplacementMap);
  42. void RegisterReverbRTPCChangedCallback();
  43. FDelegateHandle RTPCChangedHandle;
  44. virtual void RegisterAllTextureParamCallbacks() { check(0 && "This function must be overidden"); }
  45. void RegisterTextureParamChangeCallback(FGuid textureID);
  46. void UnregisterTextureParamChangeCallbacks();
  47. /* Register param changed callbacks for any textures that have not been registered. Called when the AcousticPolys array is updated */
  48. TMap<FGuid, FDelegateHandle> TextureDelegateHandles;
  49. #endif
  50. FAkReverbDescriptor* ReverbDescriptor = nullptr;
  51. bool DampingEstimationNeedsUpdate = false;
  52. virtual bool ShouldSendGeometry() const;
  53. /* Add or update a geometry in Spatial Audio. It is necessary to create at least one geometry instance
  54. * for each geometry that is to be used for diffraction and reflection simulation. See SendGeometryInstanceToWwise(). */
  55. void SendGeometryToWwise(const AkGeometryParams& params);
  56. /* Add or update an instance of the geometry. A geometry instance is a unique instance of a geometry set with a specified transform (position, rotation and scale) and room association.
  57. * It is necessary to create at least one geometry instance for each geometry set that is to be used for diffraction and reflection simulation. */
  58. void SendGeometryInstanceToWwise(const FRotator& rotation, const FVector& location, const FVector& scale, const AkRoomID roomID, bool useForReflectionAndDiffraction);
  59. /* Remove a geometry and the corresponding instance from Wwise. */
  60. void RemoveGeometryFromWwise();
  61. /* Remove a geometry instance from Wwise. */
  62. void RemoveGeometryInstanceFromWwise();
  63. private:
  64. #if WITH_EDITOR
  65. virtual bool ContainsTexture(const FGuid& textureID)
  66. {
  67. check(0 && "This function must be overidden");
  68. return false;
  69. }
  70. #endif
  71. float SecondsSinceDampingUpdate = 0.0f;
  72. bool GeometryHasBeenSent = false;
  73. bool GeometryInstanceHasBeenSent = false;
  74. };