コード例 #1
0
ファイル: idPlayer.cs プロジェクト: iainmckay/idtech4.net
		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);
				}
			}
		}
コード例 #2
0
ファイル: idPlayer.cs プロジェクト: iainmckay/idtech4.net
		/// <summary>
		/// Create the renderView for the current tic.
		/// </summary>
		private void CalculateRenderView()
		{
			if(_renderView == null)
			{
				_renderView = new idRenderView();
			}

			_renderView.Clear();

			// copy global shader parms
			for(int i = 0; i < idE.MaxGlobalMaterialParameters; i++)
			{
				_renderView.MaterialParameters[i] = idR.Game.GlobalMaterialParameters[i];
			}

			_renderView.GlobalMaterial = idR.Game.GlobalMaterial;
			_renderView.Time = idR.Game.Time;

			// calculate size of 3D view
			_renderView.X = 0;
			_renderView.Y = 0;
			_renderView.Width = idE.VirtualScreenWidth;
			_renderView.Height = idE.VirtualScreenHeight;
			_renderView.ViewID = 0;

			// check if we should be drawing from a camera's POV
			// TODO: camera
			/*if ( !noclip && (gameLocal.GetCamera() || privateCameraView) ) {
				// get origin, axis, and fov
				if ( privateCameraView ) {
					privateCameraView->GetViewParms( renderView );
				} else {
					gameLocal.GetCamera()->GetViewParms( renderView );
				}
			} 
			else */
			{
				if(idR.CvarSystem.GetBool("g_stopTime") == true)
				{
					_renderView.ViewOrigin = _firstPersonViewOrigin;
					_renderView.ViewAxis = _firstPersonViewAxis;

					if(idR.CvarSystem.GetBool("pm_thirdPerson") == true)
					{
						// set the viewID to the clientNum + 1, so we can suppress the right player bodies and
						// allow the right player view weapons
						_renderView.ViewID = this.Index + 1;
					}
				}
				else if(idR.CvarSystem.GetBool("pm_thirdPerson") == true)
				{
					idConsole.Warning("TODO: third person");
					//OffsetThirdPersonView( pm_thirdPersonAngle.GetFloat(), pm_thirdPersonRange.GetFloat(), pm_thirdPersonHeight.GetFloat(), pm_thirdPersonClip.GetBool() );
				}
				else if(idR.CvarSystem.GetBool("pm_thirdPersonDeath") == true)
				{
					idConsole.Warning("TODO: third person death");

					//range = gameLocal.time < minRespawnTime ? ( gameLocal.time + RAGDOLL_DEATH_TIME - minRespawnTime ) * ( 120.0f / RAGDOLL_DEATH_TIME ) : 120.0f;
					//OffsetThirdPersonView( 0.0f, 20.0f + range, 0.0f, false );
				}
				else
				{
					_renderView.ViewOrigin = _firstPersonViewOrigin;
					_renderView.ViewAxis = _firstPersonViewAxis;

					// set the viewID to the clientNum + 1, so we can suppress the right player bodies and
					// allow the right player view weapons
					_renderView.ViewID = this.Index + 1;
				}

				// field of view
				idR.Game.CalculateFieldOfView(CalculateFieldOfView(true), out _renderView.FovX, out _renderView.FovY);
			}

			if(_renderView.FovY == 0)
			{
				idConsole.Error("renderView.FovY == 0");
			}

			if(idR.CvarSystem.GetBool("g_showviewpos") == true)
			{
				idConsole.WriteLine("{0}: {1}", _renderView.ViewOrigin, _renderView.ViewAxis.ToAngles());
			}
		}
コード例 #3
0
ファイル: idEntity.cs プロジェクト: iainmckay/idtech4.net
		/// <summary>
		/// 
		/// </summary>
		/// <remarks>
		/// May not change the game state whatsoever!
		/// </remarks>
		/// <param name="renderEntity"></param>
		/// <param name="renderView"></param>
		/// <returns></returns>
		protected bool ModelCallback(idRenderEntity renderEntity, idRenderView renderView)
		{
			idEntity ent = idR.Game.Entities[renderEntity.EntityIndex];

			if(ent == null)
			{
				idConsole.Error("idEntity::ModelCallback: callback with null game entity");
			}

			return ent.UpdateRenderEntity(renderEntity, renderView);
		}
コード例 #4
0
ファイル: idEntity.cs プロジェクト: iainmckay/idtech4.net
		protected bool UpdateRenderEntity(idRenderEntity renderEntity, idRenderView renderView)
		{
			// TODO: cinematic
			/*if ( gameLocal.inCinematic && gameLocal.skipCinematic ) {
				return false;
			}*/

			idAnimator animator = this.Animator;

			if(animator != null)
			{
				return animator.CreateFrame(idR.Game.Time, false);
			}

			return false;
		}
コード例 #5
0
ファイル: idPlayerView.cs プロジェクト: iainmckay/idtech4.net
		public idPlayerView(idPlayer player)
		{
			_player = player;
			_screenBlobs = new ScreenBlob[idR.MaxScreenBlobs];
			_view = new idRenderView();
	
			_doubleVisionMaterial = idR.DeclManager.FindMaterial("_scratch");
			_tunnelMaterial = idR.DeclManager.FindMaterial("textures/decals/tunnel");
			_armorMaterial = idR.DeclManager.FindMaterial("armorViewEffect");
			_berserkMaterial = idR.DeclManager.FindMaterial("textures/decals/berserk");
			_irGogglesMaterial = idR.DeclManager.FindMaterial("textures/decals/irblend");
			_bloodSprayMaterial = idR.DeclManager.FindMaterial("textures/decals/bloodspray");
			_bfgMaterial = idR.DeclManager.FindMaterial("textures/decals/bfgvision");
			_lagoMaterial = idR.DeclManager.FindMaterial(idR.LagometerMaterial, false );

			ClearEffects();
		}
コード例 #6
0
		/// <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
		}
コード例 #7
0
		/// <summary>
		/// Creates a shallow copy of this instance.
		/// </summary>
		public idRenderView Copy()
		{
			idRenderView view = new idRenderView();
			view.ViewID = this.ViewID;
			view.X = this.X;
			view.Y = this.Y;
			view.Width = this.Width;
			view.Height = this.Height;
			view.FovX = this.FovX;
			view.FovY = this.FovY;

			view.ViewOrigin = this.ViewOrigin;
			view.ViewAxis = this.ViewAxis;

			view.CramZNear = this.CramZNear;
			view.ForceUpdate = this.ForceUpdate;
			view.Time = this.Time;

			view.MaterialParameters = this.MaterialParameters;
			view.GlobalMaterial = this.GlobalMaterial;

			return view;
		}
コード例 #8
0
		private void Clear()
		{
			_frameCount = 0;
			_viewCount = 0;

			_staticAllocCount = 0;
			_frameShaderTime = 0;

			_viewPortOffset = Vector2.Zero;
			_tiledViewPort = Vector2.Zero;

			_ambientLightVector = Vector4.Zero;
			_sortOffset = 0;
			_worlds.Clear();

			_primaryRenderWorld = null;
			_primaryView = null;
			_primaryRenderView = new idRenderView();

			_defaultMaterial = null;

			/*
			testImage = NULL;
			ambientCubeImage = NULL;*/

			_viewDefinition = null;

			/*memset( &pc, 0, sizeof( pc ) );
			memset( &lockSurfacesCmd, 0, sizeof( lockSurfacesCmd ) );*/

			_identitySpace = new ViewEntity();

			/*logFile = NULL;*/

			_renderCrops = new idRectangle[idE.MaxRenderCrops];
			_currentRenderCrop = 0;
			_guiRecursionLevel = 0;
			_guiModel = null;
			/*demoGuiModel = NULL;
			memset( gammaTable, 0, sizeof( gammaTable ) );
			takingScreenshot = false;*/
		}
コード例 #9
0
		/// <summary>
		/// Converts from SCREEN_WIDTH / SCREEN_HEIGHT coordinates to current cropped pixel coordinates
		/// </summary>
		/// <param name="renderView"></param>
		/// <returns></returns>
		public idScreenRect RenderViewToViewPort(idRenderView renderView)
		{
			idRectangle renderCrop = _renderCrops[_currentRenderCrop];

			float widthRatio = (float) renderCrop.Width / idE.VirtualScreenWidth;
			float heightRatio = (float) renderCrop.Height / idE.VirtualScreenHeight;

			idScreenRect viewPort = new idScreenRect();
			viewPort.X1 = (short) (renderCrop.X + renderView.X * widthRatio);
			viewPort.X2 = (short) ((renderCrop.X + idMath.Floor(renderView.X + renderView.Width) * widthRatio + 0.5f) - 1);
			viewPort.Y1 = (short) ((renderCrop.Y + renderCrop.Height) - idMath.Floor((renderView.Y + renderView.Height) * heightRatio + 0.5f));
			viewPort.Y2 = (short) ((renderCrop.Y + renderCrop.Height) - idMath.Floor(renderView.Y * heightRatio + 0.5f) - 1);

			return viewPort;
		}