StaticSoundCullObj.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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/StaticSoundCullObj.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 5/24/99 5:08p $*
  29. * *
  30. * $Revision:: 2 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __STATICSOUNDCULLOBJ_H
  39. #define __STATICSOUNDCULLOBJ_H
  40. #if 0
  41. #include "SoundObj.H"
  42. //#include "SoundCullObj.H"
  43. /////////////////////////////////////////////////////////////////////////////
  44. //
  45. // StaticSoundCullObjClass
  46. //
  47. // Simple 'sound physics' object that wraps a SoundClass object and is derived
  48. // from TileClass so it can be used with the static culling system.
  49. //
  50. class StaticSoundCullObjClass : public TileClass
  51. {
  52. public:
  53. //////////////////////////////////////////////////////////////////////
  54. // Public constructors/destructors
  55. //////////////////////////////////////////////////////////////////////
  56. StaticSoundCullObjClass (void)
  57. : m_SoundObj (NULL),
  58. m_Transform (1) {}
  59. virtual ~StaticSoundCullObjClass (void) { REF_PTR_RELEASE (m_SoundObj); }
  60. //////////////////////////////////////////////////////////////////////
  61. // Get the 'bounds' of this sound
  62. //////////////////////////////////////////////////////////////////////
  63. virtual const AABoxClass & Get_Bounding_Box (void) const;
  64. //////////////////////////////////////////////////////////////////////
  65. // Ray casting methods
  66. //////////////////////////////////////////////////////////////////////
  67. virtual bool Cast_Ray(PhysRayCollisionTestClass & raytest) { return false; }
  68. virtual bool Cast_AABox(PhysAABoxCollisionTestClass & boxtest) { return false; }
  69. virtual bool Cast_OBBox(PhysOBBoxCollisionTestClass & boxtest) { return false; }
  70. //////////////////////////////////////////////////////////////////////
  71. // Access to the Position/Orientation state of the object
  72. //////////////////////////////////////////////////////////////////////
  73. virtual const Matrix3D & Get_Transform (void) const;
  74. virtual void Set_Transform (const Matrix3D &transform);
  75. //////////////////////////////////////////////////////////////////////
  76. // Timestep methods
  77. //////////////////////////////////////////////////////////////////////
  78. virtual void Timestep (float dt) {}
  79. //////////////////////////////////////////////////////////////////////
  80. // Sound object wrapping
  81. //////////////////////////////////////////////////////////////////////
  82. virtual void Set_Sound_Obj (Sound3DClass *sound_obj);
  83. virtual Sound3DClass * Get_Sound_Obj (void) const;
  84. virtual Sound3DClass * Peek_Sound_Obj (void) const { return m_SoundObj; }
  85. protected:
  86. //////////////////////////////////////////////////////////////////////
  87. // Protected methods
  88. //////////////////////////////////////////////////////////////////////
  89. private:
  90. //////////////////////////////////////////////////////////////////////
  91. // Private member data
  92. //////////////////////////////////////////////////////////////////////
  93. Sound3DClass * m_SoundObj;
  94. mutable Matrix3D m_Transform;
  95. mutable AABoxClass m_AABox;
  96. };
  97. __inline const Matrix3D &
  98. StaticSoundCullObjClass::Get_Transform (void) const
  99. {
  100. // Determine the transform to use
  101. if (m_SoundObj != NULL) {
  102. m_Transform = m_SoundObj->Get_Transform ();
  103. }
  104. // Return a reference to the matrix
  105. return m_Transform;
  106. }
  107. __inline void
  108. StaticSoundCullObjClass::Set_Transform (const Matrix3D &transform)
  109. {
  110. m_Transform = transform;
  111. // Pass the tranform on
  112. if (m_SoundObj != NULL) {
  113. m_SoundObj->Set_Transform (m_Transform);
  114. }
  115. return ;
  116. }
  117. __inline Sound3DClass *
  118. StaticSoundCullObjClass::Get_Sound_Obj (void) const
  119. {
  120. if (m_SoundObj != NULL) {
  121. m_SoundObj->Add_Ref ();
  122. }
  123. // Return a pointer to the sound object
  124. return m_SoundObj;
  125. }
  126. __inline void
  127. StaticSoundCullObjClass::Set_Sound_Obj (Sound3DClass *sound_obj)
  128. {
  129. // Start using this sound object
  130. REF_PTR_SET (m_SoundObj, sound_obj);
  131. if (m_SoundObj != NULL) {
  132. m_Transform = m_SoundObj->Get_Transform ();
  133. }
  134. return ;
  135. }
  136. __inline const AABoxClass &
  137. StaticSoundCullObjClass::Get_Bounding_Box (void) const
  138. {
  139. // Get the 'real' values from the
  140. if (m_SoundObj != NULL) {
  141. m_Transform = m_SoundObj->Get_Transform ();
  142. m_AABox.Extent.X = m_SoundObj->Get_DropOff_Radius ();
  143. m_AABox.Extent.Y = m_SoundObj->Get_DropOff_Radius ();
  144. m_AABox.Extent.Z = m_SoundObj->Get_DropOff_Radius ();
  145. } else {
  146. m_AABox.Extent.X = 0;
  147. m_AABox.Extent.Y = 0;
  148. m_AABox.Extent.Z = 0;
  149. }
  150. m_AABox.Center = m_Transform.Get_Translation ();
  151. return m_AABox;
  152. }
  153. #endif //0
  154. #endif //__STATICSOUNDCULLOBJ_H