Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public override bool Parse(string text)
        {
            if (this.Disposed == true)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }

            idLexer lexer = new idLexer(idDeclFile.LexerOptions);

            lexer.LoadMemory(text, this.FileName, this.LineNumber);
            lexer.SkipUntilString("{");

            List <SkinMapping> mappings         = new List <SkinMapping>();
            List <string>      associatedModels = new List <string>();

            idToken token, token2;
            string  tokenLower;

            while (true)
            {
                if ((token = lexer.ReadToken()) == null)
                {
                    break;
                }

                tokenLower = token.ToString().ToLower();

                if (tokenLower == "}")
                {
                    break;
                }
                else if ((token2 = lexer.ReadToken()) == null)
                {
                    lexer.Warning("Unexpected end of file");
                    MakeDefault();

                    break;
                }
                else if (tokenLower == "model")
                {
                    associatedModels.Add(token2.ToString());
                    continue;
                }

                SkinMapping map = new SkinMapping();
                map.To = idE.DeclManager.FindMaterial(token2.ToString());

                if (tokenLower == "*")
                {
                    // wildcard.
                    map.From = null;
                }
                else
                {
                    map.From = idE.DeclManager.FindMaterial(token.ToString());
                }

                mappings.Add(map);
            }

            _mappings         = mappings.ToArray();
            _associatedModels = associatedModels.ToArray();

            return(false);
        }
Ejemplo n.º 3
0
		public override bool Parse(string text)
		{
			if(this.Disposed == true)
			{
				throw new ObjectDisposedException(this.GetType().Name);
			}

			idLexer lexer = new idLexer(idDeclFile.LexerOptions);
			lexer.LoadMemory(text, this.FileName, this.LineNumber);
			lexer.SkipUntilString("{");

			List<SkinMapping> mappings = new List<SkinMapping>();
			List<string> associatedModels = new List<string>();

			idToken token, token2;
			string tokenLower;

			while(true)
			{
				if((token = lexer.ReadToken()) == null)
				{
					break;
				}

				tokenLower = token.ToString().ToLower();

				if(tokenLower == "}")
				{
					break;
				}
				else if((token2 = lexer.ReadToken()) == null)
				{
					lexer.Warning("Unexpected end of file");
					MakeDefault();

					break;
				}
				else if(tokenLower == "model")
				{
					associatedModels.Add(token2.ToString());
					continue;
				}

				SkinMapping map = new SkinMapping();
				map.To = idE.DeclManager.FindMaterial(token2.ToString());

				if(tokenLower == "*")
				{
					// wildcard.
					map.From = null;
				}
				else
				{
					map.From = idE.DeclManager.FindMaterial(token.ToString());
				}
				
				mappings.Add(map);
			}

			_mappings = mappings.ToArray();
			_associatedModels = associatedModels.ToArray();

			return false;
		}