コード例 #1
0
ファイル: idDeclSkin.cs プロジェクト: PEMantis/idtech4.net
        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);
        }
コード例 #2
0
ファイル: idDeclSkin.cs プロジェクト: PEMantis/idtech4.net
        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);
        }
コード例 #3
0
ファイル: idDeclSkin.cs プロジェクト: iainmckay/idtech4.net
		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;
		}