示例#1
0
        private void OnDrawGizmos()
        {
            Gizmos.matrix = transform.localToWorldMatrix;

            bool intersect = UGeometry.RayBSIntersect(m_Sphere, m_Ray);

            Gizmos.color = intersect ? Color.green : Color.grey;
            Gizmos.DrawWireSphere(m_Sphere.center, m_Sphere.radius);
            Vector2 distances = UGeometry.RayBSDistance(m_Sphere, m_Ray);

            Gizmos.color = intersect ? Color.white:Color.grey;
            float rayDistance = 1f;

            if (distances.x >= 0)
            {
                Gizmos.color = Color.blue;
                rayDistance  = distances.x;
                Gizmos.DrawSphere(m_Ray.GetPoint(distances.x), .1f);
            }
            if (distances.y >= 0)
            {
                Gizmos.color = Color.red;
                rayDistance  = distances.y;
                Gizmos.DrawSphere(m_Ray.GetPoint(distances.y), .1f);
            }
            Gizmos.color = Color.white;
            Gizmos_Extend.DrawLine(m_Ray.ToLine(rayDistance));
        }
        private void OnDrawGizmos()
        {
            Gizmos.matrix = transform.localToWorldMatrix;
            Gizmos.color  = Color.white;
            Gizmos.DrawSphere(m_Point, .1f);
            float distances = UGeometry.PointRayProjection(m_Point, m_Ray);

            Handles_Extend.DrawLine(m_Ray.ToLine(distances));
            Gizmos.color = Color.blue;
            Gizmos.DrawSphere(m_Ray.GetPoint(distances), .1f);

            Gizmos.color = Color.white;
            Vector2 lineRayDistances = UGeometry.LineRayProjection(m_Line1, m_Ray1);

            Gizmos_Extend.DrawLine(m_Line1);
            Gizmos_Extend.DrawLine(m_Ray1.ToLine(lineRayDistances.y));
            Gizmos.color = Color.blue;
            Gizmos.DrawSphere(m_Line1.GetPoint(lineRayDistances.x), .1f);
            Gizmos.color = Color.red;
            Gizmos.DrawSphere(m_Ray1.GetPoint(lineRayDistances.y), .1f);

            Gizmos.color = Color.white;
            Vector2 rayrayDistances = UGeometry.RayRayProjection(m_Ray20, m_Ray21);

            Gizmos_Extend.DrawLine(m_Ray20.ToLine(rayrayDistances.x));
            Gizmos_Extend.DrawLine(m_Ray21.ToLine(rayrayDistances.y));
            Gizmos.color = Color.blue;
            Gizmos.DrawSphere(m_Ray20.GetPoint(rayrayDistances.x), .1f);
            Gizmos.color = Color.red;
            Gizmos.DrawSphere(m_Ray21.GetPoint(rayrayDistances.y), .1f);
        }
        private void OnDrawGizmos()
        {
            float distance = UGeometry.RayPlaneDistance(m_Plane, m_Ray);

            Gizmos.matrix = transform.localToWorldMatrix;
            Vector3 planeSize   = new Vector3(1, 0, 1);
            float   rayDistance = 1f;
            bool    intersect   = distance >= 0;

            if (intersect)
            {
                Vector3 hitPoint = m_Ray.GetPoint(distance);
                Gizmos.color = Color.red;
                Gizmos.DrawSphere(hitPoint, .05f);
                rayDistance = distance;
                planeSize   = new Vector3(Mathf.Max(1, Mathf.Abs(hitPoint.x) * 2), 0, Mathf.Max(1, Mathf.Abs(hitPoint.z) * 2));
            }

            Gizmos.color = intersect? Color.white:Color.grey;
            Gizmos_Extend.DrawLine(m_Ray.ToLine(rayDistance));
            Gizmos.matrix = transform.localToWorldMatrix * Matrix4x4.TRS(m_Plane.Position, Quaternion.LookRotation(Vector3.forward, m_Plane.normal), Vector3.one);
            Gizmos.color  = intersect ? Color.green : Color.grey;
            Gizmos_Extend.DrawArrow(Vector3.zero, Quaternion.LookRotation(Vector3.up), .3f, .1f);
            Gizmos.DrawWireCube(Vector3.zero, planeSize);
        }
        private void OnDrawGizmos()
        {
            Gizmos.color  = Color.grey;
            Gizmos.matrix = transform.localToWorldMatrix;
            float   rayDistance = 1f;
            Vector2 distances   = UGeometry.RayConeDistance(m_Data, m_Ray);

            if (distances.x >= 0)
            {
                Gizmos.color = Color.blue;
                rayDistance  = distances.x;
                Gizmos.DrawSphere(m_Ray.GetPoint(rayDistance), .1f);
                Gizmos.color = Color.green;
            }
            if (distances.y >= 0)
            {
                Gizmos.color = Color.red;
                rayDistance  = distances.y;
                Gizmos.DrawSphere(m_Ray.GetPoint(rayDistance), .1f);
                Gizmos.color = Color.green;
            }
            Gizmos_Extend.DrawCone(m_Data);
            Gizmos.color = Color.white;
            Gizmos_Extend.DrawLine(m_Ray.ToLine(rayDistance));
        }
        private void OnDrawGizmos()
        {
            Gizmos.matrix = transform.localToWorldMatrix;
            bool intersect = UGeometry.RayAABBIntersect(m_Box, m_Ray);

            Gizmos.color = intersect ? Color.green : Color.grey;
            Gizmos.DrawWireCube(m_Box.center, m_Box.Size);

            Vector2 distances = UGeometry.RayAABBDistance(m_Box, m_Ray);

            if (distances.y > 0)
            {
                Gizmos.color = Color.red;
                Gizmos.DrawSphere(m_Ray.GetPoint(distances.y + distances.x), .1f);
                if (distances.x > 0)
                {
                    Gizmos.color = Color.blue;
                    Gizmos.DrawSphere(m_Ray.GetPoint(distances.x), .1f);
                }
            }

            Gizmos.color = intersect ? Color.white:Color.grey;
            Gizmos_Extend.DrawLine(m_Ray.ToLine(distances.x + distances.y));
        }