public void OnSceneGUI()
        {
            ConeConstraintMB mb = (ConeConstraintMB)target;

            if (mb == null)
            {
                return;
            }

            Transform j       = mb.transform;
            Transform jparent = j.parent;
            Transform jchild  = mb.nextJoint;

            if (jchild == null)
            {
                return;
            }

            var saveColor = Handles.color;

            float szMul = EUtil.GetHandleSize(j.position, 3f) * ms_markerSize;

            Vector3 worldRefAxis = Misc.TransformDirection(jparent, mb.refAxis).normalized;

            //1. draw the refAxis
            Handles.color = Color.red;
            Handles.DrawAAPolyLine(4f, j.position, j.position + worldRefAxis * szMul * 1.5f); //ref axis

            //2. draw the cone
            float angleLimit = mb.angleLimit;

            Handles.color = ms_markerColor;

            float   zdist        = Mathf.Cos(Mathf.Deg2Rad * angleLimit) * szMul;
            float   radius       = Mathf.Sin(Mathf.Deg2Rad * angleLimit) * szMul;
            Vector3 circleCenter = j.position + worldRefAxis * zdist;

            Handles.DrawWireDisc(circleCenter, worldRefAxis, radius);

            Vector3 pseudoXAxis = Vector3.Cross(Vector3.up, worldRefAxis).normalized;

            if (pseudoXAxis == Vector3.zero)
            {
                pseudoXAxis = Vector3.right;
            }
            Vector3 pseudoYAxis = Vector3.Cross(worldRefAxis, pseudoXAxis).normalized;

            Handles.DrawAAPolyLine(3f, j.position, circleCenter + radius * pseudoXAxis);
            Handles.DrawAAPolyLine(3f, j.position, circleCenter - radius * pseudoXAxis);
            Handles.DrawAAPolyLine(3f, j.position, circleCenter + radius * pseudoYAxis);
            Handles.DrawAAPolyLine(3f, j.position, circleCenter - radius * pseudoYAxis);

            Handles.color = saveColor;
        }
        public void OnSceneGUI()
        {
            AngleConstraintMB mb = (AngleConstraintMB)target;

            if (mb == null)
            {
                return;
            }

            Transform j       = mb.transform;
            Transform jparent = j.parent;
            Transform jchild  = mb.nextJoint;

            if (jchild == null)
            {
                return;
            }

            var oldColor = Handles.color;

            float szMul = EUtil.GetHandleSize(j.position, 3f) * ms_markerSize;

            Vector3 worldRotAxis  = Misc.TransformDirection(jparent, mb.rotAxis).normalized;
            Vector3 worldPrimAxis = Misc.TransformDirection(jparent, mb.primAxis).normalized;

            float   minLimit     = mb.minLimit;
            float   maxLimit     = mb.maxLimit;
            Vector3 worldFromVec = Quaternion.AngleAxis(minLimit, worldRotAxis) * worldPrimAxis;

            Handles.color = ms_arcColor;
            Handles.DrawSolidArc(j.position, worldRotAxis, worldFromVec,
                                 maxLimit - minLimit, szMul);

            Handles.color = Color.red;
            Handles.DrawAAPolyLine(5f, j.position, j.position + worldRotAxis * szMul);  //rot axis
            Handles.color = Color.green;
            Handles.DrawAAPolyLine(5f, j.position, j.position + worldPrimAxis * szMul); //start dir

            Handles.color = oldColor;
        }