Exemplo n.º 1
0
        private static ISectData ISectGroundPlane(Vector3d direction, Point3d origin)
        {
            ISectData isect = null;

            direction.Normalize();
            direction.Scale(10000.0f);

            GPendp.Set(origin);
            GPendp.x += direction.x;
            GPendp.y += direction.y;
            GPendp.z += direction.z;
            // intersect with the imaginary groundplane object;
            if (m_gp == null)
            {
                CreateGroundPlane();
            }
            if (IntersectSphere(origin, GPendp, ref GPintersect, m_gp.m_center, m_gp.m_radius))
            {
                foreach (Polygon p in m_gp.m_lstpolys)
                {
                    //GPintersect = new Point3d();
                    // try a less- costly sphere intersect here
                    if (IntersectSphere(origin, GPendp, ref GPintersect, p.m_center, p.m_radius))
                    {
                        // if it intersects,
                        if (RTUtils.IntersectPoly(p, origin, GPendp, ref GPintersect))
                        {
                            isect = new ISectData(m_gp, p, GPintersect, origin, direction);
                        }
                    }
                }
            }
            return(isect);
        }
Exemplo n.º 2
0
        private static ISectData ISectObjSelPlane(Vector3d direction, Point3d origin)
        {
            ISectData isect = null;

            if (m_selplane == null)
            {
                return(null);
            }
            direction.Normalize();
            direction.Scale(10000.0f);

            ObSelendp.Set(origin);
            ObSelendp.x += direction.x;
            ObSelendp.y += direction.y;
            ObSelendp.z += direction.z;
            // intersect with the imaginary object selection plane
            if (IntersectSphere(origin, ObSelendp, ref ObSelintersect, m_selplane.m_center, m_selplane.m_radius))
            {
                foreach (Polygon p in m_selplane.m_lstpolys)
                {
                    // try a less- costly sphere intersect here
                    if (IntersectSphere(origin, ObSelendp, ref ObSelintersect, p.m_center, p.m_radius))
                    {
                        // if it intersects,
                        if (RTUtils.IntersectPoly(p, origin, ObSelendp, ref ObSelintersect))
                        {
                            isect = new ISectData(m_selplane, p, ObSelendp, origin, direction);
                        }
                    }
                }
            }
            return(isect);
        }
Exemplo n.º 3
0
        public static List <ISectData> IntersectObjects(Vector3d direction, Point3d origin, List <Object3d> objects, bool supports)
        {
            //List<ISectData> m_isectlst = new List<ISectData>();

            try
            {
                if (!vecinit)
                {
                    Initvecs();
                }
                m_isectlst.Clear();
                direction.Normalize();
                direction.Scale(10000.0f);


                IOendp.Set(origin);
                IOendp.x += direction.x;
                IOendp.y += direction.y;
                IOendp.z += direction.z;
                lock (lck)
                {
                    foreach (Object3d obj in objects)
                    {
                        if (obj.tag == Object3d.OBJ_SUPPORT && !supports)
                        {
                            continue;
                        }
                        // try a less- costly sphere intersect here
                        if (IntersectSphere(origin, IOendp, ref IOintersect, obj.m_center, obj.m_radius))
                        {
                            foreach (Polygon p in obj.m_lstpolys)
                            {
                                //IOintersect = new Point3d();
                                // try a less- costly sphere intersect here
                                if (IntersectSphere(origin, IOendp, ref IOintersect, p.m_center, p.m_radius))
                                {
                                    // if it intersects,
                                    if (RTUtils.IntersectPoly(p, origin, IOendp, ref IOintersect))
                                    {
                                        m_isectlst.Add(new ISectData(obj, p, IOintersect, origin, direction));
                                    }
                                }
                            }
                        }
                    }
                }
                ISectData gp = ISectGroundPlane(direction, origin);
                if (gp != null)
                {
                    m_isectlst.Add(gp);
                }
                m_isectlst.Sort();
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex.Message);
            }
            return(m_isectlst);
        }
Exemplo n.º 4
0
        public static List <ISectData> IntersectObject(Vector3d direction, Point3d origin, Object3d objectin,
                                                       bool supports)
        {
            try
            {
                if (!vecinit)
                {
                    Initvecs();
                }
                //m_isectlst.Clear();
                direction.Normalize();
                direction.Scale(10000.0f);


                IOendp.Set(origin);
                IOendp.x += direction.x;
                IOendp.y += direction.y;
                IOendp.z += direction.z;
                if (objectin.tag == Object3d.OBJ_SUPPORT && !supports)
                {
                    return(null);
                }
                // try a less- costly sphere intersect here
                if (IntersectSphere(origin, IOendp, ref IOintersect, objectin.m_center, objectin.m_radius))
                {
                    List <Polygon> interSectionObjects = objectin.IntersectForUpVector(origin, direction);
                    m_isectlst.AddRange(from p in interSectionObjects where RTUtils.IntersectPoly(p, origin, IOendp, ref IOintersect) select new ISectData(objectin, p, IOintersect, origin, direction));
                }
                //intersect the ground plane
                ISectData gp = ISectGroundPlane(direction, origin);
                if (gp != null)
                {
                    m_isectlst.Add(gp);
                }

                /*
                 * //intersect the object selection plane
                 * ISectData obsel = ISectObjSelPlane(direction, origin);
                 * if (obsel != null)
                 * {
                 *  m_isectlst.Add(obsel);
                 * }
                 */
                m_isectlst.Sort();
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex.Message);
            }
            return(m_isectlst);
        }
Exemplo n.º 5
0
        public static List <ISectData> IntersectObject(Vector3d direction, Point3d origin, List <Object3d> objectsin,
                                                       bool supports, Object3d obj)
        {
            m_isectlst.Clear();
            try
            {
                if (IntersectSphere(origin, IOendp, ref IOintersect, obj.m_center, obj.m_radius))
                {
                    List <Polygon> interSectionObjects = obj.IntersectForUpVector(origin, direction);

                    foreach (Polygon p in interSectionObjects)
                    {
                        //IOintersect = new Point3d();
                        // try a less- costly sphere intersect here
                        //if (IntersectSphere(origin, IOendp, ref IOintersect, p.m_center, p.m_radius))
                        //{
                        // if it intersects,
                        if (RTUtils.IntersectPoly(p, origin, IOendp, ref IOintersect))
                        {
                            m_isectlst.Add(new ISectData(obj, p, IOintersect, origin, direction));
                        }
                        //}
                    }
                }
                ISectData gp = ISectGroundPlane(direction, origin);
                if (gp != null)
                {
                    m_isectlst.Add(gp);
                }

                /*
                 * //intersect the object selection plane
                 * ISectData obsel = ISectObjSelPlane(direction, origin);
                 * if (obsel != null)
                 * {
                 *  m_isectlst.Add(obsel);
                 * }
                 */
                m_isectlst.Sort();
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex.Message);
            }
            return(m_isectlst);
        }