AkReflectGameData.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*******************************************************************************
  2. The content of this file includes portions of the AUDIOKINETIC Wwise Technology
  3. released in source code form as part of the SDK installer package.
  4. Commercial License Usage
  5. Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
  6. may use this file in accordance with the end user license agreement provided
  7. with the software or, alternatively, in accordance with the terms contained in a
  8. written agreement between you and Audiokinetic Inc.
  9. Apache License Usage
  10. Alternatively, this file may be used under the Apache License, Version 2.0 (the
  11. "Apache License"); you may not use this file except in compliance with the
  12. Apache License. You may obtain a copy of the Apache License at
  13. http://www.apache.org/licenses/LICENSE-2.0.
  14. Unless required by applicable law or agreed to in writing, software distributed
  15. under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
  16. OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
  17. the specific language governing permissions and limitations under the License.
  18. Copyright (c) 2023 Audiokinetic Inc.
  19. *******************************************************************************/
  20. #ifndef _AK_REFLECT_GAMEDATA_H_
  21. #define _AK_REFLECT_GAMEDATA_H_
  22. #include <AK/SoundEngine/Common/AkTypes.h>
  23. #define AK_MAX_NUM_TEXTURE 4
  24. /// Data used to describe one image source in Reflect.
  25. struct AkImageSourceName
  26. {
  27. AkImageSourceName()
  28. : uNumChar(0)
  29. , pName(NULL)
  30. {
  31. }
  32. void SetName(const char * in_pName)
  33. {
  34. pName = in_pName;
  35. if (pName)
  36. {
  37. uNumChar = (AkUInt32)strlen(in_pName);
  38. }
  39. else
  40. {
  41. uNumChar = 0;
  42. }
  43. }
  44. AkUInt32 uNumChar; ///< Number of characters in image source name.
  45. const char * pName; ///< Optional image source name. Appears in Reflect's editor when profiling.
  46. };
  47. struct AkImageSourceTexture
  48. {
  49. AkImageSourceTexture()
  50. : uNumTexture(1)
  51. {
  52. arTextureID[0] = AK_INVALID_UNIQUE_ID;
  53. }
  54. AkUInt32 uNumTexture; ///< Number of valid textures in the texture array.
  55. AkUniqueID arTextureID[AK_MAX_NUM_TEXTURE]; ///< Unique IDs of the Acoustics Texture ShareSets used to filter this image source.
  56. };
  57. struct AkImageSourceParams
  58. {
  59. AkImageSourceParams()
  60. : fDistanceScalingFactor(1.f)
  61. , fLevel(1.f)
  62. , fDiffraction(0.f)
  63. , uDiffractionEmitterSide(0)
  64. , uDiffractionListenerSide(0)
  65. {
  66. sourcePosition.X = 0.f;
  67. sourcePosition.Y = 0.f;
  68. sourcePosition.Z = 0.f;
  69. }
  70. AkImageSourceParams(AkVector64 in_sourcePosition, AkReal32 in_fDistanceScalingFactor, AkReal32 in_fLevel)
  71. : sourcePosition(in_sourcePosition)
  72. , fDistanceScalingFactor(in_fDistanceScalingFactor)
  73. , fLevel(in_fLevel)
  74. , fDiffraction(0.f)
  75. , uDiffractionEmitterSide(0)
  76. , uDiffractionListenerSide(0)
  77. {
  78. }
  79. AkVector64 sourcePosition; ///< Image source position, relative to the world.
  80. AkReal32 fDistanceScalingFactor; ///< Image source distance scaling. This number effectively scales the sourcePosition vector with respect to the listener and, consequently, scales distance and preserves orientation.
  81. AkReal32 fLevel; ///< Game-controlled level for this source, linear.
  82. AkReal32 fDiffraction; ///< Diffraction amount, normalized to the range [0,1].
  83. AkUInt8 uDiffractionEmitterSide; ///< If there is a shadow zone diffraction just after the emitter in the reflection path, indicates the number of diffraction edges, otherwise 0 if no diffraction.
  84. AkUInt8 uDiffractionListenerSide; ///< If there is a shadow zone diffraction before reaching the listener in the reflection path, indicates the number of diffraction edges, otherwise 0 if no diffraction.
  85. };
  86. struct AkReflectImageSource
  87. {
  88. AkReflectImageSource()
  89. : uID((AkImageSourceID)-1)
  90. , params()
  91. , texture()
  92. , name()
  93. {}
  94. AkReflectImageSource(AkImageSourceID in_uID, AkVector64 in_sourcePosition, AkReal32 in_fDistanceScalingFactor, AkReal32 in_fLevel)
  95. : uID(in_uID)
  96. , params(in_sourcePosition, in_fDistanceScalingFactor, in_fLevel)
  97. , texture()
  98. , name()
  99. {
  100. }
  101. void SetName(const char * in_pName)
  102. {
  103. name.SetName(in_pName);
  104. }
  105. AkImageSourceID uID; ///< Image source ID (for matching delay lines across frames)
  106. AkImageSourceParams params; ///< Image source properties
  107. AkImageSourceTexture texture; ///< Image source's acoustic textures. Note that changing any of these textures across frames for a given image source, identified by uID, may result in a discontinuity in the audio signal.
  108. AkImageSourceName name; ///< Image source name, for profiling.
  109. };
  110. /// Data structure sent by the game to an instance of the Reflect plug-in.
  111. struct AkReflectGameData
  112. {
  113. AkGameObjectID listenerID; ///< ID of the listener used to compute spatialization and distance evaluation from within the targeted Reflect plug-in instance. It needs to be one of the listeners that are listening to the game object associated with the targeted plug-in instance. See AK::SoundEngine::SetListeners and AK::SoundEngine::SetGameObjectAuxSendValues.
  114. AkUInt32 uNumImageSources; ///< Number of image sources passed in the variable array, below.
  115. AkReflectImageSource arSources[1]; ///< Variable array of image sources. You should allocate storage for the structure by calling AkReflectGameData::GetSize() with the desired number of sources.
  116. /// Default constructor.
  117. AkReflectGameData()
  118. : listenerID( AK_INVALID_GAME_OBJECT )
  119. , uNumImageSources(0)
  120. {}
  121. /// Helper function for computing the size required to allocate the AkReflectGameData structure.
  122. static AkUInt32 GetSize(AkUInt32 in_uNumSources)
  123. {
  124. return (in_uNumSources > 0) ? sizeof(AkReflectGameData) + (in_uNumSources - 1) * sizeof(AkReflectImageSource) : sizeof(AkReflectGameData);
  125. }
  126. };
  127. #endif // _AK_REFLECT_GAMEDATA_H_