1 |
e0a16874
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2016 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
46b572b5
|
Leszek Koltunski
|
// This file is part of Distorted. //
|
5 |
e0a16874
|
Leszek Koltunski
|
// //
|
6 |
46b572b5
|
Leszek Koltunski
|
// Distorted is free software: you can redistribute it and/or modify //
|
7 |
e0a16874
|
Leszek Koltunski
|
// 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 |
46b572b5
|
Leszek Koltunski
|
// Distorted is distributed in the hope that it will be useful, //
|
12 |
e0a16874
|
Leszek Koltunski
|
// 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 |
46b572b5
|
Leszek Koltunski
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18 |
e0a16874
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19 |
|
|
|
20 |
a4835695
|
Leszek Koltunski
|
package org.distorted.library.type;
|
21 |
6a06a912
|
Leszek Koltunski
|
|
22 |
|
|
import java.util.Random;
|
23 |
3002bef3
|
Leszek Koltunski
|
import java.util.Vector;
|
24 |
6a06a912
|
Leszek Koltunski
|
|
25 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
26 |
ea16dc89
|
Leszek Koltunski
|
/** A class to interpolate between a list of Statics.
|
27 |
6a06a912
|
Leszek Koltunski
|
* <p><ul>
|
28 |
c45c2ab1
|
Leszek Koltunski
|
* <li>if there is only one Point, just return it.
|
29 |
6a06a912
|
Leszek Koltunski
|
* <li>if there are two Points, linearly bounce between them
|
30 |
c45c2ab1
|
Leszek Koltunski
|
* <li>if there are more, interpolate a path between them. Exact way we interpolate depends on the MODE.
|
31 |
6a06a912
|
Leszek Koltunski
|
* </ul>
|
32 |
|
|
*/
|
33 |
|
|
|
34 |
|
|
// The way Interpolation between more than 2 Points is done:
|
35 |
|
|
//
|
36 |
f871c455
|
Leszek Koltunski
|
// Def: let V[i] = (V[i](x), V[i](y), V[i](z)) be the direction and speed (i.e. velocity) we have to
|
37 |
|
|
// be flying at Point P[i]
|
38 |
6a06a912
|
Leszek Koltunski
|
//
|
39 |
f871c455
|
Leszek Koltunski
|
// Time it takes to fly though one segment P[i] --> P[i+1] : 0.0 --> 1.0
|
40 |
|
|
//
|
41 |
|
|
// We arbitrarily decide that V[i] should be equal to (|curr|*prev + |prev|*curr) / min(|prev|,|curr|)
|
42 |
|
|
// where prev = P[i]-P[i-1] and curr = P[i+1]-P[i]
|
43 |
6a06a912
|
Leszek Koltunski
|
//
|
44 |
|
|
// Given that the flight route (X(t), Y(t), Z(t)) from P(i) to P(i+1) (0<=t<=1) has to satisfy
|
45 |
f871c455
|
Leszek Koltunski
|
// X(0) = P[i ](x), Y(0)=P[i ](y), Z(0)=P[i ](z), X'(0) = V[i ](x), Y'(0) = V[i ](y), Z'(0) = V[i ](z)
|
46 |
|
|
// X(1) = P[i+1](x), Y(1)=P[i+1](y), Z(1)=P[i+1](z), X'(1) = V[i+1](x), Y'(1) = V[i+1](y), Z'(1) = V[i+1](z)
|
47 |
6a06a912
|
Leszek Koltunski
|
//
|
48 |
|
|
// we have the solution: X(t) = at^3 + bt^2 + ct + d where
|
49 |
f871c455
|
Leszek Koltunski
|
// a = 2*P[i](x) + V[i](x) - 2*P[i+1](x) + V[i+1](x)
|
50 |
|
|
// b = -3*P[i](x) - 2*V[i](x) + 3*P[i+1](x) - V[i+1](x)
|
51 |
|
|
// c = V[i](x)
|
52 |
|
|
// d = P[i](x)
|
53 |
6a06a912
|
Leszek Koltunski
|
//
|
54 |
|
|
// and similarly Y(t) and Z(t).
|
55 |
|
|
|
56 |
568b29d8
|
Leszek Koltunski
|
public abstract class Dynamic
|
57 |
6a06a912
|
Leszek Koltunski
|
{
|
58 |
|
|
/**
|
59 |
c45c2ab1
|
Leszek Koltunski
|
* One revolution takes us from the first point to the last and back to first through the shortest path.
|
60 |
6a06a912
|
Leszek Koltunski
|
*/
|
61 |
|
|
public static final int MODE_LOOP = 0;
|
62 |
|
|
/**
|
63 |
c45c2ab1
|
Leszek Koltunski
|
* One revolution takes us from the first point to the last and back to first through the same path.
|
64 |
6a06a912
|
Leszek Koltunski
|
*/
|
65 |
|
|
public static final int MODE_PATH = 1;
|
66 |
|
|
/**
|
67 |
c45c2ab1
|
Leszek Koltunski
|
* One revolution takes us from the first point to the last and jumps straight back to the first point.
|
68 |
6a06a912
|
Leszek Koltunski
|
*/
|
69 |
|
|
public static final int MODE_JUMP = 2;
|
70 |
3002bef3
|
Leszek Koltunski
|
|
71 |
bdb341bc
|
Leszek Koltunski
|
/**
|
72 |
|
|
* The default mode of access. When in this mode, we are able to call interpolate() with points in time
|
73 |
|
|
* in any random order. This means one single Dynamic can be used in many effects simultaneously.
|
74 |
|
|
* On the other hand, when in this mode, it is not possible to smoothly interpolate when mDuration suddenly
|
75 |
|
|
* changes.
|
76 |
|
|
*/
|
77 |
c45c2ab1
|
Leszek Koltunski
|
public static final int ACCESS_TYPE_RANDOM = 0;
|
78 |
bdb341bc
|
Leszek Koltunski
|
/**
|
79 |
|
|
* Set the mode to ACCESS_SEQUENTIAL if you need to change mDuration and you would rather have the Dynamic
|
80 |
|
|
* keep on smoothly interpolating.
|
81 |
|
|
* On the other hand, in this mode, a Dynamic can only be accessed in sequential manner, which means one
|
82 |
24d22f93
|
Leszek Koltunski
|
* Dynamic can only be used in one effect at a time.
|
83 |
bdb341bc
|
Leszek Koltunski
|
*/
|
84 |
c45c2ab1
|
Leszek Koltunski
|
public static final int ACCESS_TYPE_SEQUENTIAL = 1;
|
85 |
bdb341bc
|
Leszek Koltunski
|
|
86 |
310e14fb
|
leszek
|
protected int mDimension;
|
87 |
6a06a912
|
Leszek Koltunski
|
protected int numPoints;
|
88 |
291705f6
|
Leszek Koltunski
|
protected int mSegment; // between which pair of points are we currently? (in case of PATH this is a bit complicated!)
|
89 |
6a06a912
|
Leszek Koltunski
|
protected boolean cacheDirty; // VectorCache not up to date
|
90 |
|
|
protected int mMode; // LOOP, PATH or JUMP
|
91 |
8c893ffc
|
Leszek Koltunski
|
protected long mDuration; // number of milliseconds it takes to do a full loop/path from first vector to the last and back to the first
|
92 |
6a06a912
|
Leszek Koltunski
|
protected float mCount; // number of loops/paths we will do; mCount = 1.5 means we go from the first vector to the last, back to first, and to the last again.
|
93 |
bdb341bc
|
Leszek Koltunski
|
protected double mLastPos;
|
94 |
c45c2ab1
|
Leszek Koltunski
|
protected int mAccessType;
|
95 |
3002bef3
|
Leszek Koltunski
|
|
96 |
|
|
protected class VectorNoise
|
97 |
|
|
{
|
98 |
|
|
float[][] n;
|
99 |
|
|
|
100 |
291705f6
|
Leszek Koltunski
|
VectorNoise()
|
101 |
3002bef3
|
Leszek Koltunski
|
{
|
102 |
291705f6
|
Leszek Koltunski
|
n = new float[mDimension][NUM_NOISE];
|
103 |
|
|
}
|
104 |
3002bef3
|
Leszek Koltunski
|
|
105 |
291705f6
|
Leszek Koltunski
|
void computeNoise()
|
106 |
|
|
{
|
107 |
3002bef3
|
Leszek Koltunski
|
n[0][0] = mRnd.nextFloat();
|
108 |
|
|
for(int i=1; i<NUM_NOISE; i++) n[0][i] = n[0][i-1]+mRnd.nextFloat();
|
109 |
291705f6
|
Leszek Koltunski
|
|
110 |
3002bef3
|
Leszek Koltunski
|
float sum = n[0][NUM_NOISE-1] + mRnd.nextFloat();
|
111 |
|
|
|
112 |
291705f6
|
Leszek Koltunski
|
for(int i=0; i<NUM_NOISE; i++)
|
113 |
3002bef3
|
Leszek Koltunski
|
{
|
114 |
291705f6
|
Leszek Koltunski
|
n[0][i] /=sum;
|
115 |
|
|
for(int j=1; j<mDimension; j++) n[j][i] = mRnd.nextFloat()-0.5f;
|
116 |
3002bef3
|
Leszek Koltunski
|
}
|
117 |
|
|
}
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
protected Vector<VectorNoise> vn;
|
121 |
|
|
protected float[] mFactor;
|
122 |
1e22c248
|
Leszek Koltunski
|
protected float[] mNoise;
|
123 |
649544b8
|
Leszek Koltunski
|
protected float[][] baseV;
|
124 |
|
|
|
125 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
126 |
|
|
// the coefficients of the X(t), Y(t) and Z(t) polynomials: X(t) = ax*T^3 + bx*T^2 + cx*t + dx etc.
|
127 |
|
|
// (tangent) is the vector tangent to the path.
|
128 |
|
|
// (cached) is the original vector from vv (copied here so when interpolating we can see if it is
|
129 |
|
|
// still valid and if not - rebuild the Cache
|
130 |
|
|
|
131 |
|
|
protected class VectorCache
|
132 |
|
|
{
|
133 |
|
|
float[] a;
|
134 |
|
|
float[] b;
|
135 |
|
|
float[] c;
|
136 |
|
|
float[] d;
|
137 |
|
|
float[] tangent;
|
138 |
|
|
float[] cached;
|
139 |
|
|
|
140 |
291705f6
|
Leszek Koltunski
|
VectorCache()
|
141 |
649544b8
|
Leszek Koltunski
|
{
|
142 |
291705f6
|
Leszek Koltunski
|
a = new float[mDimension];
|
143 |
|
|
b = new float[mDimension];
|
144 |
|
|
c = new float[mDimension];
|
145 |
|
|
d = new float[mDimension];
|
146 |
|
|
tangent = new float[mDimension];
|
147 |
|
|
cached = new float[mDimension];
|
148 |
649544b8
|
Leszek Koltunski
|
}
|
149 |
|
|
}
|
150 |
|
|
|
151 |
|
|
protected Vector<VectorCache> vc;
|
152 |
|
|
protected VectorCache tmp1, tmp2;
|
153 |
12ecac18
|
Leszek Koltunski
|
protected float mConvexity;
|
154 |
3002bef3
|
Leszek Koltunski
|
|
155 |
6a2ebb18
|
Leszek Koltunski
|
private float[] buf;
|
156 |
|
|
private float[] old;
|
157 |
|
|
private static Random mRnd = new Random();
|
158 |
|
|
private static final int NUM_NOISE = 5; // used iff mNoise>0.0. Number of intermediary points between each pair of adjacent vectors
|
159 |
|
|
// where we randomize noise factors to make the way between the two vectors not so smooth.
|
160 |
0273ef2a
|
Leszek Koltunski
|
private long mStartTime;
|
161 |
246d021c
|
Leszek Koltunski
|
private long mCorrectedTime;
|
162 |
0273ef2a
|
Leszek Koltunski
|
private static long mPausedTime;
|
163 |
6a2ebb18
|
Leszek Koltunski
|
|
164 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
165 |
|
|
// hide this from Javadoc
|
166 |
|
|
|
167 |
649544b8
|
Leszek Koltunski
|
protected Dynamic()
|
168 |
6a06a912
|
Leszek Koltunski
|
{
|
169 |
310e14fb
|
leszek
|
|
170 |
6a06a912
|
Leszek Koltunski
|
}
|
171 |
8c893ffc
|
Leszek Koltunski
|
|
172 |
649544b8
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
173 |
|
|
|
174 |
|
|
protected Dynamic(int duration, float count, int dimension)
|
175 |
|
|
{
|
176 |
291705f6
|
Leszek Koltunski
|
vc = new Vector<>();
|
177 |
|
|
vn = null;
|
178 |
|
|
numPoints = 0;
|
179 |
649544b8
|
Leszek Koltunski
|
cacheDirty = false;
|
180 |
291705f6
|
Leszek Koltunski
|
mMode = MODE_LOOP;
|
181 |
|
|
mDuration = duration;
|
182 |
|
|
mCount = count;
|
183 |
649544b8
|
Leszek Koltunski
|
mDimension = dimension;
|
184 |
291705f6
|
Leszek Koltunski
|
mSegment = -1;
|
185 |
bdb341bc
|
Leszek Koltunski
|
mLastPos = -1;
|
186 |
12ecac18
|
Leszek Koltunski
|
mAccessType= ACCESS_TYPE_RANDOM;
|
187 |
|
|
mConvexity = 1.0f;
|
188 |
78ff6ea9
|
Leszek Koltunski
|
mStartTime = -1;
|
189 |
246d021c
|
Leszek Koltunski
|
mCorrectedTime = 0;
|
190 |
142c7236
|
Leszek Koltunski
|
|
191 |
291705f6
|
Leszek Koltunski
|
baseV = new float[mDimension][mDimension];
|
192 |
|
|
buf = new float[mDimension];
|
193 |
|
|
old = new float[mDimension];
|
194 |
649544b8
|
Leszek Koltunski
|
}
|
195 |
|
|
|
196 |
3ac42a4c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
197 |
|
|
|
198 |
|
|
void initDynamic()
|
199 |
|
|
{
|
200 |
|
|
mStartTime = -1;
|
201 |
|
|
mCorrectedTime = 0;
|
202 |
|
|
}
|
203 |
|
|
|
204 |
0273ef2a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
205 |
|
|
|
206 |
|
|
public static void onPause()
|
207 |
|
|
{
|
208 |
|
|
mPausedTime = System.currentTimeMillis();
|
209 |
|
|
}
|
210 |
|
|
|
211 |
3002bef3
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
212 |
|
|
|
213 |
|
|
protected float noise(float time,int vecNum)
|
214 |
|
|
{
|
215 |
|
|
float lower, upper, len;
|
216 |
|
|
float d = time*(NUM_NOISE+1);
|
217 |
|
|
int index = (int)d;
|
218 |
|
|
if( index>=NUM_NOISE+1 ) index=NUM_NOISE;
|
219 |
|
|
VectorNoise tmpN = vn.elementAt(vecNum);
|
220 |
|
|
|
221 |
|
|
float t = d-index;
|
222 |
|
|
t = t*t*(3-2*t);
|
223 |
|
|
|
224 |
|
|
switch(index)
|
225 |
|
|
{
|
226 |
1e22c248
|
Leszek Koltunski
|
case 0 : for(int i=0;i<mDimension-1;i++) mFactor[i] = mNoise[i+1]*tmpN.n[i+1][0]*t;
|
227 |
|
|
return time + mNoise[0]*(d*tmpN.n[0][0]-time);
|
228 |
|
|
case NUM_NOISE: for(int i=0;i<mDimension-1;i++) mFactor[i] = mNoise[i+1]*tmpN.n[i+1][NUM_NOISE-1]*(1-t);
|
229 |
3002bef3
|
Leszek Koltunski
|
len = ((float)NUM_NOISE)/(NUM_NOISE+1);
|
230 |
1e22c248
|
Leszek Koltunski
|
lower = len + mNoise[0]*(tmpN.n[0][NUM_NOISE-1]-len);
|
231 |
3002bef3
|
Leszek Koltunski
|
return (1.0f-lower)*(d-NUM_NOISE) + lower;
|
232 |
|
|
default : float ya,yb;
|
233 |
|
|
|
234 |
|
|
for(int i=0;i<mDimension-1;i++)
|
235 |
|
|
{
|
236 |
|
|
yb = tmpN.n[i+1][index ];
|
237 |
|
|
ya = tmpN.n[i+1][index-1];
|
238 |
1e22c248
|
Leszek Koltunski
|
mFactor[i] = mNoise[i+1]*((yb-ya)*t+ya);
|
239 |
3002bef3
|
Leszek Koltunski
|
}
|
240 |
|
|
|
241 |
|
|
len = ((float)index)/(NUM_NOISE+1);
|
242 |
1e22c248
|
Leszek Koltunski
|
lower = len + mNoise[0]*(tmpN.n[0][index-1]-len);
|
243 |
3002bef3
|
Leszek Koltunski
|
len = ((float)index+1)/(NUM_NOISE+1);
|
244 |
1e22c248
|
Leszek Koltunski
|
upper = len + mNoise[0]*(tmpN.n[0][index ]-len);
|
245 |
3002bef3
|
Leszek Koltunski
|
|
246 |
|
|
return (upper-lower)*(d-index) + lower;
|
247 |
|
|
}
|
248 |
|
|
}
|
249 |
|
|
|
250 |
649544b8
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
251 |
|
|
// debugging only
|
252 |
|
|
|
253 |
|
|
private void printBase(String str)
|
254 |
|
|
{
|
255 |
|
|
String s;
|
256 |
|
|
float t;
|
257 |
|
|
|
258 |
|
|
for(int i=0; i<mDimension; i++)
|
259 |
|
|
{
|
260 |
|
|
s = "";
|
261 |
|
|
|
262 |
|
|
for(int j=0; j<mDimension; j++)
|
263 |
|
|
{
|
264 |
|
|
t = ((int)(1000*baseV[i][j]))/(1000.0f);
|
265 |
|
|
s+=(" "+t);
|
266 |
|
|
}
|
267 |
|
|
android.util.Log.e("dynamic", str+" base "+i+" : " + s);
|
268 |
|
|
}
|
269 |
|
|
}
|
270 |
|
|
|
271 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
272 |
|
|
// debugging only
|
273 |
|
|
|
274 |
24d22f93
|
Leszek Koltunski
|
@SuppressWarnings("unused")
|
275 |
649544b8
|
Leszek Koltunski
|
private void checkBase()
|
276 |
|
|
{
|
277 |
6a2ebb18
|
Leszek Koltunski
|
float tmp, cosA;
|
278 |
|
|
float[] len= new float[mDimension];
|
279 |
|
|
boolean error=false;
|
280 |
|
|
|
281 |
|
|
for(int i=0; i<mDimension; i++)
|
282 |
|
|
{
|
283 |
|
|
len[i] = 0.0f;
|
284 |
|
|
|
285 |
|
|
for(int k=0; k<mDimension; k++)
|
286 |
|
|
{
|
287 |
|
|
len[i] += baseV[i][k]*baseV[i][k];
|
288 |
|
|
}
|
289 |
|
|
|
290 |
|
|
if( len[i] == 0.0f || len[0]/len[i] < 0.95f || len[0]/len[i]>1.05f )
|
291 |
|
|
{
|
292 |
|
|
android.util.Log.e("dynamic", "length of vector "+i+" : "+Math.sqrt(len[i]));
|
293 |
|
|
error = true;
|
294 |
|
|
}
|
295 |
|
|
}
|
296 |
649544b8
|
Leszek Koltunski
|
|
297 |
|
|
for(int i=0; i<mDimension; i++)
|
298 |
|
|
for(int j=i+1; j<mDimension; j++)
|
299 |
|
|
{
|
300 |
|
|
tmp = 0.0f;
|
301 |
|
|
|
302 |
|
|
for(int k=0; k<mDimension; k++)
|
303 |
|
|
{
|
304 |
|
|
tmp += baseV[i][k]*baseV[j][k];
|
305 |
|
|
}
|
306 |
|
|
|
307 |
6a2ebb18
|
Leszek Koltunski
|
cosA = ( (len[i]==0.0f || len[j]==0.0f) ? 0.0f : tmp/(float)Math.sqrt(len[i]*len[j]));
|
308 |
649544b8
|
Leszek Koltunski
|
|
309 |
6a2ebb18
|
Leszek Koltunski
|
if( cosA > 0.05f || cosA < -0.05f )
|
310 |
|
|
{
|
311 |
|
|
android.util.Log.e("dynamic", "cos angle between vectors "+i+" and "+j+" : "+cosA);
|
312 |
|
|
error = true;
|
313 |
|
|
}
|
314 |
649544b8
|
Leszek Koltunski
|
}
|
315 |
|
|
|
316 |
6a2ebb18
|
Leszek Koltunski
|
if( error ) printBase("");
|
317 |
649544b8
|
Leszek Koltunski
|
}
|
318 |
|
|
|
319 |
9dacabea
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
320 |
|
|
|
321 |
|
|
int getNext(int curr, float time)
|
322 |
|
|
{
|
323 |
|
|
switch(mMode)
|
324 |
|
|
{
|
325 |
|
|
case MODE_LOOP: return curr==numPoints-1 ? 0:curr+1;
|
326 |
|
|
case MODE_PATH: return time<0.5f ? (curr+1) : (curr==0 ? 1 : curr-1);
|
327 |
|
|
case MODE_JUMP: return curr==numPoints-1 ? 1:curr+1;
|
328 |
|
|
default : return 0;
|
329 |
|
|
}
|
330 |
|
|
}
|
331 |
|
|
|
332 |
c6dec65b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
333 |
|
|
|
334 |
|
|
private void checkAngle(int index)
|
335 |
|
|
{
|
336 |
|
|
float cosA = 0.0f;
|
337 |
|
|
|
338 |
|
|
for(int k=0;k<mDimension; k++)
|
339 |
|
|
cosA += baseV[index][k]*old[k];
|
340 |
|
|
|
341 |
|
|
if( cosA<0.0f )
|
342 |
|
|
{
|
343 |
|
|
/*
|
344 |
|
|
/// DEBUGGING ////
|
345 |
|
|
String s = index+" (";
|
346 |
|
|
float t;
|
347 |
|
|
|
348 |
|
|
for(int j=0; j<mDimension; j++)
|
349 |
|
|
{
|
350 |
|
|
t = ((int)(100*baseV[index][j]))/(100.0f);
|
351 |
|
|
s+=(" "+t);
|
352 |
|
|
}
|
353 |
|
|
s += ") (";
|
354 |
|
|
|
355 |
|
|
for(int j=0; j<mDimension; j++)
|
356 |
|
|
{
|
357 |
|
|
t = ((int)(100*old[j]))/(100.0f);
|
358 |
|
|
s+=(" "+t);
|
359 |
|
|
}
|
360 |
|
|
s+= ")";
|
361 |
|
|
|
362 |
|
|
android.util.Log.e("dynamic", "kat: " + s);
|
363 |
|
|
/// END DEBUGGING ///
|
364 |
|
|
*/
|
365 |
|
|
for(int j=0; j<mDimension; j++)
|
366 |
|
|
baseV[index][j] = -baseV[index][j];
|
367 |
|
|
}
|
368 |
|
|
}
|
369 |
|
|
|
370 |
649544b8
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
371 |
|
|
// helper function in case we are interpolating through exactly 2 points
|
372 |
|
|
|
373 |
a20f274f
|
Leszek Koltunski
|
protected void computeOrthonormalBase2(Static curr, Static next)
|
374 |
649544b8
|
Leszek Koltunski
|
{
|
375 |
|
|
switch(mDimension)
|
376 |
|
|
{
|
377 |
a20f274f
|
Leszek Koltunski
|
case 1: Static1D curr1 = (Static1D)curr;
|
378 |
|
|
Static1D next1 = (Static1D)next;
|
379 |
|
|
baseV[0][0] = (next1.x-curr1.x);
|
380 |
649544b8
|
Leszek Koltunski
|
break;
|
381 |
|
|
case 2: Static2D curr2 = (Static2D)curr;
|
382 |
|
|
Static2D next2 = (Static2D)next;
|
383 |
|
|
baseV[0][0] = (next2.x-curr2.x);
|
384 |
|
|
baseV[0][1] = (next2.y-curr2.y);
|
385 |
|
|
break;
|
386 |
|
|
case 3: Static3D curr3 = (Static3D)curr;
|
387 |
|
|
Static3D next3 = (Static3D)next;
|
388 |
|
|
baseV[0][0] = (next3.x-curr3.x);
|
389 |
|
|
baseV[0][1] = (next3.y-curr3.y);
|
390 |
|
|
baseV[0][2] = (next3.z-curr3.z);
|
391 |
|
|
break;
|
392 |
|
|
case 4: Static4D curr4 = (Static4D)curr;
|
393 |
|
|
Static4D next4 = (Static4D)next;
|
394 |
|
|
baseV[0][0] = (next4.x-curr4.x);
|
395 |
|
|
baseV[0][1] = (next4.y-curr4.y);
|
396 |
|
|
baseV[0][2] = (next4.z-curr4.z);
|
397 |
|
|
baseV[0][3] = (next4.w-curr4.w);
|
398 |
|
|
break;
|
399 |
|
|
case 5: Static5D curr5 = (Static5D)curr;
|
400 |
|
|
Static5D next5 = (Static5D)next;
|
401 |
|
|
baseV[0][0] = (next5.x-curr5.x);
|
402 |
|
|
baseV[0][1] = (next5.y-curr5.y);
|
403 |
|
|
baseV[0][2] = (next5.z-curr5.z);
|
404 |
|
|
baseV[0][3] = (next5.w-curr5.w);
|
405 |
|
|
baseV[0][4] = (next5.v-curr5.v);
|
406 |
|
|
break;
|
407 |
|
|
default: throw new RuntimeException("Unsupported dimension");
|
408 |
|
|
}
|
409 |
|
|
|
410 |
|
|
if( baseV[0][0] == 0.0f )
|
411 |
|
|
{
|
412 |
|
|
baseV[1][0] = 1.0f;
|
413 |
|
|
baseV[1][1] = 0.0f;
|
414 |
|
|
}
|
415 |
|
|
else
|
416 |
|
|
{
|
417 |
|
|
baseV[1][0] = 0.0f;
|
418 |
|
|
baseV[1][1] = 1.0f;
|
419 |
|
|
}
|
420 |
|
|
|
421 |
|
|
for(int i=2; i<mDimension; i++)
|
422 |
|
|
{
|
423 |
|
|
baseV[1][i] = 0.0f;
|
424 |
|
|
}
|
425 |
|
|
|
426 |
|
|
computeOrthonormalBase();
|
427 |
|
|
}
|
428 |
|
|
|
429 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
430 |
|
|
// helper function in case we are interpolating through more than 2 points
|
431 |
|
|
|
432 |
|
|
protected void computeOrthonormalBaseMore(float time,VectorCache vc)
|
433 |
|
|
{
|
434 |
|
|
for(int i=0; i<mDimension; i++)
|
435 |
|
|
{
|
436 |
6a2ebb18
|
Leszek Koltunski
|
baseV[0][i] = (3*vc.a[i]*time+2*vc.b[i])*time+vc.c[i]; // first derivative, i.e. velocity vector
|
437 |
|
|
old[i] = baseV[1][i];
|
438 |
|
|
baseV[1][i] = 6*vc.a[i]*time+2*vc.b[i]; // second derivative,i.e. acceleration vector
|
439 |
649544b8
|
Leszek Koltunski
|
}
|
440 |
|
|
|
441 |
|
|
computeOrthonormalBase();
|
442 |
|
|
}
|
443 |
|
|
|
444 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
445 |
|
|
// When this function gets called, baseV[0] and baseV[1] should have been filled with two mDimension-al
|
446 |
|
|
// vectors. This function then fills the rest of the baseV array with a mDimension-al Orthonormal base.
|
447 |
|
|
// (mDimension-2 vectors, pairwise orthogonal to each other and to the original 2). The function always
|
448 |
|
|
// leaves base[0] alone but generally speaking must adjust base[1] to make it orthogonal to base[0]!
|
449 |
|
|
// The whole baseV is then used to compute Noise.
|
450 |
|
|
//
|
451 |
|
|
// When computing noise of a point travelling along a N-dimensional path, there are three cases:
|
452 |
|
|
// a) we may be interpolating through 1 point, i.e. standing in place - nothing to do in this case
|
453 |
|
|
// b) we may be interpolating through 2 points, i.e. travelling along a straight line between them -
|
454 |
|
|
// then pass the velocity vector in baseV[0] and anything linearly independent in base[1].
|
455 |
|
|
// The output will then be discontinuous in dimensions>2 (sad corollary from the Hairy Ball Theorem)
|
456 |
|
|
// but we don't care - we are travelling along a straight line, so velocity (aka baseV[0]!) does
|
457 |
|
|
// not change.
|
458 |
|
|
// c) we may be interpolating through more than 2 points. Then interpolation formulas ensure the path
|
459 |
|
|
// will never be a straight line, even locally -> we can pass in baseV[0] and baseV[1] the velocity
|
460 |
|
|
// and the acceleration (first and second derivatives of the path) which are then guaranteed to be
|
461 |
|
|
// linearly independent. Then we can ensure this is continuous in dimensions <=4. This leaves
|
462 |
|
|
// dimension 5 (ATM WAVE is 5-dimensional) discontinuous -> WAVE will suffer from chaotic noise.
|
463 |
|
|
//
|
464 |
|
|
// Bear in mind here the 'normal' in 'orthonormal' means 'length equal to the length of the original
|
465 |
|
|
// velocity vector' (rather than the standard 1)
|
466 |
|
|
|
467 |
|
|
protected void computeOrthonormalBase()
|
468 |
|
|
{
|
469 |
|
|
int last_non_zero=-1;
|
470 |
6a2ebb18
|
Leszek Koltunski
|
float tmp;
|
471 |
649544b8
|
Leszek Koltunski
|
|
472 |
6a2ebb18
|
Leszek Koltunski
|
for(int i=0; i<mDimension; i++)
|
473 |
|
|
if( baseV[0][i] != 0.0f )
|
474 |
649544b8
|
Leszek Koltunski
|
last_non_zero=i;
|
475 |
6a2ebb18
|
Leszek Koltunski
|
|
476 |
a36b0cbb
|
Leszek Koltunski
|
if( last_non_zero==-1 ) ///
|
477 |
6a2ebb18
|
Leszek Koltunski
|
{ // velocity is the 0 vector -> two
|
478 |
|
|
for(int i=0; i<mDimension-1; i++) // consecutive points we are interpolating
|
479 |
|
|
for(int j=0; j<mDimension; j++) // through are identical -> no noise,
|
480 |
|
|
baseV[i+1][j]= 0.0f; // set the base to 0 vectors.
|
481 |
|
|
} ///
|
482 |
649544b8
|
Leszek Koltunski
|
else
|
483 |
|
|
{
|
484 |
6a2ebb18
|
Leszek Koltunski
|
for(int i=1; i<mDimension; i++) /// One iteration computes baseV[i][*]
|
485 |
|
|
{ // (aka b[i]), the i-th orthonormal vector.
|
486 |
|
|
buf[i-1]=0.0f; //
|
487 |
|
|
// We can use (modified!) Gram-Schmidt.
|
488 |
|
|
for(int k=0; k<mDimension; k++) //
|
489 |
|
|
{ //
|
490 |
|
|
if( i>=2 ) // b[0] = b[0]
|
491 |
|
|
{ // b[1] = b[1] - (<b[1],b[0]>/<b[0],b[0]>)*b[0]
|
492 |
|
|
old[k] = baseV[i][k]; // b[2] = b[2] - (<b[2],b[0]>/<b[0],b[0]>)*b[0] - (<b[2],b[1]>/<b[1],b[1]>)*b[1]
|
493 |
|
|
baseV[i][k]= (k==i-(last_non_zero>=i?1:0)) ? 1.0f : 0.0f; // b[3] = b[3] - (<b[3],b[0]>/<b[0],b[0]>)*b[0] - (<b[3],b[1]>/<b[1],b[1]>)*b[1] - (<b[3],b[2]>/<b[2],b[2]>)*b[2]
|
494 |
|
|
} // (...)
|
495 |
|
|
// then b[i] = b[i] / |b[i]| ( Here really b[i] = b[i] / (|b[0]|/|b[i]|)
|
496 |
|
|
tmp = baseV[i-1][k]; //
|
497 |
|
|
buf[i-1] += tmp*tmp; //
|
498 |
|
|
} //
|
499 |
|
|
//
|
500 |
|
|
for(int j=0; j<i; j++) //
|
501 |
|
|
{ //
|
502 |
|
|
tmp = 0.0f; //
|
503 |
|
|
for(int k=0;k<mDimension; k++) tmp += baseV[i][k]*baseV[j][k]; //
|
504 |
|
|
tmp /= buf[j]; //
|
505 |
|
|
for(int k=0;k<mDimension; k++) baseV[i][k] -= tmp*baseV[j][k]; //
|
506 |
|
|
} //
|
507 |
|
|
//
|
508 |
|
|
checkAngle(i); //
|
509 |
|
|
} /// end compute baseV[i][*]
|
510 |
|
|
|
511 |
|
|
buf[mDimension-1]=0.0f; /// Normalize
|
512 |
|
|
for(int k=0; k<mDimension; k++) //
|
513 |
|
|
{ //
|
514 |
|
|
tmp = baseV[mDimension-1][k]; //
|
515 |
|
|
buf[mDimension-1] += tmp*tmp; //
|
516 |
|
|
} //
|
517 |
|
|
//
|
518 |
|
|
for(int i=1; i<mDimension; i++) //
|
519 |
|
|
{ //
|
520 |
|
|
tmp = (float)Math.sqrt(buf[0]/buf[i]); //
|
521 |
|
|
for(int k=0;k<mDimension; k++) baseV[i][k] *= tmp; //
|
522 |
|
|
} /// End Normalize
|
523 |
649544b8
|
Leszek Koltunski
|
}
|
524 |
6a06a912
|
Leszek Koltunski
|
}
|
525 |
3002bef3
|
Leszek Koltunski
|
|
526 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
527 |
3002bef3
|
Leszek Koltunski
|
|
528 |
6a06a912
|
Leszek Koltunski
|
abstract void interpolate(float[] buffer, int offset, float time);
|
529 |
|
|
|
530 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
531 |
|
|
// PUBLIC API
|
532 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
533 |
8c893ffc
|
Leszek Koltunski
|
|
534 |
6a06a912
|
Leszek Koltunski
|
/**
|
535 |
|
|
* Sets the mode of the interpolation to Loop, Path or Jump.
|
536 |
|
|
* <ul>
|
537 |
|
|
* <li>Loop is when we go from the first point all the way to the last, and the back to the first through
|
538 |
|
|
* the shortest way.
|
539 |
|
|
* <li>Path is when we come back from the last point back to the first the same way we got there.
|
540 |
c45c2ab1
|
Leszek Koltunski
|
* <li>Jump is when we go from first to last and then jump straight back to the first.
|
541 |
6a06a912
|
Leszek Koltunski
|
* </ul>
|
542 |
|
|
*
|
543 |
568b29d8
|
Leszek Koltunski
|
* @param mode {@link Dynamic#MODE_LOOP}, {@link Dynamic#MODE_PATH} or {@link Dynamic#MODE_JUMP}.
|
544 |
6a06a912
|
Leszek Koltunski
|
*/
|
545 |
|
|
public void setMode(int mode)
|
546 |
|
|
{
|
547 |
|
|
mMode = mode;
|
548 |
|
|
}
|
549 |
|
|
|
550 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
551 |
|
|
/**
|
552 |
c45c2ab1
|
Leszek Koltunski
|
* Returns the number of Points this Dynamic has been fed with.
|
553 |
6a06a912
|
Leszek Koltunski
|
*
|
554 |
c45c2ab1
|
Leszek Koltunski
|
* @return the number of Points we are currently interpolating through.
|
555 |
6a06a912
|
Leszek Koltunski
|
*/
|
556 |
|
|
public synchronized int getNumPoints()
|
557 |
|
|
{
|
558 |
|
|
return numPoints;
|
559 |
|
|
}
|
560 |
|
|
|
561 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
562 |
|
|
/**
|
563 |
c45c2ab1
|
Leszek Koltunski
|
* Sets how many revolutions we want to do.
|
564 |
6a06a912
|
Leszek Koltunski
|
* <p>
|
565 |
c45c2ab1
|
Leszek Koltunski
|
* Does not have to be an integer. What constitutes 'one revolution' depends on the MODE:
|
566 |
|
|
* {@link Dynamic#MODE_LOOP}, {@link Dynamic#MODE_PATH} or {@link Dynamic#MODE_JUMP}.
|
567 |
6a06a912
|
Leszek Koltunski
|
* Count<=0 means 'go on interpolating indefinitely'.
|
568 |
|
|
*
|
569 |
c45c2ab1
|
Leszek Koltunski
|
* @param count the number of times we want to interpolate between our collection of Points.
|
570 |
6a06a912
|
Leszek Koltunski
|
*/
|
571 |
|
|
public void setCount(float count)
|
572 |
|
|
{
|
573 |
|
|
mCount = count;
|
574 |
|
|
}
|
575 |
|
|
|
576 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
577 |
|
|
/**
|
578 |
c45c2ab1
|
Leszek Koltunski
|
* Return the number of revolutions this Dynamic will make.
|
579 |
|
|
* What constitutes 'one revolution' depends on the MODE:
|
580 |
|
|
* {@link Dynamic#MODE_LOOP}, {@link Dynamic#MODE_PATH} or {@link Dynamic#MODE_JUMP}.
|
581 |
b920c848
|
Leszek Koltunski
|
*
|
582 |
c45c2ab1
|
Leszek Koltunski
|
* @return the number revolutions this Dynamic will make.
|
583 |
b920c848
|
Leszek Koltunski
|
*/
|
584 |
|
|
public float getCount()
|
585 |
|
|
{
|
586 |
|
|
return mCount;
|
587 |
|
|
}
|
588 |
|
|
|
589 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
590 |
|
|
/**
|
591 |
|
|
* Start running from the beginning again.
|
592 |
c45c2ab1
|
Leszek Koltunski
|
*
|
593 |
|
|
* If a Dynamic has been used already, and we want to use it again and start interpolating from the
|
594 |
|
|
* first Point, first we need to reset it using this method.
|
595 |
6a06a912
|
Leszek Koltunski
|
*/
|
596 |
b920c848
|
Leszek Koltunski
|
public void resetToBeginning()
|
597 |
6a06a912
|
Leszek Koltunski
|
{
|
598 |
78ff6ea9
|
Leszek Koltunski
|
mStartTime = -1;
|
599 |
b920c848
|
Leszek Koltunski
|
}
|
600 |
|
|
|
601 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
602 |
|
|
/**
|
603 |
c45c2ab1
|
Leszek Koltunski
|
* @param duration Number of milliseconds one revolution will take.
|
604 |
|
|
* What constitutes 'one revolution' depends on the MODE:
|
605 |
|
|
* {@link Dynamic#MODE_LOOP}, {@link Dynamic#MODE_PATH} or {@link Dynamic#MODE_JUMP}.
|
606 |
b920c848
|
Leszek Koltunski
|
*/
|
607 |
|
|
public void setDuration(long duration)
|
608 |
|
|
{
|
609 |
|
|
mDuration = duration;
|
610 |
|
|
}
|
611 |
|
|
|
612 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
613 |
|
|
/**
|
614 |
c45c2ab1
|
Leszek Koltunski
|
* @return Number of milliseconds one revolution will take.
|
615 |
b920c848
|
Leszek Koltunski
|
*/
|
616 |
|
|
public long getDuration()
|
617 |
|
|
{
|
618 |
|
|
return mDuration;
|
619 |
6a06a912
|
Leszek Koltunski
|
}
|
620 |
|
|
|
621 |
12ecac18
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
622 |
|
|
/**
|
623 |
|
|
* @param convexity If set to the default (1.0f) then interpolation between 4 points
|
624 |
|
|
* (1,0) (0,1) (-1,0) (0,-1) will be the natural circle centered at (0,0) with radius 1.
|
625 |
|
|
* The less it is, the less convex the circle becomes, ultimately when convexity=0.0f
|
626 |
|
|
* then the interpolation shape will be straight lines connecting the four points.
|
627 |
|
|
* Further setting this to negative values will make the shape concave.
|
628 |
|
|
* Valid values: all floats. (although probably only something around (0,2) actually
|
629 |
|
|
* makes sense)
|
630 |
|
|
*/
|
631 |
|
|
public void setConvexity(float convexity)
|
632 |
|
|
{
|
633 |
|
|
if( mConvexity!=convexity )
|
634 |
|
|
{
|
635 |
|
|
mConvexity = convexity;
|
636 |
|
|
cacheDirty = true;
|
637 |
|
|
}
|
638 |
|
|
}
|
639 |
|
|
|
640 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
641 |
|
|
/**
|
642 |
|
|
* @return See {@link Dynamic#setConvexity(float)}
|
643 |
|
|
*/
|
644 |
|
|
public float getConvexity()
|
645 |
|
|
{
|
646 |
|
|
return mConvexity;
|
647 |
|
|
}
|
648 |
|
|
|
649 |
bdb341bc
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
650 |
|
|
/**
|
651 |
c45c2ab1
|
Leszek Koltunski
|
* Sets the access type this Dynamic will be working in.
|
652 |
bdb341bc
|
Leszek Koltunski
|
*
|
653 |
c45c2ab1
|
Leszek Koltunski
|
* @param type {@link Dynamic#ACCESS_TYPE_RANDOM} or {@link Dynamic#ACCESS_TYPE_SEQUENTIAL}.
|
654 |
bdb341bc
|
Leszek Koltunski
|
*/
|
655 |
c45c2ab1
|
Leszek Koltunski
|
public void setAccessType(int type)
|
656 |
bdb341bc
|
Leszek Koltunski
|
{
|
657 |
c45c2ab1
|
Leszek Koltunski
|
mAccessType = type;
|
658 |
bdb341bc
|
Leszek Koltunski
|
mLastPos = -1;
|
659 |
|
|
}
|
660 |
|
|
|
661 |
6d62a900
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
662 |
|
|
/**
|
663 |
|
|
* Return the Dimension, ie number of floats in a single Point this Dynamic interpolates through.
|
664 |
c45c2ab1
|
Leszek Koltunski
|
*
|
665 |
|
|
* @return number of floats in a single Point (ie its dimension) contained in the Dynamic.
|
666 |
6d62a900
|
Leszek Koltunski
|
*/
|
667 |
|
|
public int getDimension()
|
668 |
|
|
{
|
669 |
|
|
return mDimension;
|
670 |
|
|
}
|
671 |
|
|
|
672 |
bdb341bc
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
673 |
|
|
/**
|
674 |
|
|
* Writes the results of interpolation between the Points at time 'time' to the passed float buffer.
|
675 |
|
|
* <p>
|
676 |
|
|
* This version differs from the previous in that it returns a boolean value which indicates whether
|
677 |
|
|
* the interpolation is finished.
|
678 |
|
|
*
|
679 |
24d22f93
|
Leszek Koltunski
|
* @param buffer Float buffer we will write the results to.
|
680 |
bdb341bc
|
Leszek Koltunski
|
* @param offset Offset in the buffer where to write the result.
|
681 |
c45c2ab1
|
Leszek Koltunski
|
* @param time Time of interpolation. Time=0.0 is the beginning of the first revolution, time=1.0 - the end
|
682 |
|
|
* of the first revolution, time=2.5 - the middle of the third revolution.
|
683 |
|
|
* What constitutes 'one revolution' depends on the MODE:
|
684 |
|
|
* {@link Dynamic#MODE_LOOP}, {@link Dynamic#MODE_PATH} or {@link Dynamic#MODE_JUMP}.
|
685 |
012901f5
|
Leszek Koltunski
|
* @param step Time difference between now and the last time we called this function. Needed to figure
|
686 |
|
|
* out if the previous time we were called the effect wasn't finished yet, but now it is.
|
687 |
bdb341bc
|
Leszek Koltunski
|
* @return true if the interpolation reached its end.
|
688 |
|
|
*/
|
689 |
a1d92a36
|
leszek
|
public boolean get(float[] buffer, int offset, long time, long step)
|
690 |
bdb341bc
|
Leszek Koltunski
|
{
|
691 |
|
|
if( mDuration<=0.0f )
|
692 |
|
|
{
|
693 |
|
|
interpolate(buffer,offset,mCount-(int)mCount);
|
694 |
|
|
return false;
|
695 |
|
|
}
|
696 |
b920c848
|
Leszek Koltunski
|
|
697 |
78ff6ea9
|
Leszek Koltunski
|
if( mStartTime==-1 )
|
698 |
b920c848
|
Leszek Koltunski
|
{
|
699 |
0273ef2a
|
Leszek Koltunski
|
mStartTime = time;
|
700 |
b920c848
|
Leszek Koltunski
|
mLastPos = -1;
|
701 |
|
|
}
|
702 |
|
|
|
703 |
0273ef2a
|
Leszek Koltunski
|
long diff = time-mPausedTime;
|
704 |
|
|
|
705 |
246d021c
|
Leszek Koltunski
|
if( mStartTime<mPausedTime && mCorrectedTime<mPausedTime && diff>=0 && diff<=step )
|
706 |
0273ef2a
|
Leszek Koltunski
|
{
|
707 |
246d021c
|
Leszek Koltunski
|
mCorrectedTime = mPausedTime;
|
708 |
0273ef2a
|
Leszek Koltunski
|
mStartTime += diff;
|
709 |
|
|
step -= diff;
|
710 |
|
|
}
|
711 |
|
|
|
712 |
|
|
time -= mStartTime;
|
713 |
b920c848
|
Leszek Koltunski
|
|
714 |
48d0867a
|
leszek
|
if( time+step > mDuration*mCount && mCount>0.0f )
|
715 |
|
|
{
|
716 |
|
|
interpolate(buffer,offset,mCount-(int)mCount);
|
717 |
|
|
return true;
|
718 |
|
|
}
|
719 |
bdb341bc
|
Leszek Koltunski
|
|
720 |
|
|
double pos;
|
721 |
|
|
|
722 |
c45c2ab1
|
Leszek Koltunski
|
if( mAccessType ==ACCESS_TYPE_SEQUENTIAL )
|
723 |
bdb341bc
|
Leszek Koltunski
|
{
|
724 |
|
|
pos = mLastPos<0 ? (double)time/mDuration : (double)step/mDuration + mLastPos;
|
725 |
|
|
mLastPos = pos;
|
726 |
|
|
}
|
727 |
|
|
else
|
728 |
|
|
{
|
729 |
|
|
pos = (double)time/mDuration;
|
730 |
|
|
}
|
731 |
|
|
|
732 |
48d0867a
|
leszek
|
interpolate(buffer,offset, (float)(pos-(int)pos) );
|
733 |
bdb341bc
|
Leszek Koltunski
|
return false;
|
734 |
|
|
}
|
735 |
|
|
|
736 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
737 |
|
|
}
|