Axiom.Graphics.GpuProgramParameters.GetParamIndex C# (CSharp) Метод

GetParamIndex() публичный Метод

Gets the constant index of the specified named param.
public GetParamIndex ( string name ) : int
name string /// Name of the param. ///
Результат int
		public int GetParamIndex( string name )
		{
			if ( !namedParams.ContainsKey( name ) )
			{
				// name not found in map, should it be added to the map?
				if ( autoAddParamName )
				{
					// determine index
					// don't know which Constants list the name is for
					// so pick the largest index
					int index = floatConstants.Count > intConstants.Count ? floatConstants.Count : intConstants.Count;

					floatConstants.Resize( index + 1 );
					intConstants.Resize( index + 1 );
					MapParamNameToIndex( name, index );
					return index;
				}
				else
				{
					if ( this.ignoreMissingParameters )
					{
						return -1;
					}
					throw new Exception( string.Format( "Cannot find a param index for a param named '{0}'.", name ) );
				}
			}

			return (int)namedParams[ name ];
		}

Usage Example

Пример #1
0
		protected void _updateParameter( GpuProgramParameters programParameters, String paramName, Object value, int sizeInBytes )
		{
			programParameters.AutoAddParamName = true;

			if ( value is Axiom.Math.Matrix4 )
			{
				programParameters.SetConstant( programParameters.GetParamIndex( paramName ), (Axiom.Math.Matrix4)value );
			}
			else if ( value is Axiom.Core.ColorEx )
			{
				programParameters.SetConstant( programParameters.GetParamIndex( paramName ), (Axiom.Core.ColorEx)value );
			}
			else if ( value is Axiom.Math.Vector3 )
			{
				programParameters.SetConstant( programParameters.GetParamIndex( paramName ), ( (Axiom.Math.Vector3)value ) );
			}
			else if ( value is Axiom.Math.Vector4 )
			{
				programParameters.SetConstant( programParameters.GetParamIndex( paramName ), (Axiom.Math.Vector4)value );
			}
			else if ( value is float[] )
			{
				programParameters.SetConstant( programParameters.GetParamIndex( paramName ), (float[])value );
			}
			else if ( value is int[] )
			{
				programParameters.SetConstant( programParameters.GetParamIndex( paramName ), (int[])value );
			}
			else if ( value is float )
			{
				programParameters.SetConstant( programParameters.GetParamIndex( paramName ), new float[] { (float)value, 0.0f, 0.0f, 0.0f } );
			}
			else
			{
				programParameters.SetConstant( programParameters.GetParamIndex( paramName ), (float[])value );
			}

		}