/// <summary> /// Get parameter by a given semantic and index from the given parametr list /// </summary> /// <param name="paramList"> The parameters list to look in. </param> /// <param name="semantic"> The semantic of the paraemter to search in the list </param> /// <param name="index"> The index of the parameter to search in the list </param> /// <returns> null if no matching paramter found </returns> public static Parameter GetParameterBySemantic(List <Parameter> paramList, Parameter.SemanticType semantic, int index) { for (int it = 0; it < paramList.Count; it++) { if (paramList[it].Semantic == semantic && paramList[it].Index == index) { return(paramList[it]); } } return(null); }
/// <summary> /// Resolve input paramteter of this function /// </summary> /// <param name="semantic"> The desired parameter semantic </param> /// <param name="index"> The index of the desired parameter </param> /// <param name="content"> The Content of the parameter </param> /// <param name="type"> The type of the desired parameter </param> /// <returns> paramter instance in case of that resolve operation succeed </returns> internal Parameter ResolveLocalParameter(Parameter.SemanticType semantic, int index, Parameter.ContentType content, Graphics.GpuProgramParameters.GpuConstantType type) { Parameter param = Function.GetParameterByContent(this.localParameters, content, type); if (param != null) { return(param); } param = new Parameter(type, "lLocalParam_" + this.localParameters.Count.ToString(), semantic, index, content, 0); AddParameter(this.localParameters, param); return(param); }
/// <summary> /// Resolve local paramteter of this function /// </summary> /// <param name="semantic"> The desired parameter semantic </param> /// <param name="index"> The index of the desired parameter </param> /// <param name="name"> The name of the parameter </param> /// <param name="type"> The type of the desired parameter </param> /// <returns> paramter instance in case of that resolve operation succeed </returns> internal Parameter ResolveLocalParameter(Parameter.SemanticType semantic, int index, string name, Graphics.GpuProgramParameters.GpuConstantType type) { Parameter param = null; param = GetParameterByName(this.localParameters, name); if (param != null) { if (param.Type == type && param.Semantic == semantic && param.Index == index) { return(param); } else { throw new AxiomException("Cannot resolve local parameter due to type mismatch. Function <" + Name + ">"); } } param = new Parameter(type, name, semantic, index, Parameter.ContentType.Unknown, 0); AddParameter(this.localParameters, param); return(param); }
/// <summary> /// Resolve output paramteter of this function /// </summary> /// <param name="semantic"> The desired parameter semantic </param> /// <param name="index"> The index of the desired parameter </param> /// <param name="content"> The Content of the parameter </param> /// <param name="type"> The type of the desired parameter </param> /// <returns> paramter instance in case of that resolve operation succeed </returns> /// <remarks> /// Pass -1 as index paraemter to craete a new pareamter with the desired semantic and type /// </remarks> public Parameter ResolveOutputParameter(Parameter.SemanticType semantic, int index, Parameter.ContentType content, Graphics.GpuProgramParameters.GpuConstantType type) { Parameter param = null; //Check if desired parameter already defined param = Function.GetParameterByContent(this.outputParameters, content, type); if (param != null) { return(param); } //case we have to create new parameter. if (index == -1) { index = 0; //find the next availabe index of the target semantic for (int it = 0; it < this.outputParameters.Count; it++) { if (this.outputParameters[it].Semantic == semantic) { index++; } } } else { //check if desired parameter already defined param = GetParameterBySemantic(this.outputParameters, semantic, index); if (param != null && param.Content == content) { if (param.Type == type) { return(param); } else { throw new AxiomException("Cannot resolve parameter - semantic: " + semantic.ToString() + " - index: " + index.ToString() + " due to type mimatch. Function <" + Name + ">"); } } } //No parameter found -> create new one switch (semantic) { case Parameter.SemanticType.Unknown: break; case Parameter.SemanticType.Position: param = ParameterFactory.CreateOutPosition(index); break; case Parameter.SemanticType.BlendWeights: case Parameter.SemanticType.BlendIndicies: throw new AxiomException("Can not resolve parameter - semantic: " + semantic.ToString() + " - index: " + index.ToString() + " since support init is not implemented yet. Function <" + Name + ">"); case Parameter.SemanticType.Normal: param = ParameterFactory.CreateOutNormal(index); break; case Parameter.SemanticType.Color: param = ParameterFactory.CreateOutColor(index); break; case Parameter.SemanticType.TextureCoordinates: param = ParameterFactory.CreateOutTexcoord(type, index, content); break; case Parameter.SemanticType.Binormal: param = ParameterFactory.CreateOutBiNormal(index); break; case Parameter.SemanticType.Tangent: param = ParameterFactory.CreateOutTangent(index); break; default: break; } if (param != null) { AddOutputParameter(param); } return(param); }