示例#1
0
    /// <summary>
    /// 绘制导线
    /// </summary>
    public void DrawLine()
    {
        Vector3 s      = m_line.StartLineLeap.Link != null ? m_line.StartLineLeap.Link.transform.position : m_line.StartLineLeap.transform.position;
        Vector3 e      = m_line.EndLineLeap.Link != null ? m_line.EndLineLeap.Link.transform.position : m_line.EndLineLeap.transform.position;
        bool    change = CheckCtrlChange(s, m_MidCtrl.transform.position, e);

        if (m_lpoint.Count > 0)
        {
            if (change == true)
            {
                Vector3[] resultList = PointController.PointList(pathList, pointnum);
                for (int i = 0; i < resultList.Length; i++)
                {
                    if (i == 0 && m_line.StartLineLeap.Link != null)
                    {
                        m_lpoint[0] = m_line.StartLineLeap.Link.transform.position;
                    }
                    else if (i == 0 && m_line.StartLineLeap.Link == null)
                    {
                        m_lpoint[0] = m_line.StartLineLeap.transform.position;
                    }
                    else
                    {
                        m_lpoint[i] = resultList[i];
                    }
                }
                if (m_line.EndLineLeap.Link != null)
                {
                    m_lpoint[resultList.Length - 1] = m_line.EndLineLeap.Link.transform.position;
                }
                else
                {
                    m_lpoint[resultList.Length - 1] = m_line.EndLineLeap.transform.position;
                }
                SetColloderPosition();
            }
        }
        else
        {
            Vector3[] resultList = PointController.PointList(pathList, pointnum);
            for (int i = 0; i < resultList.Length; i++)
            {
                m_lpoint.Add(resultList[i]);
            }
            InitCollider();
            m_fLineMiniDistance = U3DUtil.GetVectorListDistance(m_lpoint);
        }
        //if (CheckMiniDistance())
        //{
        //    return;
        //}
        //循环100遍来绘制贝塞尔曲线每个线段
        for (int i = 0; i < m_lpoint.Count; i++)
        {
            Vector3 vec = m_lpoint[i];
            //把每条线段绘制出来 完成白塞尔曲线的绘制
            Line.SetPosition(i, vec);
            Line.SetWidth(fwidth, fwidth);
        }
    }
示例#2
0
    /// <summary>
    /// 检测线是否到最短距离
    /// </summary>
    /// <returns></returns>
    public bool CheckMiniDistance()
    {
        float d = U3DUtil.GetVectorListDistance(m_lpoint);

        if (d <= m_fLineMiniDistance)
        {
            return(true);
        }
        return(false);
    }