/* ================== idPlayerView::SingleView ================== */ void idPlayerView::SingleView( idUserInterface *hud, const renderView_t *view ) { // normal rendering if ( !view ) { return; } // place the sound origin for the player gameSoundWorld->PlaceListener( view->vieworg, view->viewaxis, player->entityNumber + 1, gameLocal.time, hud ? hud->State().GetString( "location" ) : "Undefined" ); // if the objective system is up, don't do normal drawing if ( player->objectiveSystemOpen ) { player->objectiveSystem->Redraw( gameLocal.time ); return; } // 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(); gameRenderWorld->RenderScene( &hackedView ); if ( player->spectating ) { return; } // draw screen blobs if ( !pm_thirdPerson.GetBool() && !g_skipViewEffects.GetBool() ) { for ( int i = 0 ; i < MAX_SCREEN_BLOBS ; i++ ) { screenBlob_t *blob = &screenBlobs[i]; if ( blob->finishTime <= gameLocal.time ) { continue; } blob->y += blob->driftAmount; float fade = (float)( blob->finishTime - gameLocal.time ) / ( blob->finishTime - blob->startFadeTime ); if ( fade > 1.0f ) { fade = 1.0f; } if ( fade ) { renderSystem->SetColor4( 1,1,1,fade ); renderSystem->DrawStretchPic( blob->x, blob->y, blob->w, blob->h,blob->s1, blob->t1, blob->s2, blob->t2, blob->material ); } } player->DrawHUD( hud ); // armor impulse feedback float armorPulse = ( gameLocal.time - player->lastArmorPulse ) / 250.0f; if ( armorPulse > 0.0f && armorPulse < 1.0f ) { renderSystem->SetColor4( 1, 1, 1, 1.0 - armorPulse ); renderSystem->DrawStretchPic( 0, 0, 640, 480, 0, 0, 1, 1, armorMaterial ); } // tunnel vision float health = 0.0f; if ( g_testHealthVision.GetFloat() != 0.0f ) { health = g_testHealthVision.GetFloat(); } else { health = player->health; } float alpha = health / 100.0f; if ( alpha < 0.0f ) { alpha = 0.0f; } if ( alpha > 1.0f ) { alpha = 1.0f; } if ( alpha < 1.0f ) { renderSystem->SetColor4( ( player->health <= 0.0f ) ? MS2SEC( gameLocal.time ) : lastDamageTime, 1.0f, 1.0f, ( player->health <= 0.0f ) ? 0.0f : alpha ); renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, tunnelMaterial ); } if ( player->PowerUpActive(BERSERK) ) { int berserkTime = player->inventory.powerupEndTime[ BERSERK ] - gameLocal.time; if ( berserkTime > 0 ) { // start fading if within 10 seconds of going away alpha = (berserkTime < 10000) ? (float)berserkTime / 10000 : 1.0f; renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, alpha ); renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, berserkMaterial ); } } if ( bfgVision ) { renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, bfgMaterial ); } } // test a single material drawn over everything if ( g_testPostProcess.GetString()[0] ) { const idMaterial *mtr = declManager->FindMaterial( g_testPostProcess.GetString(), false ); if ( !mtr ) { common->Printf( "Material not found.\n" ); g_testPostProcess.SetString( "" ); } else { renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, mtr ); } } }
/* ================== idPlayerView::SingleView ================== */ void idPlayerView::SingleView( idUserInterface *hud, const renderView_t *view ) { // normal rendering if ( !view ) { return; } // place the sound origin for the player gameSoundWorld->PlaceListener( view->vieworg, view->viewaxis, player->entityNumber + 1, gameLocal.slow.time, hud ? hud->State().GetString( "location" ) : "Undefined" ); // if the objective system is up, don't do normal drawing if ( player->objectiveSystemOpen ) { player->objectiveSystem->Redraw( gameLocal.fast.time ); return; } // 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(); #ifdef _D3XP if ( gameLocal.portalSkyEnt.GetEntity() && gameLocal.IsPortalSkyAcive() && g_enablePortalSky.GetBool() ) { renderView_t portalView = hackedView; portalView.vieworg = gameLocal.portalSkyEnt.GetEntity()->GetPhysics()->GetOrigin(); // setup global fixup projection vars if ( 1 ) { int vidWidth, vidHeight; idVec2 shiftScale; renderSystem->GetGLSettings( vidWidth, vidHeight ); float pot; int w = vidWidth; pot = MakePowerOfTwo( w ); shiftScale.x = (float)w / pot; int h = vidHeight; pot = MakePowerOfTwo( h ); shiftScale.y = (float)h / pot; hackedView.shaderParms[4] = shiftScale.x; hackedView.shaderParms[5] = shiftScale.y; } gameRenderWorld->RenderScene( &portalView ); renderSystem->CaptureRenderToImage( "_currentRender" ); hackedView.forceUpdate = true; // FIX: for smoke particles not drawing when portalSky present } // process the frame fxManager->Process( &hackedView ); #endif if ( player->spectating ) { return; } #ifdef _D3XP if ( !hud ) { return; } #endif // draw screen blobs if ( !pm_thirdPerson.GetBool() && !g_skipViewEffects.GetBool() ) { for ( int i = 0 ; i < MAX_SCREEN_BLOBS ; i++ ) { screenBlob_t *blob = &screenBlobs[i]; if ( blob->finishTime <= gameLocal.slow.time ) { continue; } blob->y += blob->driftAmount; float fade = (float)( blob->finishTime - gameLocal.slow.time ) / ( blob->finishTime - blob->startFadeTime ); if ( fade > 1.0f ) { fade = 1.0f; } if ( fade ) { renderSystem->SetColor4( 1,1,1,fade ); renderSystem->DrawStretchPic( blob->x, blob->y, blob->w, blob->h,blob->s1, blob->t1, blob->s2, blob->t2, blob->material ); } } player->DrawHUD( hud ); // armor impulse feedback float armorPulse = ( gameLocal.fast.time - player->lastArmorPulse ) / 250.0f; if ( armorPulse > 0.0f && armorPulse < 1.0f ) { renderSystem->SetColor4( 1, 1, 1, 1.0 - armorPulse ); renderSystem->DrawStretchPic( 0, 0, 640, 480, 0, 0, 1, 1, armorMaterial ); } // tunnel vision float health = 0.0f; if ( g_testHealthVision.GetFloat() != 0.0f ) { health = g_testHealthVision.GetFloat(); } else { health = player->health; } float alpha = health / 100.0f; if ( alpha < 0.0f ) { alpha = 0.0f; } if ( alpha > 1.0f ) { alpha = 1.0f; } if ( alpha < 1.0f ) { 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, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, tunnelMaterial ); } if ( bfgVision ) { renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, bfgMaterial ); } } // test a single material drawn over everything if ( g_testPostProcess.GetString()[0] ) { const idMaterial *mtr = declManager->FindMaterial( g_testPostProcess.GetString(), false ); if ( !mtr ) { common->Printf( "Material not found.\n" ); g_testPostProcess.SetString( "" ); } else { renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, mtr ); } } }
/* ================== idPlayerView::SingleView ================== */ void idPlayerView::SingleView( const renderView_t *view, idMenuHandler_HUD * hudManager ) { // normal rendering if ( !view ) { return; } // place the sound origin for the player gameSoundWorld->PlaceListener( view->vieworg, view->viewaxis, player->entityNumber + 1 ); // if the objective system is up, don't do normal drawing if ( player->objectiveSystemOpen ) { if ( player->pdaMenu != NULL ) { player->pdaMenu->Update(); } return; } // 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(); if ( gameLocal.portalSkyEnt.GetEntity() && gameLocal.IsPortalSkyAcive() && g_enablePortalSky.GetBool() ) { renderView_t portalView = hackedView; portalView.vieworg = gameLocal.portalSkyEnt.GetEntity()->GetPhysics()->GetOrigin(); gameRenderWorld->RenderScene( &portalView ); renderSystem->CaptureRenderToImage( "_currentRender" ); hackedView.forceUpdate = true; // FIX: for smoke particles not drawing when portalSky present } // process the frame fxManager->Process( &hackedView ); if ( !hudManager ) { return; } // draw screen blobs 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 ) { continue; } blob->y += blob->driftAmount; float fade = (float)( blob->finishTime - gameLocal.fast.time ) / ( blob->finishTime - blob->startFadeTime ); if ( fade > 1.0f ) { fade = 1.0f; } if ( fade ) { renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, fade ); renderSystem->DrawStretchPic( blob->x, blob->y, blob->w, blob->h,blob->s1, blob->t1, blob->s2, blob->t2, blob->material ); } } } player->DrawHUD( hudManager ); if ( player->spectating ) { return; } // armor impulse feedback float armorPulse = ( gameLocal.fast.time - player->lastArmorPulse ) / 250.0f; if ( armorPulse > 0.0f && armorPulse < 1.0f ) { 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 ); } // tunnel vision float health = 0.0f; if ( g_testHealthVision.GetFloat() != 0.0f ) { health = g_testHealthVision.GetFloat(); } else { health = player->health; } float alpha = health / 100.0f; if ( alpha < 0.0f ) { alpha = 0.0f; } if ( alpha > 1.0f ) { alpha = 1.0f; } if ( alpha < 1.0f ) { 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 ); } if ( bfgVision ) { 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 ); } } // test a single material drawn over everything if ( g_testPostProcess.GetString()[0] ) { const idMaterial *mtr = declManager->FindMaterial( g_testPostProcess.GetString(), false ); if ( !mtr ) { common->Printf( "Material not found.\n" ); g_testPostProcess.SetString( "" ); } else { 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::SingleView ================== */ void idPlayerView::SingleView( idUserInterface *hud, const renderView_t *view, bool drawHUD ) { // normal rendering if ( !view ) { return; } // place the sound origin for the player // TODO: Support overriding the location area so that reverb settings can be applied for listening thru doors? gameSoundWorld->PlaceListener( player->GetListenerLoc(), view->viewaxis, player->entityNumber + 1, gameLocal.time, hud ? hud->State().GetString( "location" ) : "Undefined" ); // 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(); //gameRenderWorld->RenderScene( &hackedView ); // grayman #3108 - contributed by neuro & 7318 idVec3 diff, currentEyePos, PSOrigin, Zero; Zero.Zero(); if ( ( gameLocal.CheckGlobalPortalSky() ) || ( gameLocal.GetCurrentPortalSkyType() == PORTALSKY_LOCAL ) ) { // in a case of a moving portalSky currentEyePos = hackedView.vieworg; if ( gameLocal.playerOldEyePos == Zero ) { // Initialize playerOldEyePos. This will only happen in one tick. gameLocal.playerOldEyePos = currentEyePos; } diff = ( currentEyePos - gameLocal.playerOldEyePos) / gameLocal.portalSkyScale; gameLocal.portalSkyGlobalOrigin += diff; // This is for the global portalSky. // It should keep going even when not active. } if ( gameLocal.portalSkyEnt.GetEntity() && gameLocal.IsPortalSkyActive() && g_enablePortalSky.GetBool() ) { if ( gameLocal.GetCurrentPortalSkyType() == PORTALSKY_STANDARD ) { PSOrigin = gameLocal.portalSkyOrigin; } if ( gameLocal.GetCurrentPortalSkyType() == PORTALSKY_GLOBAL ) { PSOrigin = gameLocal.portalSkyGlobalOrigin; } if ( gameLocal.GetCurrentPortalSkyType() == PORTALSKY_LOCAL ) { gameLocal.portalSkyOrigin += diff; PSOrigin = gameLocal.portalSkyOrigin; } gameLocal.playerOldEyePos = currentEyePos; // end neuro & 7318 renderView_t portalView = hackedView; portalView.vieworg = PSOrigin; // grayman #3108 - contributed by neuro & 7318 // portalView.vieworg = gameLocal.portalSkyEnt.GetEntity()->GetPhysics()->GetOrigin(); portalView.viewaxis = portalView.viewaxis * gameLocal.portalSkyEnt.GetEntity()->GetPhysics()->GetAxis(); // setup global fixup projection vars if ( 1 ) { int vidWidth, vidHeight; idVec2 shiftScale; renderSystem->GetGLSettings( vidWidth, vidHeight ); float pot; int w = vidWidth; pot = MakePowerOfTwo( w ); shiftScale.x = (float)w / pot; int h = vidHeight; pot = MakePowerOfTwo( h ); shiftScale.y = (float)h / pot; hackedView.shaderParms[6] = shiftScale.x; // grayman #3108 - neuro used [4], we use [6] hackedView.shaderParms[7] = shiftScale.y; // grayman #3108 - neuro used [5], we use [7] } gameRenderWorld->RenderScene( &portalView ); renderSystem->CaptureRenderToImage( "_currentRender" ); hackedView.forceUpdate = true; // FIX: for smoke particles not drawing when portalSky present } else // grayman #3108 - contributed by 7318 { // So if g_enablePortalSky is disabled, GlobalPortalSkies doesn't break. // When g_enablePortalSky gets re-enabled, GlobalPortalSkies keeps working. gameLocal.playerOldEyePos = currentEyePos; } hackedView.forceUpdate = true; // Fix for lightgem problems? -Gildoran gameRenderWorld->RenderScene( &hackedView ); // process the frame // fxManager->Process( &hackedView ); if ( player->spectating ) { return; } // draw screen blobs if ( !pm_thirdPerson.GetBool() && !g_skipViewEffects.GetBool() ) { for ( int i = 0 ; i < MAX_SCREEN_BLOBS ; i++ ) { screenBlob_t *blob = &screenBlobs[i]; if ( blob->finishTime <= gameLocal.time ) { continue; } blob->y += blob->driftAmount; float fade = (float)( blob->finishTime - gameLocal.time ) / ( blob->finishTime - blob->startFadeTime ); if ( fade > 1.0f ) { fade = 1.0f; } if ( fade ) { renderSystem->SetColor4( 1,1,1,fade ); renderSystem->DrawStretchPic( blob->x, blob->y, blob->w, blob->h,blob->s1, blob->t1, blob->s2, blob->t2, blob->material ); } } if (drawHUD) { player->DrawHUD( hud ); } // tunnel vision // grayman - This is where the red screen overlay is // applied for player damage. The red overlay's alpha is // the player's current health divided by his max health. // Less health when damaged means more overlay is visible. // The amount of alpha is also used to determine how long // the overlay is visible, its alpha climbing to 1.0 // over the duration of the effect. Less health means a longer // duration. Some key words for search purposes: // damage dealt, damage hud, hurt hud, blood overlay float health = 0.0f; if ( g_testHealthVision.GetFloat() != 0.0f ) { health = g_testHealthVision.GetFloat(); } else { health = player->health; } float alpha = health / 100.0f; if ( alpha < 0.0f ) { alpha = 0.0f; } else if ( alpha > 1.0f ) { alpha = 1.0f; } if ( alpha < 1.0f ) { // Tels: parm0: when the last damage occured // Tels: parm1: TODO: set here f.i. to color the material different when in gas cloud // Tels: parm2: TODO: set here f.i. to color the material different when poisoned // Tels: parm3: alpha value, depending on health renderSystem->SetColor4( ( player->health <= 0.0f ) ? MS2SEC( gameLocal.time ) : lastDamageTime, 1.0f, 1.0f, ( player->health <= 0.0f ) ? 0.0f : alpha ); renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, tunnelMaterial ); } } // Rotoscope (Cartoon-like) rendering - (Rotoscope Shader v1.0 by Hellborg) - added by Dram if ( g_rotoscope.GetBool() ) { const idMaterial *mtr = declManager->FindMaterial( "textures/postprocess/rotoedge", false ); if ( !mtr ) { common->Printf( "Rotoscope material not found.\n" ); } else { renderSystem->CaptureRenderToImage( "_currentRender" ); renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, mtr ); } } // test a single material drawn over everything if ( g_testPostProcess.GetString()[0] ) { const idMaterial *mtr = declManager->FindMaterial( g_testPostProcess.GetString(), false ); if ( !mtr ) { common->Printf( "Material not found.\n" ); g_testPostProcess.SetString( "" ); } else { renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, mtr ); } } }