doom3-bfg/neo/d3xp/PlayerView.h

491 lines
10 KiB
C
Raw Normal View History

2012-11-26 18:58:24 +00:00
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
2012-11-26 18:58:24 +00:00
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
2012-11-26 18:58:24 +00:00
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition 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 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
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.
===========================================================================
*/
#ifndef __GAME_PLAYERVIEW_H__
#define __GAME_PLAYERVIEW_H__
class idMenuHandler_HUD;
/*
===============================================================================
Player view.
===============================================================================
*/
// screenBlob_t are for the on-screen damage claw marks, etc
typedef struct
{
const idMaterial* material;
2012-11-26 18:58:24 +00:00
float x, y, w, h;
float s1, t1, s2, t2;
int finishTime;
int startFadeTime;
float driftAmount;
} screenBlob_t;
#define MAX_SCREEN_BLOBS 8
class WarpPolygon_t
{
2012-11-26 18:58:24 +00:00
public:
idVec4 outer1;
idVec4 outer2;
idVec4 center;
};
class Warp_t
{
2012-11-26 18:58:24 +00:00
public:
int id;
bool active;
2012-11-26 18:58:24 +00:00
int startTime;
float initialRadius;
2012-11-26 18:58:24 +00:00
idVec3 worldOrigin;
idVec2 screenOrigin;
2012-11-26 18:58:24 +00:00
int durationMsec;
2012-11-26 18:58:24 +00:00
idList<WarpPolygon_t, TAG_IDLIB_LIST_PLAYER> polys;
};
class idPlayerView;
class FullscreenFXManager;
/*
==================
FxFader
==================
*/
class FxFader
{
enum
{
2012-11-26 18:58:24 +00:00
FX_STATE_OFF,
FX_STATE_RAMPUP,
FX_STATE_RAMPDOWN,
FX_STATE_ON
};
2012-11-26 18:58:24 +00:00
int time;
int state;
float alpha;
int msec;
2012-11-26 18:58:24 +00:00
public:
FxFader();
2012-11-26 18:58:24 +00:00
// primary functions
bool SetTriggerState( bool active );
virtual void Save( idSaveGame* savefile );
virtual void Restore( idRestoreGame* savefile );
2012-11-26 18:58:24 +00:00
// fader functions
void SetFadeTime( int t )
{
msec = t;
};
int GetFadeTime()
{
return msec;
};
2012-11-26 18:58:24 +00:00
// misc functions
float GetAlpha()
{
return alpha;
};
2012-11-26 18:58:24 +00:00
};
/*
==================
FullscreenFX
==================
*/
class FullscreenFX
{
2012-11-26 18:58:24 +00:00
protected:
idStr name;
FxFader fader;
FullscreenFXManager* fxman;
2012-11-26 18:58:24 +00:00
public:
FullscreenFX()
{
fxman = NULL;
};
2012-11-26 18:58:24 +00:00
virtual ~FullscreenFX() { };
2012-11-26 18:58:24 +00:00
virtual void Initialize() = 0;
virtual bool Active() = 0;
virtual void HighQuality() = 0;
virtual void LowQuality() { };
virtual void AccumPass( const renderView_t* view ) { };
virtual bool HasAccum()
{
return false;
};
void SetName( idStr n )
{
name = n;
};
idStr GetName()
{
return name;
};
void SetFXManager( FullscreenFXManager* fx )
{
fxman = fx;
};
bool SetTriggerState( bool state )
{
return fader.SetTriggerState( state );
};
void SetFadeSpeed( int msec )
{
fader.SetFadeTime( msec );
};
float GetFadeAlpha()
{
return fader.GetAlpha();
};
virtual void Save( idSaveGame* savefile );
virtual void Restore( idRestoreGame* savefile );
2012-11-26 18:58:24 +00:00
};
/*
==================
FullscreenFX_Helltime
==================
*/
class FullscreenFX_Helltime : public FullscreenFX
{
const idMaterial* initMaterial;
const idMaterial* captureMaterials[3];
const idMaterial* drawMaterial;
2012-11-26 18:58:24 +00:00
bool clearAccumBuffer;
2012-11-26 18:58:24 +00:00
int DetermineLevel();
2012-11-26 18:58:24 +00:00
public:
virtual void Initialize();
virtual bool Active();
virtual void HighQuality();
virtual void AccumPass( const renderView_t* view );
virtual bool HasAccum()
{
return true;
};
virtual void Restore( idRestoreGame* savefile );
2012-11-26 18:58:24 +00:00
};
/*
==================
FullscreenFX_Multiplayer
==================
*/
class FullscreenFX_Multiplayer : public FullscreenFX
{
const idMaterial* initMaterial;
const idMaterial* captureMaterial;
const idMaterial* drawMaterial;
2012-11-26 18:58:24 +00:00
bool clearAccumBuffer;
2012-11-26 18:58:24 +00:00
int DetermineLevel();
2012-11-26 18:58:24 +00:00
public:
virtual void Initialize();
virtual bool Active();
virtual void HighQuality();
virtual void AccumPass( const renderView_t* view );
virtual bool HasAccum()
{
return true;
};
virtual void Restore( idRestoreGame* savefile );
2012-11-26 18:58:24 +00:00
};
/*
==================
FullscreenFX_Warp
==================
*/
class FullscreenFX_Warp : public FullscreenFX
{
2012-11-26 18:58:24 +00:00
const idMaterial* material;
bool grabberEnabled;
int startWarpTime;
2012-11-26 18:58:24 +00:00
void DrawWarp( WarpPolygon_t wp, float interp );
2012-11-26 18:58:24 +00:00
public:
virtual void Initialize();
virtual bool Active();
virtual void HighQuality();
void EnableGrabber( bool active )
{
grabberEnabled = active;
startWarpTime = gameLocal.slow.time;
};
virtual void Save( idSaveGame* savefile );
virtual void Restore( idRestoreGame* savefile );
2012-11-26 18:58:24 +00:00
};
/*
==================
FullscreenFX_EnviroSuit
==================
*/
class FullscreenFX_EnviroSuit : public FullscreenFX
{
2012-11-26 18:58:24 +00:00
const idMaterial* material;
2012-11-26 18:58:24 +00:00
public:
virtual void Initialize();
virtual bool Active();
virtual void HighQuality();
};
/*
==================
FullscreenFX_DoubleVision
==================
*/
class FullscreenFX_DoubleVision : public FullscreenFX
{
2012-11-26 18:58:24 +00:00
const idMaterial* material;
2012-11-26 18:58:24 +00:00
public:
virtual void Initialize();
virtual bool Active();
virtual void HighQuality();
};
/*
==================
FullscreenFX_InfluenceVision
==================
*/
class FullscreenFX_InfluenceVision : public FullscreenFX
{
2012-11-26 18:58:24 +00:00
public:
virtual void Initialize();
virtual bool Active();
virtual void HighQuality();
};
/*
==================
FullscreenFX_Bloom
==================
*/
class FullscreenFX_Bloom : public FullscreenFX
{
2012-11-26 18:58:24 +00:00
const idMaterial* drawMaterial;
const idMaterial* initMaterial;
2012-11-26 18:58:24 +00:00
float currentIntensity;
float targetIntensity;
2012-11-26 18:58:24 +00:00
public:
virtual void Initialize();
virtual bool Active();
virtual void HighQuality();
virtual void Save( idSaveGame* savefile );
virtual void Restore( idRestoreGame* savefile );
2012-11-26 18:58:24 +00:00
};
/*
==================
FullscreenFXManager
==================
*/
class FullscreenFXManager
{
2012-11-26 18:58:24 +00:00
idList<FullscreenFX*, TAG_FX> fx;
idPlayerView* playerView;
2012-11-26 18:58:24 +00:00
const idMaterial* blendBackMaterial;
2012-11-26 18:58:24 +00:00
void CreateFX( idStr name, idStr fxtype, int fade );
2012-11-26 18:58:24 +00:00
public:
FullscreenFXManager();
2012-11-26 18:58:24 +00:00
virtual ~FullscreenFXManager();
void Initialize( idPlayerView* pv );
void Process( const renderView_t* view );
2012-11-26 18:58:24 +00:00
void Blendback( float alpha );
idPlayerView* GetPlayerView()
{
return playerView;
};
idPlayer* GetPlayer()
{
return gameLocal.GetLocalPlayer();
};
int GetNum()
{
return fx.Num();
};
FullscreenFX* GetFX( int index )
{
return fx[index];
};
2012-11-26 18:58:24 +00:00
FullscreenFX* FindFX( idStr name );
void Save( idSaveGame* savefile );
void Restore( idRestoreGame* savefile );
2012-11-26 18:58:24 +00:00
};
class idPlayerView
{
2012-11-26 18:58:24 +00:00
public:
idPlayerView();
~idPlayerView();
void Save( idSaveGame* savefile ) const;
void Restore( idRestoreGame* savefile );
void SetPlayerEntity( class idPlayer* playerEnt );
2012-11-26 18:58:24 +00:00
void ClearEffects();
void DamageImpulse( idVec3 localKickDir, const idDict* damageDef );
void WeaponFireFeedback( const idDict* weaponDef );
2012-11-26 18:58:24 +00:00
idAngles AngleOffset() const; // returns the current kick angle
2012-11-26 18:58:24 +00:00
idMat3 ShakeAxis() const; // returns the current shake angle
2012-11-26 18:58:24 +00:00
void CalculateShake();
2012-11-26 18:58:24 +00:00
// this may involve rendering to a texture and displaying
// that with a warp model or in double vision mode
void RenderPlayerView( idMenuHandler_HUD* hudManager );
void EmitStereoEyeView( const int eye, idMenuHandler_HUD* hudManager );
2012-11-26 18:58:24 +00:00
void Fade( idVec4 color, int time );
2012-11-26 18:58:24 +00:00
void Flash( idVec4 color, int time );
2012-11-26 18:58:24 +00:00
// temp for view testing
void EnableBFGVision( bool b )
{
bfgVision = b;
};
2012-11-26 18:58:24 +00:00
private:
void SingleView( const renderView_t* view, idMenuHandler_HUD* hudManager );
2012-11-26 18:58:24 +00:00
void ScreenFade();
screenBlob_t* GetScreenBlob();
2012-11-26 18:58:24 +00:00
screenBlob_t screenBlobs[MAX_SCREEN_BLOBS];
2012-11-26 18:58:24 +00:00
public:
int dvFinishTime; // double vision will be stopped at this time
2012-11-26 18:58:24 +00:00
int kickFinishTime; // view kick will be stopped at this time
idAngles kickAngles;
bool bfgVision; //
const idMaterial* tunnelMaterial; // health tunnel vision
const idMaterial* armorMaterial; // armor damage view effect
const idMaterial* berserkMaterial; // berserk effect
const idMaterial* irGogglesMaterial; // ir effect
const idMaterial* bloodSprayMaterial; // blood spray
const idMaterial* bfgMaterial; // when targeted with BFG
2012-11-26 18:58:24 +00:00
float lastDamageTime; // accentuate the tunnel effect for a while
2012-11-26 18:58:24 +00:00
idVec4 fadeColor; // fade color
idVec4 fadeToColor; // color to fade to
idVec4 fadeFromColor; // color to fade from
float fadeRate; // fade rate
int fadeTime; // fade time
2012-11-26 18:58:24 +00:00
idAngles shakeAng; // from the sound sources
idPlayer* player;
2012-11-26 18:58:24 +00:00
renderView_t view;
FullscreenFXManager* fxManager;
2012-11-26 18:58:24 +00:00
public:
int AddWarp( idVec3 worldOrigin, float centerx, float centery, float initialRadius, float durationMsec );
void FreeWarp( int id );
};
// the crosshair is swapped for a laser sight in stereo rendering
bool IsGameStereoRendered();
#endif /* !__GAME_PLAYERVIEW_H__ */