Axiom.SceneManagers.Bsp.SpotlightFrustum.GetLightOrientation C# (CSharp) Method

GetLightOrientation() protected method

protected GetLightOrientation ( ) : Axiom.MathLib.Quaternion
return Axiom.MathLib.Quaternion
		protected Quaternion GetLightOrientation()
		{
			Vector3 zAdjustVec = -light.DerivedDirection;
			Vector3 xAxis, yAxis, zAxis;

			Quaternion orientation = ( lightNode == null ) ? Quaternion.Identity : lightNode.DerivedOrientation;

			// Get axes from current quaternion
			// get the vector components of the derived orientation vector
			orientation.ToAxes( out xAxis, out yAxis, out zAxis );

			Quaternion rotationQuat;

			if ( ( zAxis + zAdjustVec ).LengthSquared < 0.00001f )
			{
				// Oops, a 180 degree turn (infinite possible rotation axes)
				// Default to yaw i.e. use current UP
				rotationQuat = Quaternion.FromAngleAxis( Utility.PI, yAxis );
			}
			else
			{
				// Derive shortest arc to new direction
				rotationQuat = zAxis.GetRotationTo( zAdjustVec );
			}

			return rotationQuat * orientation;
		}
	}