PlayerView.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  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. /*
  143. const idMaterial* acInitMaterials;
  144. const idMaterial* acCaptureMaterials;
  145. const idMaterial* acDrawMaterials;
  146. const idMaterial* crCaptureMaterials;
  147. const idMaterial* crDrawMaterials;
  148. */
  149. bool clearAccumBuffer;
  150. int DetermineLevel();
  151. public:
  152. virtual void Initialize();
  153. virtual bool Active();
  154. virtual void HighQuality();
  155. virtual void AccumPass( const renderView_t *view );
  156. virtual bool HasAccum() { return true; };
  157. virtual void Restore( idRestoreGame *savefile );
  158. };
  159. /*
  160. ==================
  161. FullscreenFX_Warp
  162. ==================
  163. */
  164. class FullscreenFX_Warp : public FullscreenFX {
  165. const idMaterial* material;
  166. bool grabberEnabled;
  167. int startWarpTime;
  168. void DrawWarp( WarpPolygon_t wp, float interp );
  169. public:
  170. virtual void Initialize();
  171. virtual bool Active();
  172. virtual void HighQuality();
  173. void EnableGrabber( bool active ) { grabberEnabled = active; startWarpTime = gameLocal.slow.time; };
  174. virtual void Save( idSaveGame *savefile );
  175. virtual void Restore( idRestoreGame *savefile );
  176. };
  177. /*
  178. ==================
  179. FullscreenFX_EnviroSuit
  180. ==================
  181. */
  182. class FullscreenFX_EnviroSuit : public FullscreenFX {
  183. const idMaterial* material;
  184. public:
  185. virtual void Initialize();
  186. virtual bool Active();
  187. virtual void HighQuality();
  188. };
  189. /*
  190. ==================
  191. FullscreenFX_DoubleVision
  192. ==================
  193. */
  194. class FullscreenFX_DoubleVision : public FullscreenFX {
  195. const idMaterial* material;
  196. public:
  197. virtual void Initialize();
  198. virtual bool Active();
  199. virtual void HighQuality();
  200. };
  201. /*
  202. ==================
  203. FullscreenFX_InfluenceVision
  204. ==================
  205. */
  206. class FullscreenFX_InfluenceVision : public FullscreenFX {
  207. public:
  208. virtual void Initialize();
  209. virtual bool Active();
  210. virtual void HighQuality();
  211. };
  212. /*
  213. ==================
  214. FullscreenFX_Bloom
  215. ==================
  216. */
  217. class FullscreenFX_Bloom : public FullscreenFX {
  218. const idMaterial* drawMaterial;
  219. const idMaterial* initMaterial;
  220. const idMaterial* currentMaterial;
  221. float currentIntensity;
  222. float targetIntensity;
  223. public:
  224. virtual void Initialize();
  225. virtual bool Active();
  226. virtual void HighQuality();
  227. virtual void Save( idSaveGame *savefile );
  228. virtual void Restore( idRestoreGame *savefile );
  229. };
  230. //bc
  231. class FullscreenFX_Haze : public FullscreenFX
  232. {
  233. const idMaterial* material;
  234. bool hazeActive;
  235. int hazeStartTime;
  236. int hazeEndTime;
  237. float hazeAmount;
  238. float hazeValue;
  239. public:
  240. virtual void Initialize();
  241. virtual bool Active();
  242. virtual void HighQuality();
  243. void ActivateHaze(int time, float value);
  244. };
  245. /*
  246. ==================
  247. FullscreenFXManager
  248. ==================
  249. */
  250. class FullscreenFXManager {
  251. idList<FullscreenFX*> fx;
  252. bool highQualityMode;
  253. idVec2 shiftScale;
  254. idPlayerView *playerView;
  255. void CreateFX( idStr name, idStr fxtype, int fade );
  256. public:
  257. FullscreenFXManager();
  258. virtual ~FullscreenFXManager();
  259. void Initialize( idPlayerView *pv );
  260. void Process( const renderView_t *view );
  261. void CaptureCurrentRender();
  262. void Blendback( float alpha );
  263. idVec2 GetShiftScale() { return shiftScale; };
  264. idPlayerView* GetPlayerView() { return playerView; };
  265. idPlayer* GetPlayer() { return gameLocal.GetLocalPlayer(); };
  266. int GetNum() { return fx.Num(); };
  267. FullscreenFX* GetFX( int index ) { return fx[index]; };
  268. FullscreenFX* FindFX( idStr name );
  269. void Save( idSaveGame *savefile );
  270. void Restore( idRestoreGame *savefile );
  271. };
  272. #endif
  273. class idPlayerView {
  274. public:
  275. idPlayerView();
  276. void Save( idSaveGame *savefile ) const;
  277. void Restore( idRestoreGame *savefile );
  278. void SetPlayerEntity( class idPlayer *playerEnt );
  279. void ClearEffects( void );
  280. void DamageImpulse( idVec3 localKickDir, const idDict *damageDef );
  281. void WeaponFireFeedback( const idDict *weaponDef );
  282. idAngles AngleOffset( void ) const; // returns the current kick angle
  283. idMat3 ShakeAxis( void ) const; // returns the current shake angle
  284. void CalculateShake( void );
  285. // this may involve rendering to a texture and displaying
  286. // that with a warp model or in double vision mode
  287. void RenderPlayerView( idUserInterface *hud );
  288. void Fade( idVec4 color, int time );
  289. void Flash( idVec4 color, int time );
  290. void AddBloodSpray( float duration );
  291. // temp for view testing
  292. void EnableBFGVision( bool b ) { bfgVision = b; };
  293. private:
  294. void SingleView( idUserInterface *hud, const renderView_t *view );
  295. void ScreenFade();
  296. screenBlob_t * GetScreenBlob();
  297. screenBlob_t screenBlobs[MAX_SCREEN_BLOBS];
  298. public:
  299. int dvFinishTime; // double vision will be stopped at this time
  300. const idMaterial * dvMaterial; // material to take the double vision screen shot
  301. int kickFinishTime; // view kick will be stopped at this time
  302. idAngles kickAngles;
  303. bool bfgVision; //
  304. const idMaterial * lagoMaterial; // lagometer drawing
  305. float lastDamageTime; // accentuate the tunnel effect for a while
  306. idVec4 fadeColor; // fade color
  307. idVec4 fadeToColor; // color to fade to
  308. idVec4 fadeFromColor; // color to fade from
  309. float fadeRate; // fade rate
  310. int fadeTime; // fade time
  311. idAngles shakeAng; // from the sound sources
  312. idPlayer * player;
  313. renderView_t view;
  314. #ifdef _D3XP
  315. FullscreenFXManager *fxManager;
  316. public:
  317. int AddWarp( idVec3 worldOrigin, float centerx, float centery, float initialRadius, float durationMsec );
  318. void FreeWarp( int id );
  319. void AddHaze(int time, float value);
  320. #endif
  321. };
  322. #endif /* !__GAME_PLAYERVIEW_H__ */