Material.
Any errors during parsing just set MF_DEFAULTED and return, rather than throwing a hard error. This will cause the material to fall back to default material, but otherwise let things continue.

Each material may have a set of calculations that must be evaluated before drawing with it.

Every expression that a material uses can be evaluated at one time, which will allow for perfect common subexpression removal when I get around to writing it.

Without this, scrolling an entire surface could result in evaluating the same texture matrix calculations a half dozen times.

Open question: should I allow arbitrary per-vertex color, texCoord, and vertex calculations to be specified in the material code?

Every stage will definately have a valid image pointer.

We might want the ability to change the sort value based on conditionals, but it could be a hassle to implement,

Inheritance: idTech4.Text.idDecl
Exemple #1
0
		public idMaterial RemapShaderBySkin(idMaterial shader)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			if(shader == null)
			{
				return null;
			}

			// never remap surfaces that were originally nodraw, like collision hulls.
			if(shader.IsDrawn == false)
			{
				return shader;
			}

			int count = _mappings.Length;

			for(int i = 0; i < count; i++)
			{
				SkinMapping map = _mappings[i];

				// null = wildcard match.
				if((map.From == null) || (map.From == shader))
				{
					return map.To;
				}
			}

			// didn't find a match or wildcard, so stay the same.
			return shader;
		}
		/// <summary>
		/// Draws a multi-colored string with a drop shadow, optionally forcing to a fixed color.
		/// <para/>
		/// Coordinates are at 640 by 480 virtual resolution.
		/// </summary>
		/// <param name="x"></param>
		/// <param name="y"></param>
		/// <param name="str"></param>
		/// <param name="color"></param>
		/// <param name="forceColor"></param>
		/// <param name="material"></param>
		public void DrawBigString(int x, int y, string str, Vector4 color, bool forceColor, idMaterial material)
		{
			Vector4 tmpColor;
			int xx = x;
			int length = str.Length;

			this.Color = color;

			for(int i = 0; i < length; i++)
			{
				if(idHelper.IsColor(str, i) == true)
				{
					if(forceColor == false)
					{
						if(str[i + 1] == (char) idColorIndex.Default)
						{
							this.Color = color;
						}
						else
						{
							tmpColor = idHelper.ColorForIndex(str[i + 1]);
							tmpColor.W = color.W;

							this.Color = tmpColor;
						}
					}

					i += 2;
					continue;
				}

				DrawBigCharacter(xx, y, str[i], material);

				xx += idE.BigCharacterWidth;
			}

			this.Color = idColor.White;
		}
		public override void Update()
		{
			string s = this.Name;

			if((_guiDict != null) && (s != string.Empty))
			{
				_data = _guiDict.GetString(s);

				if(_data == string.Empty)
				{
					_material = null;
				}
				else
				{
					_material = idE.DeclManager.FindMaterial(_data);
				}
			}
		}
Exemple #4
0
		/// <summary>
		/// Called in an orderly fashion at system startup, so commands, cvars, files, etc are all available.
		/// </summary>
		public void Init()
		{
			idConsole.WriteLine("-------- Initializing Session --------");

			// TODO: commands
			/*cmdSystem->AddCommand( "writePrecache", Sess_WritePrecache_f, CMD_FL_SYSTEM|CMD_FL_CHEAT, "writes precache commands" );

	#ifndef	ID_DEDICATED*/

			idE.CmdSystem.AddCommand("map", "loads a map", CommandFlags.System, Cmd_Map /* TODO: idCmdSystem::ArgCompletion_MapName*/);

		/*cmdSystem->AddCommand( "devmap", Session_DevMap_f, CMD_FL_SYSTEM, "loads a map in developer mode", idCmdSystem::ArgCompletion_MapName );
		cmdSystem->AddCommand( "testmap", Session_TestMap_f, CMD_FL_SYSTEM, "tests a map", idCmdSystem::ArgCompletion_MapName );

		cmdSystem->AddCommand( "writeCmdDemo", Session_WriteCmdDemo_f, CMD_FL_SYSTEM, "writes a command demo" );
		cmdSystem->AddCommand( "playCmdDemo", Session_PlayCmdDemo_f, CMD_FL_SYSTEM, "plays back a command demo" );
		cmdSystem->AddCommand( "timeCmdDemo", Session_TimeCmdDemo_f, CMD_FL_SYSTEM, "times a command demo" );
		cmdSystem->AddCommand( "exitCmdDemo", Session_ExitCmdDemo_f, CMD_FL_SYSTEM, "exits a command demo" );
		cmdSystem->AddCommand( "aviCmdDemo", Session_AVICmdDemo_f, CMD_FL_SYSTEM, "writes AVIs for a command demo" );
		cmdSystem->AddCommand( "aviGame", Session_AVIGame_f, CMD_FL_SYSTEM, "writes AVIs for the current game" );

		cmdSystem->AddCommand( "recordDemo", Session_RecordDemo_f, CMD_FL_SYSTEM, "records a demo" );
		cmdSystem->AddCommand( "stopRecording", Session_StopRecordingDemo_f, CMD_FL_SYSTEM, "stops demo recording" );
		cmdSystem->AddCommand( "playDemo", Session_PlayDemo_f, CMD_FL_SYSTEM, "plays back a demo", idCmdSystem::ArgCompletion_DemoName );
		cmdSystem->AddCommand( "timeDemo", Session_TimeDemo_f, CMD_FL_SYSTEM, "times a demo", idCmdSystem::ArgCompletion_DemoName );
		cmdSystem->AddCommand( "timeDemoQuit", Session_TimeDemoQuit_f, CMD_FL_SYSTEM, "times a demo and quits", idCmdSystem::ArgCompletion_DemoName );
		cmdSystem->AddCommand( "aviDemo", Session_AVIDemo_f, CMD_FL_SYSTEM, "writes AVIs for a demo", idCmdSystem::ArgCompletion_DemoName );
		cmdSystem->AddCommand( "compressDemo", Session_CompressDemo_f, CMD_FL_SYSTEM, "compresses a demo file", idCmdSystem::ArgCompletion_DemoName );
	#endif

		cmdSystem->AddCommand( "disconnect", Session_Disconnect_f, CMD_FL_SYSTEM, "disconnects from a game" );

		cmdSystem->AddCommand( "demoShot", Session_DemoShot_f, CMD_FL_SYSTEM, "writes a screenshot for a demo" );
		cmdSystem->AddCommand( "testGUI", Session_TestGUI_f, CMD_FL_SYSTEM, "tests a gui" );

	#ifndef	ID_DEDICATED
		cmdSystem->AddCommand( "saveGame", SaveGame_f, CMD_FL_SYSTEM|CMD_FL_CHEAT, "saves a game" );
		cmdSystem->AddCommand( "loadGame", LoadGame_f, CMD_FL_SYSTEM|CMD_FL_CHEAT, "loads a game", idCmdSystem::ArgCompletion_SaveGame );
	#endif

		cmdSystem->AddCommand( "takeViewNotes", TakeViewNotes_f, CMD_FL_SYSTEM, "take notes about the current map from the current view" );
		cmdSystem->AddCommand( "takeViewNotes2", TakeViewNotes2_f, CMD_FL_SYSTEM, "extended take view notes" );

		cmdSystem->AddCommand( "rescanSI", Session_RescanSI_f, CMD_FL_SYSTEM, "internal - rescan serverinfo cvars and tell game" );

		cmdSystem->AddCommand( "promptKey", Session_PromptKey_f, CMD_FL_SYSTEM, "prompt and sets the CD Key" );

		cmdSystem->AddCommand( "hitch", Session_Hitch_f, CMD_FL_SYSTEM|CMD_FL_CHEAT, "hitches the game" );*/

			// the same idRenderWorld will be used for all games
			// and demos, insuring that level specific models
			// will be freed
			_renderWorld = idE.RenderSystem.CreateRenderWorld();

			idConsole.Warning("TODO: init sound");
			/*sw = soundSystem->AllocSoundWorld( rw );

			menuSoundWorld = soundSystem->AllocSoundWorld( rw );*/

			// we have a single instance of the main menu
			_guiMainMenu = idE.UIManager.FindInterface("guis/mainmenu.gui", true, false, true);

			idConsole.Warning("TODO: map list");
			/*guiMainMenu_MapList = uiManager->AllocListGUI();
			guiMainMenu_MapList->Config(guiMainMenu, "mapList");
			idAsyncNetwork::client.serverList.GUIConfig(guiMainMenu, "serverList");*/

			_guiRestartMenu = idE.UIManager.FindInterface("guis/restart.gui", true, false, true);
			_guiGameOver = idE.UIManager.FindInterface("guis/gameover.gui", true, false, true);
			_guiMsg = idE.UIManager.FindInterface("guis/msg.gui", true, false, true);
			_guiTakeNotes = idE.UIManager.FindInterface("guis/takeNotes.gui", true, false, true);
			_guiIntro = idE.UIManager.FindInterface("guis/intro.gui", true, false, true);

			_whiteMaterial = idE.DeclManager.FindMaterial("_white");

			idConsole.WriteLine("session initialized");
			idConsole.WriteLine("--------------------------------------");
		}
Exemple #5
0
		public void DrawStretchPicture(Vertex[] vertices, int[] indexes, idMaterial material, bool clip, float minX, float minY, float maxX, float maxY)
		{
			if((vertices == null) || (indexes == null) || (material == null))
			{
				return;
			}

			// break the current surface if we are changing to a new material
			if(material != _surface.Material)
			{
				if(_surface.VertexCount > 0)
				{
					AdvanceSurface();
				}

				_surface.Material = material;
				_surface.Material.EnsureNotPurged(); // in case it was a gui item started before a level change
			}

			clip = false;

			// add the verts and indexes to the current surface
			if(clip == true)
			{
				idConsole.WriteLine("idGuiModle.DrawStretchPicture clip");

				/*int i, j;

		// FIXME:	this is grim stuff, and should be rewritten if we have any significant
		//			number of guis asking for clipping
				 
		idFixedWinding w;
		for ( i = 0; i < indexCount; i += 3 ) {
			w.Clear();
			w.AddPoint(idVec5(dverts[dindexes[i]].xyz.x, dverts[dindexes[i]].xyz.y, dverts[dindexes[i]].xyz.z, dverts[dindexes[i]].st.x, dverts[dindexes[i]].st.y));
			w.AddPoint(idVec5(dverts[dindexes[i+1]].xyz.x, dverts[dindexes[i+1]].xyz.y, dverts[dindexes[i+1]].xyz.z, dverts[dindexes[i+1]].st.x, dverts[dindexes[i+1]].st.y));
			w.AddPoint(idVec5(dverts[dindexes[i+2]].xyz.x, dverts[dindexes[i+2]].xyz.y, dverts[dindexes[i+2]].xyz.z, dverts[dindexes[i+2]].st.x, dverts[dindexes[i+2]].st.y));

			for ( j = 0; j < 3; j++ ) {
				if ( w[j].x < min_x || w[j].x > max_x ||
					w[j].y < min_y || w[j].y > max_y ) {
					break;
				}
			}
			if ( j < 3 ) {
				idPlane p;
				p.Normal().y = p.Normal().z = 0.0f; p.Normal().x = 1.0f; p.SetDist( min_x );
				w.ClipInPlace( p );
				p.Normal().y = p.Normal().z = 0.0f; p.Normal().x = -1.0f; p.SetDist( -max_x );
				w.ClipInPlace( p );
				p.Normal().x = p.Normal().z = 0.0f; p.Normal().y = 1.0f; p.SetDist( min_y );
				w.ClipInPlace( p );
				p.Normal().x = p.Normal().z = 0.0f; p.Normal().y = -1.0f; p.SetDist( -max_y );
				w.ClipInPlace( p );
			}

			int	numVerts = verts.Num();
			verts.SetNum( numVerts + w.GetNumPoints(), false );
			for ( j = 0 ; j < w.GetNumPoints() ; j++ ) {
				idDrawVert *dv = &verts[numVerts+j];

				dv->xyz.x = w[j].x;
				dv->xyz.y = w[j].y;
				dv->xyz.z = w[j].z;
				dv->st.x = w[j].s;
				dv->st.y = w[j].t;
				dv->normal.Set(0, 0, 1);
				dv->tangents[0].Set(1, 0, 0);
				dv->tangents[1].Set(0, 1, 0);
			}
			surf->numVerts += w.GetNumPoints();

			for ( j = 2; j < w.GetNumPoints(); j++ ) {
				indexes.Append( numVerts - surf->firstVert );
				indexes.Append( numVerts + j - 1 - surf->firstVert );
				indexes.Append( numVerts + j - surf->firstVert );
				surf->numIndexes += 3;
			}
		}*/

			}
			else
			{
				int currentVertexCount = _vertices.Count;
				int currentIndexCount = _indexes.Count;
				int vertexCount = vertices.Length;
				int indexCount = indexes.Length;

				_surface.VertexCount += vertexCount;
				_surface.IndexCount += indexCount;

				for(int i = 0; i < indexCount; i++)
				{
					_indexes.Add(currentVertexCount + indexes[i] - _surface.FirstVertex);
				}

				_vertices.AddRange(vertices);
			}
		}
		public void Init()
		{
			_scaleX = 0.0f;

			_whiteImage = idE.DeclManager.FindMaterial("guis/assets/white.tga");
			_whiteImage.Sort = (float) MaterialSort.Gui;

			SetupFonts();

			_matrix = Matrix.Identity;
			_origin = Vector3.Zero;
			_enableClipping = true;
			_mbcs = false;

			SetSize(idE.VirtualScreenWidth, idE.VirtualScreenHeight);

			_currentFontFamily = _fontFamilies[0];
			/*
			 * TODO*/

			_cursorImages[(int) Cursor.Arrow] = idE.DeclManager.FindMaterial("ui/assets/guicursor_arrow.tga");
			_cursorImages[(int) Cursor.Hand] = idE.DeclManager.FindMaterial("ui/assets/guicursor_hand.tga");
			_cursorImages[(int) Cursor.Arrow].Sort = (float) MaterialSort.Gui;
			_cursorImages[(int) Cursor.Hand].Sort = (float) MaterialSort.Gui;

			/*scrollBarImages[SCROLLBAR_HBACK] = declManager->FindMaterial("ui/assets/scrollbarh.tga");
			scrollBarImages[SCROLLBAR_VBACK] = declManager->FindMaterial("ui/assets/scrollbarv.tga");
			scrollBarImages[SCROLLBAR_THUMB] = declManager->FindMaterial("ui/assets/scrollbar_thumb.tga");
			scrollBarImages[SCROLLBAR_RIGHT] = declManager->FindMaterial("ui/assets/scrollbar_right.tga");
			scrollBarImages[SCROLLBAR_LEFT] = declManager->FindMaterial("ui/assets/scrollbar_left.tga");
			scrollBarImages[SCROLLBAR_UP] = declManager->FindMaterial("ui/assets/scrollbar_up.tga");
			scrollBarImages[SCROLLBAR_DOWN] = declManager->FindMaterial("ui/assets/scrollbar_down.tga");*/

			/*crollBarImages[SCROLLBAR_HBACK]->SetSort( SS_GUI );
			scrollBarImages[SCROLLBAR_VBACK]->SetSort( SS_GUI );
			scrollBarImages[SCROLLBAR_THUMB]->SetSort( SS_GUI );
			scrollBarImages[SCROLLBAR_RIGHT]->SetSort( SS_GUI );
			scrollBarImages[SCROLLBAR_LEFT]->SetSort( SS_GUI );
			scrollBarImages[SCROLLBAR_UP]->SetSort( SS_GUI );
			scrollBarImages[SCROLLBAR_DOWN]->SetSort( SS_GUI );*/

			_cursor = Cursor.Arrow;

			/*overStrikeMode = true;*/
			
			_initialized = true;
		}
		public idSimpleWindow(idWindow win)
		{
			_gui = win.UserInterface;
			_context = win.DeviceContext;

			_drawRect = win.DrawRectangle;
			_clientRect = win.ClientRectangle;
			_textRect = win.TextRectangle;

			_origin = win.Origin;
			_fontFamily = win.FontFamily;
			_name = win.Name;

			_materialScaleX = win.MaterialScaleX;
			_materialScaleY = win.MaterialScaleY;

			_borderSize = win.BorderSize;
			_textAlign = win.TextAlign;
			_textAlignX = win.TextAlignX;
			_textAlignY = win.TextAlignY;
			_background = win.Background;
			_flags = win.Flags;
			_textShadow = win.TextShadow;

			_visible.Set(win.IsVisible);
			_text.Set(win.Text);
			_rect.Set(win.Rectangle);
			_backColor.Set(win.BackColor);
			_materialColor.Set(win.MaterialColor);
			_foreColor.Set(win.ForeColor);
			_borderColor.Set(win.BorderColor);
			_textScale.Set(win.TextScale);
			_rotate.Set(win.Rotate);
			_shear.Set(win.Shear);
			_backgroundName.Set(win.BackgroundName);

			if(_backgroundName != string.Empty)
			{
				_background = idE.DeclManager.FindMaterial(_backgroundName);
				_background.Sort = (float) MaterialSort.Gui; ;
				_background.ImageClassification = 1; // just for resource tracking
			}

			_backgroundName.Material = _background;

			_parent = win.Parent;
			_hideCursor.Set(win.HideCursor);

			if(_parent != null)
			{
				if(_text.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_text);
				}

				if(_visible.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_visible);
				}

				if(_rect.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_rect);
				}

				if(_backColor.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_backColor);
				}

				if(_materialColor.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_materialColor);
				}

				if(_foreColor.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_foreColor);
				}

				if(_borderColor.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_borderColor);
				}

				if(_textScale.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_textScale);
				}

				if(_rotate.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_rotate);
				}

				if(_shear.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_shear);
				}

				if(_backgroundName.NeedsUpdate == true)
				{
					_parent.AddUpdateVariable(_backgroundName);
				}
			}
		}
Exemple #8
0
		private void Init()
		{
			_childID = 0;
			_flags = 0;
			_lastTimeRun = 0;

			_origin = Vector2.Zero;
						
			_fontFamily = null;
			_timeLine = -1;
			_offsetX = 0;
			_offsetY = 0;
			
			_cursor = Cursor.Arrow;
			_forceAspectWidth = 640;
			_forceAspectHeight = 480;
			_materialScaleX = 1;
			_materialScaleY = 1;
			_borderSize = 0;

			_textAlign = TextAlign.Left;
			_textAlignX = 0;
			_textAlignY = 0;
			
			_noEvents.Set(false);
			_noTime.Set(false);
			_visible.Set(true);
			_hideCursor.Set(false);

			_shear = Vector2.Zero;
			_rotate.Set(0);
			_textScale.Set(0.35f);

			_backColor.Set(Vector4.Zero);
			_foreColor.Set(new Vector4(1, 1, 1, 1));
			_hoverColor.Set(new Vector4(1, 1, 1, 1));
			_materialColor.Set(new Vector4(1, 1, 1, 1));
			_borderColor.Set(Vector4.Zero);

			_background = null;
			_backgroundName.Set(string.Empty);

			_focusedChild = null;
			_captureChild = null;
			_overChild = null;

			// TODO
			/*
			*/
			_parent = null;
			/*saveOps = NULL;
			saveRegs = NULL;*/
			_timeLine = -1;
			_textShadow = 0;
			_hover = false;

			int count = _scripts.Length;
			
			for(int i = 0; i < count; i++)
			{
				_scripts[i] = null;
			}
		}
Exemple #9
0
		private void SetupBackground()
		{
			if(_backgroundName != string.Empty)
			{
				_background = idE.DeclManager.FindMaterial(_backgroundName);
				_background.ImageClassification = 1; // just for resource tracking

				if((_background != null) && (_background.TestMaterialFlag(MaterialFlags.Defaulted) == false))
				{
					_background.Sort = (float) MaterialSort.Gui;
				}
			}

			_backgroundName.Material = _background;
		}
		public void DrawStretchPicture(float x, float y, float width, float height, float s, float t, float s2, float t2, idMaterial material)
		{
			_guiModel.DrawStretchPicture(x, y, width, height, s, t, s2, t2, material);
		}
		/// <summary>
		/// Sets the stage to a default state.
		/// </summary>
		public void Default()
		{
			_material = idE.DeclManager.FindMaterial("_default");
			_totalParticles = 100;
			_spawnBunching = 1.0f;
			_particleLife = 1.5f;
			_timeOffset = 0.0f;
			_deadTime = 0.0f;

			_distribution = ParticleDistribution.Rectangle;
			_distributionParms[0] = 8.0f;
			_distributionParms[1] = 8.0f;
			_distributionParms[2] = 8.0f;
			_distributionParms[3] = 0.0f;

			_direction = ParticleDirection.Cone;
			_directionParms[0] = 90.0f;
			_directionParms[1] = 0.0f;
			_directionParms[2] = 0.0f;
			_directionParms[3] = 0.0f;

			_orientation = ParticleOrientation.View;
			_orientationParms[0] = 0.0f;
			_orientationParms[1] = 0.0f;
			_orientationParms[2] = 0.0f;
			_orientationParms[3] = 0.0f;

			_customPath = ParticleCustomPath.Standard;
			_customPathParms[0] = 0.0f;
			_customPathParms[1] = 0.0f;
			_customPathParms[2] = 0.0f;
			_customPathParms[3] = 0.0f;
			_customPathParms[4] = 0.0f;
			_customPathParms[5] = 0.0f;
			_customPathParms[6] = 0.0f;
			_customPathParms[7] = 0.0f;

			_gravity = 1.0f;
			_worldGravity = false;

			_offset = Vector3.Zero;

			_animationFrames = 0;
			_animationRate = 0.0f;
			_initialAngle = 0.0f;

			_speed = new idParticleParameter(150.0f, 150.0f, null);
			_rotationSpeed = new idParticleParameter(0.0f, 0.0f, null);
			_size = new idParticleParameter(4.0f, 4.0f, null);
			_aspect = new idParticleParameter(1.0f, 1.0f, null);

			_color = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
			_fadeColor = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
			_fadeInFraction = 0.1f;
			_fadeOutFraction = 0.25f;
			_fadeIndexFraction = 0.0f;
			_boundsExpansion = 0.0f;
			_randomDistribution = true;
			_entityColor = false;
			_cycleTime = (int) (_particleLife + _deadTime) * 1000;
		}
		public void DrawStretchPicture(Vertex[] vertices, int[] indexes, idMaterial material, bool clip = true, float minX = 0.0f, float minY = 0.0f, float maxX = 640.0f, float maxY = 0.0f)
		{
			_guiModel.DrawStretchPicture(vertices, indexes, material, clip, minX, minY, maxX, maxY);
		}
		/// <summary>
		/// Draws a multi-colored string with a drop shadow, optionally forcing to a fixed color.
		/// </summary>
		/// <remarks>
		/// Coordinates are at 640x480 virtual resolution.
		/// </remarks>
		/// <param name="x"></param>
		/// <param name="y"></param>
		/// <param name="str"></param>
		/// <param name="setColor"></param>
		/// <param name="forceColor"></param>
		/// <param name="material"></param>
		public void DrawSmallString(int x, int y, string str, Vector4 setColor, bool forceColor, idMaterial material)
		{
			Vector4 color;
			char c;
			int xx = x;
			int length = str.Length;

			this.Color = setColor;

			for(int i = 0; i < length; i++)
			{
				c = str[i];

				if(idHelper.IsColor(str, i) == true)
				{
					if(forceColor == false)
					{
						if(str[i + 1] == (char) idColorIndex.Default)
						{
							this.Color = setColor;
						}
						else
						{
							color = idHelper.ColorForIndex(str[i + 1]);
							color.Z = setColor.Z;

							this.Color = color;
						}
					}

					i += 2;
				}
				else
				{
					DrawSmallCharacter(xx, y, str[i], material);
					xx += idE.SmallCharacterWidth;
				}
			}

			this.Color = idColor.White;
		}
		/// <summary>
		/// Small characters are drawn at native screen resolution.
		/// </summary>
		/// <param name="x"></param>
		/// <param name="y"></param>
		/// <param name="c"></param>
		/// <param name="material"></param>
		public void DrawSmallCharacter(int x, int y, int c, idMaterial material)
		{
			c &= 255;

			if(c == ' ')
			{
				return;
			}

			if(y < -idE.SmallCharacterHeight)
			{
				return;
			}

			int row = c >> 4;
			int col = c & 15;

			float actualRow = row * 0.0625f;
			float actualCol = col * 0.0625f;
			float size = 0.0625f;

			DrawStretchPicture(x, y, idE.SmallCharacterWidth, idE.SmallCharacterHeight, actualCol, actualRow, actualCol + size, actualRow + size, material);
		}
		public void DrawMaterial(float x, float y, float width, float height, idMaterial material, Vector4 color, float scaleX = 1.0f, float scaleY = 1.0f)
		{
			idE.RenderSystem.Color = color;

			float s0, s1, t0, t1;

			// 
			//  handle negative scales as well	
			if(scaleX < 0)
			{
				width *= -1;
				scaleX *= -1;
			}

			if(scaleY < 0)
			{
				height *= -1;
				scaleY *= -1;
			}

			// 
			if(width < 0)
			{
				// flip about vertical
				width = -width;
				s0 = 1 * scaleX;
				s1 = 0;
			}
			else
			{
				s0 = 0;
				s1 = 1 * scaleX;
			}

			if(height < 0)
			{
				// flip about horizontal
				height = -height;
				t0 = 1 * scaleY;
				t1 = 0;
			}
			else
			{
				t0 = 0;
				t1 = 1 * scaleY;
			}

			if(ClipCoordinates(ref x, ref y, ref width, ref height, ref s0, ref t0, ref s1, ref t1) == true)
			{
				return;
			}

			AdjustCoordinates(ref x, ref y, ref width, ref height);
			DrawStretchPicture(x, y, width, height, s0, t0, s1, t1, material);
		}
Exemple #16
0
		private void Dispose(bool disposing)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			if(disposing == true)
			{
				CleanUp();

				_gui = null;
				_context = null;
				_parent = null;
				_background = null;
				_focusedChild = null;
				_captureChild = null;
				_overChild = null;				
				_children = null;
				_drawWindows = null;
				_definedVariables = null;
				_updateVariables = null;
				_scripts = null;
				_timeLineEvents = null;
				_transitions = null;
				_namedEvents = null;
				_expressionRegisters = null;
				_ops = null;
				_regList = null;
				_lastEval = null;
				_builtInVariables = null;
			}

			_disposed = true;
		}
		public void DrawStretchPicture(float x, float y, float width, float height, float s, float t, float s2, float t2, idMaterial material)
		{
			Vertex[] verts = new Vertex[4];
			int[] indexes = new int[6];

			/*indexes[0] = 0;
			indexes[1] = 1;
			indexes[2] = 2;
			indexes[3] = 0;
			indexes[4] = 2;
			indexes[5] = 3;*/
			
			indexes[0] = 3;
			indexes[1] = 0;
			indexes[2] = 2;
			indexes[3] = 2;
			indexes[4] = 0;
			indexes[5] = 1;

			verts[0].Position = new Vector3(x, y, 0);
			verts[0].TextureCoordinates = new Vector2(s, t);
			verts[0].Normal = new Vector3(0, 0, 1);
			/*verts[0].Tangents = new Vector3[] {
				new Vector3(1, 0, 0),
				new Vector3(0, 1, 0)
			};*/

			verts[1].Position = new Vector3(x + width, y, 0);
			verts[1].TextureCoordinates = new Vector2(s2, t);
			verts[1].Normal = new Vector3(0, 0, 1);
			/*verts[1].Tangents = new Vector3[] {
				new Vector3(1, 0, 0),
				new Vector3(0, 1, 0)
			};*/

			verts[2].Position = new Vector3(x + width, y + height, 0);
			verts[2].TextureCoordinates = new Vector2(s2, t2);
			verts[2].Normal = new Vector3(0, 0, 1);
			/*verts[2].Tangents = new Vector3[] {
				new Vector3(1, 0, 0),
				new Vector3(0, 1, 0)
			};*/

			verts[3].Position = new Vector3(x, y + height, 0);
			verts[3].TextureCoordinates = new Vector2(s, t2);
			verts[3].Normal = new Vector3(0, 0, 1);
			/*verts[3].Tangents = new Vector3[] {
				new Vector3(1, 0, 0),
				new Vector3(0, 1, 0)
			};*/

			bool ident = _matrix != Matrix.Identity;

			if(ident == true)
			{
				idConsole.Warning("TODO: IDENT == true");
				/*verts[0].Position -= _origin;
				verts[0].Position *= _matrix.Translation;
				verts[0].Position += _origin;
				verts[1].Position -= _origin;
				verts[1].Position *= _matrix.Translation;
				verts[1].Position += _origin;
				verts[2].Position -= _origin;
				verts[2].Position *= _matrix.Translation;
				verts[2].Position += _origin;
				verts[3].Position -= _origin;
				verts[3].Position *= _matrix.Translation;
				verts[3].Position += _origin;*/
			}

			idE.RenderSystem.DrawStretchPicture(verts.ToArray(), indexes.ToArray(), material, ident);
		}
		/// <summary>
		/// Can't be combined with init, because init happens before the renderSystem is initialized.
		/// </summary>
		public void LoadGraphics()
		{
			_charSetShader = idE.DeclManager.FindMaterial("textures/bigchars");
			_whiteShader = idE.DeclManager.FindMaterial("_white");
			_consoleShader = idE.DeclManager.FindMaterial("console");
		}
		private void PaintCharacter(float x, float y, float width, float height, float scale, float s, float t, float s2, float t2, idMaterial shader)
		{
			float tmpWidth = width * scale;
			float tmpHeight = height * scale;

			if(ClipCoordinates(ref x, ref y, ref tmpWidth, ref tmpHeight, ref s, ref t, ref s2, ref t2) == true)
			{
				return;
			}

			AdjustCoordinates(ref x, ref y, ref tmpWidth, ref tmpHeight);
			DrawStretchPicture(x, y, tmpWidth, tmpHeight, s, t, s2, t2, shader);
		}
Exemple #20
0
		public idClipModel(idClipModel model)
		{
			_id = model.ID;
			_owner = model.Owner;
			
			_enabled = model.Enabled;
			_entity = model.Entity;

			_origin = model.Origin;
			_axis = model.Axis;
			_bounds = model.Bounds;
			_absBounds = model.AbsoluteBounds;

			_material = model.Material;
			_contents = model.Contents;
			_collisionModelHandle = model.CollisionModelHandle;
			_traceModelCache = null;

			if(model.TraceModelCache != null)
			{
				idConsole.Warning("TODO: LoadModel( *GetCachedTraceModel( model->traceModelIndex ) );");
			}

			_renderModelHandle = model.RenderModelHandle;
			_touchCount = -1;
		}
		private void SetupTraceModelStructure()
		{
			// setup model
			CollisionModel model = new CollisionModel();

			_models[idE.MaxSubModels] = model;

			// create node to hold the collision data
			CollisionModelNode node = new CollisionModelNode();
			node.PlaneType = -1;
			model.Node = node;

			// allocate vertex and edge arrays
			//model.Vertices = new CollisionModelVertex[idE.MaxTraceModelVertices];
			//model->edges = (cm_edge_t *) Mem_ClearedAlloc( model->maxEdges * sizeof(cm_edge_t) );

			// create a material for the trace model polygons
			_traceModelMaterial = idE.DeclManager.FindMaterial("_tracemodel", false);

			if(_traceModelMaterial == null)
			{
				idConsole.FatalError("_tracemodel material not found");
			}

			// allocate polygons
			/*for ( i = 0; i < MAX_TRACEMODEL_POLYS; i++ ) {
				trmPolygons[i] = AllocPolygonReference( model, MAX_TRACEMODEL_POLYS );
				trmPolygons[i]->p = AllocPolygon( model, MAX_TRACEMODEL_POLYEDGES );
				trmPolygons[i]->p->bounds.Clear();
				trmPolygons[i]->p->plane.Zero();
				trmPolygons[i]->p->checkcount = 0;
				trmPolygons[i]->p->contents = -1;		// all contents
				trmPolygons[i]->p->material = trmMaterial;
				trmPolygons[i]->p->numEdges = 0;
			}
			// allocate brush for position test
			trmBrushes[0] = AllocBrushReference( model, 1 );
			trmBrushes[0]->b = AllocBrush( model, MAX_TRACEMODEL_POLYS );
			trmBrushes[0]->b->primitiveNum = 0;
			trmBrushes[0]->b->bounds.Clear();
			trmBrushes[0]->b->checkcount = 0;
			trmBrushes[0]->b->contents = -1;		// all contents
			trmBrushes[0]->b->numPlanes = 0;*/
		}
		public void InitWithDefaults(string name, idRectangle rect, Vector4 foreColor, Vector4 materialColor, string background, string thumbMaterial, bool vertical, bool scrollbar)
		{
			SetInitialState(name);

			_rect.Set(rect);
			_foreColor.Set(foreColor);
			_materialColor.Set(materialColor);

			_thumbMaterial = idE.DeclManager.FindMaterial(thumbMaterial);
			_thumbMaterial.Sort = (float) MaterialSort.Gui;

			_thumbWidth = _thumbMaterial.ImageWidth;
			_thumbHeight = _thumbMaterial.ImageHeight;

			_background = idE.DeclManager.FindMaterial(_backgroundName);
			_background.Sort = (float) MaterialSort.Gui;

			_vertical = vertical;
			_scrollBar = scrollbar;

			this.Flags |= WindowFlags.HoldCapture;
		}
Exemple #23
0
		public void DrawStretchPicture(float x, float y, float width, float height, float s, float t, float s2, float t2, idMaterial material)
		{
			Vertex[] vertices = new Vertex[4];
			int[] indexes = new int[6];

			if(material == null)
			{
				return;
			}

			// clip to edges, because the pic may be going into a guiShader
			// instead of full screen
			if(x < 0)
			{
				s += (s2 - s) * -x / width;
				width += x;
				x = 0;
			}

			if(y < 0)
			{
				t += (t2 - t) * -y / height;
				height += y;
				y = 0;
			}
			if((x + width) > 640)
			{
				s2 -= (s2 - s) * (x + width - 640) / width;
				width = 640 - x;
			}

			if((y + height) > 480)
			{
				t2 -= (t2 - t) * (y + height - 480) / height;
				height = 480 - y;
			}

			if((width <= 0) || (height <= 0))
			{
				// completely clipped away
				return;		
			}

			indexes[0] = 3;
			indexes[1] = 0;
			indexes[2] = 2;
			indexes[3] = 2;
			indexes[4] = 0;
			indexes[5] = 1;

			vertices[0].Position = new Vector3(x, y, 0);
			vertices[0].TextureCoordinates = new Vector2(s, t);
			vertices[0].Normal = new Vector3(0, 0, 1);

			// TODO: tangents
			/*vertices[0].tangents[0][0] = 1;
			vertices[0].tangents[0][1] = 0;
			vertices[0].tangents[0][2] = 0;
			vertices[0].tangents[1][0] = 0;
			vertices[0].tangents[1][1] = 1;
			vertices[0].tangents[1][2] = 0;*/


			vertices[1].Position = new Vector3(x + width, y, 0);
			vertices[1].TextureCoordinates = new Vector2(s2, t);
			vertices[1].Normal = new Vector3(0, 0, 1);
			/*vertices[1].tangents[0][0] = 1;
			vertices[1].tangents[0][1] = 0;
			vertices[1].tangents[0][2] = 0;
			vertices[1].tangents[1][0] = 0;
			vertices[1].tangents[1][1] = 1;
			vertices[1].tangents[1][2] = 0;*/

			vertices[2].Position = new Vector3(x + width, y + height, 0);
			vertices[2].TextureCoordinates = new Vector2(s2, t2);
			vertices[2].Normal = new Vector3(0, 0, 1);
			/*vertices[2].tangents[0][0] = 1;
			vertices[2].tangents[0][1] = 0;
			vertices[2].tangents[0][2] = 0;
			vertices[2].tangents[1][0] = 0;
			vertices[2].tangents[1][1] = 1;
			vertices[2].tangents[1][2] = 0;*/

			vertices[3].Position = new Vector3(x, y + height, 0);
			vertices[3].TextureCoordinates = new Vector2(s, t2);
			vertices[3].Normal = new Vector3(0, 0, 1);
			/*vertices[3].tangents[0][0] = 1;
			vertices[3].tangents[0][1] = 0;
			vertices[3].tangents[0][2] = 0;
			vertices[3].tangents[1][0] = 0;
			vertices[3].tangents[1][1] = 1;
			vertices[3].tangents[1][2] = 0;*/

			DrawStretchPicture(vertices, indexes, material, false, 0, 0, 640.0f, 480.0f);
		}
		private void Init()
		{
			_value.Set(0.0f);
			_low = 0.0f;
			_high = 100.0f;
			_stepSize = 1.0f;
			_thumbMaterial = idE.DeclManager.FindMaterial("_default");
			_buddyWindow = null;

			_cvar = null;
			_cvarInit = false;
			_vertical = false;
			_scrollBar = false;
			_verticalFlip = false;

			_liveUpdate.Set(true);
		}
Exemple #25
0
		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();
		}
		protected override void PostParse()
		{
			base.PostParse();
						
			_value.Set(0.0f);

			_thumbMaterial = idE.DeclManager.FindMaterial(_thumbMaterialName);
			_thumbMaterial.Sort = (float) MaterialSort.Gui;
			_thumbWidth = _thumbMaterial.ImageWidth;
			_thumbHeight = _thumbMaterial.ImageHeight;


			this.Flags |= WindowFlags.HoldCapture | WindowFlags.CanFocus;

			InitCvar();
		}
		public override void Set(string value)
		{
			_data = value;

			if(_guiDict != null)
			{
				_guiDict.Set(this.Name, _data);
			}

			if(_material != null)
			{
				if(_data == string.Empty)
				{
					_material = null;
				}
				else
				{
					_material = idE.DeclManager.FindMaterial(_data);
				}
			}
		}
		public void Parse(idLexer lexer, idJointMatrix[] joints)
		{
			lexer.ExpectTokenString("{");

			//
			// parse name
			//
			if(lexer.CheckTokenString("name") == true)
			{
				lexer.ReadToken();
			}

			//
			// parse shader
			//
			lexer.ExpectTokenString("shader");

			idToken token = lexer.ReadToken();
			string materialName = token.ToString();

			_material = idE.DeclManager.FindMaterial(materialName);

			//
			// parse texture coordinates
			//
			lexer.ExpectTokenString("numverts");
			int count = lexer.ParseInt();

			if(count < 0)
			{
				lexer.Error("Invalid size: {0}", token.ToString());
			}

			_texCoords = new Vector2[count];

			int[] firstWeightForVertex = new int[count];
			int[] weightCountForVertex = new int[count];
			int maxWeight = 0;
			int coordCount = _texCoords.Length;

			_weightCount = 0;

			for(int i = 0; i < coordCount; i++)
			{
				lexer.ExpectTokenString("vert");
				lexer.ParseInt();

				float[] tmp = lexer.Parse1DMatrix(2);

				_texCoords[i] = new Vector2(tmp[0], tmp[1]);
				
				firstWeightForVertex[i] = lexer.ParseInt();
				weightCountForVertex[i] = lexer.ParseInt();

				if(weightCountForVertex[i] == 0)
				{
					lexer.Error("Vertex without any joint weights.");
				}

				_weightCount += weightCountForVertex[i];

				if((weightCountForVertex[i] + firstWeightForVertex[i]) > maxWeight)
				{
					maxWeight = weightCountForVertex[i] + firstWeightForVertex[i];
				}
			}

			//
			// parse tris
			//
			lexer.ExpectTokenString("numtris");
			_triangleCount = lexer.ParseInt();

			if(_triangleCount < 0)
			{
				lexer.Error("Invalid size: {0}", _triangleCount);
			}

			int[] tris = new int[_triangleCount * 3];

			for(int i = 0; i < _triangleCount; i++)
			{
				lexer.ExpectTokenString("tri");
				lexer.ParseInt();

				tris[i * 3 + 0] = lexer.ParseInt();
				tris[i * 3 + 1] = lexer.ParseInt();
				tris[i * 3 + 2] = lexer.ParseInt();
			}

			//
			// parse weights
			//
			lexer.ExpectTokenString("numweights");
			count = lexer.ParseInt();

			if(count < 0)
			{
				lexer.Error("Invalid size: {0}", count);
			}

			if(maxWeight > count)
			{
				lexer.Warning("Vertices reference out of range weights in model ({0} of {1} weights).", maxWeight, count);
			}

			VertexWeight[] tempWeights = new VertexWeight[count];

			for(int i = 0; i < count; i++)
			{
				lexer.ExpectTokenString("weight");
				lexer.ParseInt();

				int jointIndex = lexer.ParseInt();

				if((jointIndex < 0) || (jointIndex >= joints.Length))
				{
					lexer.Error("Joint index out of range({0}): {1}", joints.Length, jointIndex);
				}

				tempWeights[i].JointIndex = jointIndex;
				tempWeights[i].JointWeight = lexer.ParseFloat();

				float[] tmp = lexer.Parse1DMatrix(3);

				tempWeights[i].Offset = new Vector3(tmp[0], tmp[1], tmp[2]);
			}

			// create pre-scaled weights and an index for the vertex/joint lookup
			_scaledWeights = new Vector4[_weightCount];
			_weightIndex = new int[_weightCount * 2];

			count = 0;
			coordCount = _texCoords.Length;

			for(int i = 0; i < coordCount; i++)
			{
				int num = firstWeightForVertex[i];
				int weightCount = weightCountForVertex[i];

				for(int j = 0; j < weightCount; j++, num++, count++)
				{
					Vector3 tmp = tempWeights[num].Offset * tempWeights[num].JointWeight;

					_scaledWeights[count].X = tmp.X;
					_scaledWeights[count].Y = tmp.Y;
					_scaledWeights[count].Z = tmp.Z;
					_scaledWeights[count].W = tempWeights[num].JointWeight;

					_weightIndex[count * 2 + 0] = tempWeights[num].JointIndex;
				}

				_weightIndex[count * 2 - 1] = 1;
			}

			lexer.ExpectTokenString("}");

			// update counters
			idConsole.Warning("TODO: idRenderModel_MD5 update counters");

			/*c_numVerts += texCoords.Num();
			c_numWeights += numWeights;
			c_numWeightJoints++;
			for ( i = 0; i < numWeights; i++ ) {
				c_numWeightJoints += weightIndex[i*2+1];
			}*/

			//
			// build the information that will be common to all animations of this mesh:
			// silhouette edge connectivity and normal / tangent generation information
			//
			Vertex[] verts = new Vertex[_texCoords.Length];
			int vertCount = verts.Length;

			for(int i = 0; i < vertCount; i++)
			{
				verts[i].TextureCoordinates = _texCoords[i];
			}

			TransformVertices(verts, joints);

			idConsole.Warning("TODO: idMD5Mesh Deform");
			//_deformInfo = idE.RenderSystem.BuildDeformInformation(verts, tris, _material.UseUnsmoothedTangents);
		}
Exemple #29
0
		private void LoadMap(string mapName, int randomSeed)
		{
			bool isSameMap = ((_currentMapFile != null) && (_currentMapFileName.ToLower() == mapName.ToLower()));

			// clear the sound system
			_currentSoundWorld.ClearAllSoundEmitters();

			InitAsyncNetwork();

			if((isSameMap == false) || ((_currentMapFile != null) && (_currentMapFile.NeedsReload == true)))
			{
				// load the .map file
				if(_currentMapFile != null)
				{
					_currentMapFile.Dispose();
					_currentMapFile = null;
				}

				_currentMapFile = new idMapFile();

				if(_currentMapFile.Parse(mapName) == false)
				{
					_currentMapFile.Dispose();
					_currentMapFile = null;

					idConsole.Error("Couldn't load {0}", mapName);
				}
			}

			_currentMapFileName = _currentMapFile.Name;

			// load the collision map
			idR.CollisionModelManager.LoadMap(_currentMapFile);

			_clientCount = 0;

			// initialize all entities for this game
			_entities = new idEntity[idR.MaxGameEntities];
			_spawnIds = new int[idR.MaxGameEntities];

			_userCommands = new idUserCommand[0];
			_spawnCount = idGame.InitialSpawnCount;

			_spawnedEntities.Clear();
			_activeEntities.Clear();
			_entitiesToDeactivate = 0;

			_sortTeamMasters = false;
			_sortPushers = false;
			/*lastGUIEnt = NULL;
			lastGUI = 0;*/

			_globalMaterial = null;
			_globalMaterialParameters = new float[idE.MaxGlobalMaterialParameters];

			// always leave room for the max number of clients,
			// even if they aren't all used, so numbers inside that
			// range are NEVER anything but clients

			_entityCount = idR.MaxClients;
			_firstFreeIndex = idR.MaxClients;

			// reset the random number generator.
			_random = new Random((this.IsMultiplayer == true) ? randomSeed : 0);

			/*

			camera			= NULL;
			world			= NULL;
			testmodel		= NULL;
			testFx			= NULL;

			lastAIAlertEntity = NULL;
			lastAIAlertTime = 0;*/
			_previousTime = 0;
			_time = 0;
			_frameCount = 0;

			_sessionCommand = string.Empty;
			/*
			nextGibTime		= 0;

			vacuumAreaNum = -1;		// if an info_vacuum is spawned, it will set this

			*/

			_gravity = new Vector3(0, 0, -idR.CvarSystem.GetFloat("g_gravity"));
			_spawnArgs.Clear();

			/*skipCinematic = false;
			inCinematic = false;
			cinematicSkipTime = 0;
			cinematicStopTime = 0;
			cinematicMaxSkipTime = 0;*/

			_clip.Init();

			/*pvs.Init();
			playerPVS.i = -1;
			playerConnectedAreas.i = -1;

			// load navigation system for all the different monster sizes
			for( i = 0; i < aasNames.Num(); i++ ) {
				aasList[ i ]->Init( idStr( mapFileName ).SetFileExtension( aasNames[ i ] ).c_str(), mapFile->GetGeometryCRC() );
			}

			// clear the smoke particle free list
			smokeParticles->Init();*/

			// cache miscellanious media references
			FindEntityDef("preCacheExtras", false);

			if(isSameMap == false)
			{
				_currentMapFile.RemovePrimitiveData();
			}
		}
		public void DrawBigCharacter(int x, int y, int ch, idMaterial material)
		{
			ch &= 255;

			if(ch == ' ')
			{
				return;
			}

			if(y < -idE.BigCharacterHeight)
			{
				return;
			}

			int row = ch >> 4;
			int col = ch & 15;

			float frow = row * 0.0625f;
			float fcol = col * 0.0625f;
			float size = 0.0625f;

			DrawStretchPicture(x, y, idE.BigCharacterWidth, idE.BigCharacterHeight, fcol, frow, fcol + size, frow + size, material);
		}