camerashakesystem.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 : WWPhys *
  23. * *
  24. * $Archive:: /Commando/Code/wwphys/camerashakesystem.h $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 7/13/00 4:06p $*
  31. * *
  32. * $Revision:: 1 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #ifndef CAMERASHAKESYSTEM_H
  38. #define CAMERASHAKESYSTEM_H
  39. #include "always.h"
  40. #include "vector3.h"
  41. #include "multilist.h"
  42. #include "mempool.h"
  43. class CameraClass;
  44. /**
  45. ** CameraShakeSystemClass
  46. ** This class encapsulates all of the logic and data needed to implement camera "shakes"
  47. ** These are used to simulate explosions, earthquakes, etc.
  48. */
  49. class CameraShakeSystemClass
  50. {
  51. public:
  52. CameraShakeSystemClass(void);
  53. ~CameraShakeSystemClass(void);
  54. enum
  55. {
  56. FLAGS_NONE = 0,
  57. FLAGS_IGNOREPOSITION,
  58. };
  59. void Add_Camera_Shake( const Vector3 & position,
  60. float radius = 50.0f,
  61. float duration = 1.5f,
  62. float power = 1.0f );
  63. void Timestep(float dt);
  64. void Update_Camera(CameraClass & camera);
  65. protected:
  66. /**
  67. ** CameraShakerClass
  68. ** This class encapsulates the current state of a camera shaker. It is a multi-list object
  69. ** and is allocated in pools.
  70. */
  71. class CameraShakerClass : public MultiListObjectClass, public AutoPoolClass<CameraShakerClass,256>
  72. {
  73. public:
  74. CameraShakerClass(const Vector3 & position,float radius,float duration,float power);
  75. ~CameraShakerClass(void);
  76. void Timestep(float dt) { ElapsedTime += dt; }
  77. bool Is_Expired(void) { return (ElapsedTime >= Duration); }
  78. void Compute_Rotations(const Vector3 & pos,Vector3 * set_angles);
  79. protected:
  80. Vector3 Position;
  81. float Radius;
  82. float Duration;
  83. float Intensity;
  84. float ElapsedTime;
  85. Vector3 Omega;
  86. Vector3 Phi;
  87. };
  88. MultiListClass<CameraShakerClass> CameraShakerList;
  89. };
  90. #endif //CAMERASHAKESYSTEM_H