ccamera.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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 : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/ccamera.h $*
  25. * *
  26. * $Author:: Byon_g $*
  27. * *
  28. * $Modtime:: 12/10/01 2:08p $*
  29. * *
  30. * $Revision:: 62 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef CCAMERA_H
  36. #define CCAMERA_H
  37. #ifndef ALWAYS_H
  38. #include "always.h"
  39. #endif
  40. #ifndef CAMERA_H
  41. #include "camera.h"
  42. #endif
  43. #ifndef WWSTRING_H
  44. #include "wwstring.h"
  45. #endif
  46. class CCameraProfileClass;
  47. class Listener3DClass;
  48. /*
  49. ** CCameraClass (Commando Camera Class)
  50. */
  51. class CCameraClass : public CameraClass
  52. {
  53. public:
  54. // Constructor & Destructor
  55. CCameraClass();
  56. virtual ~CCameraClass();
  57. // Get all the profiles loaded
  58. static void Init( void );
  59. static void Shutdown( void );
  60. // Save and Load
  61. virtual bool Save( ChunkSaveClass &csave );
  62. virtual bool Load( ChunkLoadClass &cload );
  63. // Function to update the camera's parameters each frame.
  64. virtual void Update();
  65. bool Is_In_Cinematic( void ) { return HostModel != NULL; }
  66. bool Is_Valid( void ) { return IsValid; }
  67. const Vector2 &Get_Camera_Target_2D_Offset() { return CameraTarget2DOffset; }
  68. void Set_Anchor_Position( Vector3 pos );
  69. void Force_Look( const Vector3 & target );
  70. // Profile access
  71. void Use_Profile( const char * name );
  72. void Use_Default_Profile( void );
  73. void Set_Profile_Height( float height );
  74. void Set_Profile_Distance( float distance );
  75. float Get_Profile_Zoom( void );
  76. void Force_Heading( float heading ) { Heading = heading; }
  77. float Get_Heading( void ) { return Heading; }
  78. void Set_Tilt( float tilt ) { Tilt = tilt; }
  79. float Get_Tilt( void ) { return Tilt; }
  80. void Set_Lerp_Time( float time );
  81. bool Is_Lerping( void ) { return LerpTimeTotal != 0; }
  82. void Set_Host_Model( RenderObjClass * host );
  83. bool Is_Using_Host_Model( void ) { return (HostModel != NULL); }
  84. void Enable_2D_Targeting( bool on_off ) { Enable2DTargeting = on_off; }
  85. bool Is_2D_Targeting( void ) { return Enable2DTargeting; }
  86. void Enable_Weapon_Help( bool on_off ) { EnableWeaponHelp = on_off; }
  87. bool Is_Weapon_Help_Enabled( void ) { return EnableWeaponHelp; }
  88. // Sniper Mode
  89. bool Draw_Sniper( void );
  90. void Cinematic_Sniper_Control( bool enabled, float zoom );
  91. void Set_Is_Star_Sniping( bool yes );
  92. bool Is_Star_Sniping( void ) { return IsStarSniping; }
  93. float Get_Sniper_Zoom( void ) { return SniperZoom; }
  94. void Set_Sniper_Distance( float dist );
  95. float Get_Sniper_Distance( void ) { return SniperDistance; }
  96. Vector3 Get_First_Person_Offset_Tweak( void );
  97. void Reset_First_Person_Offset_Tweak( void );
  98. // Snap Shot Mode
  99. void Set_Snap_Shot_Mode( bool mode ) { SnapShotMode = mode ? SNAPSHOT_ON : SNAPSHOT_OFF; }
  100. bool Is_Snap_Shot_Mode( void ) { return SnapShotMode == SNAPSHOT_ON; }
  101. protected:
  102. // Camera Host Model
  103. RenderObjClass * HostModel;
  104. // Camera Anchor Position
  105. Vector3 AnchorPosition;
  106. bool IsValid;
  107. // Current orientation of the camera
  108. float Tilt;
  109. float Heading;
  110. float DistanceFraction;
  111. bool Enable2DTargeting;
  112. float LagPersistTimer;
  113. bool DisableLag;
  114. // WeaponHelp
  115. bool EnableWeaponHelp;
  116. float WeaponHelpTimer;
  117. int WeaponHelpTargetID; // Should probably be changed to a ObjRef
  118. Vector3 StarTargetingPosition;
  119. Vector2 CameraTarget2DOffset;
  120. // Linear Interpolation
  121. float LerpTimeTotal;
  122. float LerpTimeRemaining;
  123. Vector3 LastAnchorPosition;
  124. float LastHeading;
  125. // Parameter profile
  126. CCameraProfileClass * CurrentProfile;
  127. CCameraProfileClass * LastProfile;
  128. CCameraProfileClass * DefaultProfile;
  129. StringClass CurrentProfileName;
  130. StringClass LastProfileName;
  131. StringClass DefaultProfileName;
  132. float NearClipPlane;
  133. float FarClipPlane;
  134. // Sniper Mode
  135. bool IsStarSniping;
  136. bool WasStarSniping;
  137. float SniperZoom;
  138. float SniperDistance;
  139. Listener3DClass * SniperListener;
  140. bool CinematicSnipingEnabled;
  141. float CinematicSnipingDesiredZoom;
  142. enum {
  143. SNAPSHOT_OFF,
  144. SNAPSHOT_ON,
  145. SNAPSHOT_PROGRESS,
  146. };
  147. int SnapShotMode;
  148. /*
  149. **
  150. */
  151. Vector3 Get_Camera_Pos( const Vector3 & offset,
  152. float distance, Vector3 * intermediate_pos );
  153. void Use_Host_Model( void );
  154. void Handle_Input();
  155. // Targeting
  156. bool Determine_Targeting_Position( void );
  157. void Apply_Weapon_Help( void );
  158. void Update_Sniper_Listener_Pos( void );
  159. void Handle_Snap_Shot_Mode( void );
  160. };
  161. #endif // CCAMERA_H