Axiom.Graphics.AutoParamDataSource.GetLight C# (CSharp) Method

GetLight() public method

Get the light which is 'index'th closest to the current object
public GetLight ( int index ) : Light
index int Ordinal value signifying the light to retreive, with 0 being closest, 1 being next closest, etc.
return Axiom.Core.Light
		public Light GetLight( int index )
		{
			if ( currentLightList.Count <= index )
			{
				return blankLight;
			}
			else
			{
				return currentLightList[ index ];
			}
		}

Usage Example

		/// <summary>
		///    Updates the automatic light parameters based on the details provided.
		/// </summary>
		/// <param name="source">
		///    A source containing all the updated data to be made available for auto updating
		///    the GPU program constants.
		/// </param>
		public void UpdateAutoParamsLightsOnly( AutoParamDataSource source )
		{
			// return if no constants
			if ( !this.HasAutoConstantType )
			{
				return;
			}

            PassIterationNumberIndex = int.MaxValue;

			// loop through and update all constants based on their type
			for ( int i = 0; i < autoConstantList.Count; i++ )
			{
				AutoConstantEntry entry = autoConstantList[ i ];

				Vector3 vec3;

				switch ( entry.Type )
				{
					case AutoConstantType.LightDiffuseColor:
						SetConstant( entry.PhysicalIndex, source.GetLight( entry.Data ).Diffuse );
						break;

					case AutoConstantType.LightSpecularColor:
						SetConstant( entry.PhysicalIndex, source.GetLight( entry.Data ).Specular );
						break;

					case AutoConstantType.LightPosition:
						// Fix from Multiverse to enable Normal Mapping Sample Material from OGRE
						SetConstant( entry.PhysicalIndex, source.GetLight( entry.Data ).GetAs4DVector() );
						break;

					case AutoConstantType.LightDirection:
						vec3 = source.GetLight( 1 ).DerivedDirection;
						SetConstant( entry.PhysicalIndex, vec3.x, vec3.y, vec3.z, 1.0f );
						break;

					case AutoConstantType.LightPositionObjectSpace:
						SetConstant( entry.PhysicalIndex, source.InverseWorldMatrix * source.GetLight( entry.Data ).GetAs4DVector() );
						break;

					case AutoConstantType.LightDirectionObjectSpace:
						vec3 = source.InverseWorldMatrix * source.GetLight( entry.Data ).DerivedDirection;
						vec3.Normalize();
						SetConstant( entry.PhysicalIndex, vec3.x, vec3.y, vec3.z, 1.0f );
						break;

					case AutoConstantType.LightDistanceObjectSpace:
						vec3 = source.InverseWorldMatrix * source.GetLight( entry.Data ).DerivedPosition;
						SetConstant( entry.PhysicalIndex, vec3.Length, 0f, 0f, 0f );
						break;

					case AutoConstantType.ShadowExtrusionDistance:
						SetConstant( entry.PhysicalIndex, source.ShadowExtrusionDistance, 0f, 0f, 0f );
						break;

					case AutoConstantType.LightAttenuation:
						Light light = source.GetLight( entry.Data );
						SetConstant( entry.PhysicalIndex, light.AttenuationRange, light.AttenuationConstant, light.AttenuationLinear, light.AttenuationQuadratic );
						break;
					case AutoConstantType.LightPowerScale:
						SetConstant( entry.PhysicalIndex, source.GetLightPowerScale( entry.Data ) );
						break;
					case AutoConstantType.WorldMatrix:
						SetConstant( entry.PhysicalIndex, source.WorldMatrix );
						break;
					//case AutoConstantType.ViewProjMatrix:
					//    SetConstant( entry.PhysicalIndex, source.ViewProjectionMatrix );
					//    break;
                    case AutoConstantType.PassIterationNumber:
                        SetConstant(entry.PhysicalIndex, 0.0f);
                        PassIterationNumberIndex = entry.PhysicalIndex;
				        break;
				}
			}
		}
All Usage Examples Of Axiom.Graphics.AutoParamDataSource::GetLight