68 using System.Collections.Generic;
110 OutputKeyNodes=
new List<float[]>();
111 OutputTypeArray=
new List<string>();
113 OutputBfactArray =
new List<float> ();
115 Gizmos.color =
new Color(0.0f, 0.0f, 1.0f);
117 float currTime = c * Duration /
lineCount;
120 float[] currposfloat=
new float[3];
121 currposfloat[0]=currPos.x;
122 currposfloat[1]=currPos.y;
123 currposfloat[2]=currPos.z;
124 OutputKeyNodes.Add(currposfloat);
125 OutputTypeArray.Add(InputTypeArray[0]);
133 mNodes =
new List<SplineNode>();
134 step = Duration/InputKeyNodes.Count;
136 for (c = 0; c < InputKeyNodes.Count; c++) {
137 float[] vect=(
float[])InputKeyNodes[c];
138 Vector3 inputnode=
new Vector3(vect[0],vect[1],vect[2]);
139 mNodes.Add(
new SplineNode(inputnode, step*c));
143 mNodes.Insert(0,mNodes[0]);
144 mNodes.Add(mNodes[mNodes.Count-1]);
149 float t2 = t*t;
float t3 = t2*t;
151 Vector3 P0 = mNodes[idxFirstPoint-1].Point;
152 Vector3 P1 = mNodes[idxFirstPoint].Point;
153 Vector3 P2 = mNodes[idxFirstPoint+1].Point;
154 Vector3 P3 = mNodes[idxFirstPoint+2].Point;
156 float tension = 0.5f;
158 Vector3 T1 = tension * (P2 - P0);
159 Vector3 T2 = tension * (P3 - P1);
161 float Blend1 = 2*t3 - 3*t2 + 1;
162 float Blend2 = -2*t3 + 3*t2;
163 float Blend3 = t3 - 2*t2 + t;
164 float Blend4 = t3 - t2;
168 if (idxFirstPoint < mNodes.Count - 3) {
169 OutputBfactArray.Add (InputBfactArray [idxFirstPoint] + ((InputBfactArray [idxFirstPoint+1] - InputBfactArray [idxFirstPoint]) / smoothnessFactor) * (t * smoothnessFactor));
172 OutputBfactArray.Add (InputBfactArray [idxFirstPoint]);
176 return Blend1*P1 + Blend2*P2 + Blend3*T1 + Blend4*T2;
181 if (timeParam >= mNodes [mNodes.Count - 2].Time) {
183 OutputBfactArray.Add (InputBfactArray[InputBfactArray.Count-1]);
185 return mNodes [mNodes.Count - 2].Point;
188 for (c = 1; c < mNodes.Count-2; c++){
189 if (mNodes[c].Time > timeParam)
194 float param = (timeParam - mNodes[idx].Time) / (mNodes[idx+1].Time - mNodes[idx].Time);
static int smoothnessFactor
List< float > InputBfactArray
void SetupSplineInterpolator()
List< float > OutputBfactArray
List< float[]> OutputKeyNodes
static float Ease(float t, float k1, float k2)
Vector3 GetHermiteAtTime(float timeParam)
Vector3 GetHermiteInternal(int idxFirstPoint, float t)
List< SplineNode > mNodes
SplineNode(Vector3 p, float t)
List< string > OutputTypeArray
List< string > InputTypeArray