PlayerView.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code 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. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __GAME_PLAYERVIEW_H__
  21. #define __GAME_PLAYERVIEW_H__
  22. /*
  23. ===============================================================================
  24. Player view.
  25. ===============================================================================
  26. */
  27. // screenBlob_t are for the on-screen damage claw marks, etc
  28. typedef struct {
  29. const idMaterial * material;
  30. float x, y, w, h;
  31. float s1, t1, s2, t2;
  32. int finishTime;
  33. int startFadeTime;
  34. float driftAmount;
  35. } screenBlob_t;
  36. #define MAX_SCREEN_BLOBS 8
  37. #ifdef _D3XP
  38. class WarpPolygon_t {
  39. public:
  40. idVec4 outer1;
  41. idVec4 outer2;
  42. idVec4 center;
  43. };
  44. class Warp_t {
  45. public:
  46. int id;
  47. bool active;
  48. int startTime;
  49. float initialRadius;
  50. idVec3 worldOrigin;
  51. idVec2 screenOrigin;
  52. int durationMsec;
  53. idList<WarpPolygon_t> polys;
  54. };
  55. #endif
  56. #ifdef _D3XP
  57. class idPlayerView;
  58. class FullscreenFXManager;
  59. /*
  60. ==================
  61. FxFader
  62. ==================
  63. */
  64. class FxFader {
  65. enum {
  66. FX_STATE_OFF,
  67. FX_STATE_RAMPUP,
  68. FX_STATE_RAMPDOWN,
  69. FX_STATE_ON
  70. };
  71. int time;
  72. int state;
  73. float alpha;
  74. int msec;
  75. public:
  76. FxFader();
  77. // primary functions
  78. bool SetTriggerState( bool active );
  79. virtual void Save( idSaveGame *savefile );
  80. virtual void Restore( idRestoreGame *savefile );
  81. // fader functions
  82. void SetFadeTime( int t ) { msec = t; };
  83. int GetFadeTime() { return msec; };
  84. // misc functions
  85. float GetAlpha() { return alpha; };
  86. };
  87. /*
  88. ==================
  89. FullscreenFX
  90. ==================
  91. */
  92. class FullscreenFX {
  93. protected:
  94. idStr name;
  95. FxFader fader;
  96. FullscreenFXManager *fxman;
  97. public:
  98. FullscreenFX() { fxman = NULL; };
  99. virtual ~FullscreenFX() { };
  100. virtual void Initialize() = 0;
  101. virtual bool Active() = 0;
  102. virtual void HighQuality() = 0;
  103. virtual void LowQuality() { };
  104. virtual void AccumPass( const renderView_t *view ) { };
  105. virtual bool HasAccum() { return false; };
  106. void SetName( idStr n ) { name = n; };
  107. idStr GetName() { return name; };
  108. void SetFXManager( FullscreenFXManager *fx ) { fxman = fx; };
  109. bool SetTriggerState( bool state ) { return fader.SetTriggerState( state ); };
  110. void SetFadeSpeed( int msec ) { fader.SetFadeTime( msec ); };
  111. float GetFadeAlpha() { return fader.GetAlpha(); };
  112. virtual void Save( idSaveGame *savefile );
  113. virtual void Restore( idRestoreGame *savefile );
  114. };
  115. /*
  116. ==================
  117. FullscreenFX_Helltime
  118. ==================
  119. */
  120. class FullscreenFX_Helltime : public FullscreenFX {
  121. const idMaterial* acInitMaterials[3];
  122. const idMaterial* acCaptureMaterials[3];
  123. const idMaterial* acDrawMaterials[3];
  124. const idMaterial* crCaptureMaterials[3];
  125. const idMaterial* crDrawMaterials[3];
  126. bool clearAccumBuffer;
  127. int DetermineLevel();
  128. public:
  129. virtual void Initialize();
  130. virtual bool Active();
  131. virtual void HighQuality();
  132. virtual void AccumPass( const renderView_t *view );
  133. virtual bool HasAccum() { return true; };
  134. virtual void Restore( idRestoreGame *savefile );
  135. };
  136. /*
  137. ==================
  138. FullscreenFX_Multiplayer
  139. ==================
  140. */
  141. class FullscreenFX_Multiplayer : public FullscreenFX {
  142. const idMaterial* acInitMaterials;
  143. const idMaterial* acCaptureMaterials;
  144. const idMaterial* acDrawMaterials;
  145. const idMaterial* crCaptureMaterials;
  146. const idMaterial* crDrawMaterials;
  147. bool clearAccumBuffer;
  148. int DetermineLevel();
  149. public:
  150. virtual void Initialize();
  151. virtual bool Active();
  152. virtual void HighQuality();
  153. virtual void AccumPass( const renderView_t *view );
  154. virtual bool HasAccum() { return true; };
  155. virtual void Restore( idRestoreGame *savefile );
  156. };
  157. /*
  158. ==================
  159. FullscreenFX_Warp
  160. ==================
  161. */
  162. class FullscreenFX_Warp : public FullscreenFX {
  163. const idMaterial* material;
  164. bool grabberEnabled;
  165. int startWarpTime;
  166. void DrawWarp( WarpPolygon_t wp, float interp );
  167. public:
  168. virtual void Initialize();
  169. virtual bool Active();
  170. virtual void HighQuality();
  171. void EnableGrabber( bool active ) { grabberEnabled = active; startWarpTime = gameLocal.slow.time; };
  172. virtual void Save( idSaveGame *savefile );
  173. virtual void Restore( idRestoreGame *savefile );
  174. };
  175. /*
  176. ==================
  177. FullscreenFX_EnviroSuit
  178. ==================
  179. */
  180. class FullscreenFX_EnviroSuit : public FullscreenFX {
  181. const idMaterial* material;
  182. public:
  183. virtual void Initialize();
  184. virtual bool Active();
  185. virtual void HighQuality();
  186. };
  187. /*
  188. ==================
  189. FullscreenFX_DoubleVision
  190. ==================
  191. */
  192. class FullscreenFX_DoubleVision : public FullscreenFX {
  193. const idMaterial* material;
  194. public:
  195. virtual void Initialize();
  196. virtual bool Active();
  197. virtual void HighQuality();
  198. };
  199. /*
  200. ==================
  201. FullscreenFX_InfluenceVision
  202. ==================
  203. */
  204. class FullscreenFX_InfluenceVision : public FullscreenFX {
  205. public:
  206. virtual void Initialize();
  207. virtual bool Active();
  208. virtual void HighQuality();
  209. };
  210. /*
  211. ==================
  212. FullscreenFX_Bloom
  213. ==================
  214. */
  215. class FullscreenFX_Bloom : public FullscreenFX {
  216. const idMaterial* drawMaterial;
  217. const idMaterial* initMaterial;
  218. const idMaterial* currentMaterial;
  219. float currentIntensity;
  220. float targetIntensity;
  221. public:
  222. virtual void Initialize();
  223. virtual bool Active();
  224. virtual void HighQuality();
  225. virtual void Save( idSaveGame *savefile );
  226. virtual void Restore( idRestoreGame *savefile );
  227. };
  228. /*
  229. ==================
  230. FullscreenFXManager
  231. ==================
  232. */
  233. class FullscreenFXManager {
  234. idList<FullscreenFX*> fx;
  235. bool highQualityMode;
  236. idVec2 shiftScale;
  237. idPlayerView *playerView;
  238. const idMaterial* blendBackMaterial;
  239. void CreateFX( idStr name, idStr fxtype, int fade );
  240. public:
  241. FullscreenFXManager();
  242. virtual ~FullscreenFXManager();
  243. void Initialize( idPlayerView *pv );
  244. void Process( const renderView_t *view );
  245. void CaptureCurrentRender();
  246. void Blendback( float alpha );
  247. idVec2 GetShiftScale() { return shiftScale; };
  248. idPlayerView* GetPlayerView() { return playerView; };
  249. idPlayer* GetPlayer() { return gameLocal.GetLocalPlayer(); };
  250. int GetNum() { return fx.Num(); };
  251. FullscreenFX* GetFX( int index ) { return fx[index]; };
  252. FullscreenFX* FindFX( idStr name );
  253. void Save( idSaveGame *savefile );
  254. void Restore( idRestoreGame *savefile );
  255. };
  256. #endif
  257. class idPlayerView {
  258. public:
  259. idPlayerView();
  260. void Save( idSaveGame *savefile ) const;
  261. void Restore( idRestoreGame *savefile );
  262. void SetPlayerEntity( class idPlayer *playerEnt );
  263. void ClearEffects( void );
  264. void DamageImpulse( idVec3 localKickDir, const idDict *damageDef );
  265. void WeaponFireFeedback( const idDict *weaponDef );
  266. idAngles AngleOffset( void ) const; // returns the current kick angle
  267. idMat3 ShakeAxis( void ) const; // returns the current shake angle
  268. void CalculateShake( void );
  269. // this may involve rendering to a texture and displaying
  270. // that with a warp model or in double vision mode
  271. void RenderPlayerView( idUserInterface *hud );
  272. void Fade( idVec4 color, int time );
  273. void Flash( idVec4 color, int time );
  274. void AddBloodSpray( float duration );
  275. // temp for view testing
  276. void EnableBFGVision( bool b ) { bfgVision = b; };
  277. private:
  278. void SingleView( idUserInterface *hud, const renderView_t *view );
  279. void ScreenFade();
  280. screenBlob_t * GetScreenBlob();
  281. screenBlob_t screenBlobs[MAX_SCREEN_BLOBS];
  282. public:
  283. int dvFinishTime; // double vision will be stopped at this time
  284. const idMaterial * dvMaterial; // material to take the double vision screen shot
  285. int kickFinishTime; // view kick will be stopped at this time
  286. idAngles kickAngles;
  287. bool bfgVision; //
  288. const idMaterial * tunnelMaterial; // health tunnel vision
  289. const idMaterial * armorMaterial; // armor damage view effect
  290. const idMaterial * berserkMaterial; // berserk effect
  291. const idMaterial * irGogglesMaterial; // ir effect
  292. const idMaterial * bloodSprayMaterial; // blood spray
  293. const idMaterial * bfgMaterial; // when targeted with BFG
  294. const idMaterial * lagoMaterial; // lagometer drawing
  295. float lastDamageTime; // accentuate the tunnel effect for a while
  296. idVec4 fadeColor; // fade color
  297. idVec4 fadeToColor; // color to fade to
  298. idVec4 fadeFromColor; // color to fade from
  299. float fadeRate; // fade rate
  300. int fadeTime; // fade time
  301. idAngles shakeAng; // from the sound sources
  302. idPlayer * player;
  303. renderView_t view;
  304. #ifdef _D3XP
  305. FullscreenFXManager *fxManager;
  306. public:
  307. int AddWarp( idVec3 worldOrigin, float centerx, float centery, float initialRadius, float durationMsec );
  308. void FreeWarp( int id );
  309. #endif
  310. };
  311. #endif /* !__GAME_PLAYERVIEW_H__ */