Beispiel #1
0
        private bool ChildContains(RTObject child, RTObject obj)
        {
            if (child.Equals(obj))
            {
                return(true);
            }

            var group = child as Group;

            if (group != null)
            {
                if (group.Contains(obj))
                {
                    return(true);
                }
            }

            var csg = child as CSG;

            if (csg != null)
            {
                return(ChildContains(csg.Left, obj) || ChildContains(csg.Right, obj));
            }

            return(false);
        }
Beispiel #2
0
        public bool IsShadowed(RTObject obj, Computations comps, Point lightPosition, Point point)
        {
            bool isShadowed = false;

            var v         = new Vector(lightPosition - point);
            var distance  = v.Magnitude;
            var direction = v.Normalize;

            var r             = new Ray(point, direction);
            var intersections = Intersect(r);

            var h = intersections.Hit;

            if ((h != null) && (h.t < distance) && (h.t > MathHelper.Epsilon))
            {
                var dN = obj is Triangle?direction.Dot(comps.NormalVector) : -1;

                if (!obj.Equals(h.Object) && h.Object.HasShadow && (dN <= 0))
                {
                    isShadowed = true;
                }
            }

            return(isShadowed);
        }