SoundNode.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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 : LevelEdit *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/LevelEdit/SoundNode.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 7/16/01 4:49p $*
  29. * *
  30. * $Revision:: 9 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __SOUND_NODE_H
  39. #define __SOUND_NODE_H
  40. #include "node.h"
  41. #include "vector.h"
  42. #include "icons.h"
  43. #include "decophys.h"
  44. #include "audiblesound.h"
  45. #include "AttenuationSphere.h"
  46. #include "definitionclassids.h"
  47. ////////////////////////////////////////////////////////////////////////////
  48. // Forward declarations
  49. ////////////////////////////////////////////////////////////////////////////
  50. class PresetClass;
  51. ////////////////////////////////////////////////////////////////////////////
  52. //
  53. // SoundNodeClass
  54. //
  55. ////////////////////////////////////////////////////////////////////////////
  56. class SoundNodeClass : public NodeClass
  57. {
  58. public:
  59. //////////////////////////////////////////////////////////////////
  60. // Public constructors/destructors
  61. //////////////////////////////////////////////////////////////////
  62. SoundNodeClass (PresetClass *preset = NULL);
  63. SoundNodeClass (const SoundNodeClass &src);
  64. ~SoundNodeClass (void);
  65. //////////////////////////////////////////////////////////////
  66. // Public operators
  67. //////////////////////////////////////////////////////////////
  68. const SoundNodeClass &operator= (const SoundNodeClass &src);
  69. //////////////////////////////////////////////////////////////////
  70. // Public methods
  71. //////////////////////////////////////////////////////////////////
  72. //
  73. // From PersistClass
  74. //
  75. virtual const PersistFactoryClass & Get_Factory (void) const;
  76. virtual bool Save (ChunkSaveClass &csave);
  77. virtual bool Load (ChunkLoadClass &cload);
  78. //
  79. // RTTI
  80. //
  81. SoundNodeClass *As_SoundNodeClass (void) { return this; }
  82. //
  83. // From NodeClass
  84. //
  85. void Initialize (void);
  86. NodeClass * Clone (void) { return new SoundNodeClass (*this); }
  87. NODE_TYPE Get_Type (void) const { return NODE_TYPE_SOUND; }
  88. int Get_Icon_Index (void) const { return SOUND_ICON; }
  89. PhysClass * Peek_Physics_Obj (void) const { return PhysObj; }
  90. bool Is_Static (void) const { return false; }
  91. bool Can_Be_Rotated_Freely (void) const { return true; }
  92. bool Is_Rotation_Restricted (void) const { return false; }
  93. void Add_To_Scene (void);
  94. void Remove_From_Scene (void);
  95. void Set_ID (uint32 id);
  96. bool Show_Settings_Dialog (void);
  97. bool Is_Attenuation_Sphere_Shown (void) { return (Sphere != NULL); }
  98. void Show_Attenuation_Spheres (bool onoff);
  99. float Get_Attenuation_Radius (void);
  100. void Set_Attenuation_Radius (float radius);
  101. //
  102. // Load support
  103. //
  104. void Use_Legacy_Load (bool onoff) { UseLegacyLoad = onoff; }
  105. //
  106. // Export methods
  107. //
  108. void Pre_Export (void);
  109. void Post_Export (void);
  110. //
  111. // Notifications
  112. //
  113. void On_Rotate (void);
  114. void On_Translate (void);
  115. void On_Transform (void);
  116. protected:
  117. //////////////////////////////////////////////////////////////////
  118. // Protected methods
  119. //////////////////////////////////////////////////////////////////
  120. void Release_Sound (void);
  121. void Update_Sound (void);
  122. //////////////////////////////////////////////////////////////////
  123. // Protected member data
  124. //////////////////////////////////////////////////////////////////
  125. DecorationPhysClass * PhysObj;
  126. AudibleSoundClass * SoundObj;
  127. AttenuationSphereClass * Sphere;
  128. AudibleSoundDefinitionClass InstanceSettings;
  129. bool OverridePreset;
  130. bool UseLegacyLoad;
  131. };
  132. //////////////////////////////////////////////////////////////////
  133. // On_Rotate
  134. //////////////////////////////////////////////////////////////////
  135. inline void
  136. SoundNodeClass::On_Rotate (void)
  137. {
  138. if (SoundObj != NULL) {
  139. SoundObj->Set_Transform (m_Transform);
  140. }
  141. if (Sphere != NULL) {
  142. Sphere->Set_Transform (m_Transform);
  143. }
  144. NodeClass::On_Rotate ();
  145. return ;
  146. }
  147. //////////////////////////////////////////////////////////////////
  148. // On_Translate
  149. //////////////////////////////////////////////////////////////////
  150. inline void
  151. SoundNodeClass::On_Translate (void)
  152. {
  153. if (SoundObj != NULL) {
  154. SoundObj->Set_Transform (m_Transform);
  155. }
  156. if (Sphere != NULL) {
  157. Sphere->Set_Transform (m_Transform);
  158. }
  159. NodeClass::On_Translate ();
  160. return ;
  161. }
  162. //////////////////////////////////////////////////////////////////
  163. // On_Transform
  164. //////////////////////////////////////////////////////////////////
  165. inline void
  166. SoundNodeClass::On_Transform (void)
  167. {
  168. if (SoundObj != NULL) {
  169. SoundObj->Set_Transform (m_Transform);
  170. }
  171. if (Sphere != NULL) {
  172. Sphere->Set_Transform (m_Transform);
  173. }
  174. NodeClass::On_Transform ();
  175. return ;
  176. }
  177. //////////////////////////////////////////////////////////////////
  178. // Get_Attenuation_Radius
  179. //////////////////////////////////////////////////////////////////
  180. inline float
  181. SoundNodeClass::Get_Attenuation_Radius (void)
  182. {
  183. return InstanceSettings.Get_DropOff_Radius ();
  184. }
  185. //////////////////////////////////////////////////////////////////
  186. // Set_Attenuation_Radius
  187. //////////////////////////////////////////////////////////////////
  188. inline void
  189. SoundNodeClass::Set_Attenuation_Radius (float radius)
  190. {
  191. if (radius != InstanceSettings.Get_DropOff_Radius ()) {
  192. InstanceSettings.Set_DropOff_Radius (radius);
  193. Update_Sound ();
  194. }
  195. return ;
  196. }
  197. #endif //__SOUND_NODE_H