2012-11-26 18:58:24 +00:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
|
|
|
|
Doom 3 BFG Edition GPL Source Code
|
2012-11-28 15:47:07 +00:00
|
|
|
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +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.
|
|
|
|
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
|
2012-12-22 15:18:19 +00:00
|
|
|
#include "precompiled.h"
|
2012-11-26 18:58:24 +00:00
|
|
|
#pragma hdrstop
|
|
|
|
|
|
|
|
#include "Game_local.h"
|
|
|
|
|
|
|
|
// _D3XP : rename all gameLocal.time to gameLocal.slow.time for merge!
|
|
|
|
|
|
|
|
const int IMPULSE_DELAY = 150;
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
idPlayerView::idPlayerView
|
|
|
|
==============
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
idPlayerView::idPlayerView()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
memset( screenBlobs, 0, sizeof( screenBlobs ) );
|
|
|
|
memset( &view, 0, sizeof( view ) );
|
|
|
|
player = NULL;
|
|
|
|
tunnelMaterial = declManager->FindMaterial( "textures/decals/tunnel" );
|
|
|
|
armorMaterial = declManager->FindMaterial( "armorViewEffect" );
|
|
|
|
berserkMaterial = declManager->FindMaterial( "textures/decals/berserk" );
|
|
|
|
irGogglesMaterial = declManager->FindMaterial( "textures/decals/irblend" );
|
|
|
|
bloodSprayMaterial = declManager->FindMaterial( "textures/decals/bloodspray" );
|
|
|
|
bfgMaterial = declManager->FindMaterial( "textures/decals/bfgvision" );
|
|
|
|
bfgVision = false;
|
|
|
|
dvFinishTime = 0;
|
|
|
|
kickFinishTime = 0;
|
|
|
|
kickAngles.Zero();
|
|
|
|
lastDamageTime = 0.0f;
|
|
|
|
fadeTime = 0;
|
|
|
|
fadeRate = 0.0;
|
|
|
|
fadeFromColor.Zero();
|
|
|
|
fadeToColor.Zero();
|
|
|
|
fadeColor.Zero();
|
|
|
|
shakeAng.Zero();
|
|
|
|
fxManager = NULL;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( fxManager == NULL )
|
|
|
|
{
|
|
|
|
fxManager = new( TAG_ENTITY ) FullscreenFXManager;
|
2012-11-26 18:58:24 +00:00
|
|
|
fxManager->Initialize( this );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
ClearEffects();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
idPlayerView::~idPlayerView
|
|
|
|
==============
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
idPlayerView::~idPlayerView()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
delete fxManager;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
idPlayerView::Save
|
|
|
|
==============
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idPlayerView::Save( idSaveGame* savefile ) const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int i;
|
2012-11-28 15:47:07 +00:00
|
|
|
const screenBlob_t* blob;
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
blob = &screenBlobs[ 0 ];
|
2012-11-28 15:47:07 +00:00
|
|
|
for( i = 0; i < MAX_SCREEN_BLOBS; i++, blob++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->WriteMaterial( blob->material );
|
|
|
|
savefile->WriteFloat( blob->x );
|
|
|
|
savefile->WriteFloat( blob->y );
|
|
|
|
savefile->WriteFloat( blob->w );
|
|
|
|
savefile->WriteFloat( blob->h );
|
|
|
|
savefile->WriteFloat( blob->s1 );
|
|
|
|
savefile->WriteFloat( blob->t1 );
|
|
|
|
savefile->WriteFloat( blob->s2 );
|
|
|
|
savefile->WriteFloat( blob->t2 );
|
|
|
|
savefile->WriteInt( blob->finishTime );
|
|
|
|
savefile->WriteInt( blob->startFadeTime );
|
|
|
|
savefile->WriteFloat( blob->driftAmount );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->WriteInt( dvFinishTime );
|
|
|
|
savefile->WriteInt( kickFinishTime );
|
|
|
|
savefile->WriteAngles( kickAngles );
|
|
|
|
savefile->WriteBool( bfgVision );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->WriteMaterial( tunnelMaterial );
|
|
|
|
savefile->WriteMaterial( armorMaterial );
|
|
|
|
savefile->WriteMaterial( berserkMaterial );
|
|
|
|
savefile->WriteMaterial( irGogglesMaterial );
|
|
|
|
savefile->WriteMaterial( bloodSprayMaterial );
|
|
|
|
savefile->WriteMaterial( bfgMaterial );
|
|
|
|
savefile->WriteFloat( lastDamageTime );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->WriteVec4( fadeColor );
|
|
|
|
savefile->WriteVec4( fadeToColor );
|
|
|
|
savefile->WriteVec4( fadeFromColor );
|
|
|
|
savefile->WriteFloat( fadeRate );
|
|
|
|
savefile->WriteInt( fadeTime );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->WriteAngles( shakeAng );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->WriteObject( player );
|
|
|
|
savefile->WriteRenderView( view );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( fxManager )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
fxManager->Save( savefile );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
idPlayerView::Restore
|
|
|
|
==============
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idPlayerView::Restore( idRestoreGame* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int i;
|
2012-11-28 15:47:07 +00:00
|
|
|
screenBlob_t* blob;
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
blob = &screenBlobs[ 0 ];
|
2012-11-28 15:47:07 +00:00
|
|
|
for( i = 0; i < MAX_SCREEN_BLOBS; i++, blob++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->ReadMaterial( blob->material );
|
|
|
|
savefile->ReadFloat( blob->x );
|
|
|
|
savefile->ReadFloat( blob->y );
|
|
|
|
savefile->ReadFloat( blob->w );
|
|
|
|
savefile->ReadFloat( blob->h );
|
|
|
|
savefile->ReadFloat( blob->s1 );
|
|
|
|
savefile->ReadFloat( blob->t1 );
|
|
|
|
savefile->ReadFloat( blob->s2 );
|
|
|
|
savefile->ReadFloat( blob->t2 );
|
|
|
|
savefile->ReadInt( blob->finishTime );
|
|
|
|
savefile->ReadInt( blob->startFadeTime );
|
|
|
|
savefile->ReadFloat( blob->driftAmount );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->ReadInt( dvFinishTime );
|
|
|
|
savefile->ReadInt( kickFinishTime );
|
2012-11-28 15:47:07 +00:00
|
|
|
savefile->ReadAngles( kickAngles );
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->ReadBool( bfgVision );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->ReadMaterial( tunnelMaterial );
|
|
|
|
savefile->ReadMaterial( armorMaterial );
|
|
|
|
savefile->ReadMaterial( berserkMaterial );
|
|
|
|
savefile->ReadMaterial( irGogglesMaterial );
|
|
|
|
savefile->ReadMaterial( bloodSprayMaterial );
|
|
|
|
savefile->ReadMaterial( bfgMaterial );
|
|
|
|
savefile->ReadFloat( lastDamageTime );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->ReadVec4( fadeColor );
|
|
|
|
savefile->ReadVec4( fadeToColor );
|
|
|
|
savefile->ReadVec4( fadeFromColor );
|
|
|
|
savefile->ReadFloat( fadeRate );
|
|
|
|
savefile->ReadInt( fadeTime );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->ReadAngles( shakeAng );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
savefile->ReadObject( reinterpret_cast<idClass*&>( player ) );
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->ReadRenderView( view );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( fxManager )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
fxManager->Restore( savefile );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
idPlayerView::SetPlayerEntity
|
|
|
|
==============
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idPlayerView::SetPlayerEntity( idPlayer* playerEnt )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
player = playerEnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
idPlayerView::ClearEffects
|
|
|
|
==============
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idPlayerView::ClearEffects()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
lastDamageTime = MS2SEC( gameLocal.slow.time - 99999 );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
dvFinishTime = ( gameLocal.fast.time - 99999 );
|
|
|
|
kickFinishTime = ( gameLocal.slow.time - 99999 );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
for( int i = 0 ; i < MAX_SCREEN_BLOBS ; i++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
screenBlobs[i].finishTime = gameLocal.fast.time;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
fadeTime = 0;
|
|
|
|
bfgVision = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
idPlayerView::GetScreenBlob
|
|
|
|
==============
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
screenBlob_t* idPlayerView::GetScreenBlob()
|
|
|
|
{
|
|
|
|
screenBlob_t* oldest = &screenBlobs[0];
|
|
|
|
|
|
|
|
for( int i = 1 ; i < MAX_SCREEN_BLOBS ; i++ )
|
|
|
|
{
|
|
|
|
if( screenBlobs[i].finishTime < oldest->finishTime )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
oldest = &screenBlobs[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return oldest;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============
|
|
|
|
idPlayerView::DamageImpulse
|
|
|
|
|
|
|
|
LocalKickDir is the direction of force in the player's coordinate system,
|
|
|
|
which will determine the head kick direction
|
|
|
|
==============
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idPlayerView::DamageImpulse( idVec3 localKickDir, const idDict* damageDef )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
//
|
|
|
|
// double vision effect
|
|
|
|
//
|
2012-11-28 15:47:07 +00:00
|
|
|
if( lastDamageTime > 0.0f && SEC2MS( lastDamageTime ) + IMPULSE_DELAY > gameLocal.slow.time )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// keep shotgun from obliterating the view
|
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
float dvTime = damageDef->GetFloat( "dv_time" );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( dvTime )
|
|
|
|
{
|
|
|
|
if( dvFinishTime < gameLocal.fast.time )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
dvFinishTime = gameLocal.fast.time;
|
|
|
|
}
|
|
|
|
dvFinishTime += g_dvTime.GetFloat() * dvTime;
|
|
|
|
// don't let it add up too much in god mode
|
2012-11-28 15:47:07 +00:00
|
|
|
if( dvFinishTime > gameLocal.fast.time + 5000 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
dvFinishTime = gameLocal.fast.time + 5000;
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
//
|
|
|
|
// head angle kick
|
|
|
|
//
|
|
|
|
float kickTime = damageDef->GetFloat( "kick_time" );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( kickTime )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
kickFinishTime = gameLocal.slow.time + g_kickTime.GetFloat() * kickTime;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// forward / back kick will pitch view
|
|
|
|
kickAngles[0] = localKickDir[0];
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// side kick will yaw view
|
2012-11-28 15:47:07 +00:00
|
|
|
kickAngles[1] = localKickDir[1] * 0.5f;
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// up / down kick will pitch view
|
|
|
|
kickAngles[0] += localKickDir[2];
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// roll will come from side
|
|
|
|
kickAngles[2] = localKickDir[1];
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
float kickAmplitude = damageDef->GetFloat( "kick_amplitude" );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( kickAmplitude )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
kickAngles *= kickAmplitude;
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
//
|
|
|
|
// screen blob
|
|
|
|
//
|
|
|
|
float blobTime = damageDef->GetFloat( "blob_time" );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( blobTime )
|
|
|
|
{
|
|
|
|
screenBlob_t* blob = GetScreenBlob();
|
2012-11-26 18:58:24 +00:00
|
|
|
blob->startFadeTime = gameLocal.fast.time;
|
|
|
|
blob->finishTime = gameLocal.fast.time + blobTime * g_blobTime.GetFloat();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
const char* materialName = damageDef->GetString( "mtr_blob" );
|
2012-11-26 18:58:24 +00:00
|
|
|
blob->material = declManager->FindMaterial( materialName );
|
|
|
|
blob->x = damageDef->GetFloat( "blob_x" );
|
2012-11-28 15:47:07 +00:00
|
|
|
blob->x += ( gameLocal.random.RandomInt() & 63 ) - 32;
|
2012-11-26 18:58:24 +00:00
|
|
|
blob->y = damageDef->GetFloat( "blob_y" );
|
2012-11-28 15:47:07 +00:00
|
|
|
blob->y += ( gameLocal.random.RandomInt() & 63 ) - 32;
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
float scale = ( 256 + ( ( gameLocal.random.RandomInt() & 63 ) - 32 ) ) / 256.0f;
|
2012-11-26 18:58:24 +00:00
|
|
|
blob->w = damageDef->GetFloat( "blob_width" ) * g_blobSize.GetFloat() * scale;
|
|
|
|
blob->h = damageDef->GetFloat( "blob_height" ) * g_blobSize.GetFloat() * scale;
|
|
|
|
blob->s1 = 0.0f;
|
|
|
|
blob->t1 = 0.0f;
|
|
|
|
blob->s2 = 1.0f;
|
|
|
|
blob->t2 = 1.0f;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
//
|
|
|
|
// save lastDamageTime for tunnel vision accentuation
|
|
|
|
//
|
|
|
|
lastDamageTime = MS2SEC( gameLocal.fast.time );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
idPlayerView::WeaponFireFeedback
|
|
|
|
|
|
|
|
Called when a weapon fires, generates head twitches, etc
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idPlayerView::WeaponFireFeedback( const idDict* weaponDef )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int recoilTime = weaponDef->GetInt( "recoilTime" );
|
|
|
|
// don't shorten a damage kick in progress
|
2012-11-28 15:47:07 +00:00
|
|
|
if( recoilTime && kickFinishTime < gameLocal.slow.time )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idAngles angles;
|
|
|
|
weaponDef->GetAngles( "recoilAngles", "5 0 0", angles );
|
|
|
|
kickAngles = angles;
|
|
|
|
int finish = gameLocal.slow.time + g_kickTime.GetFloat() * recoilTime;
|
|
|
|
kickFinishTime = finish;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
idPlayerView::CalculateShake
|
|
|
|
===================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idPlayerView::CalculateShake()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
float shakeVolume = gameSoundWorld->CurrentShakeAmplitude();
|
|
|
|
//
|
|
|
|
// shakeVolume should somehow be molded into an angle here
|
|
|
|
// it should be thought of as being in the range 0.0 -> 1.0, although
|
|
|
|
// since CurrentShakeAmplitudeForPosition() returns all the shake sounds
|
|
|
|
// the player can hear, it can go over 1.0 too.
|
|
|
|
//
|
|
|
|
shakeAng[0] = gameLocal.random.CRandomFloat() * shakeVolume;
|
|
|
|
shakeAng[1] = gameLocal.random.CRandomFloat() * shakeVolume;
|
|
|
|
shakeAng[2] = gameLocal.random.CRandomFloat() * shakeVolume;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
idPlayerView::ShakeAxis
|
|
|
|
===================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
idMat3 idPlayerView::ShakeAxis() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return shakeAng.ToMat3();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
idPlayerView::AngleOffset
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
kickVector, a world space direction that the attack should
|
2012-11-26 18:58:24 +00:00
|
|
|
===================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
idAngles idPlayerView::AngleOffset() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idAngles ang( 0.0f, 0.0f, 0.0f );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( gameLocal.slow.time < kickFinishTime )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
float offset = kickFinishTime - gameLocal.slow.time;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
ang = kickAngles * offset * offset * g_kickAmplitude.GetFloat();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
for( int i = 0 ; i < 3 ; i++ )
|
|
|
|
{
|
|
|
|
if( ang[i] > 70.0f )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
ang[i] = 70.0f;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( ang[i] < -70.0f )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
ang[i] = -70.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ang;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
idPlayerView::SingleView
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idPlayerView::SingleView( const renderView_t* view, idMenuHandler_HUD* hudManager )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
// normal rendering
|
2012-11-28 15:47:07 +00:00
|
|
|
if( !view )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// place the sound origin for the player
|
|
|
|
gameSoundWorld->PlaceListener( view->vieworg, view->viewaxis, player->entityNumber + 1 );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// if the objective system is up, don't do normal drawing
|
2012-11-28 15:47:07 +00:00
|
|
|
if( player->objectiveSystemOpen )
|
|
|
|
{
|
|
|
|
if( player->pdaMenu != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
player->pdaMenu->Update();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// hack the shake in at the very last moment, so it can't cause any consistency problems
|
|
|
|
renderView_t hackedView = *view;
|
|
|
|
hackedView.viewaxis = hackedView.viewaxis * ShakeAxis();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( gameLocal.portalSkyEnt.GetEntity() && gameLocal.IsPortalSkyAcive() && g_enablePortalSky.GetBool() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
renderView_t portalView = hackedView;
|
|
|
|
portalView.vieworg = gameLocal.portalSkyEnt.GetEntity()->GetPhysics()->GetOrigin();
|
|
|
|
gameRenderWorld->RenderScene( &portalView );
|
|
|
|
renderSystem->CaptureRenderToImage( "_currentRender" );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
hackedView.forceUpdate = true; // FIX: for smoke particles not drawing when portalSky present
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// process the frame
|
|
|
|
fxManager->Process( &hackedView );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( !hudManager )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// draw screen blobs
|
2012-11-28 15:47:07 +00:00
|
|
|
if( !pm_thirdPerson.GetBool() && !g_skipViewEffects.GetBool() )
|
|
|
|
{
|
|
|
|
if( !player->spectating )
|
|
|
|
{
|
|
|
|
for( int i = 0 ; i < MAX_SCREEN_BLOBS ; i++ )
|
|
|
|
{
|
|
|
|
screenBlob_t* blob = &screenBlobs[i];
|
|
|
|
if( blob->finishTime <= gameLocal.fast.time )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
continue;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
blob->y += blob->driftAmount;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
float fade = ( float )( blob->finishTime - gameLocal.fast.time ) / ( blob->finishTime - blob->startFadeTime );
|
|
|
|
if( fade > 1.0f )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
fade = 1.0f;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( fade )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, fade );
|
2012-11-28 15:47:07 +00:00
|
|
|
renderSystem->DrawStretchPic( blob->x, blob->y, blob->w, blob->h, blob->s1, blob->t1, blob->s2, blob->t2, blob->material );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
player->DrawHUD( hudManager );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( player->spectating )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// armor impulse feedback
|
|
|
|
float armorPulse = ( gameLocal.fast.time - player->lastArmorPulse ) / 250.0f;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( armorPulse > 0.0f && armorPulse < 1.0f )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f - armorPulse );
|
|
|
|
renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f, 1.0f, armorMaterial );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// tunnel vision
|
|
|
|
float health = 0.0f;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( g_testHealthVision.GetFloat() != 0.0f )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
health = g_testHealthVision.GetFloat();
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
health = player->health;
|
|
|
|
}
|
|
|
|
float alpha = health / 100.0f;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( alpha < 0.0f )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
alpha = 0.0f;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( alpha > 1.0f )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
alpha = 1.0f;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( alpha < 1.0f )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->SetColor4( ( player->health <= 0.0f ) ? MS2SEC( gameLocal.slow.time ) : lastDamageTime, 1.0f, 1.0f, ( player->health <= 0.0f ) ? 0.0f : alpha );
|
|
|
|
renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f, 1.0f, tunnelMaterial );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( bfgVision )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f );
|
|
|
|
renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f, 1.0f, bfgMaterial );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// test a single material drawn over everything
|
2012-11-28 15:47:07 +00:00
|
|
|
if( g_testPostProcess.GetString()[0] )
|
|
|
|
{
|
|
|
|
const idMaterial* mtr = declManager->FindMaterial( g_testPostProcess.GetString(), false );
|
|
|
|
if( !mtr )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
common->Printf( "Material not found.\n" );
|
|
|
|
g_testPostProcess.SetString( "" );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f );
|
|
|
|
renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f, 1.0f, mtr );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
idPlayerView::Flash
|
|
|
|
|
|
|
|
flashes the player view with the given color
|
|
|
|
=================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idPlayerView::Flash( idVec4 color, int time )
|
|
|
|
{
|
|
|
|
Fade( idVec4( 0.0f, 0.0f, 0.0f, 0.0f ), time );
|
2012-11-26 18:58:24 +00:00
|
|
|
fadeFromColor = colorWhite;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
idPlayerView::Fade
|
|
|
|
|
|
|
|
used for level transition fades
|
|
|
|
assumes: color.w is 0 or 1
|
|
|
|
=================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idPlayerView::Fade( idVec4 color, int time )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
SetTimeState ts( player->timeGroup );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( !fadeTime )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
fadeFromColor.Set( 0.0f, 0.0f, 0.0f, 1.0f - color[ 3 ] );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
fadeFromColor = fadeColor;
|
|
|
|
}
|
|
|
|
fadeToColor = color;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( time <= 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
fadeRate = 0;
|
|
|
|
time = 0;
|
|
|
|
fadeColor = fadeToColor;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
fadeRate = 1.0f / ( float )time;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( gameLocal.realClientTime == 0 && time == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
fadeTime = 1;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
fadeTime = gameLocal.realClientTime + time;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
idPlayerView::ScreenFade
|
|
|
|
=================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idPlayerView::ScreenFade()
|
|
|
|
{
|
|
|
|
if( !fadeTime )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
SetTimeState ts( player->timeGroup );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
int msec = fadeTime - gameLocal.realClientTime;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( msec <= 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
fadeColor = fadeToColor;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( fadeColor[ 3 ] == 0.0f )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
fadeTime = 0;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
float t = ( float )msec * fadeRate;
|
|
|
|
fadeColor = fadeFromColor * t + fadeToColor * ( 1.0f - t );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( fadeColor[ 3 ] != 0.0f )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->SetColor4( fadeColor[ 0 ], fadeColor[ 1 ], fadeColor[ 2 ], fadeColor[ 3 ] );
|
|
|
|
renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f, 1.0f, declManager->FindMaterial( "_white" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
idCVar stereoRender_interOccularCentimeters( "stereoRender_interOccularCentimeters", "3.0", CVAR_ARCHIVE | CVAR_RENDERER, "Distance between eyes" );
|
|
|
|
idCVar stereoRender_convergence( "stereoRender_convergence", "6", CVAR_RENDERER, "0 = head mounted display, otherwise world units to convergence plane" );
|
|
|
|
|
|
|
|
extern idCVar stereoRender_screenSeparation; // screen units from center to eyes
|
|
|
|
extern idCVar stereoRender_swapEyes;
|
|
|
|
|
|
|
|
// In a head mounted display with separate displays for each eye,
|
|
|
|
// screen separation will be zero and world separation will be the eye distance.
|
2012-11-28 15:47:07 +00:00
|
|
|
struct stereoDistances_t
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// Offset to projection matrix, positive one eye, negative the other.
|
|
|
|
// Total distance is twice this, so 0.05 would give a 10% of screen width
|
|
|
|
// separation for objects at infinity.
|
2012-11-28 15:47:07 +00:00
|
|
|
float screenSeparation;
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// Game world units from one eye to the centerline.
|
|
|
|
// Total distance is twice this.
|
|
|
|
float worldSeparation;
|
|
|
|
};
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
float CentimetersToInches( const float cm )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return cm / 2.54f;
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
float CentimetersToWorldUnits( const float cm )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// In Doom 3, one world unit == one inch
|
|
|
|
return CentimetersToInches( cm );
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
float CalculateWorldSeparation(
|
|
|
|
const float screenSeparation,
|
|
|
|
const float convergenceDistance,
|
|
|
|
const float fov_x_degrees )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
const float fovRadians = DEG2RAD( fov_x_degrees );
|
|
|
|
const float screen = tan( fovRadians * 0.5f ) * fabs( screenSeparation );
|
|
|
|
const float worldSeparation = screen * convergenceDistance / 0.5f;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return worldSeparation;
|
|
|
|
}
|
|
|
|
|
|
|
|
stereoDistances_t CaclulateStereoDistances(
|
|
|
|
const float interOcularCentimeters, // distance between two eyes, typically 6.0 - 7.0
|
|
|
|
const float screenWidthCentimeters, // read from operating system
|
|
|
|
const float convergenceWorldUnits, // pass 0 for head mounted display mode
|
2012-11-28 15:47:07 +00:00
|
|
|
const float fov_x_degrees ) // edge to edge horizontal field of view, typically 60 - 90
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
stereoDistances_t dists = {};
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( convergenceWorldUnits == 0.0f )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// head mounted display mode
|
|
|
|
dists.worldSeparation = CentimetersToInches( interOcularCentimeters * 0.5 );
|
|
|
|
dists.screenSeparation = 0.0f;
|
|
|
|
return dists;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// 3DTV mode
|
|
|
|
dists.screenSeparation = 0.5f * interOcularCentimeters / screenWidthCentimeters;
|
|
|
|
dists.worldSeparation = CalculateWorldSeparation( dists.screenSeparation, convergenceWorldUnits, fov_x_degrees );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return dists;
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
float GetScreenSeparationForGuis()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
const stereoDistances_t dists = CaclulateStereoDistances(
|
2012-11-28 15:47:07 +00:00
|
|
|
stereoRender_interOccularCentimeters.GetFloat(),
|
|
|
|
renderSystem->GetPhysicalScreenWidthInCentimeters(),
|
|
|
|
stereoRender_convergence.GetFloat(),
|
|
|
|
80.0f /* fov */ );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return dists.screenSeparation;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
idPlayerView::EmitStereoEyeView
|
|
|
|
===================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idPlayerView::EmitStereoEyeView( const int eye, idMenuHandler_HUD* hudManager )
|
|
|
|
{
|
|
|
|
renderView_t* view = player->GetRenderView();
|
|
|
|
if( view == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
renderView_t eyeView = *view;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
const stereoDistances_t dists = CaclulateStereoDistances(
|
2012-11-28 15:47:07 +00:00
|
|
|
stereoRender_interOccularCentimeters.GetFloat(),
|
|
|
|
renderSystem->GetPhysicalScreenWidthInCentimeters(),
|
|
|
|
stereoRender_convergence.GetFloat(),
|
|
|
|
view->fov_x );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
eyeView.vieworg += eye * dists.worldSeparation * eyeView.viewaxis[1];
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
eyeView.viewEyeBuffer = stereoRender_swapEyes.GetBool() ? eye : -eye;
|
|
|
|
eyeView.stereoScreenSeparation = eye * dists.screenSeparation;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
SingleView( &eyeView, hudManager );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
IsGameStereoRendered
|
|
|
|
|
|
|
|
The crosshair is swapped for a laser sight in stereo rendering
|
|
|
|
===================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool IsGameStereoRendered()
|
|
|
|
{
|
|
|
|
if( renderSystem->GetStereo3DMode() != STEREO3D_OFF )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
int EyeForHalfRateFrame( const int frameCount )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return ( renderSystem->GetFrameCount() & 1 ) ? -1 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
idPlayerView::RenderPlayerView
|
|
|
|
===================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idPlayerView::RenderPlayerView( idMenuHandler_HUD* hudManager )
|
|
|
|
{
|
|
|
|
const renderView_t* view = player->GetRenderView();
|
|
|
|
if( renderSystem->GetStereo3DMode() != STEREO3D_OFF )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// render both eye views each frame on the PC
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int eye = 1 ; eye >= -1 ; eye -= 2 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
EmitStereoEyeView( eye, hudManager );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
2012-11-26 18:58:24 +00:00
|
|
|
{
|
|
|
|
SingleView( view, hudManager );
|
|
|
|
}
|
|
|
|
ScreenFade();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
idPlayerView::WarpVision
|
|
|
|
===================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
int idPlayerView::AddWarp( idVec3 worldOrigin, float centerx, float centery, float initialRadius, float durationMsec )
|
|
|
|
{
|
|
|
|
FullscreenFX_Warp* fx = ( FullscreenFX_Warp* )( fxManager->FindFX( "warp" ) );
|
|
|
|
|
|
|
|
if( fx )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
fx->EnableGrabber( true );
|
|
|
|
return 1;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void idPlayerView::FreeWarp( int id )
|
|
|
|
{
|
|
|
|
FullscreenFX_Warp* fx = ( FullscreenFX_Warp* )( fxManager->FindFX( "warp" ) );
|
|
|
|
|
|
|
|
if( fx )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
fx->EnableGrabber( false );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FxFader::FxFader
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
FxFader::FxFader()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
time = 0;
|
|
|
|
state = FX_STATE_OFF;
|
|
|
|
alpha = 0;
|
|
|
|
msec = 1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FxFader::SetTriggerState
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool FxFader::SetTriggerState( bool active )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
// handle on/off states
|
2012-11-28 15:47:07 +00:00
|
|
|
if( active && state == FX_STATE_OFF )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
state = FX_STATE_RAMPUP;
|
|
|
|
time = gameLocal.slow.time + msec;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
else if( !active && state == FX_STATE_ON )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
state = FX_STATE_RAMPDOWN;
|
|
|
|
time = gameLocal.slow.time + msec;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// handle rampup/rampdown states
|
2012-11-28 15:47:07 +00:00
|
|
|
if( state == FX_STATE_RAMPUP )
|
|
|
|
{
|
|
|
|
if( gameLocal.slow.time >= time )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
state = FX_STATE_ON;
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
else if( state == FX_STATE_RAMPDOWN )
|
|
|
|
{
|
|
|
|
if( gameLocal.slow.time >= time )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
state = FX_STATE_OFF;
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// compute alpha
|
2012-11-28 15:47:07 +00:00
|
|
|
switch( state )
|
|
|
|
{
|
|
|
|
case FX_STATE_ON:
|
|
|
|
alpha = 1;
|
|
|
|
break;
|
|
|
|
case FX_STATE_OFF:
|
|
|
|
alpha = 0;
|
|
|
|
break;
|
|
|
|
case FX_STATE_RAMPUP:
|
|
|
|
alpha = 1 - ( float )( time - gameLocal.slow.time ) / msec;
|
|
|
|
break;
|
|
|
|
case FX_STATE_RAMPDOWN:
|
|
|
|
alpha = ( float )( time - gameLocal.slow.time ) / msec;
|
|
|
|
break;
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( alpha > 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FxFader::Save
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FxFader::Save( idSaveGame* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->WriteInt( time );
|
|
|
|
savefile->WriteInt( state );
|
|
|
|
savefile->WriteFloat( alpha );
|
|
|
|
savefile->WriteInt( msec );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FxFader::Restore
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FxFader::Restore( idRestoreGame* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->ReadInt( time );
|
|
|
|
savefile->ReadInt( state );
|
|
|
|
savefile->ReadFloat( alpha );
|
|
|
|
savefile->ReadInt( msec );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Helltime::Save
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX::Save( idSaveGame* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
fader.Save( savefile );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Helltime::Restore
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX::Restore( idRestoreGame* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
fader.Restore( savefile );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Helltime::Initialize
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_Helltime::Initialize()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
initMaterial = declManager->FindMaterial( "textures/d3bfg/bloodorb/init" );
|
|
|
|
drawMaterial = declManager->FindMaterial( "textures/d3bfg/bloodorb/draw" );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
captureMaterials[0] = declManager->FindMaterial( "textures/d3bfg/bloodorb1/capture" );
|
|
|
|
captureMaterials[1] = declManager->FindMaterial( "textures/d3bfg/bloodorb2/capture" );
|
|
|
|
captureMaterials[2] = declManager->FindMaterial( "textures/d3bfg/bloodorb3/capture" );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
clearAccumBuffer = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Helltime::DetermineLevel
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
int FullscreenFX_Helltime::DetermineLevel()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int testfx = g_testHelltimeFX.GetInteger();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// for testing purposes
|
2012-11-28 15:47:07 +00:00
|
|
|
if( testfx >= 0 && testfx < 3 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return testfx;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idPlayer* player = fxman->GetPlayer();
|
|
|
|
|
|
|
|
if( player != NULL && player->PowerUpActive( INVULNERABILITY ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return 2;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
else if( player != NULL && player->PowerUpActive( BERSERK ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
else if( player != NULL && player->PowerUpActive( HELLTIME ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Helltime::Active
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool FullscreenFX_Helltime::Active()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
if( gameLocal.inCinematic || common->IsMultiplayer() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( DetermineLevel() >= 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// latch the clear flag
|
2012-11-28 15:47:07 +00:00
|
|
|
if( fader.GetAlpha() == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
clearAccumBuffer = true;
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Helltime::AccumPass
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_Helltime::AccumPass( const renderView_t* view )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
int level = DetermineLevel();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// for testing
|
2012-11-28 15:47:07 +00:00
|
|
|
if( level < 0 || level > 2 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
level = 0;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
float t0 = 1.0f;
|
|
|
|
float t1 = 0.0f;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// capture pass
|
2012-11-28 15:47:07 +00:00
|
|
|
if( clearAccumBuffer )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
clearAccumBuffer = false;
|
|
|
|
renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, t0, 1.0f, t1, initMaterial );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, t0, 1.0f, t1, captureMaterials[level] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Helltime::HighQuality
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_Helltime::HighQuality()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
float t0 = 1.0f;
|
|
|
|
float t1 = 0.0f;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f );
|
|
|
|
renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, t0, 1.0f, t1, drawMaterial );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Helltime::Restore
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_Helltime::Restore( idRestoreGame* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
FullscreenFX::Restore( savefile );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// latch the clear flag
|
|
|
|
clearAccumBuffer = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Multiplayer::Initialize
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_Multiplayer::Initialize()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
initMaterial = declManager->FindMaterial( "textures/d3bfg/multiplayer/init" );
|
|
|
|
captureMaterial = declManager->FindMaterial( "textures/d3bfg/multiplayer/capture" );
|
|
|
|
drawMaterial = declManager->FindMaterial( "textures/d3bfg/bloodorb/draw" );
|
|
|
|
clearAccumBuffer = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Multiplayer::DetermineLevel
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
int FullscreenFX_Multiplayer::DetermineLevel()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int testfx = g_testMultiplayerFX.GetInteger();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// for testing purposes
|
2012-11-28 15:47:07 +00:00
|
|
|
if( testfx >= 0 && testfx < 3 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return testfx;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idPlayer* player = fxman->GetPlayer();
|
|
|
|
|
|
|
|
if( player != NULL && player->PowerUpActive( INVULNERABILITY ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
//else if ( player->PowerUpActive( HASTE ) ) {
|
|
|
|
// return 1;
|
|
|
|
//}
|
2012-11-28 15:47:07 +00:00
|
|
|
else if( player != NULL && player->PowerUpActive( BERSERK ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Multiplayer::Active
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool FullscreenFX_Multiplayer::Active()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
if( !common->IsMultiplayer() && g_testMultiplayerFX.GetInteger() == -1 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( DetermineLevel() >= 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// latch the clear flag
|
2012-11-28 15:47:07 +00:00
|
|
|
if( fader.GetAlpha() == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
clearAccumBuffer = true;
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Multiplayer::AccumPass
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_Multiplayer::AccumPass( const renderView_t* view )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f );
|
|
|
|
|
|
|
|
float t0 = 1.0f;
|
|
|
|
float t1 = 0.0f;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// capture pass
|
2012-11-28 15:47:07 +00:00
|
|
|
if( clearAccumBuffer )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
clearAccumBuffer = false;
|
|
|
|
renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, t0, 1.0f, t1, initMaterial );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, t0, 1.0f, t1, captureMaterial );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Multiplayer::HighQuality
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_Multiplayer::HighQuality()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
float t0 = 1.0f;
|
|
|
|
float t1 = 0.0f;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f );
|
|
|
|
renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, t0, 1.0f, t1, drawMaterial );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Multiplayer::Restore
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_Multiplayer::Restore( idRestoreGame* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
FullscreenFX::Restore( savefile );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// latch the clear flag
|
|
|
|
clearAccumBuffer = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Warp::Initialize
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_Warp::Initialize()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
material = declManager->FindMaterial( "textures/d3bfg/warp" );
|
|
|
|
grabberEnabled = false;
|
|
|
|
startWarpTime = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Warp::Active
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool FullscreenFX_Warp::Active()
|
|
|
|
{
|
|
|
|
if( grabberEnabled )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Warp::Save
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_Warp::Save( idSaveGame* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
FullscreenFX::Save( savefile );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->WriteBool( grabberEnabled );
|
|
|
|
savefile->WriteInt( startWarpTime );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Warp::Restore
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_Warp::Restore( idRestoreGame* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
FullscreenFX::Restore( savefile );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->ReadBool( grabberEnabled );
|
|
|
|
savefile->ReadInt( startWarpTime );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Warp::DrawWarp
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_Warp::DrawWarp( WarpPolygon_t wp, float interp )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idVec4 mid1_uv, mid2_uv;
|
|
|
|
idVec4 mid1, mid2;
|
|
|
|
idVec2 drawPts[6];
|
|
|
|
WarpPolygon_t trans;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
trans = wp;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// compute mid points
|
|
|
|
mid1 = trans.outer1 * ( interp ) + trans.center * ( 1 - interp );
|
|
|
|
mid2 = trans.outer2 * ( interp ) + trans.center * ( 1 - interp );
|
|
|
|
mid1_uv = trans.outer1 * ( 0.5 ) + trans.center * ( 1 - 0.5 );
|
|
|
|
mid2_uv = trans.outer2 * ( 0.5 ) + trans.center * ( 1 - 0.5 );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// draw [outer1, mid2, mid1]
|
|
|
|
drawPts[0].Set( trans.outer1.x, trans.outer1.y );
|
|
|
|
drawPts[1].Set( mid2.x, mid2.y );
|
|
|
|
drawPts[2].Set( mid1.x, mid1.y );
|
|
|
|
drawPts[3].Set( trans.outer1.z, trans.outer1.w );
|
|
|
|
drawPts[4].Set( mid2_uv.z, mid2_uv.w );
|
|
|
|
drawPts[5].Set( mid1_uv.z, mid1_uv.w );
|
|
|
|
renderSystem->DrawStretchTri( drawPts[0], drawPts[1], drawPts[2], drawPts[3], drawPts[4], drawPts[5], material );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// draw [outer1, outer2, mid2]
|
|
|
|
drawPts[0].Set( trans.outer1.x, trans.outer1.y );
|
|
|
|
drawPts[1].Set( trans.outer2.x, trans.outer2.y );
|
|
|
|
drawPts[2].Set( mid2.x, mid2.y );
|
|
|
|
drawPts[3].Set( trans.outer1.z, trans.outer1.w );
|
|
|
|
drawPts[4].Set( trans.outer2.z, trans.outer2.w );
|
|
|
|
drawPts[5].Set( mid2_uv.z, mid2_uv.w );
|
|
|
|
renderSystem->DrawStretchTri( drawPts[0], drawPts[1], drawPts[2], drawPts[3], drawPts[4], drawPts[5], material );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// draw [mid1, mid2, center]
|
|
|
|
drawPts[0].Set( mid1.x, mid1.y );
|
|
|
|
drawPts[1].Set( mid2.x, mid2.y );
|
|
|
|
drawPts[2].Set( trans.center.x, trans.center.y );
|
|
|
|
drawPts[3].Set( mid1_uv.z, mid1_uv.w );
|
|
|
|
drawPts[4].Set( mid2_uv.z, mid2_uv.w );
|
|
|
|
drawPts[5].Set( trans.center.z, trans.center.w );
|
|
|
|
renderSystem->DrawStretchTri( drawPts[0], drawPts[1], drawPts[2], drawPts[3], drawPts[4], drawPts[5], material );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Warp::HighQuality
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_Warp::HighQuality()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
float x1, y1, x2, y2, radius, interp;
|
|
|
|
idVec2 center;
|
|
|
|
int STEP = 9;
|
|
|
|
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
interp = ( idMath::Sin( ( float )( gameLocal.slow.time - startWarpTime ) / 1000 ) + 1 ) / 2.f;
|
2012-11-26 18:58:24 +00:00
|
|
|
interp = 0.7 * ( 1 - interp ) + 0.3 * ( interp );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// draw the warps
|
|
|
|
center.x = 320;
|
|
|
|
center.y = 240;
|
|
|
|
radius = 200;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
for( float i = 0; i < 360; i += STEP )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// compute the values
|
|
|
|
x1 = idMath::Sin( DEG2RAD( i ) );
|
|
|
|
y1 = idMath::Cos( DEG2RAD( i ) );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
x2 = idMath::Sin( DEG2RAD( i + STEP ) );
|
|
|
|
y2 = idMath::Cos( DEG2RAD( i + STEP ) );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// add warp polygon
|
|
|
|
WarpPolygon_t p;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
p.outer1.x = center.x + x1 * radius;
|
|
|
|
p.outer1.y = center.y + y1 * radius;
|
2012-11-28 15:47:07 +00:00
|
|
|
p.outer1.z = p.outer1.x / ( float )SCREEN_WIDTH;
|
|
|
|
p.outer1.w = 1 - ( p.outer1.y / ( float )SCREEN_HEIGHT );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
p.outer2.x = center.x + x2 * radius;
|
|
|
|
p.outer2.y = center.y + y2 * radius;
|
2012-11-28 15:47:07 +00:00
|
|
|
p.outer2.z = p.outer2.x / ( float )SCREEN_WIDTH;
|
|
|
|
p.outer2.w = 1 - ( p.outer2.y / ( float )SCREEN_HEIGHT );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
p.center.x = center.x;
|
|
|
|
p.center.y = center.y;
|
2012-11-28 15:47:07 +00:00
|
|
|
p.center.z = p.center.x / ( float )SCREEN_WIDTH;
|
|
|
|
p.center.w = 1 - ( p.center.y / ( float )SCREEN_HEIGHT );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// draw it
|
|
|
|
DrawWarp( p, interp );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_EnviroSuit::Initialize
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_EnviroSuit::Initialize()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
material = declManager->FindMaterial( "textures/d3bfg/enviro_suit" );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_EnviroSuit::Active
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool FullscreenFX_EnviroSuit::Active()
|
|
|
|
{
|
|
|
|
idPlayer* player = fxman->GetPlayer();
|
|
|
|
|
|
|
|
if( player != NULL && player->PowerUpActive( ENVIROSUIT ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_EnviroSuit::HighQuality
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_EnviroSuit::HighQuality()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f );
|
|
|
|
float s0 = 0.0f;
|
|
|
|
float t0 = 1.0f;
|
|
|
|
float s1 = 1.0f;
|
|
|
|
float t1 = 0.0f;
|
|
|
|
renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, s0, t0, s1, t1, material );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_DoubleVision::Initialize
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_DoubleVision::Initialize()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
material = declManager->FindMaterial( "textures/d3bfg/doubleVision" );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_DoubleVision::Active
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool FullscreenFX_DoubleVision::Active()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
if( gameLocal.fast.time < fxman->GetPlayerView()->dvFinishTime )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_DoubleVision::HighQuality
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_DoubleVision::HighQuality()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int offset = fxman->GetPlayerView()->dvFinishTime - gameLocal.fast.time;
|
|
|
|
float scale = offset * g_dvAmplitude.GetFloat();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// for testing purposes
|
2012-11-28 15:47:07 +00:00
|
|
|
if( !Active() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
static int test = 0;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( test > 312 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
test = 0;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
offset = test++;
|
|
|
|
scale = offset * g_dvAmplitude.GetFloat();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idPlayer* player = fxman->GetPlayer();
|
|
|
|
|
|
|
|
if( player == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
offset *= 2; // crutch up for higher res
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// set the scale and shift
|
2012-11-28 15:47:07 +00:00
|
|
|
if( scale > 0.5f )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
scale = 0.5f;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
float shift = scale * sin( sqrtf( ( float )offset ) * g_dvFrequency.GetFloat() );
|
2012-11-26 18:58:24 +00:00
|
|
|
shift = fabs( shift );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// carry red tint if in berserk mode
|
|
|
|
idVec4 color( 1.0f, 1.0f, 1.0f, 1.0f );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( gameLocal.fast.time < player->inventory.powerupEndTime[ BERSERK ] )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
color.y = 0.0f;
|
|
|
|
color.z = 0.0f;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( !common->IsMultiplayer() && gameLocal.fast.time < player->inventory.powerupEndTime[ HELLTIME ] || gameLocal.fast.time < player->inventory.powerupEndTime[ INVULNERABILITY ] )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
color.y = 0.0f;
|
|
|
|
color.z = 0.0f;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// uv coordinates
|
|
|
|
float s0 = shift;
|
|
|
|
float t0 = 1.0f;
|
|
|
|
float s1 = 1.0f;
|
|
|
|
float t1 = 0.0f;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->SetColor4( color.x, color.y, color.z, 1.0f );
|
|
|
|
renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, s0, t0, s1, t1, material );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->SetColor4( color.x, color.y, color.z, 0.5f );
|
|
|
|
s0 = 0.0f;
|
|
|
|
t0 = 1.0f;
|
2012-11-28 15:47:07 +00:00
|
|
|
s1 = ( 1.0 - shift );
|
2012-11-26 18:58:24 +00:00
|
|
|
t1 = 0.0f;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, s0, t0, s1, t1, material );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_InfluenceVision::Initialize
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_InfluenceVision::Initialize()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_InfluenceVision::Active
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool FullscreenFX_InfluenceVision::Active()
|
|
|
|
{
|
|
|
|
idPlayer* player = fxman->GetPlayer();
|
|
|
|
|
|
|
|
if( player != NULL && ( player->GetInfluenceMaterial() || player->GetInfluenceEntity() ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_InfluenceVision::HighQuality
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_InfluenceVision::HighQuality()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
float distance = 0.0f;
|
|
|
|
float pct = 1.0f;
|
2012-11-28 15:47:07 +00:00
|
|
|
idPlayer* player = fxman->GetPlayer();
|
|
|
|
|
|
|
|
if( player == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( player->GetInfluenceEntity() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
distance = ( player->GetInfluenceEntity()->GetPhysics()->GetOrigin() - player->GetPhysics()->GetOrigin() ).Length();
|
2012-11-28 15:47:07 +00:00
|
|
|
if( player->GetInfluenceRadius() != 0.0f && distance < player->GetInfluenceRadius() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
pct = distance / player->GetInfluenceRadius();
|
|
|
|
pct = 1.0f - idMath::ClampFloat( 0.0f, 1.0f, pct );
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( player->GetInfluenceMaterial() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, pct );
|
|
|
|
renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f, 1.0f, player->GetInfluenceMaterial() );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( player->GetInfluenceEntity() == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// int offset = 25 + sinf( gameLocal.slow.time );
|
|
|
|
// DoubleVision( hud, view, pct * offset );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Bloom::Initialize
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_Bloom::Initialize()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
drawMaterial = declManager->FindMaterial( "textures/d3bfg/bloom2/draw" );
|
|
|
|
initMaterial = declManager->FindMaterial( "textures/d3bfg/bloom2/init" );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
currentIntensity = 0;
|
|
|
|
targetIntensity = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Bloom::Active
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool FullscreenFX_Bloom::Active()
|
|
|
|
{
|
|
|
|
idPlayer* player = fxman->GetPlayer();
|
|
|
|
|
|
|
|
if( player != NULL && player->bloomEnabled )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Bloom::HighQuality
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_Bloom::HighQuality()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
float shift = 1;
|
2012-11-28 15:47:07 +00:00
|
|
|
idPlayer* player = fxman->GetPlayer();
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// if intensity value is different, start the blend
|
|
|
|
targetIntensity = g_testBloomIntensity.GetFloat();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( player != NULL && player->bloomEnabled )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
targetIntensity = player->bloomIntensity;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
float delta = targetIntensity - currentIntensity;
|
|
|
|
float step = 0.001f;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( step < fabs( delta ) )
|
|
|
|
{
|
|
|
|
if( delta < 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
step = -step;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
currentIntensity += step;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// draw the blends
|
|
|
|
int num = g_testBloomNumPasses.GetInteger();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
for( int i = 0; i < num; i++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
float s1 = 0.0f, t1 = 0.0f, s2 = 1.0f, t2 = 1.0f;
|
|
|
|
float alpha;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// do the center scale
|
|
|
|
s1 -= 0.5;
|
|
|
|
s1 *= shift;
|
|
|
|
s1 += 0.5;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
t1 -= 0.5;
|
|
|
|
t1 *= shift;
|
|
|
|
t1 += 0.5;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
s2 -= 0.5;
|
|
|
|
s2 *= shift;
|
|
|
|
s2 += 0.5;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
t2 -= 0.5;
|
|
|
|
t2 *= shift;
|
|
|
|
t2 += 0.5;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// draw it
|
2012-11-28 15:47:07 +00:00
|
|
|
if( num == 1 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
alpha = 1;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
alpha = 1 - ( float )i / ( num - 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
float yScale = 1.0f;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->SetColor4( alpha, alpha, alpha, 1 );
|
|
|
|
renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, s1, t2 * yScale, s2, t1 * yScale, drawMaterial );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
shift += currentIntensity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Bloom::Save
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_Bloom::Save( idSaveGame* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
FullscreenFX::Save( savefile );
|
|
|
|
savefile->WriteFloat( currentIntensity );
|
|
|
|
savefile->WriteFloat( targetIntensity );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFX_Bloom::Restore
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFX_Bloom::Restore( idRestoreGame* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
FullscreenFX::Restore( savefile );
|
|
|
|
savefile->ReadFloat( currentIntensity );
|
|
|
|
savefile->ReadFloat( targetIntensity );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFXManager::FullscreenFXManager
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
FullscreenFXManager::FullscreenFXManager()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
playerView = NULL;
|
|
|
|
blendBackMaterial = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFXManager::~FullscreenFXManager
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
FullscreenFXManager::~FullscreenFXManager()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
fx.DeleteContents();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFXManager::FindFX
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
FullscreenFX* FullscreenFXManager::FindFX( idStr name )
|
|
|
|
{
|
|
|
|
for( int i = 0; i < fx.Num(); i++ )
|
|
|
|
{
|
|
|
|
if( fx[i]->GetName() == name )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return fx[i];
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFXManager::CreateFX
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFXManager::CreateFX( idStr name, idStr fxtype, int fade )
|
|
|
|
{
|
|
|
|
FullscreenFX* pfx = NULL;
|
|
|
|
|
|
|
|
if( fxtype == "helltime" )
|
|
|
|
{
|
|
|
|
pfx = new( TAG_FX ) FullscreenFX_Helltime;
|
|
|
|
}
|
|
|
|
else if( fxtype == "warp" )
|
|
|
|
{
|
|
|
|
pfx = new( TAG_FX ) FullscreenFX_Warp;
|
|
|
|
}
|
|
|
|
else if( fxtype == "envirosuit" )
|
|
|
|
{
|
|
|
|
pfx = new( TAG_FX ) FullscreenFX_EnviroSuit;
|
|
|
|
}
|
|
|
|
else if( fxtype == "doublevision" )
|
|
|
|
{
|
|
|
|
pfx = new( TAG_FX ) FullscreenFX_DoubleVision;
|
|
|
|
}
|
|
|
|
else if( fxtype == "multiplayer" )
|
|
|
|
{
|
|
|
|
pfx = new( TAG_FX ) FullscreenFX_Multiplayer;
|
|
|
|
}
|
|
|
|
else if( fxtype == "influencevision" )
|
|
|
|
{
|
|
|
|
pfx = new( TAG_FX ) FullscreenFX_InfluenceVision;
|
|
|
|
}
|
|
|
|
else if( fxtype == "bloom" )
|
|
|
|
{
|
|
|
|
pfx = new( TAG_FX ) FullscreenFX_Bloom;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
assert( 0 );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( pfx )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
pfx->Initialize();
|
|
|
|
pfx->SetFXManager( this );
|
|
|
|
pfx->SetName( name );
|
|
|
|
pfx->SetFadeSpeed( fade );
|
|
|
|
fx.Append( pfx );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFXManager::Initialize
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFXManager::Initialize( idPlayerView* pv )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// set the playerview
|
|
|
|
playerView = pv;
|
|
|
|
blendBackMaterial = declManager->FindMaterial( "textures/d3bfg/blendBack" );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// allocate the fx
|
|
|
|
CreateFX( "helltime", "helltime", 1000 );
|
|
|
|
CreateFX( "warp", "warp", 0 );
|
|
|
|
CreateFX( "envirosuit", "envirosuit", 500 );
|
|
|
|
CreateFX( "doublevision", "doublevision", 0 );
|
|
|
|
CreateFX( "multiplayer", "multiplayer", 1000 );
|
|
|
|
CreateFX( "influencevision", "influencevision", 1000 );
|
|
|
|
CreateFX( "bloom", "bloom", 0 );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// pre-cache the texture grab so we dont hitch
|
|
|
|
renderSystem->CropRenderSize( 512, 512 );
|
|
|
|
renderSystem->CaptureRenderToImage( "_accum" );
|
|
|
|
renderSystem->UnCrop();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->CaptureRenderToImage( "_currentRender" );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFXManager::Blendback
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFXManager::Blendback( float alpha )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// alpha fade
|
2012-11-28 15:47:07 +00:00
|
|
|
if( alpha < 1.f )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f - alpha );
|
|
|
|
float s0 = 0.0f;
|
|
|
|
float t0 = 1.0f;
|
|
|
|
float s1 = 1.0f;
|
|
|
|
float t1 = 0.0f;
|
|
|
|
renderSystem->DrawStretchPic( 0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, s0, t0, s1, t1, blendBackMaterial );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFXManager::Save
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFXManager::Save( idSaveGame* savefile )
|
|
|
|
{
|
|
|
|
for( int i = 0; i < fx.Num(); i++ )
|
|
|
|
{
|
|
|
|
FullscreenFX* pfx = fx[i];
|
2012-11-26 18:58:24 +00:00
|
|
|
pfx->Save( savefile );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFXManager::Restore
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFXManager::Restore( idRestoreGame* savefile )
|
|
|
|
{
|
|
|
|
for( int i = 0; i < fx.Num(); i++ )
|
|
|
|
{
|
|
|
|
FullscreenFX* pfx = fx[i];
|
2012-11-26 18:58:24 +00:00
|
|
|
pfx->Restore( savefile );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
idCVar player_allowScreenFXInStereo( "player_allowScreenFXInStereo", "1", CVAR_BOOL, "allow full screen fx in stereo mode" );
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
FullscreenFXManager::Process
|
|
|
|
==================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void FullscreenFXManager::Process( const renderView_t* view )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
bool allpass = false;
|
|
|
|
bool atLeastOneFX = false;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( g_testFullscreenFX.GetInteger() == -2 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
allpass = true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// do the first render
|
|
|
|
gameRenderWorld->RenderScene( view );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// we should consider these on a case-by-case basis for stereo rendering
|
|
|
|
// double vision could be implemented "for real" by shifting the
|
|
|
|
// eye views
|
2012-11-28 15:47:07 +00:00
|
|
|
if( IsGameStereoRendered() && !player_allowScreenFXInStereo.GetBool() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// do the process
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int i = 0; i < fx.Num(); i++ )
|
|
|
|
{
|
|
|
|
FullscreenFX* pfx = fx[i];
|
2012-11-26 18:58:24 +00:00
|
|
|
bool drawIt = false;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// determine if we need to draw
|
2012-11-28 15:47:07 +00:00
|
|
|
if( pfx->Active() || g_testFullscreenFX.GetInteger() == i || allpass )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
drawIt = pfx->SetTriggerState( true );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
drawIt = pfx->SetTriggerState( false );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// do the actual drawing
|
2012-11-28 15:47:07 +00:00
|
|
|
if( drawIt )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
atLeastOneFX = true;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// we need to dump to _currentRender
|
|
|
|
renderSystem->CaptureRenderToImage( "_currentRender" );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// handle the accum pass if we have one
|
2012-11-28 15:47:07 +00:00
|
|
|
if( pfx->HasAccum() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// we need to crop the accum pass
|
|
|
|
renderSystem->CropRenderSize( 512, 512 );
|
|
|
|
pfx->AccumPass( view );
|
|
|
|
renderSystem->CaptureRenderToImage( "_accum" );
|
|
|
|
renderSystem->UnCrop();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// do the high quality pass
|
|
|
|
pfx->HighQuality();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// do the blendback
|
|
|
|
Blendback( pfx->GetFadeAlpha() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|