Ejemplo n.º 1
0
        private void OnDrawGizmos()
        {
            Segment3 segment = CreateSegment3(P0, P1);
            AAB3     box     = CreateAAB3(Box_Point0, Box_Point1);

            bool             test = Intersection.TestSegment3AAB3(ref segment, ref box);
            Segment3AAB3Intr info;
            bool             find = Intersection.FindSegment3AAB3(ref segment, ref box, out info);

            FiguresColor();
            DrawSegment(ref segment);
            DrawAAB(ref box);

            if (find)
            {
                ResultsColor();
                if (info.IntersectionType == IntersectionTypes.Point)
                {
                    DrawPoint(info.Point0);
                }
                else if (info.IntersectionType == IntersectionTypes.Segment)
                {
                    DrawSegment(info.Point0, info.Point1);
                    DrawPoint(info.Point0);
                    DrawPoint(info.Point1);
                }
            }

            LogInfo(info.IntersectionType);
            if (test != find)
            {
                LogError("test != find");
            }
        }
        private void OnDrawGizmos()
        {
            Line3 line = CreateLine3(Line);
            AAB3  box  = CreateAAB3(Box_Point0, Box_Point1);

            bool          test = Intersection.TestLine3AAB3(ref line, ref box);
            Line3AAB3Intr info;
            bool          find = Intersection.FindLine3AAB3(ref line, ref box, out info);

            FiguresColor();
            DrawLine(ref line);
            DrawAAB(ref box);

            if (find)
            {
                ResultsColor();
                if (info.IntersectionType == IntersectionTypes.Point)
                {
                    DrawPoint(info.Point0);
                }
                else if (info.IntersectionType == IntersectionTypes.Segment)
                {
                    DrawSegment(info.Point0, info.Point1);
                    DrawPoint(info.Point0);
                    DrawPoint(info.Point1);
                }
            }

            LogInfo(info.IntersectionType);
            if (test != find)
            {
                LogError("test != find");
            }
        }
        private void OnDrawGizmos()
        {
            Ray3 ray = CreateRay3(Ray);
            AAB3 box = CreateAAB3(Box_Point0, Box_Point1);

            bool         test = Intersection.TestRay3AAB3(ref ray, ref box);
            Ray3AAB3Intr info;
            bool         find = Intersection.FindRay3AAB3(ref ray, ref box, out info);

            FiguresColor();
            DrawRay(ref ray);
            DrawAAB(ref box);

            if (find)
            {
                ResultsColor();
                if (info.IntersectionType == IntersectionTypes.Point)
                {
                    DrawPoint(info.Point0);
                }
                else if (info.IntersectionType == IntersectionTypes.Segment)
                {
                    DrawSegment(info.Point0, info.Point1);
                    DrawPoint(info.Point0);
                    DrawPoint(info.Point1);
                }
            }

            LogInfo(info.IntersectionType);
            if (test != find)
            {
                LogError("test != find");
            }
        }
Ejemplo n.º 4
0
 private void Update()
 {
     if (ToggleToGenerate != _previous)
     {
         _points = GenerateRandomSet3D(GenerateRadius, GenerateCountMin, GenerateCountMax);
         _aab    = AAB3.CreateFromPoints(_points);
     }
     _previous = ToggleToGenerate;
 }
        private void OnDrawGizmos()
        {
            Plane3 plane = CreatePlane3(Plane);
            AAB3   box   = CreateAAB3(Box_Point0, Box_Point1);

            bool test = Intersection.TestPlane3AAB3(ref plane, ref box);

            FiguresColor();
            DrawPlane(ref plane, Plane);
            DrawAAB(ref box);

            LogInfo("Intersection: " + test);
        }
Ejemplo n.º 6
0
        private void OnDrawGizmos()
        {
            AAB3    box    = CreateAAB3(Box_Point0, Box_Point1);
            Sphere3 sphere = CreateSphere3(Sphere);

            bool test = Intersection.TestAAB3Sphere3(ref box, ref sphere);

            FiguresColor();
            DrawAAB(ref box);
            DrawSphere(ref sphere);

            LogInfo(test);
        }
Ejemplo n.º 7
0
        private void OnDrawGizmos()
        {
            Vector3 point = Point.position;
            AAB3    box   = CreateAAB3(Box_Point0, Box_Point1);

            bool cont = box.Contains(point);

            FiguresColor();
            DrawAAB(ref box);
            if (cont)
            {
                ResultsColor();
            }
            DrawPoint(point);

            LogInfo(cont);
        }
Ejemplo n.º 8
0
        private void OnDrawGizmos()
        {
            Vector3 point = Point.position;
            AAB3    box   = CreateAAB3(Box_Point0, Box_Point1);

            Vector3 closestPoint;
            float   dist  = Distance.Point3AAB3(ref point, ref box, out closestPoint);
            float   dist1 = Distance.SqrPoint3AAB3(ref point, ref box);
            float   dist2 = box.DistanceTo(point);

            FiguresColor();
            DrawAAB(ref box);

            ResultsColor();
            DrawPoint(closestPoint);

            LogInfo(dist + " " + Mathf.Sqrt(dist1) + " " + dist2);
        }
        protected void DrawAAB(ref AAB3 box)
        {
            Vector3 v0, v1, v2, v3, v4, v5, v6, v7;

            box.CalcVertices(out v0, out v1, out v2, out v3, out v4, out v5, out v6, out v7);
            Gizmos.DrawLine(v0, v1);
            Gizmos.DrawLine(v1, v2);
            Gizmos.DrawLine(v2, v3);
            Gizmos.DrawLine(v3, v0);
            Gizmos.DrawLine(v4, v5);
            Gizmos.DrawLine(v5, v6);
            Gizmos.DrawLine(v6, v7);
            Gizmos.DrawLine(v7, v4);
            Gizmos.DrawLine(v0, v4);
            Gizmos.DrawLine(v1, v5);
            Gizmos.DrawLine(v2, v6);
            Gizmos.DrawLine(v3, v7);
        }
        private void OnDrawGizmos()
        {
            Plane3  plane  = CreatePlane3(Plane);
            Vector3 point  = Point.position;
            AAB3    aab    = CreateAAB3(AABMin, AABMax);
            Box3    box    = CreateBox3(Box);
            Sphere3 sphere = CreateSphere3(Sphere);

            // Get side information.
            // -1 - on the negative side of the plane
            //  0 - on the plane or intersecting the plane
            // +1 - on the positive side of the plane
            int pointSide  = plane.QuerySide(point);
            int aabSide    = plane.QuerySide(ref aab);
            int boxSide    = plane.QuerySide(ref box);
            int sphereSide = plane.QuerySide(ref sphere);

            // true when an object is on the positive side of the plane
            bool pointPos  = plane.QuerySidePositive(point);
            bool aabPos    = plane.QuerySidePositive(ref aab);
            bool boxPos    = plane.QuerySidePositive(ref box);
            bool spherePos = plane.QuerySidePositive(ref sphere);

            // true when an object is on the negative side of the plane
            bool pointNeg  = plane.QuerySideNegative(point);
            bool aabNeg    = plane.QuerySideNegative(ref aab);
            bool boxNeg    = plane.QuerySideNegative(ref box);
            bool sphereNeg = plane.QuerySideNegative(ref sphere);

            // Note that positive/negative tests are little bit more optimized than just query,
            // as they don't have separate check for 0 case.

            FiguresColor();
            DrawPlane(ref plane, Plane);

            SetColor(pointSide); DrawPoint(point);
            SetColor(aabSide); DrawAAB(ref aab);
            SetColor(boxSide); DrawBox(ref box);
            SetColor(sphereSide); DrawSphere(ref sphere);

            LogInfo("PointSignedDistance: " + plane.SignedDistanceTo(point) + " PointNeg: " + pointNeg + " PointPos: " + pointPos + "     AABNeg: " + aabNeg + " AABPos: " + aabPos + "     BoxNeg: " + boxNeg + " BoxPos: " + boxPos + "     SphereNeg: " + sphereNeg + " SpherePos: " + spherePos);
        }
Ejemplo n.º 11
0
        private void OnDrawGizmos()
        {
            AAB3 box0 = CreateAAB3(Box0_Point0, Box0_Point1);
            AAB3 box1 = CreateAAB3(Box1_Point0, Box1_Point1);

            AAB3 intr;
            bool find = Intersection.FindAAB3AAB3(ref box0, ref box1, out intr);

            FiguresColor();
            DrawAAB(ref box0);
            DrawAAB(ref box1);

            if (find)
            {
                ResultsColor();
                DrawAAB(ref intr);
            }

            LogInfo(find);
        }
 protected AAB3 CreateAAB3(Transform point0, Transform point1)
 {
     // Creates aab from two unsorted points, if you know min and max use constructor
     return(AAB3.CreateFromTwoPoints(point0.position, point1.position));
 }