GetLight() public méthode

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.
Résultat Axiom.Core.Light
		/// <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;
				}
			}
		}
        /// <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.HasAutoConstants) {
                return;
            }

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

                Vector3 vec3;
                Light light;
                int i;

                switch(entry.type) {
                    case AutoConstants.LightDiffuseColor:
                        SetConstant(entry.index, source.GetLight(entry.data).Diffuse);
                        break;

                    case AutoConstants.LightSpecularColor:
                        SetConstant(entry.index, source.GetLight(entry.data).Specular);
                        break;

                    case AutoConstants.LightPosition:
                        SetConstant(entry.index, source.GetLight(entry.data).DerivedPosition);
                        break;

                    case AutoConstants.LightDirection:
                        vec3 = source.GetLight(entry.data).DerivedDirection;
                        SetConstant(entry.index, vec3.x, vec3.y, vec3.z, 1.0f);
                        break;

                    case AutoConstants.LightPositionObjectSpace:
                        SetConstant(entry.index, source.InverseWorldMatrix * source.GetLight(entry.data).GetAs4DVector());
                        break;

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

                    case AutoConstants.LightPositionViewSpace:
                        SetConstant(entry.index, source.ViewMatrix.TransformAffine(source.GetLight(entry.data).GetAs4DVector()));
                        break;

                    case AutoConstants.LightDirectionViewSpace:
                        vec3 = source.InverseViewMatrix.Transpose() * source.GetLight(entry.data).DerivedDirection;
                        vec3.Normalize();
                        SetConstant(entry.index, vec3.x, vec3.y, vec3.z, 1.0f);
                        break;

                    case AutoConstants.LightDistanceObjectSpace:
                        vec3 = source.InverseWorldMatrix * source.GetLight(entry.data).DerivedPosition;
                        SetConstant(entry.index, vec3.Length);
                        break;

                    case AutoConstants.ShadowExtrusionDistance:
                        SetConstant(entry.index, source.ShadowExtrusionDistance);
                        break;

                    case AutoConstants.ShadowSceneDepthRange:
                        SetConstant(entry.index, source.GetShadowSceneDepthRange(entry.data));
                        break;

                    case AutoConstants.LightPower:
                        SetConstant(entry.index, source.GetLight(entry.data).PowerScale);
                        break;

                    case AutoConstants.LightAttenuation:
                        light = source.GetLight(entry.data);
                        SetConstant(entry.index, light.AttenuationRange, light.AttenuationConstant, light.AttenuationLinear, light.AttenuationQuadratic);
                        break;

                    case AutoConstants.SpotlightParams:
                        light = source.GetLight(entry.data);
                        if (light.Type == LightType.Spotlight)
                            SetConstant(entry.index,
                                (float)Math.Cos(MathUtil.DegreesToRadians(light.SpotlightInnerAngle) * 0.5),
                                (float)Math.Cos(MathUtil.DegreesToRadians(light.SpotlightOuterAngle) * 0.5),
                                light.SpotlightFalloff,
                                1.0f);
                        else
                            SetConstant(entry.index, 1f, 0f, 0f, 1f);
                        break;

                    case AutoConstants.LightDiffuseColorArray:
                        for (i=0; i<entry.data; i++)
                            SetConstant(entry.index + i, source.GetLight(i).Diffuse);
                        break;

                    case AutoConstants.LightSpecularColorArray:
                        for (i=0; i<entry.data; i++)
                            SetConstant(entry.index + i, source.GetLight(i).Specular);
                        break;

                    case AutoConstants.LightPositionArray:
                        for (i=0; i<entry.data; i++)
                            SetConstant(entry.index + i, source.GetLight(i).DerivedPosition);
                        break;

                    case AutoConstants.LightDirectionArray:
                        for (i=0; i<entry.data; i++) {
                            vec3 = source.GetLight(i).DerivedDirection;
                            SetConstant(entry.index + i, vec3.x, vec3.y, vec3.z, 1.0f);
                        }
                        break;

                    case AutoConstants.LightPositionObjectSpaceArray:
                        for (i=0; i<entry.data; i++)
                            SetConstant(entry.index + i, source.ViewMatrix.TransformAffine(source.GetLight(i).GetAs4DVector()));
                        break;

                    case AutoConstants.LightDirectionObjectSpaceArray:
                        for (i=0; i<entry.data; i++) {
                            vec3 = source.InverseWorldMatrix.TransformAffine(source.GetLight(i).DerivedDirection);
                            SetConstant(entry.index + i, vec3.x, vec3.y, vec3.z, 1.0f);
                        }
                        break;

                    case AutoConstants.LightPositionViewSpaceArray:
                        for (i=0; i<entry.data; i++)
             						    SetConstant(entry.index + i, source.ViewMatrix.TransformAffine(source.GetLight(i).GetAs4DVector()));
                        break;

                    case AutoConstants.LightDirectionViewSpaceArray:
                        for (i=0; i<entry.data; i++) {
                            vec3 = source.InverseViewMatrix.Transpose() * source.GetLight(i).DerivedDirection;
                            vec3.Normalize();
                            SetConstant(entry.index + i, vec3.x, vec3.y, vec3.z, 1.0f);
                        }
                        break;

                    case AutoConstants.LightDistanceObjectSpaceArray:
                        for (i=0; i<entry.data; i++) {
                            vec3 = source.InverseWorldMatrix * source.GetLight(i).DerivedPosition;
                            SetConstant(entry.index + i, vec3.Length);
                        }
                        break;

                    case AutoConstants.LightPowerArray:
                        for (i=0; i<entry.data; i++)
                            SetConstant(entry.index + i, source.GetLight(i).PowerScale);
                        break;

                    case AutoConstants.LightAttenuationArray:
                        for (i=0; i<entry.data; i++) {
                            light = source.GetLight(i);
                            SetConstant(entry.index + i, light.AttenuationRange, light.AttenuationConstant, light.AttenuationLinear, light.AttenuationQuadratic);
                        }
                        break;

                    case AutoConstants.SpotlightParamsArray:
                        for (i=0; i<entry.data; i++) {
                            light = source.GetLight(i);
                            if (light.Type == LightType.Spotlight)
                                SetConstant(entry.index + 1,
                                    (float)Math.Cos(MathUtil.DegreesToRadians(light.SpotlightInnerAngle) * 0.5),
                                    (float)Math.Cos(MathUtil.DegreesToRadians(light.SpotlightOuterAngle) * 0.5),
                                    light.SpotlightFalloff,
                                    1.0f);
                            else
                                SetConstant(entry.index + i, 1f, 0f, 0f, 1f);
                        }
                        break;

                    case AutoConstants.DerivedLightDiffuseColor:
                        SetConstant(entry.index, source.GetLight(entry.data).Diffuse * source.CurrentPass.Diffuse);
                        break;

                    case AutoConstants.DerivedLightSpecularColor:
                        SetConstant(entry.index, source.GetLight(entry.data).Diffuse * source.CurrentPass.Specular);
                        break;

                    case AutoConstants.DerivedLightDiffuseColorArray:
                        for (i=0; i<entry.data; i++) {
                            light = source.GetLight(i);
                            SetConstant(entry.index + i, light.Diffuse * source.CurrentPass.Diffuse);
                        }
                        break;

                    case AutoConstants.DerivedLightSpecularColorArray:
                        for (i=0; i<entry.data; i++) {
                            light = source.GetLight(i);
                            SetConstant(entry.index + i, light.Specular * source.CurrentPass.Diffuse);
                        }
                        break;

                    case AutoConstants.TextureViewProjMatrix:
                        SetConstant(entry.index, source.GetTextureViewProjectionMatrix(entry.data));
                        break;

                    default:
                        // do nothing
                        break;
                }
            }
        }