Exemplo n.º 1
0
        /// <summary>
        /// Creates a new CSpline.
        /// </summary>
        static public CSpline CSpline(bool inbLooped, List <CSplineVertex> inVertices)
        {
            CSpline spline = new CSpline(inVertices.Count);

            spline.SetAsCSpline();
            spline.SetLooped(inbLooped);
            spline.SetVertices(inVertices);
            return(spline);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new CSpline.
        /// </summary>
        static public CSpline CSpline(bool inbLooped, params CSplineVertex[] inVertices)
        {
            CSpline spline = new CSpline(inVertices.Length);

            spline.SetAsCSpline();
            spline.SetLooped(inbLooped);
            spline.SetVertices(inVertices);
            return(spline);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new CSpline from the given transforms using the Cardinal algorithm.
        /// </summary>
        static public CSpline Cardinal(bool inbLooped, float inTension, Space inSpace, List <Transform> inPoints)
        {
            CSpline spline = new CSpline(inPoints.Count);

            spline.SetAsCardinal(inTension);
            spline.SetLooped(inbLooped);
            spline.SetVertices(inPoints, inSpace);
            if (!inbLooped)
            {
                spline.ResetControlPoints();
            }
            return(spline);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a new CSpline from the given transforms using the Catmull-Rom algorithm.
        /// </summary>
        static public CSpline CatmullRom(bool inbLooped, Space inSpace, params Transform[] inPoints)
        {
            CSpline spline = new CSpline(inPoints.Length);

            spline.SetAsCatmullRom();
            spline.SetLooped(inbLooped);
            spline.SetVertices(inPoints, inSpace);
            if (!inbLooped)
            {
                spline.ResetControlPoints();
            }
            return(spline);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a new CSpline using the Cardinal algorithm.
        /// </summary>
        static public CSpline Cardinal(bool inbLooped, float inTension, params Vector2[] inPoints)
        {
            CSpline spline = new CSpline(inPoints.Length);

            spline.SetAsCardinal(inTension);
            spline.SetLooped(inbLooped);
            spline.SetVertices(inPoints);
            if (!inbLooped)
            {
                spline.ResetControlPoints();
            }
            return(spline);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a new CSpline using the Catmull-Rom algorithm.
        /// </summary>
        static public CSpline CatmullRom(bool inbLooped, List <Vector2> inPoints)
        {
            CSpline spline = new CSpline(inPoints.Count);

            spline.SetAsCatmullRom();
            spline.SetLooped(inbLooped);
            spline.SetVertices(inPoints);
            if (!inbLooped)
            {
                spline.ResetControlPoints();
            }
            return(spline);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates a new CSpline using the Catmull-Rom algorithm.
        /// </summary>
        static public CSpline CatmullRom(bool inbLooped, params Vector2[] inPoints)
        {
            CSpline spline = new CSpline(inPoints.Length);

            spline.SetAsCatmullRom();
            spline.SetLooped(inbLooped);
            spline.SetVertices(inPoints);
            if (!inbLooped)
            {
                spline.ResetControlPoints();
            }
            return(spline);
        }
Exemplo n.º 8
0
        private bool Generate(ref ISpline ioSpline)
        {
            bool bCreatedNew = false;

            switch (m_Type)
            {
            case GenType.Simple:
            {
                SimpleSpline s;
                if (ioSpline == null || ioSpline.GetSplineType() != SplineType.SimpleSpline)
                {
                    ioSpline    = s = new SimpleSpline(m_Vertices[0].Point, m_Vertices[1].Point, m_ControlPointA);
                    bCreatedNew = true;
                }
                else
                {
                    s = (SimpleSpline)ioSpline;

                    s.Start   = m_Vertices[0].Point;
                    s.End     = m_Vertices[1].Point;
                    s.Control = m_ControlPointA;

                    ioSpline = s;
                }
                break;
            }

            case GenType.Linear:
            {
                LinearSpline s;
                if (ioSpline == null || ioSpline.GetSplineType() != SplineType.LinearSpline)
                {
                    ioSpline    = s = new LinearSpline(m_Vertices.Length);
                    bCreatedNew = true;
                }
                else
                {
                    s = (LinearSpline)ioSpline;
                }

                s.SetLooped(m_Looped);
                s.SetVertices(m_Vertices);
                break;
            }

            case GenType.CSpline:
            {
                CSpline s;
                if (ioSpline == null || (ioSpline.GetSplineType() != SplineType.Cardinal && ioSpline.GetSplineType() != SplineType.CSpline))
                {
                    ioSpline    = s = new CSpline(m_Vertices.Length);
                    bCreatedNew = true;
                }
                else
                {
                    s = (CSpline)ioSpline;
                }

                s.SetAsCSpline();

                s.SetLooped(m_Looped);
                s.SetVertices(m_Vertices);
                break;
            }

            case GenType.Cardinal:
            {
                CSpline s;
                if (ioSpline == null || (ioSpline.GetSplineType() != SplineType.Cardinal && ioSpline.GetSplineType() != SplineType.CSpline))
                {
                    ioSpline    = s = new CSpline(m_Vertices.Length);
                    bCreatedNew = true;
                }
                else
                {
                    s = (CSpline)ioSpline;
                }

                s.SetAsCardinal(m_CRTension);

                s.SetLooped(m_Looped);
                s.SetVertices(m_Vertices);
                if (!m_Looped)
                {
                    s.SetControlPoints(m_ControlPointA, m_ControlPointB);
                }
                break;
            }

            default:
                throw new Exception("MultiSpline has not been properly set up in the inspector!");
            }

            return(bCreatedNew);
        }