Exemple #1
0
 /// <summary>
 /// Default constructor. Creates and initializes a spline from a List of nodes
 /// </summary>
 /// <param name="nodes">Nodes.</param>
 /// <param name="useBezierIfPossible">If set to <c>true</c> use bezier if possible.</param>
 /// <param name="useStraightLines">If set to <c>true</c> use straight lines.</param>
 public Spline(List <Vector3> nodes, bool useBezierIfPossible = false, bool useStraightLines = false)
 {
     // determine spline type and solver based on number of nodes
     if (useStraightLines || nodes.Count == 2)
     {
         splineType = SplineType.StraightLine;
         _solver    = new StraightLineSplineSolver(nodes);
     }
     else if (nodes.Count == 3)
     {
         splineType = SplineType.QuadraticBezier;
         _solver    = new QuadraticBezierSplineSolver(nodes);
     }
     else if (nodes.Count == 4)
     {
         splineType = SplineType.CubicBezier;
         _solver    = new CubicBezierSplineSolver(nodes);
     }
     else
     {
         if (useBezierIfPossible)
         {
             splineType = SplineType.Bezier;
             _solver    = new BezierSplineSolver(nodes);
         }
         else
         {
             splineType = SplineType.CatmullRom;
             _solver    = new CatmullRomSplineSolver(nodes);
         }
     }
 }
Exemple #2
0
		// default constructor
		public Spline( List<Vector3> nodes, bool useBezierIfPossible = false, bool useStraightLines = false )
		{
			// determine spline type and solver based on number of nodes
			if( useStraightLines || nodes.Count == 2 )
			{
				splineType = SplineType.StraightLine;
				_solver = new StraightLineSplineSolver( nodes );
			}
			else if( nodes.Count == 3 )
			{
				splineType = SplineType.QuadraticBezier;
				_solver = new QuadraticBezierSplineSolver( nodes );
			}
			else if( nodes.Count == 4 )
			{
				splineType = SplineType.CubicBezier;
				_solver = new CubicBezierSplineSolver( nodes );
			}
			else
			{
				if( useBezierIfPossible )
				{
					splineType = SplineType.Bezier;
					_solver = new BezierSplineSolver( nodes );
				}
				else
				{
					splineType = SplineType.CatmullRom;
					_solver = new CatmullRomSplineSolver( nodes );
				}
			}
		}