camerashakesystem.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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. bool IsCameraShaking(void);
  65. void Update_Camera_Shaker(Vector3 camera_position, Vector3 * shaker_angles);
  66. protected:
  67. /**
  68. ** CameraShakerClass
  69. ** This class encapsulates the current state of a camera shaker. It is a multi-list object
  70. ** and is allocated in pools.
  71. */
  72. class CameraShakerClass : public MultiListObjectClass, public AutoPoolClass<CameraShakerClass,256>
  73. {
  74. public:
  75. CameraShakerClass(const Vector3 & position,float radius,float duration,float power);
  76. ~CameraShakerClass(void);
  77. void Timestep(float dt) { ElapsedTime += dt; }
  78. bool Is_Expired(void) { return (ElapsedTime >= Duration); }
  79. void Compute_Rotations(const Vector3 & pos,Vector3 * set_angles);
  80. protected:
  81. Vector3 Position;
  82. float Radius;
  83. float Duration;
  84. float Intensity;
  85. float ElapsedTime;
  86. Vector3 Omega;
  87. Vector3 Phi;
  88. };
  89. MultiListClass<CameraShakerClass> CameraShakerList;
  90. };
  91. extern CameraShakeSystemClass CameraShakerSystem; //WST 11/12/2002 This is the new Camera Shaker system upgrade
  92. #endif //CAMERASHAKESYSTEM_H