public int collision(Rect3D src)
        {
            int ret = 0;

            if (ShowSubstationVisual3D)
            {
                for (int i = 0; i < ((Model3DGroup)group1.Children[0]).Children.Count; i++)
                {
                    Rect3D bb = ((Model3DGroup)group1.Children[0]).Children[i].Bounds;

                    if (src.IntersectsWith(bb))
                    {
                        ret++;
                    }
                }
            }

            if (ShowNodeVisual3D)
            {
                for (int i = 0; i < ((Model3DGroup)group2.Children[0]).Children.Count; i++)
                {
                    Rect3D bb = ((Model3DGroup)group2.Children[0]).Children[i].Bounds;

                    if (src.IntersectsWith(bb))
                    {
                        ret++;
                    }
                }
            }

            if (SwitchNodeVisual3D)
            {
                for (int i = 0; i < ((Model3DGroup)group3.Children[0]).Children.Count; i++)
                {
                    Rect3D bb = ((Model3DGroup)group3.Children[0]).Children[i].Bounds;

                    if (src.IntersectsWith(bb))
                    {
                        ret++;
                    }
                }
            }


            return(ret);
        }
Exemple #2
0
        bool IsInside(ModelVisual3D other)
        {
            Rect3D r = this.Content.Bounds;
            Rect3D o = other.Content.Bounds;

            return(r.IntersectsWith(o));

            /*return r.X <= o.X &&
             *     r.Y <= o.Y &&
             *     r.Z <= o.Z &&
             *     o.X >= r.X &&
             *     o.Y >= r.Y &&
             *     o.Z >= r.Z;
             */
        }
Exemple #3
0
 /// <summary>
 /// Returns true if either rectangle is inside the other or touching
 /// </summary>
 public static bool OverlapsWith(this Rect3D thisRect, Rect3D rect)
 {
     return(thisRect.IntersectsWith(rect) || thisRect.Contains(rect) || rect.Contains(thisRect));
 }