AkSpatialAudioDrawUtils.cpp 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. AkSpatialAudioDrawUtils.cpp:
  17. =============================================================================*/
  18. #include "AkSpatialAudioDrawUtils.h"
  19. #if WITH_EDITOR
  20. #include "WwiseUEFeatures.h"
  21. #include "AkAcousticPortal.h"
  22. #include "AkSpatialAudioVolume.h"
  23. #include "AkSurfaceReflectorSetComponent.h"
  24. AkDrawBounds::AkDrawBounds(const FTransform& T, const FVector& Extent) : Transform(T), BoxExtent(Extent) {}
  25. FVector AkDrawBounds::FRU() const { return Transform.TransformPosition(FVector(BoxExtent)); }
  26. FVector AkDrawBounds::BLD() const { return Transform.TransformPosition(FVector(-BoxExtent)); }
  27. FVector AkDrawBounds::FLD() const { return Transform.TransformPosition(FVector(BoxExtent.X, -BoxExtent.Y, -BoxExtent.Z)); }
  28. FVector AkDrawBounds::BRU() const { return Transform.TransformPosition(FVector(-BoxExtent.X, BoxExtent.Y, BoxExtent.Z)); }
  29. FVector AkDrawBounds::FLU() const { return Transform.TransformPosition(FVector(BoxExtent.X, -BoxExtent.Y, BoxExtent.Z)); }
  30. FVector AkDrawBounds::BLU() const { return Transform.TransformPosition(FVector(-BoxExtent.X, -BoxExtent.Y, BoxExtent.Z)); }
  31. FVector AkDrawBounds::FRD() const { return Transform.TransformPosition(FVector(BoxExtent.X, BoxExtent.Y, -BoxExtent.Z)); }
  32. FVector AkDrawBounds::BRD() const { return Transform.TransformPosition(FVector(-BoxExtent.X, BoxExtent.Y, -BoxExtent.Z)); }
  33. FVector AkDrawBounds::RU() const { return Transform.TransformPosition(FVector(0.0, BoxExtent.Y, BoxExtent.Z)); }
  34. FVector AkDrawBounds::LU() const { return Transform.TransformPosition(FVector(0.0, -BoxExtent.Y, BoxExtent.Z)); }
  35. FVector AkDrawBounds::RD() const { return Transform.TransformPosition(FVector(0.0, BoxExtent.Y, -BoxExtent.Z)); }
  36. FVector AkDrawBounds::LD() const { return Transform.TransformPosition(FVector(0.0, -BoxExtent.Y, -BoxExtent.Z)); }
  37. namespace AkSpatialAudioColors
  38. {
  39. float kAlphaValue = 0.35f;
  40. float kDraggingAlphaValue = 0.05f;
  41. void GetPortalColors(const UAkPortalComponent* Portal, FLinearColor& FrontColor, FLinearColor& BackColor)
  42. {
  43. FLinearColor ConnectedColor = FAkAppStyle::Get().GetSlateColor("SelectionColor").GetSpecifiedColor();
  44. FrontColor = ConnectedColor;
  45. BackColor = ConnectedColor;
  46. if (!Portal->PortalPlacementValid())
  47. {
  48. FLinearColor ErrorColor = FLinearColor::Red;
  49. FrontColor = ErrorColor;
  50. BackColor = ErrorColor;
  51. }
  52. else if (!Portal->GetFrontRoomComponent().IsValid())
  53. {
  54. FLinearColor DisconnectedColor = FLinearColor::Gray;
  55. FrontColor = DisconnectedColor;
  56. }
  57. else if (!Portal->GetBackRoomComponent().IsValid())
  58. {
  59. FLinearColor DisconnectedColor = FLinearColor::Gray;
  60. BackColor = DisconnectedColor;
  61. }
  62. FrontColor.A = kAlphaValue;
  63. BackColor.A = kAlphaValue;
  64. }
  65. FLinearColor GetPortalOutlineColor(const UAkPortalComponent* Portal)
  66. {
  67. FLinearColor OutlineColor = FAkAppStyle::Get().GetSlateColor("SelectionColor").GetSpecifiedColor();
  68. if (false == Portal->PortalPlacementValid())
  69. {
  70. OutlineColor = FLinearColor::Red;
  71. OutlineColor.A = 0.85f;
  72. }
  73. return OutlineColor;
  74. }
  75. FLinearColor GetRoomColor()
  76. {
  77. return FAkAppStyle::Get().GetSlateColor("SelectionColor").GetSpecifiedColor();
  78. }
  79. FLinearColor GetRadialEmitterOutlineColor()
  80. {
  81. return FAkAppStyle::Get().GetSlateColor("SelectionColor").GetSpecifiedColor();
  82. }
  83. FLinearColor GetRadialEmitterColor()
  84. {
  85. return GetRadialEmitterOutlineColor();
  86. }
  87. float GetRadialEmitterInnerOpacity() { return kAlphaValue; }
  88. float GetRadialEmitterOuterOpacity() { return kAlphaValue * 0.15f; }
  89. FLinearColor GetSurfaceReflectorColor(const UAkSurfaceReflectorSetComponent* SurfaceReflectorSet, int NodeIdx, bool IsDragging)
  90. {
  91. const FLinearColor DefaultColor(FColor(0x4280AF));
  92. FLinearColor Color = FLinearColor::Gray;
  93. FAkSurfacePoly AcousticProperties = SurfaceReflectorSet->AcousticPolys[NodeIdx];
  94. if (AcousticProperties.EnableSurface)
  95. {
  96. Color = DefaultColor;
  97. if (AcousticProperties.Texture != nullptr)
  98. {
  99. Color = AcousticProperties.Texture->EditColor;
  100. }
  101. }
  102. Color.A = IsDragging ? kDraggingAlphaValue : kAlphaValue;
  103. return Color;
  104. }
  105. FLinearColor GetSpatialAudioVolumeOutlineColor()
  106. {
  107. return FAkAppStyle::Get().GetSlateColor("SelectionColor").GetSpecifiedColor();
  108. }
  109. FLinearColor GetBadFitSpatialAudioVolumeOutlineColor()
  110. {
  111. return FLinearColor::Red;
  112. }
  113. FLinearColor GetDiffractionEdgeColor()
  114. {
  115. return FLinearColor(FColor(0x09558F));
  116. }
  117. FLinearColor GetBoundaryDiffractionEdgeColor()
  118. {
  119. return FLinearColor(FColor(0x480D97));
  120. }
  121. }
  122. #endif // WITH_EDITOR