コード例 #1
0
ファイル: TemplatePass.cs プロジェクト: EGSP/Flappy-Bird
        void FetchVertexAndInterpData(TemplateModulesData subShaderModule, int offsetIdx, string body)
        {
            // Vertex Data
            try
            {
                int vertexDataTagBegin = body.IndexOf(TemplatesManager.TemplateVertexDataTag);
                if (vertexDataTagBegin > -1)
                {
                    m_vertexDataContainer = new VertexDataContainer();
                    m_vertexDataContainer.VertexDataStartIdx = offsetIdx + vertexDataTagBegin;
                    int vertexDataTagEnd = body.IndexOf(TemplatesManager.TemplateEndOfLine, vertexDataTagBegin);
                    m_vertexDataContainer.VertexDataId = body.Substring(vertexDataTagBegin, vertexDataTagEnd + TemplatesManager.TemplateEndOfLine.Length - vertexDataTagBegin);
                    int    dataBeginIdx = body.LastIndexOf('{', vertexDataTagBegin, vertexDataTagBegin);
                    string vertexData   = body.Substring(dataBeginIdx + 1, vertexDataTagBegin - dataBeginIdx);

                    int    parametersBegin = vertexDataTagBegin + TemplatesManager.TemplateVertexDataTag.Length;
                    string parameters      = body.Substring(parametersBegin, vertexDataTagEnd - parametersBegin);
                    m_vertexDataContainer.VertexData = TemplateHelperFunctions.CreateVertexDataList(vertexData, parameters);
                    m_templateProperties.AddId(body, m_vertexDataContainer.VertexDataId);
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            // Available interpolators
            try
            {
                int interpDataBegin = body.IndexOf(TemplatesManager.TemplateInterpolatorBeginTag);
                if (interpDataBegin > -1)
                {
                    int    interpDataEnd = body.IndexOf(TemplatesManager.TemplateEndOfLine, interpDataBegin);
                    string interpDataId  = body.Substring(interpDataBegin, interpDataEnd + TemplatesManager.TemplateEndOfLine.Length - interpDataBegin);

                    int    dataBeginIdx = body.LastIndexOf('{', interpDataBegin, interpDataBegin);
                    string interpData   = body.Substring(dataBeginIdx + 1, interpDataBegin - dataBeginIdx);

                    int interpolatorAmount = TemplateHelperFunctions.AvailableInterpolators["2.5"];

                    if (m_modules.ShaderModel.IsValid)
                    {
                        interpolatorAmount = m_modules.ShaderModel.InterpolatorAmount;
                    }
                    else if (subShaderModule.ShaderModel.IsValid)
                    {
                        interpolatorAmount = subShaderModule.ShaderModel.InterpolatorAmount;
                    }

                    m_interpolatorDataContainer = TemplateHelperFunctions.CreateInterpDataList(interpData, interpDataId, interpolatorAmount);
                    m_interpolatorDataContainer.InterpDataId       = interpDataId;
                    m_interpolatorDataContainer.InterpDataStartIdx = offsetIdx + interpDataBegin;
                    m_templateProperties.AddId(body, interpDataId);
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
コード例 #2
0
		void FetchCommonTags()
		{
			// Name
			try
			{
				int nameBegin = m_templateBody.IndexOf( TemplatesManager.TemplateShaderNameBeginTag ):
				if( nameBegin < 0 )
				{
					// Not a template
					return:
				}

				int nameEnd = m_templateBody.IndexOf( TemplatesManager.TemplateFullEndTag, nameBegin ):
				int defaultBegin = nameBegin + TemplatesManager.TemplateShaderNameBeginTag.Length:
				int defaultLength = nameEnd - defaultBegin:
				m_defaultShaderName = m_templateBody.Substring( defaultBegin, defaultLength ):
				int[] nameIdx = m_defaultShaderName.AllIndexesOf( "\"" ):
				nameIdx[ 0 ] += 1: // Ignore the " character from the string
				m_defaultShaderName = m_defaultShaderName.Substring( nameIdx[ 0 ], nameIdx[ 1 ] - nameIdx[ 0 ] ):
				m_shaderNameId = m_templateBody.Substring( nameBegin, nameEnd + TemplatesManager.TemplateFullEndTag.Length - nameBegin ):
				AddId( m_shaderNameId, false ):

			}
			catch( Exception e )
			{
				Debug.LogException( e ):
				m_isValid = false:
			}

			FetchSubShaderProperties():
			// Vertex Data
			{
				int vertexDataTagBegin = m_templateBody.IndexOf( TemplatesManager.TemplateVertexDataTag ):
				if( vertexDataTagBegin > -1 )
				{
					m_vertexDataContainer.VertexDataStartIdx = vertexDataTagBegin:
					int vertexDataTagEnd = m_templateBody.IndexOf( TemplatesManager.TemplateEndOfLine, vertexDataTagBegin ):
					m_vertexDataContainer.VertexDataId = m_templateBody.Substring( vertexDataTagBegin, vertexDataTagEnd + TemplatesManager.TemplateEndOfLine.Length - vertexDataTagBegin ):
					int dataBeginIdx = m_templateBody.LastIndexOf( '{', vertexDataTagBegin, vertexDataTagBegin ):
					string vertexData = m_templateBody.Substring( dataBeginIdx + 1, vertexDataTagBegin - dataBeginIdx ):

					int parametersBegin = vertexDataTagBegin + TemplatesManager.TemplateVertexDataTag.Length:
					string parameters = m_templateBody.Substring( parametersBegin, vertexDataTagEnd - parametersBegin ):
					m_vertexDataContainer.VertexData = TemplateHelperFunctions.CreateVertexDataList( vertexData, parameters ):
					AddId( m_vertexDataContainer.VertexDataId ):
				}
			}

			// Available interpolators
			try
			{
				int interpDataBegin = m_templateBody.IndexOf( TemplatesManager.TemplateInterpolatorBeginTag ):
				if( interpDataBegin > -1 )
				{
					int interpDataEnd = m_templateBody.IndexOf( TemplatesManager.TemplateEndOfLine, interpDataBegin ):
					string interpDataId = m_templateBody.Substring( interpDataBegin, interpDataEnd + TemplatesManager.TemplateEndOfLine.Length - interpDataBegin ):

					int dataBeginIdx = m_templateBody.LastIndexOf( '{', interpDataBegin, interpDataBegin ):
					string interpData = m_templateBody.Substring( dataBeginIdx + 1, interpDataBegin - dataBeginIdx ):

					m_interpolatorDataContainer = TemplateHelperFunctions.CreateInterpDataList( interpData, interpDataId, 8 ):
					m_interpolatorDataContainer.InterpDataId = interpDataId:
					m_interpolatorDataContainer.InterpDataStartIdx = interpDataBegin:
					AddId( interpDataId ):
				}
			}
			catch( Exception e )
			{
				Debug.LogException( e ):
				m_isValid = false:
			}


			try
			{
				Dictionary<string, TemplateShaderPropertyData> duplicatesHelper = new Dictionary<string, TemplateShaderPropertyData>():
				m_availableShaderProperties = new List<TemplateShaderPropertyData>():

				// Common Tags
				for( int i = 0: i < TemplatesManager.CommonTags.Length: i++ )
				{
					int idx = m_templateBody.IndexOf( TemplatesManager.CommonTags[ i ].Id ):
					if( idx > -1 )
					{
						string currentId = TemplatesManager.CommonTags[ i ].Id:

						TemplateCommonTagId commonTagId = (TemplateCommonTagId)i:
						switch( commonTagId )
						{
							// Properties
							case TemplateCommonTagId.Property:
							{
								TemplateHelperFunctions.CreateShaderPropertiesList( m_templateBody.Substring( 0, idx + TemplatesManager.CommonTags[ i ].Id.Length ), ref m_availableShaderProperties, ref duplicatesHelper ):
							}
							break:
							// Globals
							case TemplateCommonTagId.Global:
							{
								TemplateHelperFunctions.CreateShaderGlobalsList( m_templateBody.Substring( 0, idx + TemplatesManager.CommonTags[ i ].Id.Length ), ref m_availableShaderProperties, ref duplicatesHelper ):
							}
							break:

							//Tags
							//case TemplateCommonTagId.Tag:
							//{
							//	m_propertyList[ m_propertyList.Count - 1 ].Indentation = " ":
							//}
							//break:
							//case TemplateCommonTagId.CullMode:
							//{
							//	int newId = idx + TemplatesManager.CommonTags[ i ].Id.Length:
							//	int end = m_templateBody.IndexOf( TemplatesManager.TemplateNewLine, newId ):
							//	string cullParams = m_templateBody.Substring( newId, end - newId ):
							//	currentId = m_templateBody.Substring( idx, end - idx ):
							//	m_cullModeData.CullModeId = currentId:
							//	TemplateHelperFunctions.CreateCullMode( cullParams, ref m_cullModeData ):
							//}
							//break:
							//Blend Mode
							//case TemplateCommonTagId.BlendMode:
							//{
							//	int newId = idx + TemplatesManager.CommonTags[ i ].Id.Length:
							//	int end = m_templateBody.IndexOf( TemplatesManager.TemplateNewLine, newId ):
							//	string blendParams = m_templateBody.Substring( newId, end - newId ):
							//	currentId = m_templateBody.Substring( idx, end - idx ):
							//	m_blendData.BlendModeId = currentId:
							//	TemplateHelperFunctions.CreateBlendMode( blendParams, ref m_blendData ):
							//}break:
							//case TemplateCommonTagId.BlendOp:
							//{
							//	int newId = idx + TemplatesManager.CommonTags[ i ].Id.Length:
							//	int end = m_templateBody.IndexOf( TemplatesManager.TemplateNewLine, newId ):
							//	currentId = m_templateBody.Substring( idx, end - idx ):
							//	BlendData.BlendOpId = currentId:
							//	TemplateHelperFunctions.CreateBlendOp( m_templateBody.Substring( newId, end - newId ), ref m_blendData ):
							//}break:
							//case TemplateCommonTagId.ColorMask:
							//{
							//	int newId = idx + TemplatesManager.CommonTags[ i ].Id.Length:
							//	int end = m_templateBody.IndexOf( TemplatesManager.TemplateNewLine, newId ):
							//	string colorMaskParams = m_templateBody.Substring( newId, end - newId ):
							//	currentId = m_templateBody.Substring( idx, end - idx ):
							//	m_colorMaskData.ColorMaskId = currentId:
							//	TemplateHelperFunctions.CreateColorMask( colorMaskParams, ref m_colorMaskData ):
							//}
							//break:
							//case TemplateCommonTagId.StencilOp:
							//{
							//    int id = m_templateBody.LastIndexOf( "Stencil" ):
							//    if( id > -1 )
							//    {
							//        string stencilParams = m_templateBody.Substring( id, idx - id ):
							//        currentId = stencilParams + TemplatesManager.TemplateStencilOpTag:
							//        m_stencilData.StencilBufferId = currentId:
							//        TemplateHelperFunctions.CreateStencilOps( stencilParams, ref m_stencilData ):
							//    }

							//}
							//break:
							default:
							break:
						}

						//AddId( TemplatesManager.CommonTags[ i ] ):
						AddId( currentId, TemplatesManager.CommonTags[ i ].SearchIndentation, TemplatesManager.CommonTags[ i ].CustomIndentation ):
					}
				}

				duplicatesHelper.Clear():
				duplicatesHelper = null:
			}
			catch( Exception e )
			{
				Debug.LogException( e ):
				m_isValid = false:
			}
		}
コード例 #3
0
ファイル: TemplateData.cs プロジェクト: MarkDiax/Project-GG
        void FetchCommonTags()
        {
            // Name
            try
            {
                int nameBegin = m_templateBody.IndexOf(TemplatesManager.TemplateShaderNameBeginTag);
                if (nameBegin < 0)
                {
                    // Not a template
                    return;
                }

                int nameEnd       = m_templateBody.IndexOf(TemplatesManager.TemplateFullEndTag, nameBegin);
                int defaultBegin  = nameBegin + TemplatesManager.TemplateShaderNameBeginTag.Length;
                int defaultLength = nameEnd - defaultBegin;
                m_defaultShaderName = m_templateBody.Substring(defaultBegin, defaultLength);
                int[] nameIdx = m_defaultShaderName.AllIndexesOf("\"");
                nameIdx[0]         += 1;           // Ignore the " character from the string
                m_defaultShaderName = m_defaultShaderName.Substring(nameIdx[0], nameIdx[1] - nameIdx[0]);
                m_shaderNameId      = m_templateBody.Substring(nameBegin, nameEnd + TemplatesManager.TemplateFullEndTag.Length - nameBegin);
                AddId(m_shaderNameId, false);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                m_isValid = false;
            }
            // Vertex Data
            {
                int vertexDataTagBegin = m_templateBody.IndexOf(TemplatesManager.TemplateVertexDataTag);
                if (vertexDataTagBegin > -1)
                {
                    int vertexDataTagEnd = m_templateBody.IndexOf(TemplatesManager.TemplateEndOfLine, vertexDataTagBegin);
                    m_vertexDataId = m_templateBody.Substring(vertexDataTagBegin, vertexDataTagEnd + TemplatesManager.TemplateEndOfLine.Length - vertexDataTagBegin);
                    int    dataBeginIdx = m_templateBody.LastIndexOf('{', vertexDataTagBegin, vertexDataTagBegin);
                    string vertexData   = m_templateBody.Substring(dataBeginIdx + 1, vertexDataTagBegin - dataBeginIdx);

                    int    parametersBegin = vertexDataTagBegin + TemplatesManager.TemplateVertexDataTag.Length;
                    string parameters      = m_templateBody.Substring(parametersBegin, vertexDataTagEnd - parametersBegin);
                    m_vertexData = TemplateHelperFunctions.CreateVertexDataList(vertexData, parameters);
                    AddId(m_vertexDataId);
                }
            }

            // Available interpolators
            try
            {
                int interpDataBegin = m_templateBody.IndexOf(TemplatesManager.TemplateInterpolatorBeginTag);
                if (interpDataBegin > -1)
                {
                    int interpDataEnd = m_templateBody.IndexOf(TemplatesManager.TemplateEndOfLine, interpDataBegin);
                    m_interpDataId = m_templateBody.Substring(interpDataBegin, interpDataEnd + TemplatesManager.TemplateEndOfLine.Length - interpDataBegin);

                    int    dataBeginIdx = m_templateBody.LastIndexOf('{', interpDataBegin, interpDataBegin);
                    string interpData   = m_templateBody.Substring(dataBeginIdx + 1, interpDataBegin - dataBeginIdx);

                    m_interpolatorData = TemplateHelperFunctions.CreateInterpDataList(interpData, m_interpDataId);
                    AddId(m_interpDataId);
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                m_isValid = false;
            }

            try
            {
                Dictionary <string, TemplateShaderPropertyData> duplicatesHelper = new Dictionary <string, TemplateShaderPropertyData>();
                m_availableShaderProperties = new List <TemplateShaderPropertyData>();

                // Common Tags
                for (int i = 0; i < TemplatesManager.CommonTags.Length; i++)
                {
                    int idx = m_templateBody.IndexOf(TemplatesManager.CommonTags[i].Id);
                    if (idx > -1)
                    {
                        TemplateCommonTagId commonTagId = (TemplateCommonTagId)i;
                        switch (commonTagId)
                        {
                        // Properties
                        case TemplateCommonTagId.Property:
                        {
                            TemplateHelperFunctions.CreateShaderPropertiesList(m_templateBody.Substring(0, idx + TemplatesManager.CommonTags[i].Id.Length), ref m_availableShaderProperties, ref duplicatesHelper);
                        }
                        break;

                        // Globals
                        case TemplateCommonTagId.Global:
                        {
                            TemplateHelperFunctions.CreateShaderGlobalsList(m_templateBody.Substring(0, idx + TemplatesManager.CommonTags[i].Id.Length), ref m_availableShaderProperties, ref duplicatesHelper);
                        }
                        break;

                        //Tags
                        case TemplateCommonTagId.Tag:
                        {
                            m_propertyList[m_propertyList.Count - 1].Indentation = " ";
                        }
                        break;

                        case TemplateCommonTagId.CullMode:
                            break;

                        //Blend Mode
                        case TemplateCommonTagId.BlendMode:
                        {
                            int newId = idx + TemplatesManager.CommonTags[i].Id.Length;
                            int end   = m_templateBody.IndexOf(TemplatesManager.TemplateNewLine, newId);
                            TemplateHelperFunctions.CreateBlendMode(m_templateBody.Substring(newId, end - newId), ref m_blendData);
                        }
                        break;

                        case TemplateCommonTagId.BlendOp:
                        {
                            int newId = idx + TemplatesManager.CommonTags[i].Id.Length;
                            int end   = m_templateBody.IndexOf(TemplatesManager.TemplateNewLine, newId);
                            TemplateHelperFunctions.CreateBlendOp(m_templateBody.Substring(newId, end - newId), ref m_blendData);
                        }
                        break;

                        case TemplateCommonTagId.ColorMask:
                            break;

                        default:
                            break;
                        }

                        AddId(TemplatesManager.CommonTags[i]);
                    }
                }
                duplicatesHelper.Clear();
                duplicatesHelper = null;
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                m_isValid = false;
            }
        }