Axiom.Core.Camera.ForwardIntersect C# (CSharp) Method

ForwardIntersect() private method

private ForwardIntersect ( Plane worldPlane, IList intersect3D ) : void
worldPlane Axiom.Math.Plane
intersect3D IList
return void
        public virtual void ForwardIntersect(Plane worldPlane, IList<Vector4> intersect3D)
        {
            if (intersect3D == null)
                return;

            var trCorner = WorldSpaceCorners[0];
            var tlCorner = WorldSpaceCorners[1];
            var blCorner = WorldSpaceCorners[2];
            var brCorner = WorldSpaceCorners[3];

            // need some sort of rotation that will bring the plane normal to the z axis
            var pval = worldPlane;
            if (pval.Normal.z < 0.0)
            {
                pval.Normal *= -1.0;
                pval.D *= -1.0;
            }
            var invPlaneRot = pval.Normal.GetRotationTo(Vector3.UnitZ);

            var vec = new Vector3[4];

            // get rotated light
            var lPos = invPlaneRot * DerivedPosition;
            vec[0] = invPlaneRot * trCorner - lPos;
            vec[1] = invPlaneRot * tlCorner - lPos;
            vec[2] = invPlaneRot * blCorner - lPos;
            vec[3] = invPlaneRot * brCorner - lPos;

            var iPnt = GetRayForwardIntersect(lPos, vec, -pval.D);

            // return wanted data
            //if (intersect3D != null) // cant be null
            {
                var planeRot = invPlaneRot.Inverse();
                intersect3D.Clear();
                foreach (var v in iPnt)
                {
                    var intersection = planeRot * new Vector3(v.x, v.y, v.z);
                    intersect3D.Add(new Vector4(intersection.x, intersection.y, intersection.z, v.w));
                }
            }
        }