Axiom.Core.Light.GetAs4DVector C# (CSharp) Method

GetAs4DVector() public method

Gets the details of this light as a 4D vector.
Getting details of a light as a 4D vector can be useful for doing general calculations between different light types; for example the vector can represent both position lights (w=1.0f) and directional lights (w=0.0f) and be used in the same calculations.
public GetAs4DVector ( ) : Vector4
return Vector4
		public virtual Vector4 GetAs4DVector()
		{
			Vector4 vec;

			if ( this.type == LightType.Directional )
			{
				// negate direction as 'position'
				vec = -(Vector4)this.DerivedDirection;

				// infinite distance
				vec.w = 0.0f;
			}
			else
			{
				vec = (Vector4)this.DerivedPosition;
				vec.w = 1.0f;
			}

			return vec;
		}

Usage Example

        /// <summary>
        ///
        /// </summary>
        /// <param name="light"></param>
        /// <param name="extrusionDistance"></param>
        /// <returns></returns>
        public override AxisAlignedBox GetDarkCapBounds(Light light, float extrusionDistance)
        {
            // Extrude own light cap bounds
            // need a clone to avoid modifying the original bounding box
            worldDarkCapBounds = (AxisAlignedBox)GetLightCapBounds().Clone();

            ExtrudeBounds(worldDarkCapBounds, light.GetAs4DVector(), extrusionDistance);

            return(worldDarkCapBounds);
        }
All Usage Examples Of Axiom.Core.Light::GetAs4DVector