68 using System.Collections.Generic;
105 OutputKeyNodes=
new List<float[]>();
106 OutputTypeArray=
new List<string>();
108 Gizmos.color =
new Color(0.0f, 0.0f, 1.0f);
110 float currTime = c * Duration /
lineCount;
113 float[] currposfloat=
new float[3];
114 currposfloat[0]=currPos.x;
115 currposfloat[1]=currPos.y;
116 currposfloat[2]=currPos.z;
117 OutputKeyNodes.Add(currposfloat);
118 OutputTypeArray.Add(InputTypeArray[0]);
127 mNodes =
new List<SplineNode>();
128 step = Duration/InputKeyNodes.Count;
130 for (c = 0; c < InputKeyNodes.Count; c++) {
131 float[] vect=(
float[])InputKeyNodes[c];
132 Vector3 inputnode=
new Vector3(vect[0],vect[1],vect[2]);
133 mNodes.Add(
new SplineNode(inputnode, step*c));
137 mNodes.Insert(0,mNodes[0]);
138 mNodes.Add(mNodes[mNodes.Count-1]);
143 float t2 = t*t;
float t3 = t2*t;
145 Vector3 P0 = mNodes[idxFirstPoint-1].Point;
146 Vector3 P1 = mNodes[idxFirstPoint].Point;
147 Vector3 P2 = mNodes[idxFirstPoint+1].Point;
148 Vector3 P3 = mNodes[idxFirstPoint+2].Point;
150 float tension = 0.5f;
152 Vector3 T1 = tension * (P2 - P0);
153 Vector3 T2 = tension * (P3 - P1);
155 float Blend1 = 2*t3 - 3*t2 + 1;
156 float Blend2 = -2*t3 + 3*t2;
157 float Blend3 = t3 - 2*t2 + t;
158 float Blend4 = t3 - t2;
160 return Blend1*P1 + Blend2*P2 + Blend3*T1 + Blend4*T2;
165 if (timeParam >= mNodes[mNodes.Count-2].Time)
166 return mNodes[mNodes.Count-2].Point;
168 for (c = 1; c < mNodes.Count-2; c++){
169 if (mNodes[c].Time > timeParam)
174 float param = (timeParam - mNodes[idx].Time) / (mNodes[idx+1].Time - mNodes[idx].Time);
static float Ease(float t, float k1, float k2)
List< float[]> OutputKeyNodes
List< SplineNode > mNodes
List< string > OutputTypeArray
void SetupSplineInterpolator()
static int smoothnessFactor
Vector3 GetHermiteAtTime(float timeParam)
SplineNode(Vector3 p, float t)
List< string > InputTypeArray
Vector3 GetHermiteInternal(int idxFirstPoint, float t)