Пример #1
0
    /**
     * Method to get position based on spline segment (Points[segPos]-Points[segPos+1]) and
     * t value.
     **/
    public OrientedPoint GetPos(int segPos, float t)
    {
        Vector3 p0;
        Vector3 p1;
        Vector3 m0;
        Vector3 m1;

        p0 = Points[segPos].transform.position;
        p1 = Points[segPos + 1].transform.position;

        if (segPos == 0)
        {
            m0 = p1 - p0;
        }
        else
        {
            m0 = 0.5f * (p1 - Points[segPos - 1].transform.position);
        }

        if (segPos < Points.Count - 2)
        {
            m1 = 0.5f * (Points[(segPos + 2) % Points.Count].transform.position - p0);
        }
        else
        {
            m1 = p1 - p0;
        }

        return(CatmullRom.GetOrientedPoint(p0, p1, m0, m1, t));
    }
Пример #2
0
    public OrientedPoint GetWallPos(int segPos, float t, List <Vector3> wallPoints)
    {
        Vector3 p0;
        Vector3 p1;
        Vector3 m0;
        Vector3 m1;

        p0 = wallPoints[segPos];
        p1 = wallPoints[segPos + 1];

        if (segPos == 0)
        {
            m0 = p1 - p0;
        }
        else
        {
            m0 = 0.5f * (p1 - wallPoints[segPos - 1]);
        }

        if (segPos < Points.Count - 2)
        {
            m1 = 0.5f * (wallPoints[(segPos + 2) % wallPoints.Count] - p0);
        }
        else
        {
            m1 = p1 - p0;
        }

        return(CatmullRom.GetOrientedPoint(p0, p1, m0, m1, t));
    }