29 #include "../idlib/precompiled.h"
39 for (pot = 1 ; pot <
num ; pot<<=1) {
78 fxManager =
new FullscreenFXManager;
79 fxManager->Initialize(
this );
138 fxManager->Save( savefile );
195 fxManager->Restore( savefile );
261 float dvTime = damageDef->
GetFloat(
"dv_time" );
276 float kickTime = damageDef->
GetFloat(
"kick_time" );
292 float kickAmplitude = damageDef->
GetFloat(
"kick_amplitude" );
293 if ( kickAmplitude ) {
301 float blobTime = damageDef->
GetFloat(
"blob_time" );
307 const char *materialName = damageDef->
GetString(
"mtr_blob" );
309 blob->
x = damageDef->
GetFloat(
"blob_x" );
311 blob->
y = damageDef->
GetFloat(
"blob_y" );
387 recoilTime = weaponDef->
GetInt(
"recoilTime" );
391 weaponDef->
GetAngles(
"recoilAngles",
"5 0 0", angles );
445 for (
int i = 0 ;
i < 3 ;
i++ ) {
446 if ( ang[
i] > 70.0
f ) {
448 }
else if ( ang[
i] < -70.0
f ) {
482 if (
gameLocal.portalSkyEnt.GetEntity() &&
gameLocal.IsPortalSkyAcive() && g_enablePortalSky.GetBool() ) {
484 portalView.
vieworg =
gameLocal.portalSkyEnt.GetEntity()->GetPhysics()->GetOrigin();
488 int vidWidth, vidHeight;
496 shiftScale.
x = (
float)w / pot;
500 shiftScale.
y = (
float)h / pot;
513 fxManager->Process( &hackedView );
550 if ( armorPulse > 0.0
f && armorPulse < 1.0
f ) {
563 float alpha = health / 100.0f;
564 if ( alpha < 0.0
f ) {
567 if ( alpha > 1.0
f ) {
571 if ( alpha < 1.0
f ) {
619 SetTimeState ts(
player->timeGroup );
658 SetTimeState ts(
player->timeGroup );
702 int idPlayerView::AddWarp(
idVec3 worldOrigin,
float centerx,
float centery,
float initialRadius,
float durationMsec ) {
703 FullscreenFX_Warp *fx = (FullscreenFX_Warp*)( fxManager->FindFX(
"warp" ) );
706 fx->EnableGrabber(
true );
713 void idPlayerView::FreeWarp(
int id ) {
714 FullscreenFX_Warp *fx = (FullscreenFX_Warp*)( fxManager->FindFX(
"warp" ) );
717 fx->EnableGrabber(
false );
733 state = FX_STATE_OFF;
743 bool FxFader::SetTriggerState(
bool active ) {
746 if ( active && state == FX_STATE_OFF ) {
747 state = FX_STATE_RAMPUP;
750 else if ( !active && state == FX_STATE_ON ) {
751 state = FX_STATE_RAMPDOWN;
756 if ( state == FX_STATE_RAMPUP ) {
761 else if ( state == FX_STATE_RAMPDOWN ) {
763 state = FX_STATE_OFF;
769 case FX_STATE_ON:
alpha = 1;
break;
770 case FX_STATE_OFF:
alpha = 0;
break;
816 void FullscreenFX::Save(
idSaveGame *savefile ) {
817 fader.Save( savefile );
826 fader.Restore( savefile );
835 void FullscreenFX_Helltime::Initialize() {
856 clearAccumBuffer =
true;
864 int FullscreenFX_Helltime::DetermineLevel() {
866 int testfx = g_testHelltimeFX.GetInteger();
869 if ( testfx >= 0 && testfx < 3 ) {
873 player = fxman->GetPlayer();
893 bool FullscreenFX_Helltime::Active() {
899 if ( DetermineLevel() >= 0 ) {
904 if ( fader.GetAlpha() == 0 ) {
905 clearAccumBuffer =
true;
917 void FullscreenFX_Helltime::AccumPass(
const renderView_t *view ) {
919 int level = DetermineLevel();
926 shiftScale = fxman->GetShiftScale();
930 if ( clearAccumBuffer ) {
931 clearAccumBuffer =
false;
947 void FullscreenFX_Helltime::HighQuality() {
949 int level = DetermineLevel();
956 shiftScale = fxman->GetShiftScale();
969 void FullscreenFX_Helltime::Restore(
idRestoreGame *savefile ) {
970 FullscreenFX::Restore( savefile );
973 clearAccumBuffer =
true;
985 void FullscreenFX_Multiplayer::Initialize() {
991 clearAccumBuffer =
true;
999 int FullscreenFX_Multiplayer::DetermineLevel() {
1001 int testfx = g_testMultiplayerFX.GetInteger();
1004 if ( testfx >= 0 && testfx < 3 ) {
1008 player = fxman->GetPlayer();
1028 bool FullscreenFX_Multiplayer::Active() {
1034 if ( DetermineLevel() >= 0 ) {
1039 if ( fader.GetAlpha() == 0 ) {
1040 clearAccumBuffer =
true;
1052 void FullscreenFX_Multiplayer::AccumPass(
const renderView_t *view ) {
1054 int level = DetermineLevel();
1061 shiftScale = fxman->GetShiftScale();
1065 if ( clearAccumBuffer ) {
1066 clearAccumBuffer =
false;
1082 void FullscreenFX_Multiplayer::HighQuality() {
1084 int level = DetermineLevel();
1091 shiftScale = fxman->GetShiftScale();
1104 void FullscreenFX_Multiplayer::Restore(
idRestoreGame *savefile ) {
1105 FullscreenFX::Restore( savefile );
1108 clearAccumBuffer =
true;
1120 void FullscreenFX_Warp::Initialize() {
1122 grabberEnabled =
false;
1131 bool FullscreenFX_Warp::Active() {
1132 if ( grabberEnabled ) {
1144 void FullscreenFX_Warp::Save(
idSaveGame *savefile ) {
1145 FullscreenFX::Save( savefile );
1148 savefile->
WriteInt( startWarpTime );
1156 void FullscreenFX_Warp::Restore(
idRestoreGame *savefile ) {
1157 FullscreenFX::Restore( savefile );
1159 savefile->
ReadBool( grabberEnabled );
1160 savefile->
ReadInt( startWarpTime );
1168 void FullscreenFX_Warp::DrawWarp( WarpPolygon_t wp,
float interp ) {
1171 idVec2 drawPts[6], shiftScale;
1172 WarpPolygon_t trans;
1175 shiftScale = fxman->GetShiftScale();
1178 mid1 = trans.outer1 * (
interp ) + trans.center * ( 1 - interp );
1179 mid2 = trans.outer2 * (
interp ) + trans.center * ( 1 - interp );
1180 mid1_uv = trans.outer1 * ( 0.5 ) + trans.center * ( 1 - 0.5 );
1181 mid2_uv = trans.outer2 * ( 0.5 ) + trans.center * ( 1 - 0.5 );
1184 drawPts[0].
Set( trans.outer1.x, trans.outer1.y );
1185 drawPts[1].
Set( mid2.
x, mid2.
y );
1186 drawPts[2].
Set( mid1.
x, mid1.
y );
1187 drawPts[3].
Set( trans.outer1.z, trans.outer1.w );
1188 drawPts[4].
Set( mid2_uv.
z, mid2_uv.
w );
1189 drawPts[5].
Set( mid1_uv.
z, mid1_uv.
w );
1190 for (
int j = 0;
j < 3;
j++ ) {
1191 drawPts[
j+3].
x *= shiftScale.
x;
1192 drawPts[
j+3].
y *= shiftScale.
y;
1197 drawPts[0].
Set( trans.outer1.x, trans.outer1.y );
1198 drawPts[1].
Set( trans.outer2.x, trans.outer2.y );
1199 drawPts[2].
Set( mid2.
x, mid2.
y );
1200 drawPts[3].
Set( trans.outer1.z, trans.outer1.w );
1201 drawPts[4].
Set( trans.outer2.z, trans.outer2.w );
1202 drawPts[5].
Set( mid2_uv.
z, mid2_uv.
w );
1203 for (
int j = 0;
j < 3;
j++ ) {
1204 drawPts[
j+3].
x *= shiftScale.
x;
1205 drawPts[
j+3].
y *= shiftScale.
y;
1210 drawPts[0].
Set( mid1.
x, mid1.
y );
1211 drawPts[1].
Set( mid2.
x, mid2.
y );
1212 drawPts[2].
Set( trans.center.x, trans.center.y );
1213 drawPts[3].
Set( mid1_uv.
z, mid1_uv.
w );
1214 drawPts[4].
Set( mid2_uv.
z, mid2_uv.
w );
1215 drawPts[5].
Set( trans.center.z, trans.center.w );
1216 for (
int j = 0;
j < 3;
j++ ) {
1217 drawPts[
j+3].
x *= shiftScale.
x;
1218 drawPts[
j+3].
y *= shiftScale.
y;
1228 void FullscreenFX_Warp::HighQuality() {
1234 interp = 0.7 * ( 1 -
interp ) + 0.3 * ( interp );
1241 for (
float i = 0;
i < 360;
i += STEP ) {
1252 p.outer1.x = center.
x + x1 * radius;
1253 p.outer1.y = center.
y + y1 * radius;
1254 p.outer1.z = p.outer1.x / 640.f;
1255 p.outer1.w = 1 - ( p.outer1.y / 480.f );
1257 p.outer2.x = center.
x + x2 * radius;
1258 p.outer2.y = center.
y + y2 * radius;
1259 p.outer2.z = p.outer2.x / 640.f;
1260 p.outer2.w = 1 - ( p.outer2.y / 480.f );
1262 p.center.x = center.
x;
1263 p.center.y = center.
y;
1264 p.center.z = p.center.x / 640.f;
1265 p.center.w = 1 - ( p.center.y / 480.f );
1268 DrawWarp( p, interp );
1281 void FullscreenFX_EnviroSuit::Initialize() {
1290 bool FullscreenFX_EnviroSuit::Active() {
1293 player = fxman->GetPlayer();
1307 void FullscreenFX_EnviroSuit::HighQuality() {
1321 void FullscreenFX_DoubleVision::Initialize() {
1330 bool FullscreenFX_DoubleVision::Active() {
1332 if (
gameLocal.fast.
time < fxman->GetPlayerView()->dvFinishTime ) {
1344 void FullscreenFX_DoubleVision::HighQuality() {
1352 static int test = 0;
1361 player = fxman->GetPlayer();
1362 shiftScale = fxman->GetShiftScale();
1367 if ( scale > 0.5
f ) {
1371 shift = fabs( shift );
1399 void FullscreenFX_InfluenceVision::Initialize() {
1408 bool FullscreenFX_InfluenceVision::Active() {
1411 player = fxman->GetPlayer();
1425 void FullscreenFX_InfluenceVision::HighQuality() {
1426 float distance = 0.0f;
1431 shiftScale = fxman->GetShiftScale();
1432 player = fxman->GetPlayer();
1461 void FullscreenFX_Bloom::Initialize() {
1466 currentIntensity = 0;
1467 targetIntensity = 0;
1475 bool FullscreenFX_Bloom::Active() {
1478 player = fxman->GetPlayer();
1480 if ( player && player->bloomEnabled ) {
1492 void FullscreenFX_Bloom::HighQuality() {
1499 player = fxman->GetPlayer();
1500 shiftScale = fxman->GetShiftScale();
1504 targetIntensity = g_testBloomIntensity.GetFloat();
1506 if ( player && player->bloomEnabled ) {
1507 targetIntensity = player->bloomIntensity;
1510 delta = targetIntensity - currentIntensity;
1511 float step = 0.001f;
1513 if ( step < fabs( delta ) ) {
1518 currentIntensity += step;
1522 num = g_testBloomNumPasses.GetInteger();
1524 for (
int i = 0;
i <
num;
i++ ) {
1525 float s1 = 0, t1 = 0, s2 = 1, t2 = 1;
1554 alpha = 1 - (
float)
i / ( num - 1 );
1560 shift += currentIntensity;
1569 void FullscreenFX_Bloom::Save(
idSaveGame *savefile ) {
1570 FullscreenFX::Save( savefile );
1580 void FullscreenFX_Bloom::Restore(
idRestoreGame *savefile ) {
1581 FullscreenFX::Restore( savefile );
1582 savefile->
ReadFloat( currentIntensity );
1596 FullscreenFXManager::FullscreenFXManager() {
1597 highQualityMode =
false;
1599 blendBackMaterial =
NULL;
1600 shiftScale.
Set( 0, 0 );
1608 FullscreenFXManager::~FullscreenFXManager() {
1617 FullscreenFX* FullscreenFXManager::FindFX(
idStr name ) {
1618 for (
int i = 0;
i < fx.Num();
i++ ) {
1619 if ( fx[
i]->GetName() ==
name ) {
1632 void FullscreenFXManager::CreateFX(
idStr name,
idStr fxtype,
int fade ) {
1633 FullscreenFX *pfx =
NULL;
1635 if ( fxtype ==
"helltime" ) {
1636 pfx =
new FullscreenFX_Helltime;
1638 else if ( fxtype ==
"warp" ) {
1639 pfx =
new FullscreenFX_Warp;
1641 else if ( fxtype ==
"envirosuit" ) {
1642 pfx =
new FullscreenFX_EnviroSuit;
1644 else if ( fxtype ==
"doublevision" ) {
1645 pfx =
new FullscreenFX_DoubleVision;
1647 else if ( fxtype ==
"multiplayer" ) {
1648 pfx =
new FullscreenFX_Multiplayer;
1650 else if ( fxtype ==
"influencevision" ) {
1651 pfx =
new FullscreenFX_InfluenceVision;
1653 else if ( fxtype ==
"bloom" ) {
1654 pfx =
new FullscreenFX_Bloom;
1662 pfx->SetFXManager(
this );
1663 pfx->SetName( name );
1664 pfx->SetFadeSpeed( fade );
1674 void FullscreenFXManager::Initialize(
idPlayerView *pv ) {
1680 CreateFX(
"helltime",
"helltime", 1000 );
1681 CreateFX(
"warp",
"warp", 0 );
1682 CreateFX(
"envirosuit",
"envirosuit", 500 );
1683 CreateFX(
"doublevision",
"doublevision", 0 );
1684 CreateFX(
"multiplayer",
"multiplayer", 1000 );
1685 CreateFX(
"influencevision",
"influencevision", 1000 );
1686 CreateFX(
"bloom",
"bloom", 0 );
1705 void FullscreenFXManager::Blendback(
float alpha ) {
1707 if ( alpha < 1.
f ) {
1718 void FullscreenFXManager::Save(
idSaveGame *savefile ) {
1722 for (
int i = 0;
i < fx.Num();
i++ ) {
1723 FullscreenFX *pfx = fx[
i];
1724 pfx->Save( savefile );
1733 void FullscreenFXManager::Restore(
idRestoreGame *savefile ) {
1734 savefile->
ReadBool( highQualityMode );
1737 for (
int i = 0;
i < fx.Num();
i++ ) {
1738 FullscreenFX *pfx = fx[
i];
1739 pfx->Restore( savefile );
1748 void FullscreenFXManager::CaptureCurrentRender() {
1757 void FullscreenFXManager::Process(
const renderView_t *view ) {
1758 bool allpass =
false;
1759 bool atLeastOneFX =
false;
1761 if ( g_testFullscreenFX.GetInteger() == -2 ) {
1765 if ( g_lowresFullscreenFX.GetBool() ) {
1766 highQualityMode =
false;
1769 highQualityMode =
true;
1773 if ( highQualityMode ) {
1774 int vidWidth, vidHeight;
1780 shiftScale.
x = (
float)w / pot;
1784 shiftScale.
y = (
float)h / pot;
1797 for (
int i = 0;
i < fx.Num();
i++ ) {
1798 FullscreenFX *pfx = fx[
i];
1799 bool drawIt =
false;
1802 if ( pfx->Active() || g_testFullscreenFX.GetInteger() ==
i || allpass ) {
1803 drawIt = pfx->SetTriggerState(
true );
1806 drawIt = pfx->SetTriggerState(
false );
1811 atLeastOneFX =
true;
1814 CaptureCurrentRender();
1817 if ( pfx->HasAccum() ) {
1820 if ( highQualityMode ) {
1822 pfx->AccumPass( view );
1826 pfx->AccumPass( view );
1834 Blendback( pfx->GetFadeAlpha() );
1838 if ( !highQualityMode ) {
1840 CaptureCurrentRender();
virtual const idVec3 & GetOrigin(int id=0) const =0
idCVar g_skipViewEffects("g_skipViewEffects","0", CVAR_GAME|CVAR_BOOL,"skip damage and other view effects")
float GetFloat(const char *key, const char *defaultString="0") const
int GetInt(const char *key, const char *defaultString="0") const
assert(prefInfo.fullscreenBtn)
void ReadVec2(idVec2 &vec)
void ReadMaterial(const idMaterial *&material)
void WriteObject(const idClass *obj)
idCVar g_blobSize("g_blobSize","1", CVAR_GAME|CVAR_FLOAT,"")
float GetFloat(void) const
const idMaterial * lagoMaterial
void SetPlayerEntity(class idPlayer *playerEnt)
const idMaterial * material
idCVar g_testHealthVision("g_testHealthVision","0", CVAR_GAME|CVAR_FLOAT,"")
GLenum GLenum GLenum GLenum GLenum scale
idCVar g_dvAmplitude("g_dvAmplitude","0.001", CVAR_GAME|CVAR_FLOAT,"")
idAngles GetAngles(const char *key, const char *defaultString=NULL) const
void RenderPlayerView(idUserInterface *hud)
void WriteVec4(const idVec4 &vec)
idRenderSystem * renderSystem
const idMaterial * GetInfluenceMaterial(void)
idAngles AngleOffset(void) const
static float ClampFloat(float min, float max, float value)
void ReadBool(bool &value)
void Save(idSaveGame *savefile) const
virtual void GetGLSettings(int &width, int &height)=0
GLclampf GLclampf GLclampf alpha
virtual const idMaterial * FindMaterial(const char *name, bool makeDefault=true)=0
idMat3 ShakeAxis(void) const
idSoundWorld * gameSoundWorld
void WriteMaterial(const idMaterial *material)
void WriteBool(const bool value)
void Flash(idVec4 color, int time)
idCVar g_testPostProcess("g_testPostProcess","", CVAR_GAME,"name of material to draw over screen")
const idMaterial * bfgMaterial
void DrawHUD(idUserInterface *hud)
void AddBloodSpray(float duration)
const idMaterial * bloodSprayMaterial
screenBlob_t * GetScreenBlob()
virtual float CurrentShakeAmplitudeForPosition(const int time, const idVec3 &listenerPosition)=0
void SetString(const char *value)
idPhysics * GetPhysics(void) const
const char * GetString(const char *key, const char *defaultString="") const
virtual void CaptureRenderToImage(const char *imageName)=0
GLubyte GLubyte GLubyte GLubyte w
void ReadFloat(float &value)
idCVar net_clientLagOMeter("net_clientLagOMeter","1", CVAR_GAME|CVAR_BOOL|CVAR_NOCHEAT|CVAR_ARCHIVE,"draw prediction graph")
static float Sin(float a)
int powerupEndTime[MAX_POWERUPS]
void WriteFloat(const float value)
idEntity * GetInfluenceEntity(void)
idVec3 firstPersonViewOrigin
void DamageImpulse(idVec3 localKickDir, const idDict *damageDef)
renderView_t * GetRenderView(void)
virtual void Redraw(int time)=0
const idMaterial * armorMaterial
bool PowerUpActive(int powerup) const
void ReadVec4(idVec4 &vec)
float shaderParms[MAX_GLOBAL_SHADER_PARMS]
virtual void SetColor4(float r, float g, float b, float a)=0
virtual void Printf(const char *fmt,...) id_attribute((format(printf
virtual const idDict & State() const =0
virtual void DrawStretchPic(const idDrawVert *verts, const glIndex_t *indexes, int vertCount, int indexCount, const idMaterial *material, bool clip=true, float min_x=0.0f, float min_y=0.0f, float max_x=640.0f, float max_y=480.0f)=0
GLdouble GLdouble GLdouble y2
void WriteInt(const int value)
void WriteRenderView(const renderView_t &view)
idDeclManager * declManager
const char * GetString(void) const
idCVar g_dvTime("g_dvTime","1", CVAR_GAME|CVAR_FLOAT,"")
idCVar g_kickTime("g_kickTime","1", CVAR_GAME|CVAR_FLOAT,"")
idCVar g_dvFrequency("g_dvFrequency","0.5", CVAR_GAME|CVAR_FLOAT,"")
void WeaponFireFeedback(const idDict *weaponDef)
void Fade(idVec4 color, int time)
void WriteAngles(const idAngles &angles)
void SingleView(idUserInterface *hud, const renderView_t *view)
const idMaterial * irGogglesMaterial
float GetInfluenceRadius(void)
idMat3 ToMat3(void) const
void Restore(idRestoreGame *savefile)
idCVar pm_thirdPerson("pm_thirdPerson","0", CVAR_GAME|CVAR_NETWORKSYNC|CVAR_BOOL,"enables third person view")
const idMaterial * berserkMaterial
virtual void PlaceListener(const idVec3 &origin, const idMat3 &axis, const int listenerId, const int gameTime, const idStr &areaName)=0
void ReadRenderView(renderView_t &view)
void WriteVec2(const idVec2 &vec)
virtual void RenderScene(const renderView_t *renderView)=0
void ReadAngles(idAngles &angles)
screenBlob_t screenBlobs[MAX_SCREEN_BLOBS]
void Set(const float x, const float y)
virtual void CropRenderSize(int width, int height, bool makePowerOfTwo=false, bool forceDimensions=false)=0
idRenderWorld * gameRenderWorld
const idMaterial * dvMaterial
idCVar g_kickAmplitude("g_kickAmplitude","0.0001", CVAR_GAME|CVAR_FLOAT,"")
idUserInterface * objectiveSystem
idCVar g_blobTime("g_blobTime","1", CVAR_GAME|CVAR_FLOAT,"")
int MakePowerOfTwo(int num)
void CalculateShake(void)
void Set(const float x, const float y, const float z, const float w)
void ReadObject(idClass *&obj)
virtual void DrawStretchTri(idVec2 p1, idVec2 p2, idVec2 p3, idVec2 t1, idVec2 t2, idVec2 t3, const idMaterial *material)=0
const idMaterial * tunnelMaterial
static float Cos(float a)