Revision 291705f6
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/library/type/Dynamic.java | ||
---|---|---|
68 | 68 |
|
69 | 69 |
protected int mDimension; |
70 | 70 |
protected int numPoints; |
71 |
protected int mVecCurr;
|
|
71 |
protected int mSegment; // between which pair of points are we currently? (in case of PATH this is a bit complicated!)
|
|
72 | 72 |
protected boolean cacheDirty; // VectorCache not up to date |
73 | 73 |
protected int mMode; // LOOP, PATH or JUMP |
74 | 74 |
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 |
... | ... | |
78 | 78 |
{ |
79 | 79 |
float[][] n; |
80 | 80 |
|
81 |
VectorNoise(int dim)
|
|
81 |
VectorNoise() |
|
82 | 82 |
{ |
83 |
n = new float[dim][NUM_NOISE]; |
|
83 |
n = new float[mDimension][NUM_NOISE]; |
|
84 |
} |
|
84 | 85 |
|
86 |
void computeNoise() |
|
87 |
{ |
|
85 | 88 |
n[0][0] = mRnd.nextFloat(); |
86 | 89 |
for(int i=1; i<NUM_NOISE; i++) n[0][i] = n[0][i-1]+mRnd.nextFloat(); |
90 |
|
|
87 | 91 |
float sum = n[0][NUM_NOISE-1] + mRnd.nextFloat(); |
88 |
for(int i=0; i<NUM_NOISE; i++) n[0][i] /=sum; |
|
89 | 92 |
|
90 |
for(int j=1; j<dim; j++)
|
|
93 |
for(int i=0; i<NUM_NOISE; i++)
|
|
91 | 94 |
{ |
92 |
for(int i=0; i<NUM_NOISE; i++) n[j][i] = mRnd.nextFloat()-0.5f; |
|
95 |
n[0][i] /=sum; |
|
96 |
for(int j=1; j<mDimension; j++) n[j][i] = mRnd.nextFloat()-0.5f; |
|
93 | 97 |
} |
94 | 98 |
} |
95 | 99 |
} |
... | ... | |
114 | 118 |
float[] tangent; |
115 | 119 |
float[] cached; |
116 | 120 |
|
117 |
VectorCache(int dim)
|
|
121 |
VectorCache() |
|
118 | 122 |
{ |
119 |
a = new float[dim];
|
|
120 |
b = new float[dim];
|
|
121 |
c = new float[dim];
|
|
122 |
d = new float[dim];
|
|
123 |
tangent = new float[dim];
|
|
124 |
cached = new float[dim];
|
|
123 |
a = new float[mDimension];
|
|
124 |
b = new float[mDimension];
|
|
125 |
c = new float[mDimension];
|
|
126 |
d = new float[mDimension];
|
|
127 |
tangent = new float[mDimension];
|
|
128 |
cached = new float[mDimension];
|
|
125 | 129 |
} |
126 | 130 |
} |
127 | 131 |
|
... | ... | |
147 | 151 |
|
148 | 152 |
protected Dynamic(int duration, float count, int dimension) |
149 | 153 |
{ |
150 |
vc = new Vector<>(); |
|
151 |
vn = null; |
|
152 |
numPoints = 0; |
|
154 |
vc = new Vector<>();
|
|
155 |
vn = null;
|
|
156 |
numPoints = 0;
|
|
153 | 157 |
cacheDirty = false; |
154 |
mMode = MODE_LOOP; |
|
155 |
mDuration = duration; |
|
156 |
mCount = count; |
|
158 |
mMode = MODE_LOOP;
|
|
159 |
mDuration = duration;
|
|
160 |
mCount = count;
|
|
157 | 161 |
mDimension = dimension; |
162 |
mSegment = -1; |
|
158 | 163 |
|
159 |
baseV = new float[mDimension][mDimension]; |
|
160 |
buf= new float[mDimension]; |
|
161 |
old= new float[mDimension]; |
|
164 |
baseV = new float[mDimension][mDimension];
|
|
165 |
buf = new float[mDimension];
|
|
166 |
old = new float[mDimension];
|
|
162 | 167 |
} |
163 | 168 |
|
164 | 169 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
re-generate noise after passing each Point.