/// <summary> /// Creates the destination parameter by a given class and index. /// </summary> /// <param name="usage"> </param> /// <param name="index"> </param> protected void CreateDestinationParamter(int usage, int index) { Axiom.Graphics.GpuProgramParameters.GpuConstantType dstParamType = Graphics.GpuProgramParameters.GpuConstantType.Unknown; switch (UsedFloatCount) { case 1: dstParamType = Graphics.GpuProgramParameters.GpuConstantType.Float1; break; case 2: dstParamType = Graphics.GpuProgramParameters.GpuConstantType.Float2; break; case 3: dstParamType = Graphics.GpuProgramParameters.GpuConstantType.Float3; break; case 4: dstParamType = Graphics.GpuProgramParameters.GpuConstantType.Float4; break; } if (usage == (int)Operand.OpSemantic.In) { this.dstParameter = ParameterFactory.CreateInTexcoord(dstParamType, index, Parameter.ContentType.Unknown); } else { this.dstParameter = ParameterFactory.CreateOutTexcoord(dstParamType, index, Parameter.ContentType.Unknown); } }
/// <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> /// <remarks> /// Pass -1 as index paraemter to craete a new pareamter with the desired semantic and type /// </remarks> public Parameter ResolveInputParameter(Parameter.SemanticType semantic, int index, Parameter.ContentType content, Graphics.GpuProgramParameters.GpuConstantType type) { Parameter param = null; //Check if desried parameter already defined param = Function.GetParameterByContent(this.inputParameters, content, type); if (param != null) { return(param); } //Case we have to create new parameter if (index == -1) { index = 0; //find the next available index of the target semantic for (int it = 0; it < this.inputParameters.Count; it++) { if (this.inputParameters[it].Semantic == semantic) { index++; } } } else { //check if desried parameter already defined param = Function.GetParameterBySemantic(this.inputParameters, 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 one switch (semantic) { case Parameter.SemanticType.Unknown: break; case Parameter.SemanticType.Position: param = ParameterFactory.CreateInPosition(index); break; case Parameter.SemanticType.BlendWeights: param = ParameterFactory.CreateInWeights(index); break; case Parameter.SemanticType.BlendIndicies: param = ParameterFactory.CreateInIndices(index); break; case Parameter.SemanticType.Normal: param = ParameterFactory.CreateInNormal(index); break; case Parameter.SemanticType.Color: param = ParameterFactory.CreateInColor(index); break; case Parameter.SemanticType.TextureCoordinates: param = ParameterFactory.CreateInTexcoord(type, index, content); break; case Parameter.SemanticType.Binormal: param = ParameterFactory.CreateInBiNormal(index); break; case Parameter.SemanticType.Tangent: param = ParameterFactory.CreateInTangent(index); break; } if (param != null) { AddInputParameter(param); } return(param); }