private void SingleView(idUserInterface hud, idRenderView renderView) { // normal rendering if(renderView == null) { return; } // place the sound origin for the player // TODO: 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 // TODO: objectives /*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 idRenderView hackedView = renderView.Copy(); // TODO: hackedView.viewaxis = hackedView.viewaxis * ShakeAxis(); idR.Game.CurrentRenderWorld.RenderScene(hackedView); if(_player.IsSpectating == true) { return; } // draw screen blobs if((idR.CvarSystem.GetBool("pm_thirdPerson") == false) && (idR.CvarSystem.GetBool("g_skipViewEffects") == false)) { idConsole.Warning("TODO: screen blobs"); /*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(idR.CvarSystem.GetString("g_testPostProcess") != string.Empty) { idMaterial material = idR.DeclManager.FindMaterial(idR.CvarSystem.GetString("g_testPostProcess"), false); if(material == null) { idConsole.Warning("Material not found."); idR.CvarSystem.SetString("g_testPostProcess", string.Empty); } else { idR.RenderSystem.Color = new Vector4(1, 1, 1, 1); idR.RenderSystem.DrawStretchPicture(0, 0, idE.VirtualScreenWidth, idE.VirtualScreenHeight, 0, 0, 1, 1, material); } } }
/// <summary> /// Rendering a scene may actually render multiple subviews for mirrors and portals, and /// may render composite textures for gui console screens and light projections. /// It would also be acceptable to render a scene multiple times, for "rear view mirrors", etc. /// </summary> /// <param name="renderView"></param> public void RenderScene(idRenderView renderView) { #if ID_DEDICATED #else if(idE.RenderSystem.IsRunning == false) { return; } // skip front end rendering work, which will result // in only gui drawing if(idE.CvarSystem.GetBool("r_skipFrontEnd") == true) { return; } if((renderView.FovX <= 0) || (renderView.FovY <= 0)) { idConsole.Error("idRenderWorld::RenderScene: bad FOVS: {0}, {1}", renderView.FovX, renderView.FovY); } idRenderView copy = renderView.Copy(); // close any gui drawing idE.RenderSystem.GuiModel.EmitFullScreen(); idE.RenderSystem.GuiModel.Clear(); int startTime = idE.System.Milliseconds; // setup view parms for the initial view // View parms = new View(); parms.RenderView = copy; // TODO: screenshot /*if ( tr.takingScreenshot ) { parms->renderView.forceUpdate = true; }*/ // set up viewport, adjusted for resolution and OpenGL style 0 at the bottom parms.ViewPort = idE.RenderSystem.RenderViewToViewPort(parms.RenderView); // the scissor bounds may be shrunk in subviews even if // the viewport stays the same // this scissor range is local inside the viewport parms.Scissor.X1 = 0; parms.Scissor.Y1 = 0; parms.Scissor.X2 = (short) (parms.ViewPort.X2 - parms.ViewPort.X1); parms.Scissor.Y2 = (short) (parms.ViewPort.Y2 - parms.ViewPort.Y1); parms.IsSubview = false; parms.InitialViewAreaOrigin = renderView.ViewOrigin; parms.FloatTime = parms.RenderView.Time * 0.001f; parms.RenderWorld = this; // use this time for any subsequent 2D rendering, so damage blobs/etc // can use level time idE.RenderSystem.FrameShaderTime = parms.FloatTime; // see if the view needs to reverse the culling sense in mirrors // or environment cube sides Vector3 tmp = new Vector3(parms.RenderView.ViewAxis.M21, parms.RenderView.ViewAxis.M22, parms.RenderView.ViewAxis.M23); Vector3 tmp2 = new Vector3(parms.RenderView.ViewAxis.M31, parms.RenderView.ViewAxis.M32, parms.RenderView.ViewAxis.M33); Vector3 tmp3 = new Vector3(parms.RenderView.ViewAxis.M11, parms.RenderView.ViewAxis.M12, parms.RenderView.ViewAxis.M13); Vector3 cross = Vector3.Cross(tmp, tmp2); if((cross * tmp3).Length() > 0) { parms.IsMirror = false; } else { parms.IsMirror = true; } if(idE.CvarSystem.GetBool("r_lockSurfaces") == true) { idConsole.Warning("TODO: R_LockSurfaceScene( parms );"); return; } // save this world for use by some console commands idE.RenderSystem.PrimaryRenderWorld = this; idE.RenderSystem.PrimaryRenderView = copy; idE.RenderSystem.PrimaryView = parms; // rendering this view may cause other views to be rendered // for mirrors / portals / shadows / environment maps // this will also cause any necessary entities and lights to be // updated to the demo file idE.RenderSystem.RenderView(parms); // now write delete commands for any modified-but-not-visible entities, and // add the renderView command to the demo // TODO: demo /*if ( session->writeDemo ) { WriteRenderView( renderView ); }*/ int endTime = idE.System.Milliseconds; // TODO: tr.pc.frontEndMsec += endTime - startTime; // prepare for any 2D drawing after this idE.RenderSystem.GuiModel.Clear(); #endif }