]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/d3xp/PlayerView.h
hello world
[icculus/iodoom3.git] / neo / d3xp / PlayerView.h
1 /*
2 ===========================================================================
3
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. 
6
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).  
8
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code.  If not, see <http://www.gnu.org/licenses/>.
21
22 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.
23
24 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.
25
26 ===========================================================================
27 */
28
29 #ifndef __GAME_PLAYERVIEW_H__
30 #define __GAME_PLAYERVIEW_H__
31
32 /*
33 ===============================================================================
34
35   Player view.
36
37 ===============================================================================
38 */
39
40 // screenBlob_t are for the on-screen damage claw marks, etc
41 typedef struct {
42         const idMaterial *      material;
43         float                           x, y, w, h;
44         float                           s1, t1, s2, t2;
45         int                                     finishTime;
46         int                                     startFadeTime;
47         float                           driftAmount;
48 } screenBlob_t;
49
50 #define MAX_SCREEN_BLOBS        8
51
52
53
54
55
56 #ifdef _D3XP
57 class WarpPolygon_t {
58 public:
59         idVec4                                  outer1;
60         idVec4                                  outer2;
61         idVec4                                  center;
62 };
63
64 class Warp_t {
65 public:
66         int                                             id;
67         bool                                    active;
68
69         int                                             startTime;
70         float                                   initialRadius;
71
72         idVec3                                  worldOrigin;
73         idVec2                                  screenOrigin;
74
75         int                                             durationMsec;
76
77         idList<WarpPolygon_t>   polys;
78 };
79 #endif
80
81
82
83
84
85
86
87 #ifdef _D3XP
88
89 class idPlayerView;
90 class FullscreenFXManager;
91
92
93 /*
94 ==================
95 FxFader
96 ==================
97 */
98 class FxFader {
99         enum {
100                 FX_STATE_OFF,
101                 FX_STATE_RAMPUP,
102                 FX_STATE_RAMPDOWN,
103                 FX_STATE_ON
104         };
105
106         int                                             time;
107         int                                             state;
108         float                                   alpha;
109         int                                             msec;
110
111 public:
112                                                         FxFader();
113
114         // primary functions
115         bool                                    SetTriggerState( bool active );
116
117         virtual void                    Save( idSaveGame *savefile );
118         virtual void                    Restore( idRestoreGame *savefile );
119
120         // fader functions
121         void                                    SetFadeTime( int t )            { msec = t; };
122         int                                             GetFadeTime()                           { return msec; };
123
124         // misc functions
125         float                                   GetAlpha()                                      { return alpha; };
126 };
127
128
129 /*
130 ==================
131 FullscreenFX
132 ==================
133 */
134 class FullscreenFX {
135 protected:
136         idStr                                   name;
137         FxFader                                 fader;
138         FullscreenFXManager             *fxman;
139
140 public:
141                                                         FullscreenFX()                                                  { fxman = NULL; };
142         virtual                                 ~FullscreenFX()                                                 { };
143
144         virtual void                    Initialize()                                                    = 0;
145         virtual bool                    Active()                                                                = 0;
146         virtual void                    HighQuality()                                                   = 0;
147         virtual void                    LowQuality()                                                    { };
148         virtual void                    AccumPass( const renderView_t *view )   { };
149         virtual bool                    HasAccum()                                                              { return false; };
150
151         void                                    SetName( idStr n )                                              { name = n; };
152         idStr                                   GetName()                                                               { return name; };
153
154         void                                    SetFXManager( FullscreenFXManager *fx ) { fxman = fx; };
155
156         bool                                    SetTriggerState( bool state )                   { return fader.SetTriggerState( state ); };
157         void                                    SetFadeSpeed( int msec )                                { fader.SetFadeTime( msec ); };
158         float                                   GetFadeAlpha()                                                  { return fader.GetAlpha(); };
159
160         virtual void                    Save( idSaveGame *savefile );
161         virtual void                    Restore( idRestoreGame *savefile );
162 };
163
164 /*
165 ==================
166 FullscreenFX_Helltime
167 ==================
168 */
169 class FullscreenFX_Helltime : public FullscreenFX {
170         const idMaterial*               acInitMaterials[3];
171         const idMaterial*               acCaptureMaterials[3];
172         const idMaterial*               acDrawMaterials[3];
173         const idMaterial*               crCaptureMaterials[3];
174         const idMaterial*               crDrawMaterials[3];
175         bool                                    clearAccumBuffer;
176
177         int                                             DetermineLevel();
178
179 public:
180         virtual void                    Initialize();
181         virtual bool                    Active();
182         virtual void                    HighQuality();
183         virtual void                    AccumPass( const renderView_t *view );
184         virtual bool                    HasAccum()              { return true; };
185
186         virtual void                    Restore( idRestoreGame *savefile );
187 };
188
189 /*
190 ==================
191 FullscreenFX_Multiplayer
192 ==================
193 */
194 class FullscreenFX_Multiplayer : public FullscreenFX {
195         const idMaterial*               acInitMaterials;
196         const idMaterial*               acCaptureMaterials;
197         const idMaterial*               acDrawMaterials;
198         const idMaterial*               crCaptureMaterials;
199         const idMaterial*               crDrawMaterials;
200         bool                                    clearAccumBuffer;
201
202         int                                             DetermineLevel();
203
204 public:
205         virtual void                    Initialize();
206         virtual bool                    Active();
207         virtual void                    HighQuality();
208         virtual void                    AccumPass( const renderView_t *view );
209         virtual bool                    HasAccum()              { return true; };
210
211         virtual void                    Restore( idRestoreGame *savefile );
212 };
213
214 /*
215 ==================
216 FullscreenFX_Warp
217 ==================
218 */
219 class FullscreenFX_Warp : public FullscreenFX {
220         const idMaterial*               material;
221         bool                                    grabberEnabled;
222         int                                             startWarpTime;
223
224         void                                    DrawWarp( WarpPolygon_t wp, float interp );
225
226 public:
227         virtual void                    Initialize();
228         virtual bool                    Active();
229         virtual void                    HighQuality();
230
231         void                                    EnableGrabber( bool active )                    { grabberEnabled = active; startWarpTime = gameLocal.slow.time; };
232
233         virtual void                    Save( idSaveGame *savefile );
234         virtual void                    Restore( idRestoreGame *savefile );
235 };
236
237 /*
238 ==================
239 FullscreenFX_EnviroSuit
240 ==================
241 */
242 class FullscreenFX_EnviroSuit : public FullscreenFX {
243         const idMaterial*               material;
244
245 public:
246         virtual void                    Initialize();
247         virtual bool                    Active();
248         virtual void                    HighQuality();
249 };
250
251 /*
252 ==================
253 FullscreenFX_DoubleVision
254 ==================
255 */
256 class FullscreenFX_DoubleVision : public FullscreenFX {
257         const idMaterial*               material;
258
259 public:
260         virtual void                    Initialize();
261         virtual bool                    Active();
262         virtual void                    HighQuality();
263 };
264
265 /*
266 ==================
267 FullscreenFX_InfluenceVision
268 ==================
269 */
270 class FullscreenFX_InfluenceVision : public FullscreenFX {
271
272 public:
273         virtual void                    Initialize();
274         virtual bool                    Active();
275         virtual void                    HighQuality();
276 };
277
278 /*
279 ==================
280 FullscreenFX_Bloom
281 ==================
282 */
283 class FullscreenFX_Bloom : public FullscreenFX {
284         const idMaterial*               drawMaterial;
285         const idMaterial*               initMaterial;
286         const idMaterial*               currentMaterial;
287
288         float                                   currentIntensity;
289         float                                   targetIntensity;
290
291 public:
292         virtual void                    Initialize();
293         virtual bool                    Active();
294         virtual void                    HighQuality();
295
296         virtual void                    Save( idSaveGame *savefile );
297         virtual void                    Restore( idRestoreGame *savefile );
298 };
299
300
301
302 /*
303 ==================
304 FullscreenFXManager
305 ==================
306 */
307 class FullscreenFXManager {
308         idList<FullscreenFX*>   fx;
309         bool                                    highQualityMode;
310         idVec2                                  shiftScale;
311
312         idPlayerView                    *playerView;
313         const idMaterial*               blendBackMaterial;
314
315         void                                    CreateFX( idStr name, idStr fxtype, int fade );
316
317 public:
318                                                         FullscreenFXManager();
319         virtual                                 ~FullscreenFXManager();
320
321         void                                    Initialize( idPlayerView *pv );
322
323         void                                    Process( const renderView_t *view );
324         void                                    CaptureCurrentRender();
325         void                                    Blendback( float alpha );
326
327         idVec2                                  GetShiftScale()                 { return shiftScale; };
328         idPlayerView*                   GetPlayerView()                 { return playerView; };
329         idPlayer*                               GetPlayer()                             { return gameLocal.GetLocalPlayer(); };
330
331         int                                             GetNum()                                { return fx.Num(); };
332         FullscreenFX*                   GetFX( int index )              { return fx[index]; };
333         FullscreenFX*                   FindFX( idStr name );
334
335         void                                    Save( idSaveGame *savefile );
336         void                                    Restore( idRestoreGame *savefile );
337 };
338
339 #endif
340
341
342
343
344
345
346
347
348
349 class idPlayerView {
350 public:
351                                                 idPlayerView();
352
353         void                            Save( idSaveGame *savefile ) const;
354         void                            Restore( idRestoreGame *savefile );
355
356         void                            SetPlayerEntity( class idPlayer *playerEnt );
357
358         void                            ClearEffects( void );
359
360         void                            DamageImpulse( idVec3 localKickDir, const idDict *damageDef );
361
362         void                            WeaponFireFeedback( const idDict *weaponDef );
363
364         idAngles                        AngleOffset( void ) const;                      // returns the current kick angle
365
366         idMat3                          ShakeAxis( void ) const;                        // returns the current shake angle
367
368         void                            CalculateShake( void );
369
370         // this may involve rendering to a texture and displaying
371         // that with a warp model or in double vision mode
372         void                            RenderPlayerView( idUserInterface *hud );
373
374         void                            Fade( idVec4 color, int time );
375
376         void                            Flash( idVec4 color, int time );
377
378         void                            AddBloodSpray( float duration );
379
380         // temp for view testing
381         void                            EnableBFGVision( bool b ) { bfgVision = b; };
382
383 private:
384         void                            SingleView( idUserInterface *hud, const renderView_t *view );
385         void                            ScreenFade();
386
387         screenBlob_t *          GetScreenBlob();
388
389         screenBlob_t            screenBlobs[MAX_SCREEN_BLOBS];
390
391 public:
392         int                                     dvFinishTime;           // double vision will be stopped at this time
393         const idMaterial *      dvMaterial;                     // material to take the double vision screen shot
394
395         int                                     kickFinishTime;         // view kick will be stopped at this time
396         idAngles                        kickAngles;                     
397
398         bool                            bfgVision;                      // 
399
400         const idMaterial *      tunnelMaterial;         // health tunnel vision
401         const idMaterial *      armorMaterial;          // armor damage view effect
402         const idMaterial *      berserkMaterial;        // berserk effect
403         const idMaterial *      irGogglesMaterial;      // ir effect
404         const idMaterial *      bloodSprayMaterial; // blood spray
405         const idMaterial *      bfgMaterial;            // when targeted with BFG
406         const idMaterial *      lagoMaterial;           // lagometer drawing
407         float                           lastDamageTime;         // accentuate the tunnel effect for a while
408
409         idVec4                          fadeColor;                      // fade color
410         idVec4                          fadeToColor;            // color to fade to
411         idVec4                          fadeFromColor;          // color to fade from
412         float                           fadeRate;                       // fade rate
413         int                                     fadeTime;                       // fade time
414
415         idAngles                        shakeAng;                       // from the sound sources
416
417         idPlayer *                      player;
418         renderView_t            view;
419
420 #ifdef _D3XP
421         FullscreenFXManager     *fxManager;
422
423 public:
424         int                                     AddWarp( idVec3 worldOrigin, float centerx, float centery, float initialRadius, float durationMsec );
425         void                            FreeWarp( int id );
426 #endif
427 };
428
429 #endif /* !__GAME_PLAYERVIEW_H__ */