LogicalSound.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : WWAudio *
  23. * *
  24. * $Archive:: /Commando/Code/WWAudio/LogicalSound.h $Modtime:: 7/01/99 10:18a $*
  25. * *
  26. * $Revision:: 5 $*
  27. * *
  28. *---------------------------------------------------------------------------------------------*
  29. * Functions: *
  30. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  31. #if defined(_MSC_VER)
  32. #pragma once
  33. #endif
  34. #ifndef __LOGICAL_SOUND_H
  35. #define __LOGICAL_SOUND_H
  36. #include "SoundSceneObj.H"
  37. #include "BitType.H"
  38. #include "Vector3.H"
  39. #include "Matrix3D.H"
  40. /////////////////////////////////////////////////////////////////////////////////
  41. //
  42. // LogicalSoundClass
  43. //
  44. // This class represents 'logical' sounds that affect gameplay but do not
  45. // actually make an audible sound
  46. //
  47. class LogicalSoundClass : public SoundSceneObjClass
  48. {
  49. public:
  50. //////////////////////////////////////////////////////////////////////
  51. // Public friends
  52. //////////////////////////////////////////////////////////////////////
  53. friend class SoundSceneClass;
  54. //////////////////////////////////////////////////////////////////////
  55. // Public constructors/destructors
  56. //////////////////////////////////////////////////////////////////////
  57. LogicalSoundClass (void);
  58. virtual ~LogicalSoundClass (void);
  59. //////////////////////////////////////////////////////////////////////
  60. // Public methods
  61. //////////////////////////////////////////////////////////////////////
  62. //////////////////////////////////////////////////////////////////////
  63. // LogicalSoundClass specific
  64. //////////////////////////////////////////////////////////////////////
  65. virtual bool Is_Single_Shot (void) const { return m_IsSingleShot; }
  66. virtual void Set_Single_Shot (bool single_shot) { m_IsSingleShot = single_shot; }
  67. virtual void Set_Type_Mask (uint32 mask = 0) { m_TypeMask = mask; }
  68. virtual uint32 Get_Type_Mask (void) const { return m_TypeMask; }
  69. virtual float Get_Notify_Delay (void) const { return (float)m_NotifyDelayInMS / 1000.0F; }
  70. virtual void Set_Notify_Delay (float secs) { m_NotifyDelayInMS = uint32(secs * 1000.0F); }
  71. virtual bool Allow_Notify (uint32 timestamp);
  72. virtual uint32 Get_Listener_Timestamp (void) const { return m_OldestListenerTimestamp; }
  73. virtual void Set_Listener_Timestamp (int timestamp) { m_OldestListenerTimestamp = timestamp; }
  74. //////////////////////////////////////////////////////////////////////
  75. // Update methods
  76. //////////////////////////////////////////////////////////////////////
  77. virtual bool On_Frame_Update (unsigned int milliseconds = 0);
  78. //////////////////////////////////////////////////////////////////////
  79. // Position/direction methods
  80. //////////////////////////////////////////////////////////////////////
  81. virtual void Set_Position (const Vector3 &position) { m_Position = position; }
  82. virtual Vector3 Get_Position (void) const { return m_Position; }
  83. virtual void Set_Transform (const Matrix3D &transform) { m_Position = transform.Get_Translation (); }
  84. virtual Matrix3D Get_Transform (void) const { Matrix3D tm(1); tm.Set_Translation (m_Position); return tm; }
  85. //////////////////////////////////////////////////////////////////////
  86. // Culling methods
  87. //////////////////////////////////////////////////////////////////////
  88. virtual void Cull_Sound (bool culled = true) { };
  89. virtual bool Is_Sound_Culled (void) const { return false; };
  90. //////////////////////////////////////////////////////////////////////
  91. // Scene integration
  92. //////////////////////////////////////////////////////////////////////
  93. virtual void Add_To_Scene (bool start_playing = true);
  94. virtual void Remove_From_Scene (void);
  95. //////////////////////////////////////////////////////////////////////
  96. // Attenuation settings
  97. //////////////////////////////////////////////////////////////////////
  98. //
  99. // This is the distance where the sound can not be heard any longer. (its vol is 0)
  100. //
  101. virtual void Set_DropOff_Radius (float radius = 1) { m_DropOffRadius = radius; }
  102. virtual float Get_DropOff_Radius (void) const { return m_DropOffRadius; }
  103. //////////////////////////////////////////////////////////////////////
  104. // From PersistClass
  105. //////////////////////////////////////////////////////////////////////
  106. bool Save (ChunkSaveClass &csave);
  107. bool Load (ChunkLoadClass &cload);
  108. const PersistFactoryClass & Get_Factory (void) const;
  109. protected:
  110. //////////////////////////////////////////////////////////////////////
  111. // Protected methods
  112. //////////////////////////////////////////////////////////////////////
  113. private:
  114. //////////////////////////////////////////////////////////////////////
  115. // Private member data
  116. //////////////////////////////////////////////////////////////////////
  117. float m_DropOffRadius;
  118. bool m_IsSingleShot;
  119. uint32 m_TypeMask;
  120. Vector3 m_Position;
  121. uint32 m_OldestListenerTimestamp;
  122. int m_MaxListeners;
  123. uint32 m_NotifyDelayInMS;
  124. uint32 m_LastNotification;
  125. };
  126. #endif //__LOGICAL_SOUND_H