|
1 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
2 |
// Copyright 2016 Leszek Koltunski //
|
|
3 |
// //
|
|
4 |
// This file is part of Distorted. //
|
|
5 |
// //
|
|
6 |
// Distorted is free software: you can redistribute it and/or modify //
|
|
7 |
// it under the terms of the GNU General Public License as published by //
|
|
8 |
// the Free Software Foundation, either version 2 of the License, or //
|
|
9 |
// (at your option) any later version. //
|
|
10 |
// //
|
|
11 |
// Distorted is distributed in the hope that it will be useful, //
|
|
12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
14 |
// GNU General Public License for more details. //
|
|
15 |
// //
|
|
16 |
// You should have received a copy of the GNU General Public License //
|
|
17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
|
18 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
19 |
|
|
20 |
package org.distorted.library.type;
|
|
21 |
|
|
22 |
import java.util.Vector;
|
|
23 |
|
|
24 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
25 |
/**
|
|
26 |
* A 5-dimensional implementation of the Dynamic class to interpolate between a list
|
|
27 |
* of Static5Ds.
|
|
28 |
*/
|
|
29 |
|
|
30 |
public class Dynamic5D extends Dynamic implements Data5D
|
|
31 |
{
|
|
32 |
|
|
33 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
34 |
// the coefficients of the X(t), Y(t), Z(t), W(t), V(t) polynomials: X(t) = ax*T^3 + bx*T^2 + cx*t + dx etc.
|
|
35 |
// (x,y,z,w,v) is the vector tangent to the path.
|
|
36 |
// (vx,vy,vz,vw,vv) is the original vector from vv (copied here so when interpolating we can see if it is
|
|
37 |
// still valid and if not - rebuild the Cache
|
|
38 |
|
|
39 |
private class VectorCache
|
|
40 |
{
|
|
41 |
float ax, bx, cx, dx;
|
|
42 |
float ay, by, cy, dy;
|
|
43 |
float az, bz, cz, dz;
|
|
44 |
float aw, bw, cw, dw;
|
|
45 |
float av, bv, cv, dv;
|
|
46 |
|
|
47 |
float x,y,z,w,v;
|
|
48 |
float vx,vy,vz,vw,vv;
|
|
49 |
}
|
|
50 |
|
|
51 |
private class VectorNoise
|
|
52 |
{
|
|
53 |
float[] nx;
|
|
54 |
float[] ny;
|
|
55 |
float[] nz;
|
|
56 |
float[] nw;
|
|
57 |
float[] nv;
|
|
58 |
|
|
59 |
VectorNoise()
|
|
60 |
{
|
|
61 |
nx = new float[NUM_NOISE];
|
|
62 |
nx[0] = mRnd.nextFloat();
|
|
63 |
for(int i=1; i<NUM_NOISE; i++) nx[i] = nx[i-1] + mRnd.nextFloat();
|
|
64 |
float sum = nx[NUM_NOISE-1] + mRnd.nextFloat();
|
|
65 |
for(int i=0; i<NUM_NOISE; i++) nx[i] /=sum;
|
|
66 |
|
|
67 |
ny = new float[NUM_NOISE];
|
|
68 |
for(int i=0; i<NUM_NOISE; i++) ny[i] = mRnd.nextFloat()-0.5f;
|
|
69 |
|
|
70 |
nz = new float[NUM_NOISE];
|
|
71 |
for(int i=0; i<NUM_NOISE; i++) nz[i] = mRnd.nextFloat()-0.5f;
|
|
72 |
|
|
73 |
nw = new float[NUM_NOISE];
|
|
74 |
for(int i=0; i<NUM_NOISE; i++) nw[i] = mRnd.nextFloat()-0.5f;
|
|
75 |
|
|
76 |
nv = new float[NUM_NOISE];
|
|
77 |
for(int i=0; i<NUM_NOISE; i++) nv[i] = mRnd.nextFloat()-0.5f;
|
|
78 |
}
|
|
79 |
}
|
|
80 |
|
|
81 |
private Vector<VectorCache> vc;
|
|
82 |
private VectorCache tmp1, tmp2;
|
|
83 |
|
|
84 |
private Vector<Static5D> vv;
|
|
85 |
private Static5D prev, curr, next;
|
|
86 |
|
|
87 |
private Vector<VectorNoise> vn;
|
|
88 |
private VectorNoise tmpN;
|
|
89 |
|
|
90 |
private float mFactor1, mFactor2, mFactor3, mFactor4; // used in Noise only. FactorN = noise factor of vector vecN.
|
|
91 |
private float vec1X,vec1Y,vec1Z,vec1W,vec1V; //
|
|
92 |
private float vec2X,vec2Y,vec2Z,vec2W,vec2V; // 4 noise vectors.
|
|
93 |
private float vec3X,vec3Y,vec3Z,vec3W,vec3V; //
|
|
94 |
private float vec4X,vec4Y,vec4Z,vec4W,vec4V; //
|
|
95 |
|
|
96 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
97 |
|
|
98 |
synchronized void createNoise()
|
|
99 |
{
|
|
100 |
if( vn==null )
|
|
101 |
{
|
|
102 |
vn = new Vector<>();
|
|
103 |
for(int i=0; i<numPoints; i++) vn.add(new VectorNoise());
|
|
104 |
}
|
|
105 |
}
|
|
106 |
|
|
107 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
108 |
// no array bounds checking!
|
|
109 |
|
|
110 |
private void vec(int c)
|
|
111 |
{
|
|
112 |
int p = c>0 ? c-1: numPoints-1;
|
|
113 |
int n = c<numPoints-1 ? c+1: 0;
|
|
114 |
|
|
115 |
prev = vv.elementAt(p);
|
|
116 |
curr = vv.elementAt(c);
|
|
117 |
next = vv.elementAt(n);
|
|
118 |
|
|
119 |
tmp1 = vc.elementAt(c);
|
|
120 |
|
|
121 |
float px = curr.x - prev.x;
|
|
122 |
float py = curr.y - prev.y;
|
|
123 |
float pz = curr.z - prev.z;
|
|
124 |
float pw = curr.w - prev.w;
|
|
125 |
float pv = curr.v - prev.v;
|
|
126 |
float nx = next.x - curr.x;
|
|
127 |
float ny = next.y - curr.y;
|
|
128 |
float nz = next.z - curr.z;
|
|
129 |
float nw = next.w - curr.w;
|
|
130 |
float nv = next.v - curr.v;
|
|
131 |
|
|
132 |
float d = nx*nx+ny*ny+nz*nz+nw*nw+nv*nv;
|
|
133 |
|
|
134 |
if( d>0 )
|
|
135 |
{
|
|
136 |
float q = (float)Math.sqrt((px*px+py*py+pz*pz+pw*pw+pv*pv)/d);
|
|
137 |
|
|
138 |
if( q>1 )
|
|
139 |
{
|
|
140 |
tmp1.x = nx+px/q;
|
|
141 |
tmp1.y = ny+py/q;
|
|
142 |
tmp1.z = nz+pz/q;
|
|
143 |
tmp1.w = nw+pw/q;
|
|
144 |
tmp1.v = nv+pv/q;
|
|
145 |
}
|
|
146 |
else
|
|
147 |
{
|
|
148 |
tmp1.x = px+nx*q;
|
|
149 |
tmp1.y = py+ny*q;
|
|
150 |
tmp1.z = pz+nz*q;
|
|
151 |
tmp1.w = pw+nw*q;
|
|
152 |
tmp1.v = pv+nv*q;
|
|
153 |
}
|
|
154 |
}
|
|
155 |
else
|
|
156 |
{
|
|
157 |
tmp1.x = 0.0f;
|
|
158 |
tmp1.y = 0.0f;
|
|
159 |
tmp1.z = 0.0f;
|
|
160 |
tmp1.w = 0.0f;
|
|
161 |
tmp1.v = 0.0f;
|
|
162 |
}
|
|
163 |
}
|
|
164 |
|
|
165 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
166 |
|
|
167 |
private void recomputeCache()
|
|
168 |
{
|
|
169 |
if( numPoints==1 )
|
|
170 |
{
|
|
171 |
tmp1= vc.elementAt(0);
|
|
172 |
curr= vv.elementAt(0);
|
|
173 |
|
|
174 |
tmp1.ax = tmp1.ay = tmp1.az = tmp1.aw = tmp1.av = 0.0f;
|
|
175 |
tmp1.bx = tmp1.by = tmp1.bz = tmp1.bw = tmp1.bv = 0.0f;
|
|
176 |
tmp1.cx = curr.x;
|
|
177 |
tmp1.cy = curr.y;
|
|
178 |
tmp1.cz = curr.z;
|
|
179 |
tmp1.cw = curr.w;
|
|
180 |
tmp1.cv = curr.v;
|
|
181 |
tmp1.dx = tmp1.dy = tmp1.dz = tmp1.dw = tmp1.dv = 0.0f;
|
|
182 |
}
|
|
183 |
else if( numPoints==2 )
|
|
184 |
{
|
|
185 |
tmp1= vc.elementAt(0);
|
|
186 |
tmp2= vc.elementAt(1);
|
|
187 |
curr= vv.elementAt(0);
|
|
188 |
next= vv.elementAt(1);
|
|
189 |
|
|
190 |
tmp1.ax = tmp1.ay = tmp1.az = tmp1.aw = tmp1.av = 0.0f;
|
|
191 |
tmp1.bx = tmp1.by = tmp1.bz = tmp1.bw = tmp1.bv = 0.0f;
|
|
192 |
tmp1.cx = next.x - curr.x;
|
|
193 |
tmp1.cy = next.y - curr.y;
|
|
194 |
tmp1.cz = next.z - curr.z;
|
|
195 |
tmp1.cw = next.w - curr.w;
|
|
196 |
tmp1.cv = next.v - curr.v;
|
|
197 |
tmp1.dx = curr.x;
|
|
198 |
tmp1.dy = curr.y;
|
|
199 |
tmp1.dz = curr.z;
|
|
200 |
tmp1.dw = curr.w;
|
|
201 |
tmp1.dv = curr.v;
|
|
202 |
|
|
203 |
tmp2.ax = tmp2.ay = tmp2.az = tmp2.aw = tmp2.av = 0.0f;
|
|
204 |
tmp2.bx = tmp2.by = tmp2.bz = tmp2.bw = tmp2.bv = 0.0f;
|
|
205 |
tmp2.cx = curr.x - next.x;
|
|
206 |
tmp2.cy = curr.y - next.y;
|
|
207 |
tmp2.cz = curr.z - next.z;
|
|
208 |
tmp2.cw = curr.w - next.w;
|
|
209 |
tmp2.cv = curr.v - next.v;
|
|
210 |
tmp2.dx = next.x;
|
|
211 |
tmp2.dy = next.y;
|
|
212 |
tmp2.dz = next.z;
|
|
213 |
tmp2.dw = next.w;
|
|
214 |
tmp2.dv = next.v;
|
|
215 |
}
|
|
216 |
else
|
|
217 |
{
|
|
218 |
int i, n;
|
|
219 |
|
|
220 |
for(i=0; i<numPoints; i++) vec(i);
|
|
221 |
|
|
222 |
for(i=0; i<numPoints; i++)
|
|
223 |
{
|
|
224 |
n = i<numPoints-1 ? i+1:0;
|
|
225 |
|
|
226 |
tmp1= vc.elementAt(i);
|
|
227 |
tmp2= vc.elementAt(n);
|
|
228 |
curr= vv.elementAt(i);
|
|
229 |
next= vv.elementAt(n);
|
|
230 |
|
|
231 |
tmp1.vx = curr.x;
|
|
232 |
tmp1.vy = curr.y;
|
|
233 |
tmp1.vz = curr.z;
|
|
234 |
tmp1.vw = curr.w;
|
|
235 |
tmp1.vv = curr.v;
|
|
236 |
|
|
237 |
tmp1.ax = 2*curr.x + tmp1.x - 2*next.x + tmp2.x;
|
|
238 |
tmp1.bx = -3*curr.x - 2*tmp1.x + 3*next.x - tmp2.x;
|
|
239 |
tmp1.cx = tmp1.x;
|
|
240 |
tmp1.dx = curr.x;
|
|
241 |
|
|
242 |
tmp1.ay = 2*curr.y + tmp1.y - 2*next.y + tmp2.y;
|
|
243 |
tmp1.by = -3*curr.y - 2*tmp1.y + 3*next.y - tmp2.y;
|
|
244 |
tmp1.cy = tmp1.y;
|
|
245 |
tmp1.dy = curr.y;
|
|
246 |
|
|
247 |
tmp1.az = 2*curr.z + tmp1.z - 2*next.z + tmp2.z;
|
|
248 |
tmp1.bz = -3*curr.z - 2*tmp1.z + 3*next.z - tmp2.z;
|
|
249 |
tmp1.cz = tmp1.z;
|
|
250 |
tmp1.dz = curr.z;
|
|
251 |
|
|
252 |
tmp1.aw = 2*curr.w + tmp1.w - 2*next.w + tmp2.w;
|
|
253 |
tmp1.bw = -3*curr.w - 2*tmp1.w + 3*next.w - tmp2.w;
|
|
254 |
tmp1.cw = tmp1.w;
|
|
255 |
tmp1.dw = curr.w;
|
|
256 |
|
|
257 |
tmp1.av = 2*curr.v + tmp1.v - 2*next.v + tmp2.v;
|
|
258 |
tmp1.bv = -3*curr.v - 2*tmp1.v + 3*next.v - tmp2.v;
|
|
259 |
tmp1.cv = tmp1.v;
|
|
260 |
tmp1.dv = curr.v;
|
|
261 |
}
|
|
262 |
}
|
|
263 |
|
|
264 |
cacheDirty = false;
|
|
265 |
}
|
|
266 |
|
|
267 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
268 |
|
|
269 |
private float noise(float time,int vecNum)
|
|
270 |
{
|
|
271 |
float lower, upper, len;
|
|
272 |
float d = time*(NUM_NOISE+1);
|
|
273 |
int index = (int)d;
|
|
274 |
if( index>=NUM_NOISE+1 ) index=NUM_NOISE;
|
|
275 |
tmpN = vn.elementAt(vecNum);
|
|
276 |
|
|
277 |
float t = d-index;
|
|
278 |
t = t*t*(3-2*t);
|
|
279 |
|
|
280 |
switch(index)
|
|
281 |
{
|
|
282 |
case 0 : mFactor1 = mNoise*tmpN.ny[0]*t;
|
|
283 |
mFactor2 = mNoise*tmpN.nz[0]*t;
|
|
284 |
mFactor3 = mNoise*tmpN.nw[0]*t;
|
|
285 |
mFactor4 = mNoise*tmpN.nv[0]*t;
|
|
286 |
return time + mNoise*(d*tmpN.nx[0]-time);
|
|
287 |
case NUM_NOISE: mFactor1= mNoise*tmpN.ny[NUM_NOISE-1]*(1-t);
|
|
288 |
mFactor2= mNoise*tmpN.nz[NUM_NOISE-1]*(1-t);
|
|
289 |
mFactor3= mNoise*tmpN.nw[NUM_NOISE-1]*(1-t);
|
|
290 |
mFactor4= mNoise*tmpN.nv[NUM_NOISE-1]*(1-t);
|
|
291 |
len = ((float)NUM_NOISE)/(NUM_NOISE+1);
|
|
292 |
lower = len + mNoise*(tmpN.nx[NUM_NOISE-1]-len);
|
|
293 |
return (1.0f-lower)*(d-NUM_NOISE) + lower;
|
|
294 |
default : float ya,yb;
|
|
295 |
yb = tmpN.ny[index ];
|
|
296 |
ya = tmpN.ny[index-1];
|
|
297 |
mFactor1 = mNoise*((yb-ya)*t+ya);
|
|
298 |
yb = tmpN.nz[index ];
|
|
299 |
ya = tmpN.nz[index-1];
|
|
300 |
mFactor2 = mNoise*((yb-ya)*t+ya);
|
|
301 |
yb = tmpN.nw[index ];
|
|
302 |
ya = tmpN.nw[index-1];
|
|
303 |
mFactor3 = mNoise*((yb-ya)*t+ya);
|
|
304 |
yb = tmpN.nv[index ];
|
|
305 |
ya = tmpN.nv[index-1];
|
|
306 |
mFactor4 = mNoise*((yb-ya)*t+ya);
|
|
307 |
|
|
308 |
len = ((float)index)/(NUM_NOISE+1);
|
|
309 |
lower = len + mNoise*(tmpN.nx[index-1]-len);
|
|
310 |
len = ((float)index+1)/(NUM_NOISE+1);
|
|
311 |
upper = len + mNoise*(tmpN.nx[index ]-len);
|
|
312 |
|
|
313 |
return (upper-lower)*(d-index) + lower;
|
|
314 |
}
|
|
315 |
}
|
|
316 |
|
|
317 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
318 |
// v is the speed vector (i.e. position p(t) differentiated by time)
|
|
319 |
// a is the acceleration vector (differentiate once more)
|
|
320 |
//
|
|
321 |
// Now we construct orthogonal basis with Gram-Schmidt:
|
|
322 |
//
|
|
323 |
// vec1 = a-delta*v
|
|
324 |
// where delta = (v*a)/|v|^2
|
|
325 |
// vec2 = (0,0,1,0,0) - coeff1*(vx,vy,vz,vw,vv) - coeff2*(vec1x,vec1y,vec1z,vec1w,vec1v)
|
|
326 |
// where coeff1 = vz/|v|^2, coeff2 = vec1Z/|vec1|^2
|
|
327 |
// vec3 = (0,0,0,1,0) - coeff1*(vx,vy,vz,vw,vv) - coeff2*(vec1x,vec1y,vec1z,vec1w,vec1v) - coeff3*(vec2x,vec2y,vec2z,vec2w,vec2v)
|
|
328 |
// where coeff1 = vw/|v|^2, coeff2 = vec1W/|vec1|^2, coeff3 = vec2W/|vec2|^2
|
|
329 |
// vec4 = (0,0,0,0,1) - coeff1*(vx,vy,vz,vw,vv) - coeff2*(vec1x,vec1y,vec1z,vec1w,vec1v) - coeff3*(vec2x,vec2y,vec2z,vec2w,vec2v) - coeff4*(vec3x,vec3y,vec3z,vec3w,vec3v)
|
|
330 |
// where coeff1 = vv/|v|^2, coeff2 = vec1V/|vec1|^2, coeff3 = vec2V/|vec2|^2, coeff4 = vec3V/|vec3|^2
|
|
331 |
//
|
|
332 |
// this is going to fail if by chance v(t) happens to be one of the standard (0,...,1,...,0) vectors of the orthonormal base!
|
|
333 |
|
|
334 |
private void setUpVectors(float time,VectorCache vc)
|
|
335 |
{
|
|
336 |
if( vc!=null )
|
|
337 |
{
|
|
338 |
float vx = (3*vc.ax*time+2*vc.bx)*time+vc.cx;
|
|
339 |
float vy = (3*vc.ay*time+2*vc.by)*time+vc.cy;
|
|
340 |
float vz = (3*vc.az*time+2*vc.bz)*time+vc.cz;
|
|
341 |
float vw = (3*vc.aw*time+2*vc.bw)*time+vc.cw;
|
|
342 |
float vv = (3*vc.av*time+2*vc.bv)*time+vc.cv;
|
|
343 |
|
|
344 |
float ax = 6*vc.ax*time+2*vc.bx;
|
|
345 |
float ay = 6*vc.ay*time+2*vc.by;
|
|
346 |
float az = 6*vc.az*time+2*vc.bz;
|
|
347 |
float aw = 6*vc.aw*time+2*vc.bw;
|
|
348 |
float av = 6*vc.av*time+2*vc.bv;
|
|
349 |
|
|
350 |
float v_sq = vx*vx+vy*vy+vz*vz+vw*vw+vv*vv;
|
|
351 |
float delta = (vx*ax+vy*ay+vz*az+vw*aw+vv*av)/v_sq;
|
|
352 |
|
|
353 |
vec1X = ax-delta*vx;
|
|
354 |
vec1Y = ay-delta*vy;
|
|
355 |
vec1Z = az-delta*vz;
|
|
356 |
vec1W = aw-delta*vw;
|
|
357 |
vec1V = av-delta*vv;
|
|
358 |
|
|
359 |
// construct vec2, vec3 and vec4. Cross product does not work in 5th dimension!
|
|
360 |
float vec1_sq = vec1X*vec1X+vec1Y*vec1Y+vec1Z*vec1Z+vec1W*vec1W+vec1V*vec1V;
|
|
361 |
float coeff21 = vz/v_sq;
|
|
362 |
float coeff22 = vec1Z/vec1_sq;
|
|
363 |
vec2X = 0.0f - coeff21*vx - coeff22*vec1X;
|
|
364 |
vec2Y = 0.0f - coeff21*vy - coeff22*vec1Y;
|
|
365 |
vec2Z = 1.0f - coeff21*vz - coeff22*vec1Z;
|
|
366 |
vec2W = 0.0f - coeff21*vw - coeff22*vec1W;
|
|
367 |
vec2V = 0.0f - coeff21*vv - coeff22*vec1V;
|
|
368 |
|
|
369 |
float vec2_sq = vec2X*vec2X+vec2Y*vec2Y+vec2Z*vec2Z+vec2W*vec2W+vec2V*vec2V;
|
|
370 |
float coeff31 = vw/v_sq;
|
|
371 |
float coeff32 = vec1W/vec1_sq;
|
|
372 |
float coeff33 = vec2W/vec2_sq;
|
|
373 |
vec3X = 0.0f - coeff31*vx - coeff32*vec1X - coeff33*vec2X;
|
|
374 |
vec3Y = 0.0f - coeff31*vy - coeff32*vec1Y - coeff33*vec2Y;
|
|
375 |
vec3Z = 0.0f - coeff31*vz - coeff32*vec1Z - coeff33*vec2Z;
|
|
376 |
vec3W = 1.0f - coeff31*vw - coeff32*vec1W - coeff33*vec2W;
|
|
377 |
vec3V = 0.0f - coeff31*vv - coeff32*vec1V - coeff33*vec2V;
|
|
378 |
|
|
379 |
float vec3_sq = vec3X*vec3X+vec3Y*vec3Y+vec3Z*vec3Z+vec3W*vec3W+vec3V*vec3V;
|
|
380 |
float coeff41 = vv/v_sq;
|
|
381 |
float coeff42 = vec1V/vec1_sq;
|
|
382 |
float coeff43 = vec2V/vec2_sq;
|
|
383 |
float coeff44 = vec3V/vec3_sq;
|
|
384 |
vec4X = 0.0f - coeff41*vx - coeff42*vec1X - coeff43*vec2X - coeff44*vec3X;
|
|
385 |
vec4Y = 0.0f - coeff41*vy - coeff42*vec1Y - coeff43*vec2Y - coeff44*vec3Y;
|
|
386 |
vec4Z = 0.0f - coeff41*vz - coeff42*vec1Z - coeff43*vec2Z - coeff44*vec3Z;
|
|
387 |
vec4W = 0.0f - coeff41*vw - coeff42*vec1W - coeff43*vec2W - coeff44*vec3W;
|
|
388 |
vec4V = 1.0f - coeff41*vv - coeff42*vec1V - coeff43*vec2V - coeff44*vec3V;
|
|
389 |
|
|
390 |
float vec4_sq = vec4X*vec4X+vec4Y*vec4Y+vec4Z*vec4Z+vec4W*vec4W+vec4V*vec4V;
|
|
391 |
|
|
392 |
float len1 = (float)Math.sqrt(v_sq/vec1_sq);
|
|
393 |
float len2 = (float)Math.sqrt(v_sq/vec2_sq);
|
|
394 |
float len3 = (float)Math.sqrt(v_sq/vec3_sq);
|
|
395 |
float len4 = (float)Math.sqrt(v_sq/vec4_sq);
|
|
396 |
|
|
397 |
vec1X*=len1;
|
|
398 |
vec1Y*=len1;
|
|
399 |
vec1Z*=len1;
|
|
400 |
vec1W*=len1;
|
|
401 |
vec1V*=len1;
|
|
402 |
|
|
403 |
vec2X*=len2;
|
|
404 |
vec2Y*=len2;
|
|
405 |
vec2Z*=len2;
|
|
406 |
vec2W*=len2;
|
|
407 |
vec2V*=len2;
|
|
408 |
|
|
409 |
vec3X*=len3;
|
|
410 |
vec3Y*=len3;
|
|
411 |
vec3Z*=len3;
|
|
412 |
vec3W*=len3;
|
|
413 |
vec3V*=len3;
|
|
414 |
|
|
415 |
vec4X*=len4;
|
|
416 |
vec4Y*=len4;
|
|
417 |
vec4Z*=len4;
|
|
418 |
vec4W*=len4;
|
|
419 |
vec4V*=len4;
|
|
420 |
}
|
|
421 |
else
|
|
422 |
{
|
|
423 |
curr = vv.elementAt(0);
|
|
424 |
next = vv.elementAt(1);
|
|
425 |
|
|
426 |
float vx = (next.x-curr.x);
|
|
427 |
float vy = (next.y-curr.y);
|
|
428 |
float vz = (next.z-curr.z);
|
|
429 |
float vw = (next.w-curr.w);
|
|
430 |
float vv = (next.v-curr.v);
|
|
431 |
|
|
432 |
float b = (float)Math.sqrt(vx*vx+vy*vy+vz*vz+vw*vw);
|
|
433 |
|
|
434 |
if( b>0.0f )
|
|
435 |
{
|
|
436 |
vec1X = vx*vv/b;
|
|
437 |
vec1Y = vy*vv/b;
|
|
438 |
vec1Z = vz*vv/b;
|
|
439 |
vec1W = vw*vv/b;
|
|
440 |
vec1V = -b;
|
|
441 |
|
|
442 |
float v_sq = vx*vx+vy*vy+vz*vz+vw*vw+vv*vv;
|
|
443 |
|
|
444 |
// construct vec2, vec3 and vec4. Cross product does not work in 5th dimension!
|
|
445 |
float vec1_sq = vec1X*vec1X+vec1Y*vec1Y+vec1Z*vec1Z+vec1W*vec1W+vec1V*vec1V;
|
|
446 |
float coeff21 = vz/v_sq;
|
|
447 |
float coeff22 = vec1Z/vec1_sq;
|
|
448 |
vec2X = 0.0f - coeff21*vx - coeff22*vec1X;
|
|
449 |
vec2Y = 0.0f - coeff21*vy - coeff22*vec1Y;
|
|
450 |
vec2Z = 1.0f - coeff21*vz - coeff22*vec1Z;
|
|
451 |
vec2W = 0.0f - coeff21*vw - coeff22*vec1W;
|
|
452 |
vec2V = 0.0f - coeff21*vv - coeff22*vec1V;
|
|
453 |
|
|
454 |
float vec2_sq = vec2X*vec2X+vec2Y*vec2Y+vec2Z*vec2Z+vec2W*vec2W+vec2V*vec2V;
|
|
455 |
float coeff31 = vw/v_sq;
|
|
456 |
float coeff32 = vec1W/vec1_sq;
|
|
457 |
float coeff33 = vec2W/vec2_sq;
|
|
458 |
vec3X = 0.0f - coeff31*vx - coeff32*vec1X - coeff33*vec2X;
|
|
459 |
vec3Y = 0.0f - coeff31*vy - coeff32*vec1Y - coeff33*vec2Y;
|
|
460 |
vec3Z = 0.0f - coeff31*vz - coeff32*vec1Z - coeff33*vec2Z;
|
|
461 |
vec3W = 1.0f - coeff31*vw - coeff32*vec1W - coeff33*vec2W;
|
|
462 |
vec3V = 0.0f - coeff31*vv - coeff32*vec1V - coeff33*vec2V;
|
|
463 |
|
|
464 |
float vec3_sq = vec3X*vec3X+vec3Y*vec3Y+vec3Z*vec3Z+vec3W*vec3W+vec3V*vec3V;
|
|
465 |
float coeff41 = vv/v_sq;
|
|
466 |
float coeff42 = vec1V/vec1_sq;
|
|
467 |
float coeff43 = vec2V/vec2_sq;
|
|
468 |
float coeff44 = vec3V/vec3_sq;
|
|
469 |
vec4X = 0.0f - coeff41*vx - coeff42*vec1X - coeff43*vec2X - coeff44*vec3X;
|
|
470 |
vec4Y = 0.0f - coeff41*vy - coeff42*vec1Y - coeff43*vec2Y - coeff44*vec3Y;
|
|
471 |
vec4Z = 0.0f - coeff41*vz - coeff42*vec1Z - coeff43*vec2Z - coeff44*vec3Z;
|
|
472 |
vec4W = 0.0f - coeff41*vw - coeff42*vec1W - coeff43*vec2W - coeff44*vec3W;
|
|
473 |
vec4V = 1.0f - coeff41*vv - coeff42*vec1V - coeff43*vec2V - coeff44*vec3V;
|
|
474 |
|
|
475 |
float vec4_sq = vec4X*vec4X+vec4Y*vec4Y+vec4Z*vec4Z+vec4W*vec4W+vec4V*vec4V;
|
|
476 |
|
|
477 |
float len1 = (float)Math.sqrt(v_sq/vec1_sq);
|
|
478 |
float len2 = (float)Math.sqrt(v_sq/vec2_sq);
|
|
479 |
float len3 = (float)Math.sqrt(v_sq/vec3_sq);
|
|
480 |
float len4 = (float)Math.sqrt(v_sq/vec4_sq);
|
|
481 |
|
|
482 |
vec1X*=len1;
|
|
483 |
vec1Y*=len1;
|
|
484 |
vec1Z*=len1;
|
|
485 |
vec1W*=len1;
|
|
486 |
vec1V*=len1;
|
|
487 |
|
|
488 |
vec2X*=len2;
|
|
489 |
vec2Y*=len2;
|
|
490 |
vec2Z*=len2;
|
|
491 |
vec2W*=len2;
|
|
492 |
vec2V*=len2;
|
|
493 |
|
|
494 |
vec3X*=len3;
|
|
495 |
vec3Y*=len3;
|
|
496 |
vec3Z*=len3;
|
|
497 |
vec3W*=len3;
|
|
498 |
vec3V*=len3;
|
|
499 |
|
|
500 |
vec4X*=len4;
|
|
501 |
vec4Y*=len4;
|
|
502 |
vec4Z*=len4;
|
|
503 |
vec4W*=len4;
|
|
504 |
vec4V*=len4;
|
|
505 |
}
|
|
506 |
else
|
|
507 |
{
|
|
508 |
vec1X = vv;
|
|
509 |
vec1Y = 0.0f;
|
|
510 |
vec1Z = 0.0f;
|
|
511 |
vec1W = 0.0f;
|
|
512 |
vec1V = 0.0f;
|
|
513 |
|
|
514 |
vec2X = 0.0f;
|
|
515 |
vec2Y = vv;
|
|
516 |
vec2Z = 0.0f;
|
|
517 |
vec2W = 0.0f;
|
|
518 |
vec2V = 0.0f;
|
|
519 |
|
|
520 |
vec3X = 0.0f;
|
|
521 |
vec3Y = 0.0f;
|
|
522 |
vec3Z = vv;
|
|
523 |
vec3W = 0.0f;
|
|
524 |
vec3V = 0.0f;
|
|
525 |
|
|
526 |
vec4X = 0.0f;
|
|
527 |
vec4Y = 0.0f;
|
|
528 |
vec4Z = 0.0f;
|
|
529 |
vec4W = vv;
|
|
530 |
vec4V = 0.0f;
|
|
531 |
}
|
|
532 |
}
|
|
533 |
}
|
|
534 |
|
|
535 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
536 |
// PUBLIC API
|
|
537 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
538 |
/**
|
|
539 |
* Default constructor.
|
|
540 |
*/
|
|
541 |
public Dynamic5D()
|
|
542 |
{
|
|
543 |
vv = new Vector<>();
|
|
544 |
vc = new Vector<>();
|
|
545 |
vn = null;
|
|
546 |
numPoints = 0;
|
|
547 |
cacheDirty = false;
|
|
548 |
mMode = MODE_LOOP;
|
|
549 |
mDuration = 0;
|
|
550 |
mCount = 0.5f;
|
|
551 |
mNoise = 0.0f;
|
|
552 |
}
|
|
553 |
|
|
554 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
555 |
|
|
556 |
/**
|
|
557 |
* Default constructor.
|
|
558 |
*
|
|
559 |
* @param duration number of milliseconds it takes to do a full loop/path from first vector to the
|
|
560 |
* last and back to the first
|
|
561 |
* @param count number of loops/paths we will do; mCount = 1.5 means we go from the first vector
|
|
562 |
* to the last, back to first, and to the last again.
|
|
563 |
*/
|
|
564 |
public Dynamic5D(int duration, float count)
|
|
565 |
{
|
|
566 |
vv = new Vector<>();
|
|
567 |
vc = new Vector<>();
|
|
568 |
vn = null;
|
|
569 |
numPoints = 0;
|
|
570 |
cacheDirty = false;
|
|
571 |
mMode = MODE_LOOP;
|
|
572 |
mDuration = duration;
|
|
573 |
mCount = count;
|
|
574 |
}
|
|
575 |
|
|
576 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
577 |
/**
|
|
578 |
* Returns the location'th Static5D.
|
|
579 |
*
|
|
580 |
* @param location the index of the Point we are interested in.
|
|
581 |
* @return The Static5D, if 0<=location<getNumPoints(), or null otherwise.
|
|
582 |
*/
|
|
583 |
public synchronized Static5D getPoint(int location)
|
|
584 |
{
|
|
585 |
return (location>=0 && location<numPoints) ? vv.elementAt(location) : null;
|
|
586 |
}
|
|
587 |
|
|
588 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
589 |
/**
|
|
590 |
* Resets the location'th Point.
|
|
591 |
*
|
|
592 |
* @param location the index of the Point we are setting.
|
|
593 |
* @param x New value of its first float.
|
|
594 |
*/
|
|
595 |
public synchronized void setPoint(int location, float x, float y, float z, float w, float v)
|
|
596 |
{
|
|
597 |
if( location>=0 && location<numPoints )
|
|
598 |
{
|
|
599 |
curr = vv.elementAt(location);
|
|
600 |
|
|
601 |
if( curr!=null )
|
|
602 |
{
|
|
603 |
curr.set(x,y,z,w,v);
|
|
604 |
cacheDirty=true;
|
|
605 |
}
|
|
606 |
}
|
|
607 |
}
|
|
608 |
|
|
609 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
610 |
/**
|
|
611 |
* Adds a new Static5D to the end of our list of Points to interpolate through.
|
|
612 |
* <p>
|
|
613 |
* Only a reference to the Point gets added to the List; this means that one can add a Point
|
|
614 |
* here, and later on {@link Static5D#set(float,float,float,float,float)} it to some new value and
|
|
615 |
* the change will be seamlessly reflected in the interpolated path.
|
|
616 |
* <p>
|
|
617 |
* A Point can be added multiple times.
|
|
618 |
*
|
|
619 |
* @param v The Point to add.
|
|
620 |
*/
|
|
621 |
public synchronized void add(Static5D v)
|
|
622 |
{
|
|
623 |
if( v!=null )
|
|
624 |
{
|
|
625 |
vv.add(v);
|
|
626 |
|
|
627 |
if( vn!=null ) vn.add(new VectorNoise());
|
|
628 |
|
|
629 |
switch(numPoints)
|
|
630 |
{
|
|
631 |
case 0: break;
|
|
632 |
case 1: setUpVectors(0.0f,null);
|
|
633 |
break;
|
|
634 |
case 2: vc.add(new VectorCache());
|
|
635 |
vc.add(new VectorCache());
|
|
636 |
vc.add(new VectorCache());
|
|
637 |
break;
|
|
638 |
default:vc.add(new VectorCache());
|
|
639 |
}
|
|
640 |
|
|
641 |
numPoints++;
|
|
642 |
cacheDirty = true;
|
|
643 |
}
|
|
644 |
}
|
|
645 |
|
|
646 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
647 |
/**
|
|
648 |
* Adds a new Static5D to the location'th place in our List of Points to interpolate through.
|
|
649 |
*
|
|
650 |
* @param location Index in our List to add the new Point at.
|
|
651 |
* @param v The Static5D to add.
|
|
652 |
*/
|
|
653 |
public synchronized void add(int location, Static5D v)
|
|
654 |
{
|
|
655 |
if( v!=null )
|
|
656 |
{
|
|
657 |
vv.add(location, v);
|
|
658 |
|
|
659 |
if( vn!=null ) vn.add(new VectorNoise());
|
|
660 |
|
|
661 |
switch(numPoints)
|
|
662 |
{
|
|
663 |
case 0: break;
|
|
664 |
case 1: setUpVectors(0.0f,null);
|
|
665 |
break;
|
|
666 |
case 2: vc.add(new VectorCache());
|
|
667 |
vc.add(new VectorCache());
|
|
668 |
vc.add(new VectorCache());
|
|
669 |
break;
|
|
670 |
default:vc.add(location,new VectorCache());
|
|
671 |
}
|
|
672 |
|
|
673 |
numPoints++;
|
|
674 |
cacheDirty = true;
|
|
675 |
}
|
|
676 |
}
|
|
677 |
|
|
678 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
679 |
/**
|
|
680 |
* Removes all occurrences of Point v from the List of Points to interpolate through.
|
|
681 |
*
|
|
682 |
* @param v The Point to remove.
|
|
683 |
* @return <code>true</code> if we have removed at least one Point.
|
|
684 |
*/
|
|
685 |
public synchronized boolean remove(Static5D v)
|
|
686 |
{
|
|
687 |
int n = vv.indexOf(v);
|
|
688 |
boolean found = false;
|
|
689 |
|
|
690 |
while( n>=0 )
|
|
691 |
{
|
|
692 |
vv.remove(n);
|
|
693 |
|
|
694 |
if( vn!=null ) vn.remove(0);
|
|
695 |
|
|
696 |
switch(numPoints)
|
|
697 |
{
|
|
698 |
case 0:
|
|
699 |
case 1:
|
|
700 |
case 2: break;
|
|
701 |
case 3: vc.removeAllElements();
|
|
702 |
setUpVectors(0.0f,null);
|
|
703 |
break;
|
|
704 |
default:vc.remove(n);
|
|
705 |
}
|
|
706 |
|
|
707 |
numPoints--;
|
|
708 |
found = true;
|
|
709 |
n = vv.indexOf(v);
|
|
710 |
}
|
|
711 |
|
|
712 |
if( found )
|
|
713 |
{
|
|
714 |
cacheDirty=true;
|
|
715 |
}
|
|
716 |
|
|
717 |
return found;
|
|
718 |
}
|
|
719 |
|
|
720 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
721 |
/**
|
|
722 |
* Removes a location'th Point from the List of Points we interpolate through.
|
|
723 |
*
|
|
724 |
* @param location index of the Point we want to remove.
|
|
725 |
* @return <code>true</code> if location is valid, i.e. if 0<=location<getNumPoints().
|
|
726 |
*/
|
|
727 |
public synchronized boolean remove(int location)
|
|
728 |
{
|
|
729 |
if( location>=0 && location<numPoints )
|
|
730 |
{
|
|
731 |
vv.removeElementAt(location);
|
|
732 |
|
|
733 |
if( vn!=null ) vn.remove(0);
|
|
734 |
|
|
735 |
switch(numPoints)
|
|
736 |
{
|
|
737 |
case 0:
|
|
738 |
case 1:
|
|
739 |
case 2: break;
|
|
740 |
case 3: vc.removeAllElements();
|
|
741 |
setUpVectors(0.0f,null);
|
|
742 |
break;
|
|
743 |
default:vc.removeElementAt(location);
|
|
744 |
}
|
|
745 |
|
|
746 |
numPoints--;
|
|
747 |
cacheDirty = true;
|
|
748 |
return true;
|
|
749 |
}
|
|
750 |
|
|
751 |
return false;
|
|
752 |
}
|
|
753 |
|
|
754 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
755 |
/**
|
|
756 |
* Removes all Points.
|
|
757 |
*/
|
|
758 |
public synchronized void removeAll()
|
|
759 |
{
|
|
760 |
numPoints = 0;
|
|
761 |
vv.removeAllElements();
|
|
762 |
vc.removeAllElements();
|
|
763 |
cacheDirty = false;
|
|
764 |
|
|
765 |
if( vn!=null ) vn.removeAllElements();
|
|
766 |
}
|
|
767 |
|
|
768 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
769 |
/**
|
|
770 |
* Writes the results of interpolation between the Points at time 'time' to the passed float buffer.
|
|
771 |
* <p>
|
|
772 |
* Since this is a 5-dimensional Dynamic, the resulting interpolated Static5D gets written
|
|
773 |
* to five locations in the buffer: buffer[offset],...,buffer[offset+4].
|
|
774 |
*
|
|
775 |
* @param buffer Float buffer we will write the resulting Static5D to.
|
|
776 |
* @param offset Offset in the buffer where to write the result.
|
|
777 |
* @param time Time of interpolation. Time=0.0 would return the first Point, Time=0.5 - the last,
|
|
778 |
* time=1.0 - the first again, and time 0.1 would be 1/5 of the way between the first and the last Points.
|
|
779 |
*/
|
|
780 |
public synchronized void interpolate(float[] buffer, int offset, float time)
|
|
781 |
{
|
|
782 |
switch(numPoints)
|
|
783 |
{
|
|
784 |
case 0: buffer[offset ] = 0.0f;
|
|
785 |
buffer[offset+1] = 0.0f;
|
|
786 |
buffer[offset+2] = 0.0f;
|
|
787 |
buffer[offset+3] = 0.0f;
|
|
788 |
buffer[offset+4] = 0.0f;
|
|
789 |
break;
|
|
790 |
case 1: curr = vv.elementAt(0);
|
|
791 |
buffer[offset ] = curr.x;
|
|
792 |
buffer[offset+1] = curr.y;
|
|
793 |
buffer[offset+2] = curr.z;
|
|
794 |
buffer[offset+3] = curr.w;
|
|
795 |
buffer[offset+4] = curr.v;
|
|
796 |
break;
|
|
797 |
case 2: curr = vv.elementAt(0);
|
|
798 |
next = vv.elementAt(1);
|
|
799 |
|
|
800 |
if( mMode==MODE_LOOP || mMode==MODE_PATH ) time = (time>0.5f ? 2-2*time : 2*time);
|
|
801 |
|
|
802 |
if( vn!=null )
|
|
803 |
{
|
|
804 |
time = noise(time,0);
|
|
805 |
|
|
806 |
buffer[offset ] = (next.x-curr.x)*time + curr.x + (vec1X*mFactor1 + vec2X*mFactor2 + vec3X*mFactor3 + vec4X*mFactor4);
|
|
807 |
buffer[offset+1] = (next.y-curr.y)*time + curr.y + (vec1Y*mFactor1 + vec2Y*mFactor2 + vec3Y*mFactor3 + vec4Y*mFactor4);
|
|
808 |
buffer[offset+2] = (next.z-curr.z)*time + curr.z + (vec1Z*mFactor1 + vec2Z*mFactor2 + vec3Z*mFactor3 + vec4Z*mFactor4);
|
|
809 |
buffer[offset+3] = (next.w-curr.w)*time + curr.w + (vec1W*mFactor1 + vec2W*mFactor2 + vec3W*mFactor3 + vec4W*mFactor4);
|
|
810 |
buffer[offset+4] = (next.v-curr.v)*time + curr.v + (vec1V*mFactor1 + vec2V*mFactor2 + vec3V*mFactor3 + vec4V*mFactor4);
|
|
811 |
}
|
|
812 |
else
|
|
813 |
{
|
|
814 |
buffer[offset ] = (next.x-curr.x)*time + curr.x;
|
|
815 |
buffer[offset+1] = (next.y-curr.y)*time + curr.y;
|
|
816 |
buffer[offset+2] = (next.z-curr.z)*time + curr.z;
|
|
817 |
buffer[offset+3] = (next.w-curr.w)*time + curr.w;
|
|
818 |
buffer[offset+4] = (next.v-curr.v)*time + curr.v;
|
|
819 |
}
|
|
820 |
|
|
821 |
break;
|
|
822 |
default:float t = time;
|
|
823 |
|
|
824 |
switch(mMode)
|
|
825 |
{
|
|
826 |
case MODE_LOOP: time = time*numPoints;
|
|
827 |
break;
|
|
828 |
case MODE_PATH: time = (time<=0.5f) ? 2*time*(numPoints-1) : 2*(1-time)*(numPoints-1);
|
|
829 |
break;
|
|
830 |
case MODE_JUMP: time = time*(numPoints-1);
|
|
831 |
break;
|
|
832 |
}
|
|
833 |
|
|
834 |
int vecCurr = (int)time;
|
|
835 |
time = time-vecCurr;
|
|
836 |
|
|
837 |
if( vecCurr>=0 && vecCurr<numPoints )
|
|
838 |
{
|
|
839 |
if( cacheDirty ) recomputeCache(); // recompute cache if we have added or remove vectors since last computation
|
|
840 |
else if( mVecCurr!= vecCurr ) // ...or if we have just passed a vector and the vector we are currently flying to has changed
|
|
841 |
{
|
|
842 |
int vecNext;
|
|
843 |
mVecCurr = vecCurr;
|
|
844 |
|
|
845 |
switch(mMode)
|
|
846 |
{
|
|
847 |
case MODE_LOOP: vecNext = vecCurr==numPoints-1 ? 0:vecCurr+1;
|
|
848 |
break;
|
|
849 |
case MODE_PATH: if( t<0.5f ) vecNext = vecCurr==numPoints-1 ? numPoints-2: vecCurr+1;
|
|
850 |
else vecNext = vecCurr==0 ? 1 : vecCurr-1;
|
|
851 |
break;
|
|
852 |
case MODE_JUMP: vecNext = vecCurr==numPoints-1 ? 1:vecCurr+1;
|
|
853 |
break;
|
|
854 |
default : vecNext = 0;
|
|
855 |
}
|
|
856 |
|
|
857 |
next = vv.elementAt(vecNext);
|
|
858 |
tmp2 = vc.elementAt(vecNext);
|
|
859 |
|
|
860 |
if( tmp2.vx!=next.x || tmp2.vy!=next.y || tmp2.vz!=next.z || tmp2.vw!=next.w || tmp2.vv!=next.v ) recomputeCache();
|
|
861 |
}
|
|
862 |
|
|
863 |
tmp1 = vc.elementAt(vecCurr);
|
|
864 |
|
|
865 |
if( vn!=null )
|
|
866 |
{
|
|
867 |
time = noise(time,vecCurr);
|
|
868 |
|
|
869 |
setUpVectors(time,tmp1);
|
|
870 |
|
|
871 |
buffer[offset ]= ((tmp1.ax*time+tmp1.bx)*time+tmp1.cx)*time+tmp1.dx + (vec1X*mFactor1 + vec2X*mFactor2 + vec3X*mFactor3 + vec4X*mFactor4);
|
|
872 |
buffer[offset+1]= ((tmp1.ay*time+tmp1.by)*time+tmp1.cy)*time+tmp1.dy + (vec1Y*mFactor1 + vec2Y*mFactor2 + vec3Y*mFactor3 + vec4Y*mFactor4);
|
|
873 |
buffer[offset+2]= ((tmp1.az*time+tmp1.bz)*time+tmp1.cz)*time+tmp1.dz + (vec1Z*mFactor1 + vec2Z*mFactor2 + vec3Z*mFactor3 + vec4Z*mFactor4);
|
|
874 |
buffer[offset+3]= ((tmp1.aw*time+tmp1.bw)*time+tmp1.cw)*time+tmp1.dw + (vec1W*mFactor1 + vec2W*mFactor2 + vec3W*mFactor3 + vec4W*mFactor4);
|
|
875 |
buffer[offset+4]= ((tmp1.av*time+tmp1.bv)*time+tmp1.cv)*time+tmp1.dv + (vec1V*mFactor1 + vec2V*mFactor2 + vec3V*mFactor3 + vec4V*mFactor4);
|
|
876 |
}
|
|
877 |
else
|
|
878 |
{
|
|
879 |
buffer[offset ]= ((tmp1.ax*time+tmp1.bx)*time+tmp1.cx)*time+tmp1.dx;
|
|
880 |
buffer[offset+1]= ((tmp1.ay*time+tmp1.by)*time+tmp1.cy)*time+tmp1.dy;
|
|
881 |
buffer[offset+2]= ((tmp1.az*time+tmp1.bz)*time+tmp1.cz)*time+tmp1.dz;
|
|
882 |
buffer[offset+3]= ((tmp1.aw*time+tmp1.bw)*time+tmp1.cw)*time+tmp1.dw;
|
|
883 |
buffer[offset+4]= ((tmp1.av*time+tmp1.bv)*time+tmp1.cv)*time+tmp1.dv;
|
|
884 |
}
|
|
885 |
|
|
886 |
break;
|
|
887 |
}
|
|
888 |
}
|
|
889 |
}
|
|
890 |
|
|
891 |
}
|
|
892 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
893 |
//
|
Add Static5D and Dynamic5D.