Revision 291705f6
Added by Leszek Koltunski about 9 years ago
| src/main/java/org/distorted/library/EffectNames.java | ||
|---|---|---|
| 136 | 136 |
* Directional sinusoidal wave effect. The direction of the wave is given by the 'angle' |
| 137 | 137 |
* parameters. Details: {@link DistortedObject#wave(Data5D,Data2D)}
|
| 138 | 138 |
* <p> |
| 139 |
* Uniforms: (amplitude,length,offset,angleAlpha,
|
|
| 139 |
* Uniforms: (amplitude,length,phase,angleAlpha,
|
|
| 140 | 140 |
* angleBeta, UNUSED,centerX,centerY, |
| 141 | 141 |
* regionX,regionY,regionRX,regionRY) |
| 142 | 142 |
* <p> |
| 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 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/library/type/Dynamic1D.java | ||
|---|---|---|
| 207 | 207 |
{
|
| 208 | 208 |
vv.add(v); |
| 209 | 209 |
|
| 210 |
if( vn!=null ) vn.add(new VectorNoise(1));
|
|
| 210 |
if( vn!=null ) vn.add(new VectorNoise()); |
|
| 211 | 211 |
|
| 212 | 212 |
switch(numPoints) |
| 213 | 213 |
{
|
| 214 | 214 |
case 0: |
| 215 | 215 |
case 1: break; |
| 216 |
case 2: vc.add(new VectorCache(1));
|
|
| 217 |
vc.add(new VectorCache(1));
|
|
| 218 |
vc.add(new VectorCache(1));
|
|
| 216 |
case 2: vc.add(new VectorCache()); |
|
| 217 |
vc.add(new VectorCache()); |
|
| 218 |
vc.add(new VectorCache()); |
|
| 219 | 219 |
cacheDirty = true; |
| 220 | 220 |
break; |
| 221 |
default:vc.add(new VectorCache(1));
|
|
| 221 |
default:vc.add(new VectorCache()); |
|
| 222 | 222 |
cacheDirty = true; |
| 223 | 223 |
} |
| 224 | 224 |
|
| ... | ... | |
| 239 | 239 |
{
|
| 240 | 240 |
vv.add(location, v); |
| 241 | 241 |
|
| 242 |
if( vn!=null ) vn.add(new VectorNoise(1));
|
|
| 242 |
if( vn!=null ) vn.add(new VectorNoise()); |
|
| 243 | 243 |
|
| 244 | 244 |
switch(numPoints) |
| 245 | 245 |
{
|
| 246 | 246 |
case 0: |
| 247 | 247 |
case 1: break; |
| 248 |
case 2: vc.add(new VectorCache(1));
|
|
| 249 |
vc.add(new VectorCache(1));
|
|
| 250 |
vc.add(new VectorCache(1));
|
|
| 248 |
case 2: vc.add(new VectorCache()); |
|
| 249 |
vc.add(new VectorCache()); |
|
| 250 |
vc.add(new VectorCache()); |
|
| 251 | 251 |
cacheDirty = true; |
| 252 | 252 |
break; |
| 253 |
default:vc.add(location,new VectorCache(1));
|
|
| 253 |
default:vc.add(location,new VectorCache()); |
|
| 254 | 254 |
cacheDirty = true; |
| 255 | 255 |
} |
| 256 | 256 |
|
| ... | ... | |
| 358 | 358 |
if( vn==null ) |
| 359 | 359 |
{
|
| 360 | 360 |
vn = new Vector<>(); |
| 361 |
for(int i=0; i<numPoints; i++) vn.add(new VectorNoise(mDimension));
|
|
| 361 |
for(int i=0; i<numPoints; i++) vn.add(new VectorNoise()); |
|
| 362 | 362 |
|
| 363 | 363 |
if( mDimension>=2 ) |
| 364 | 364 |
{
|
| ... | ... | |
| 397 | 397 |
break; |
| 398 | 398 |
case 2: curr = vv.elementAt(0); |
| 399 | 399 |
next = vv.elementAt(1); |
| 400 |
|
|
| 400 |
|
|
| 401 |
int segment2= (int)(2*time); |
|
| 402 |
|
|
| 401 | 403 |
if( mMode==MODE_LOOP || mMode==MODE_PATH ) time = (time>0.5f ? 2-2*time : 2*time); |
| 402 |
|
|
| 404 |
|
|
| 403 | 405 |
if( vn!=null ) |
| 404 | 406 |
{
|
| 407 |
if( segment2 != mSegment ) |
|
| 408 |
{
|
|
| 409 |
if(mMode!=MODE_JUMP || mSegment==1) vn.elementAt(0).computeNoise(); |
|
| 410 |
mSegment = segment2; |
|
| 411 |
} |
|
| 412 |
|
|
| 405 | 413 |
time = noise(time,0); |
| 406 | 414 |
} |
| 407 | 415 |
|
| 408 | 416 |
buffer[offset] = (next.x-curr.x)*time + curr.x; |
| 409 | 417 |
break; |
| 410 | 418 |
default:float t = time; |
| 411 |
|
|
| 419 |
int vecCurr, segment; |
|
| 420 |
|
|
| 412 | 421 |
switch(mMode) |
| 413 | 422 |
{
|
| 414 | 423 |
case MODE_LOOP: time = time*numPoints; |
| 424 |
segment = (int)time; |
|
| 425 |
vecCurr = segment; |
|
| 415 | 426 |
break; |
| 416 |
case MODE_PATH: time = (time<=0.5f) ? 2*time*(numPoints-1) : 2*(1-time)*(numPoints-1); |
|
| 427 |
case MODE_PATH: segment = (int)(2*t*(numPoints-1)); |
|
| 428 |
|
|
| 429 |
if( t<=0.5f ) |
|
| 430 |
{
|
|
| 431 |
time = 2*t*(numPoints-1); |
|
| 432 |
vecCurr = segment; |
|
| 433 |
} |
|
| 434 |
else |
|
| 435 |
{
|
|
| 436 |
time = 2*(1-t)*(numPoints-1); |
|
| 437 |
vecCurr = 2*numPoints-3-segment; |
|
| 438 |
} |
|
| 417 | 439 |
break; |
| 418 | 440 |
case MODE_JUMP: time = time*(numPoints-1); |
| 441 |
segment = (int)time; |
|
| 442 |
vecCurr = segment; |
|
| 419 | 443 |
break; |
| 444 |
default : vecCurr = 0; |
|
| 445 |
segment = 0; |
|
| 420 | 446 |
} |
| 421 |
|
|
| 422 |
int vecCurr = (int)time; |
|
| 423 |
time = time-vecCurr; |
|
| 424 |
|
|
| 447 |
|
|
| 425 | 448 |
if( vecCurr>=0 && vecCurr<numPoints ) |
| 426 | 449 |
{
|
| 427 | 450 |
if( cacheDirty ) recomputeCache(); // recompute cache if we have added or remove vectors since last computation |
| 428 |
else if( mVecCurr!= vecCurr ) // ...or if we have just passed a vector and the vector we are currently flying to has changed
|
|
| 451 |
else if( mSegment!= segment ) // ...or if we have just passed a vector and the vector we are currently flying to has changed
|
|
| 429 | 452 |
{
|
| 430 |
int vecNext; |
|
| 431 |
mVecCurr = vecCurr; |
|
| 432 |
|
|
| 453 |
int vecNext; |
|
| 454 |
|
|
| 433 | 455 |
switch(mMode) |
| 434 | 456 |
{
|
| 435 |
case MODE_LOOP: vecNext = vecCurr==numPoints-1 ? 0:vecCurr+1;
|
|
| 457 |
case MODE_LOOP: vecNext = vecCurr==numPoints-1 ? 0:vecCurr+1; |
|
| 436 | 458 |
break; |
| 437 |
case MODE_PATH: if( t<0.5f ) vecNext = vecCurr==numPoints-1 ? numPoints-2: vecCurr+1;
|
|
| 438 |
else vecNext = vecCurr==0 ? 1 : vecCurr-1;
|
|
| 459 |
case MODE_PATH: if( t<0.5f ) vecNext = vecCurr==numPoints-1 ? numPoints-2: vecCurr+1; |
|
| 460 |
else vecNext = vecCurr==0 ? 1 : vecCurr-1; |
|
| 439 | 461 |
break; |
| 440 | 462 |
case MODE_JUMP: vecNext = vecCurr==numPoints-1 ? 1:vecCurr+1; |
| 441 | 463 |
break; |
| 442 |
default : vecNext = 0;
|
|
| 464 |
default : vecNext = 0; |
|
| 443 | 465 |
} |
| 444 | 466 |
|
| 445 | 467 |
next = vv.elementAt(vecNext); |
| ... | ... | |
| 447 | 469 |
|
| 448 | 470 |
if( tmp2.cached[0]!=next.x ) recomputeCache(); |
| 449 | 471 |
} |
| 450 |
|
|
| 472 |
|
|
| 473 |
if( mSegment!= segment && vn!=null ) vn.elementAt(vecCurr).computeNoise(); |
|
| 474 |
|
|
| 475 |
mSegment = segment; |
|
| 476 |
|
|
| 477 |
time = time-vecCurr; |
|
| 478 |
|
|
| 479 |
tmp1 = vc.elementAt(vecCurr); |
|
| 480 |
|
|
| 451 | 481 |
if( vn!=null ) |
| 452 | 482 |
{
|
| 453 | 483 |
time = noise(time,vecCurr); |
| 454 | 484 |
} |
| 455 | 485 |
|
| 456 |
tmp1 = vc.elementAt(vecCurr); |
|
| 457 | 486 |
buffer[offset] = ((tmp1.a[0]*time+tmp1.b[0])*time+tmp1.c[0])*time+tmp1.d[0]; |
| 458 | 487 |
break; |
| 459 | 488 |
} |
| src/main/java/org/distorted/library/type/Dynamic2D.java | ||
|---|---|---|
| 223 | 223 |
{
|
| 224 | 224 |
vv.add(v); |
| 225 | 225 |
|
| 226 |
if( vn!=null ) vn.add(new VectorNoise(2));
|
|
| 226 |
if( vn!=null ) vn.add(new VectorNoise()); |
|
| 227 | 227 |
|
| 228 | 228 |
switch(numPoints) |
| 229 | 229 |
{
|
| 230 | 230 |
case 0: |
| 231 | 231 |
case 1: break; |
| 232 |
case 2: vc.add(new VectorCache(2));
|
|
| 233 |
vc.add(new VectorCache(2));
|
|
| 234 |
vc.add(new VectorCache(2));
|
|
| 232 |
case 2: vc.add(new VectorCache()); |
|
| 233 |
vc.add(new VectorCache()); |
|
| 234 |
vc.add(new VectorCache()); |
|
| 235 | 235 |
break; |
| 236 |
default:vc.add(new VectorCache(2));
|
|
| 236 |
default:vc.add(new VectorCache()); |
|
| 237 | 237 |
} |
| 238 | 238 |
|
| 239 | 239 |
numPoints++; |
| ... | ... | |
| 254 | 254 |
{
|
| 255 | 255 |
vv.add(location, v); |
| 256 | 256 |
|
| 257 |
if( vn!=null ) vn.add(new VectorNoise(2));
|
|
| 257 |
if( vn!=null ) vn.add(new VectorNoise()); |
|
| 258 | 258 |
|
| 259 | 259 |
switch(numPoints) |
| 260 | 260 |
{
|
| 261 | 261 |
case 0: |
| 262 | 262 |
case 1: break; |
| 263 |
case 2: vc.add(new VectorCache(2));
|
|
| 264 |
vc.add(new VectorCache(2));
|
|
| 265 |
vc.add(new VectorCache(2));
|
|
| 263 |
case 2: vc.add(new VectorCache()); |
|
| 264 |
vc.add(new VectorCache()); |
|
| 265 |
vc.add(new VectorCache()); |
|
| 266 | 266 |
break; |
| 267 |
default:vc.add(location,new VectorCache(2));
|
|
| 267 |
default:vc.add(location,new VectorCache()); |
|
| 268 | 268 |
} |
| 269 | 269 |
|
| 270 | 270 |
numPoints++; |
| ... | ... | |
| 376 | 376 |
if( vn==null ) |
| 377 | 377 |
{
|
| 378 | 378 |
vn = new Vector<>(); |
| 379 |
for(int i=0; i<numPoints; i++) vn.add(new VectorNoise(mDimension));
|
|
| 379 |
for(int i=0; i<numPoints; i++) vn.add(new VectorNoise()); |
|
| 380 | 380 |
|
| 381 | 381 |
if( mDimension>=2 ) |
| 382 | 382 |
{
|
| ... | ... | |
| 420 | 420 |
break; |
| 421 | 421 |
case 2: curr = vv.elementAt(0); |
| 422 | 422 |
next = vv.elementAt(1); |
| 423 |
|
|
| 423 |
|
|
| 424 |
int segment2= (int)(2*time); |
|
| 425 |
|
|
| 424 | 426 |
if( mMode==MODE_LOOP || mMode==MODE_PATH ) time = (time>0.5f ? 2-2*time : 2*time); |
| 425 |
|
|
| 427 |
|
|
| 426 | 428 |
if( vn!=null ) |
| 427 | 429 |
{
|
| 430 |
if( segment2 != mSegment ) |
|
| 431 |
{
|
|
| 432 |
if(mMode!=MODE_JUMP || mSegment==1) vn.elementAt(0).computeNoise(); |
|
| 433 |
mSegment = segment2; |
|
| 434 |
} |
|
| 435 |
|
|
| 428 | 436 |
time = noise(time,0); |
| 429 | 437 |
|
| 430 | 438 |
baseV[1][0] = next.x-curr.x; |
| ... | ... | |
| 441 | 449 |
|
| 442 | 450 |
break; |
| 443 | 451 |
default:float t = time; |
| 444 |
|
|
| 452 |
int vecCurr, segment; |
|
| 453 |
|
|
| 445 | 454 |
switch(mMode) |
| 446 | 455 |
{
|
| 447 | 456 |
case MODE_LOOP: time = time*numPoints; |
| 457 |
segment = (int)time; |
|
| 458 |
vecCurr = segment; |
|
| 448 | 459 |
break; |
| 449 |
case MODE_PATH: time = (time<=0.5f) ? 2*time*(numPoints-1) : 2*(1-time)*(numPoints-1); |
|
| 460 |
case MODE_PATH: segment = (int)(2*t*(numPoints-1)); |
|
| 461 |
|
|
| 462 |
if( t<=0.5f ) |
|
| 463 |
{
|
|
| 464 |
time = 2*t*(numPoints-1); |
|
| 465 |
vecCurr = segment; |
|
| 466 |
} |
|
| 467 |
else |
|
| 468 |
{
|
|
| 469 |
time = 2*(1-t)*(numPoints-1); |
|
| 470 |
vecCurr = 2*numPoints-3-segment; |
|
| 471 |
} |
|
| 450 | 472 |
break; |
| 451 | 473 |
case MODE_JUMP: time = time*(numPoints-1); |
| 474 |
segment = (int)time; |
|
| 475 |
vecCurr = segment; |
|
| 452 | 476 |
break; |
| 477 |
default : vecCurr = 0; |
|
| 478 |
segment = 0; |
|
| 453 | 479 |
} |
| 454 |
|
|
| 455 |
int vecCurr = (int)time; |
|
| 456 |
time = time-vecCurr; |
|
| 457 |
|
|
| 480 |
|
|
| 458 | 481 |
if( vecCurr>=0 && vecCurr<numPoints ) |
| 459 |
{
|
|
| 460 |
if( cacheDirty ) recomputeCache(); // recompute cache if we have added or remove vectors since last computation
|
|
| 461 |
else if( mVecCurr!= vecCurr ) // ...or if we have just passed a vector and the vector we are currently flying to has changed
|
|
| 482 |
{
|
|
| 483 |
if( cacheDirty ) recomputeCache(); // recompute cache if we have added or remove vectors since last computation |
|
| 484 |
else if( mSegment!= segment ) // ...or if we have just passed a vector and the vector we are currently flying to has changed
|
|
| 462 | 485 |
{
|
| 463 |
int vecNext; |
|
| 464 |
mVecCurr = vecCurr; |
|
| 465 |
|
|
| 486 |
int vecNext; |
|
| 487 |
|
|
| 466 | 488 |
switch(mMode) |
| 467 | 489 |
{
|
| 468 |
case MODE_LOOP: vecNext = vecCurr==numPoints-1 ? 0:vecCurr+1;
|
|
| 490 |
case MODE_LOOP: vecNext = vecCurr==numPoints-1 ? 0:vecCurr+1; |
|
| 469 | 491 |
break; |
| 470 |
case MODE_PATH: if( t<0.5f ) vecNext = vecCurr==numPoints-1 ? numPoints-2: vecCurr+1;
|
|
| 471 |
else vecNext = vecCurr==0 ? 1 : vecCurr-1;
|
|
| 492 |
case MODE_PATH: if( t<0.5f ) vecNext = vecCurr==numPoints-1 ? numPoints-2: vecCurr+1; |
|
| 493 |
else vecNext = vecCurr==0 ? 1 : vecCurr-1; |
|
| 472 | 494 |
break; |
| 473 | 495 |
case MODE_JUMP: vecNext = vecCurr==numPoints-1 ? 1:vecCurr+1; |
| 474 | 496 |
break; |
| 475 |
default : vecNext = 0;
|
|
| 497 |
default : vecNext = 0; |
|
| 476 | 498 |
} |
| 477 |
|
|
| 499 |
|
|
| 478 | 500 |
next = vv.elementAt(vecNext); |
| 479 | 501 |
tmp2 = vc.elementAt(vecNext); |
| 480 |
|
|
| 481 |
if( tmp2.cached[0]!=next.x || tmp2.cached[1]!=next.y ) recomputeCache();
|
|
| 502 |
|
|
| 503 |
if( tmp2.cached[0]!=next.x ) recomputeCache(); |
|
| 482 | 504 |
} |
| 483 | 505 |
|
| 506 |
if( mSegment!= segment && vn!=null ) vn.elementAt(vecCurr).computeNoise(); |
|
| 507 |
|
|
| 508 |
mSegment = segment; |
|
| 509 |
|
|
| 510 |
time = time-vecCurr; |
|
| 484 | 511 |
tmp1 = vc.elementAt(vecCurr); |
| 485 | 512 |
|
| 486 | 513 |
if( vn!=null ) |
| src/main/java/org/distorted/library/type/Dynamic3D.java | ||
|---|---|---|
| 246 | 246 |
{
|
| 247 | 247 |
vv.add(v); |
| 248 | 248 |
|
| 249 |
if( vn!=null ) vn.add(new VectorNoise(3));
|
|
| 249 |
if( vn!=null ) vn.add(new VectorNoise()); |
|
| 250 | 250 |
|
| 251 | 251 |
switch(numPoints) |
| 252 | 252 |
{
|
| 253 | 253 |
case 0: break; |
| 254 | 254 |
case 1: computeOrthonormalBase2(vv.elementAt(0),v); |
| 255 | 255 |
break; |
| 256 |
case 2: vc.add(new VectorCache(3));
|
|
| 257 |
vc.add(new VectorCache(3));
|
|
| 258 |
vc.add(new VectorCache(3));
|
|
| 256 |
case 2: vc.add(new VectorCache()); |
|
| 257 |
vc.add(new VectorCache()); |
|
| 258 |
vc.add(new VectorCache()); |
|
| 259 | 259 |
break; |
| 260 |
default:vc.add(new VectorCache(3));
|
|
| 260 |
default:vc.add(new VectorCache()); |
|
| 261 | 261 |
} |
| 262 | 262 |
|
| 263 | 263 |
numPoints++; |
| ... | ... | |
| 278 | 278 |
{
|
| 279 | 279 |
vv.add(location, v); |
| 280 | 280 |
|
| 281 |
if( vn!=null ) vn.add(new VectorNoise(3));
|
|
| 281 |
if( vn!=null ) vn.add(new VectorNoise()); |
|
| 282 | 282 |
|
| 283 | 283 |
switch(numPoints) |
| 284 | 284 |
{
|
| 285 | 285 |
case 0: break; |
| 286 | 286 |
case 1: computeOrthonormalBase2(vv.elementAt(0),v); |
| 287 | 287 |
break; |
| 288 |
case 2: vc.add(new VectorCache(3));
|
|
| 289 |
vc.add(new VectorCache(3));
|
|
| 290 |
vc.add(new VectorCache(3));
|
|
| 288 |
case 2: vc.add(new VectorCache()); |
|
| 289 |
vc.add(new VectorCache()); |
|
| 290 |
vc.add(new VectorCache()); |
|
| 291 | 291 |
break; |
| 292 |
default:vc.add(location,new VectorCache(3));
|
|
| 292 |
default:vc.add(location,new VectorCache()); |
|
| 293 | 293 |
} |
| 294 | 294 |
|
| 295 | 295 |
numPoints++; |
| ... | ... | |
| 403 | 403 |
if( vn==null ) |
| 404 | 404 |
{
|
| 405 | 405 |
vn = new Vector<>(); |
| 406 |
for(int i=0; i<numPoints; i++) vn.add(new VectorNoise(mDimension));
|
|
| 406 |
for(int i=0; i<numPoints; i++) vn.add(new VectorNoise()); |
|
| 407 | 407 |
|
| 408 | 408 |
if( mDimension>=2 ) |
| 409 | 409 |
{
|
| ... | ... | |
| 452 | 452 |
break; |
| 453 | 453 |
case 2: curr = vv.elementAt(0); |
| 454 | 454 |
next = vv.elementAt(1); |
| 455 |
|
|
| 455 |
|
|
| 456 |
int segment2= (int)(2*time); |
|
| 457 |
|
|
| 456 | 458 |
if( mMode==MODE_LOOP || mMode==MODE_PATH ) time = (time>0.5f ? 2-2*time : 2*time); |
| 457 |
|
|
| 459 |
|
|
| 458 | 460 |
if( vn!=null ) |
| 459 | 461 |
{
|
| 462 |
if( segment2 != mSegment ) |
|
| 463 |
{
|
|
| 464 |
if(mMode!=MODE_JUMP || mSegment==1) vn.elementAt(0).computeNoise(); |
|
| 465 |
mSegment = segment2; |
|
| 466 |
} |
|
| 467 |
|
|
| 460 | 468 |
time = noise(time,0); |
| 461 | 469 |
|
| 462 | 470 |
buffer[offset ] = (next.x-curr.x)*time + curr.x + (baseV[1][0]*mFactor[0] + baseV[2][0]*mFactor[1]); |
| ... | ... | |
| 472 | 480 |
|
| 473 | 481 |
break; |
| 474 | 482 |
default:float t = time; |
| 475 |
|
|
| 483 |
int vecCurr, segment; |
|
| 484 |
|
|
| 476 | 485 |
switch(mMode) |
| 477 | 486 |
{
|
| 478 | 487 |
case MODE_LOOP: time = time*numPoints; |
| 488 |
segment = (int)time; |
|
| 489 |
vecCurr = segment; |
|
| 479 | 490 |
break; |
| 480 |
case MODE_PATH: time = (time<=0.5f) ? 2*time*(numPoints-1) : 2*(1-time)*(numPoints-1); |
|
| 491 |
case MODE_PATH: segment = (int)(2*t*(numPoints-1)); |
|
| 492 |
|
|
| 493 |
if( t<=0.5f ) |
|
| 494 |
{
|
|
| 495 |
time = 2*t*(numPoints-1); |
|
| 496 |
vecCurr = segment; |
|
| 497 |
} |
|
| 498 |
else |
|
| 499 |
{
|
|
| 500 |
time = 2*(1-t)*(numPoints-1); |
|
| 501 |
vecCurr = 2*numPoints-3-segment; |
|
| 502 |
} |
|
| 481 | 503 |
break; |
| 482 | 504 |
case MODE_JUMP: time = time*(numPoints-1); |
| 505 |
segment = (int)time; |
|
| 506 |
vecCurr = segment; |
|
| 483 | 507 |
break; |
| 508 |
default : vecCurr = 0; |
|
| 509 |
segment = 0; |
|
| 484 | 510 |
} |
| 485 |
|
|
| 486 |
int vecCurr = (int)time; |
|
| 487 |
time = time-vecCurr; |
|
| 488 |
|
|
| 511 |
|
|
| 489 | 512 |
if( vecCurr>=0 && vecCurr<numPoints ) |
| 490 | 513 |
{
|
| 491 |
if( cacheDirty ) recomputeCache(); // recompute cache if we have added or remove vectors since last computation
|
|
| 492 |
else if( mVecCurr!= vecCurr ) // ...or if we have just passed a vector and the vector we are currently flying to has changed
|
|
| 514 |
if( cacheDirty ) recomputeCache(); // recompute cache if we have added or remove vectors since last computation |
|
| 515 |
else if( mSegment!= segment ) // ...or if we have just passed a vector and the vector we are currently flying to has changed
|
|
| 493 | 516 |
{
|
| 494 |
int vecNext; |
|
| 495 |
mVecCurr = vecCurr; |
|
| 496 |
|
|
| 517 |
int vecNext; |
|
| 518 |
|
|
| 497 | 519 |
switch(mMode) |
| 498 | 520 |
{
|
| 499 |
case MODE_LOOP: vecNext = vecCurr==numPoints-1 ? 0:vecCurr+1;
|
|
| 521 |
case MODE_LOOP: vecNext = vecCurr==numPoints-1 ? 0:vecCurr+1; |
|
| 500 | 522 |
break; |
| 501 |
case MODE_PATH: if( t<0.5f ) vecNext = vecCurr==numPoints-1 ? numPoints-2: vecCurr+1;
|
|
| 502 |
else vecNext = vecCurr==0 ? 1 : vecCurr-1;
|
|
| 523 |
case MODE_PATH: if( t<0.5f ) vecNext = vecCurr==numPoints-1 ? numPoints-2: vecCurr+1; |
|
| 524 |
else vecNext = vecCurr==0 ? 1 : vecCurr-1; |
|
| 503 | 525 |
break; |
| 504 | 526 |
case MODE_JUMP: vecNext = vecCurr==numPoints-1 ? 1:vecCurr+1; |
| 505 | 527 |
break; |
| 506 |
default : vecNext = 0;
|
|
| 528 |
default : vecNext = 0; |
|
| 507 | 529 |
} |
| 508 |
|
|
| 530 |
|
|
| 509 | 531 |
next = vv.elementAt(vecNext); |
| 510 | 532 |
tmp2 = vc.elementAt(vecNext); |
| 511 |
|
|
| 512 |
if( tmp2.cached[0]!=next.x || tmp2.cached[1]!=next.y || tmp2.cached[2]!=next.z ) recomputeCache();
|
|
| 533 |
|
|
| 534 |
if( tmp2.cached[0]!=next.x ) recomputeCache(); |
|
| 513 | 535 |
} |
| 536 |
|
|
| 537 |
if( mSegment!= segment && vn!=null ) vn.elementAt(vecCurr).computeNoise(); |
|
| 538 |
|
|
| 539 |
mSegment = segment; |
|
| 540 |
|
|
| 541 |
time = time-vecCurr; |
|
| 514 | 542 |
|
| 515 | 543 |
tmp1 = vc.elementAt(vecCurr); |
| 516 | 544 |
|
| src/main/java/org/distorted/library/type/Dynamic4D.java | ||
|---|---|---|
| 255 | 255 |
{
|
| 256 | 256 |
vv.add(v); |
| 257 | 257 |
|
| 258 |
if( vn!=null ) vn.add(new VectorNoise(4));
|
|
| 258 |
if( vn!=null ) vn.add(new VectorNoise()); |
|
| 259 | 259 |
|
| 260 |
switch(numPoints)
|
|
| 261 |
{
|
|
| 262 |
case 0: break;
|
|
| 263 |
case 1: computeOrthonormalBase2(vv.elementAt(0),v);
|
|
| 264 |
break;
|
|
| 265 |
case 2: vc.add(new VectorCache(4));
|
|
| 266 |
vc.add(new VectorCache(4));
|
|
| 267 |
vc.add(new VectorCache(4));
|
|
| 268 |
break;
|
|
| 269 |
default:vc.add(new VectorCache(4));
|
|
| 270 |
}
|
|
| 271 |
|
|
| 272 |
numPoints++;
|
|
| 273 |
cacheDirty = true;
|
|
| 274 |
}
|
|
| 260 |
switch(numPoints) |
|
| 261 |
{
|
|
| 262 |
case 0: break; |
|
| 263 |
case 1: computeOrthonormalBase2(vv.elementAt(0),v); |
|
| 264 |
break; |
|
| 265 |
case 2: vc.add(new VectorCache());
|
|
| 266 |
vc.add(new VectorCache());
|
|
| 267 |
vc.add(new VectorCache());
|
|
| 268 |
break; |
|
| 269 |
default:vc.add(new VectorCache());
|
|
| 270 |
} |
|
| 271 |
|
|
| 272 |
numPoints++; |
|
| 273 |
cacheDirty = true; |
|
| 274 |
} |
|
| 275 | 275 |
} |
| 276 | 276 |
|
| 277 | 277 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 287 | 287 |
{
|
| 288 | 288 |
vv.add(location, v); |
| 289 | 289 |
|
| 290 |
if( vn!=null ) vn.add(new VectorNoise(4));
|
|
| 290 |
if( vn!=null ) vn.add(new VectorNoise()); |
|
| 291 | 291 |
|
| 292 | 292 |
switch(numPoints) |
| 293 | 293 |
{
|
| 294 | 294 |
case 0: break; |
| 295 | 295 |
case 1: computeOrthonormalBase2(vv.elementAt(0),v); |
| 296 | 296 |
break; |
| 297 |
case 2: vc.add(new VectorCache(4));
|
|
| 298 |
vc.add(new VectorCache(4));
|
|
| 299 |
vc.add(new VectorCache(4));
|
|
| 297 |
case 2: vc.add(new VectorCache()); |
|
| 298 |
vc.add(new VectorCache()); |
|
| 299 |
vc.add(new VectorCache()); |
|
| 300 | 300 |
break; |
| 301 |
default:vc.add(location,new VectorCache(4));
|
|
| 301 |
default:vc.add(location,new VectorCache()); |
|
| 302 | 302 |
} |
| 303 | 303 |
|
| 304 | 304 |
numPoints++; |
| ... | ... | |
| 412 | 412 |
if( vn==null ) |
| 413 | 413 |
{
|
| 414 | 414 |
vn = new Vector<>(); |
| 415 |
for(int i=0; i<numPoints; i++) vn.add(new VectorNoise(mDimension));
|
|
| 415 |
for(int i=0; i<numPoints; i++) vn.add(new VectorNoise()); |
|
| 416 | 416 |
|
| 417 | 417 |
if( mDimension>=2 ) |
| 418 | 418 |
{
|
| ... | ... | |
| 466 | 466 |
break; |
| 467 | 467 |
case 2: curr = vv.elementAt(0); |
| 468 | 468 |
next = vv.elementAt(1); |
| 469 |
|
|
| 469 |
|
|
| 470 |
int segment2= (int)(2*time); |
|
| 471 |
|
|
| 470 | 472 |
if( mMode==MODE_LOOP || mMode==MODE_PATH ) time = (time>0.5f ? 2-2*time : 2*time); |
| 471 |
|
|
| 473 |
|
|
| 472 | 474 |
if( vn!=null ) |
| 473 | 475 |
{
|
| 476 |
if( segment2 != mSegment ) |
|
| 477 |
{
|
|
| 478 |
if(mMode!=MODE_JUMP || mSegment==1) vn.elementAt(0).computeNoise(); |
|
| 479 |
mSegment = segment2; |
|
| 480 |
} |
|
| 481 |
|
|
| 474 | 482 |
time = noise(time,0); |
| 475 | 483 |
|
| 476 | 484 |
buffer[offset ] = (next.x-curr.x)*time + curr.x + (baseV[1][0]*mFactor[0] + baseV[2][0]*mFactor[1] + baseV[3][0]*mFactor[2]); |
| ... | ... | |
| 488 | 496 |
|
| 489 | 497 |
break; |
| 490 | 498 |
default:float t = time; |
| 491 |
|
|
| 499 |
int vecCurr, segment; |
|
| 500 |
|
|
| 492 | 501 |
switch(mMode) |
| 493 | 502 |
{
|
| 494 | 503 |
case MODE_LOOP: time = time*numPoints; |
| 504 |
segment = (int)time; |
|
| 505 |
vecCurr = segment; |
|
| 495 | 506 |
break; |
| 496 |
case MODE_PATH: time = (time<=0.5f) ? 2*time*(numPoints-1) : 2*(1-time)*(numPoints-1); |
|
| 507 |
case MODE_PATH: segment = (int)(2*t*(numPoints-1)); |
|
| 508 |
|
|
| 509 |
if( t<=0.5f ) |
|
| 510 |
{
|
|
| 511 |
time = 2*t*(numPoints-1); |
|
| 512 |
vecCurr = segment; |
|
| 513 |
} |
|
| 514 |
else |
|
| 515 |
{
|
|
| 516 |
time = 2*(1-t)*(numPoints-1); |
|
| 517 |
vecCurr = 2*numPoints-3-segment; |
|
| 518 |
} |
|
| 497 | 519 |
break; |
| 498 | 520 |
case MODE_JUMP: time = time*(numPoints-1); |
| 521 |
segment = (int)time; |
|
| 522 |
vecCurr = segment; |
|
| 499 | 523 |
break; |
| 524 |
default : vecCurr = 0; |
|
| 525 |
segment = 0; |
|
| 500 | 526 |
} |
| 501 |
|
|
| 502 |
int vecCurr = (int)time; |
|
| 503 |
time = time-vecCurr; |
|
| 504 |
|
|
| 527 |
|
|
| 505 | 528 |
if( vecCurr>=0 && vecCurr<numPoints ) |
| 506 | 529 |
{
|
| 507 |
if( cacheDirty ) recomputeCache(); // recompute cache if we have added or remove vectors since last computation
|
|
| 508 |
else if( mVecCurr!= vecCurr ) // ...or if we have just passed a vector and the vector we are currently flying to has changed
|
|
| 530 |
if( cacheDirty ) recomputeCache(); // recompute cache if we have added or remove vectors since last computation |
|
| 531 |
else if( mSegment!= segment ) // ...or if we have just passed a vector and the vector we are currently flying to has changed
|
|
| 509 | 532 |
{
|
| 510 |
int vecNext; |
|
| 511 |
mVecCurr = vecCurr; |
|
| 512 |
|
|
| 533 |
int vecNext; |
|
| 534 |
|
|
| 513 | 535 |
switch(mMode) |
| 514 | 536 |
{
|
| 515 |
case MODE_LOOP: vecNext = vecCurr==numPoints-1 ? 0:vecCurr+1;
|
|
| 537 |
case MODE_LOOP: vecNext = vecCurr==numPoints-1 ? 0:vecCurr+1; |
|
| 516 | 538 |
break; |
| 517 |
case MODE_PATH: if( t<0.5f ) vecNext = vecCurr==numPoints-1 ? numPoints-2: vecCurr+1;
|
|
| 518 |
else vecNext = vecCurr==0 ? 1 : vecCurr-1;
|
|
| 539 |
case MODE_PATH: if( t<0.5f ) vecNext = vecCurr==numPoints-1 ? numPoints-2: vecCurr+1; |
|
| 540 |
else vecNext = vecCurr==0 ? 1 : vecCurr-1; |
|
| 519 | 541 |
break; |
| 520 | 542 |
case MODE_JUMP: vecNext = vecCurr==numPoints-1 ? 1:vecCurr+1; |
| 521 | 543 |
break; |
| 522 |
default : vecNext = 0;
|
|
| 544 |
default : vecNext = 0; |
|
| 523 | 545 |
} |
| 524 |
|
|
| 546 |
|
|
| 525 | 547 |
next = vv.elementAt(vecNext); |
| 526 | 548 |
tmp2 = vc.elementAt(vecNext); |
| 527 |
|
|
| 528 |
if( tmp2.cached[0]!=next.x || tmp2.cached[1]!=next.y || tmp2.cached[2]!=next.z || tmp2.cached[3]!=next.w ) recomputeCache();
|
|
| 549 |
|
|
| 550 |
if( tmp2.cached[0]!=next.x ) recomputeCache(); |
|
| 529 | 551 |
} |
| 552 |
|
|
| 553 |
if( mSegment!= segment && vn!=null ) vn.elementAt(vecCurr).computeNoise(); |
|
| 554 |
|
|
| 555 |
mSegment = segment; |
|
| 556 |
|
|
| 557 |
time = time-vecCurr; |
|
| 530 | 558 |
|
| 531 | 559 |
tmp1 = vc.elementAt(vecCurr); |
| 532 | 560 |
|
| src/main/java/org/distorted/library/type/Dynamic5D.java | ||
|---|---|---|
| 271 | 271 |
{
|
| 272 | 272 |
vv.add(v); |
| 273 | 273 |
|
| 274 |
if( vn!=null ) vn.add(new VectorNoise(5));
|
|
| 274 |
if( vn!=null ) vn.add(new VectorNoise()); |
|
| 275 | 275 |
|
| 276 | 276 |
switch(numPoints) |
| 277 | 277 |
{
|
| 278 | 278 |
case 0: break; |
| 279 | 279 |
case 1: computeOrthonormalBase2(vv.elementAt(0),v); |
| 280 | 280 |
break; |
| 281 |
case 2: vc.add(new VectorCache(5));
|
|
| 282 |
vc.add(new VectorCache(5));
|
|
| 283 |
vc.add(new VectorCache(5));
|
|
| 281 |
case 2: vc.add(new VectorCache()); |
|
| 282 |
vc.add(new VectorCache()); |
|
| 283 |
vc.add(new VectorCache()); |
|
| 284 | 284 |
break; |
| 285 |
default:vc.add(new VectorCache(5));
|
|
| 285 |
default:vc.add(new VectorCache()); |
|
| 286 | 286 |
} |
| 287 | 287 |
|
| 288 | 288 |
numPoints++; |
| ... | ... | |
| 303 | 303 |
{
|
| 304 | 304 |
vv.add(location, v); |
| 305 | 305 |
|
| 306 |
if( vn!=null ) vn.add(new VectorNoise(5));
|
|
| 306 |
if( vn!=null ) vn.add(new VectorNoise()); |
|
| 307 | 307 |
|
| 308 | 308 |
switch(numPoints) |
| 309 | 309 |
{
|
| 310 | 310 |
case 0: break; |
| 311 | 311 |
case 1: computeOrthonormalBase2(vv.elementAt(0),v); |
| 312 | 312 |
break; |
| 313 |
case 2: vc.add(new VectorCache(5));
|
|
| 314 |
vc.add(new VectorCache(5));
|
|
| 315 |
vc.add(new VectorCache(5));
|
|
| 313 |
case 2: vc.add(new VectorCache()); |
|
| 314 |
vc.add(new VectorCache()); |
|
| 315 |
vc.add(new VectorCache()); |
|
| 316 | 316 |
break; |
| 317 |
default:vc.add(location,new VectorCache(5));
|
|
| 317 |
default:vc.add(location,new VectorCache()); |
|
| 318 | 318 |
} |
| 319 | 319 |
|
| 320 | 320 |
numPoints++; |
| ... | ... | |
| 428 | 428 |
if( vn==null ) |
| 429 | 429 |
{
|
| 430 | 430 |
vn = new Vector<>(); |
| 431 |
for(int i=0; i<numPoints; i++) vn.add(new VectorNoise(mDimension));
|
|
| 431 |
for(int i=0; i<numPoints; i++) vn.add(new VectorNoise()); |
|
| 432 | 432 |
|
| 433 | 433 |
if( mDimension>=2 ) |
| 434 | 434 |
{
|
| ... | ... | |
| 487 | 487 |
break; |
| 488 | 488 |
case 2: curr = vv.elementAt(0); |
| 489 | 489 |
next = vv.elementAt(1); |
| 490 |
|
|
| 490 |
|
|
| 491 |
int segment2= (int)(2*time); |
|
| 492 |
|
|
| 491 | 493 |
if( mMode==MODE_LOOP || mMode==MODE_PATH ) time = (time>0.5f ? 2-2*time : 2*time); |
| 492 |
|
|
| 494 |
|
|
| 493 | 495 |
if( vn!=null ) |
| 494 | 496 |
{
|
| 497 |
if( segment2 != mSegment ) |
|
| 498 |
{
|
|
| 499 |
if(mMode!=MODE_JUMP || mSegment==1) vn.elementAt(0).computeNoise(); |
|
| 500 |
mSegment = segment2; |
|
| 501 |
} |
|
| 502 |
|
|
| 495 | 503 |
time = noise(time,0); |
| 496 | 504 |
|
| 497 | 505 |
buffer[offset ] = (next.x-curr.x)*time + curr.x + (baseV[1][0]*mFactor[0] + baseV[2][0]*mFactor[1] + baseV[3][0]*mFactor[2] + baseV[4][0]*mFactor[3]); |
| ... | ... | |
| 511 | 519 |
|
| 512 | 520 |
break; |
| 513 | 521 |
default:float t = time; |
| 514 |
|
|
| 522 |
int vecCurr, segment; |
|
| 523 |
|
|
| 515 | 524 |
switch(mMode) |
| 516 | 525 |
{
|
| 517 | 526 |
case MODE_LOOP: time = time*numPoints; |
| 527 |
segment = (int)time; |
|
| 528 |
vecCurr = segment; |
|
| 518 | 529 |
break; |
| 519 |
case MODE_PATH: time = (time<=0.5f) ? 2*time*(numPoints-1) : 2*(1-time)*(numPoints-1); |
|
| 530 |
case MODE_PATH: segment = (int)(2*t*(numPoints-1)); |
|
| 531 |
|
|
| 532 |
if( t<=0.5f ) |
|
| 533 |
{
|
|
| 534 |
time = 2*t*(numPoints-1); |
|
| 535 |
vecCurr = segment; |
|
| 536 |
} |
|
| 537 |
else |
|
| 538 |
{
|
|
| 539 |
time = 2*(1-t)*(numPoints-1); |
|
| 540 |
vecCurr = 2*numPoints-3-segment; |
|
| 541 |
} |
|
| 520 | 542 |
break; |
| 521 | 543 |
case MODE_JUMP: time = time*(numPoints-1); |
| 544 |
segment = (int)time; |
|
| 545 |
vecCurr = segment; |
|
| 522 | 546 |
break; |
| 547 |
default : vecCurr = 0; |
|
| 548 |
segment = 0; |
|
| 523 | 549 |
} |
| 524 |
|
|
| 525 |
int vecCurr = (int)time; |
|
| 526 |
time = time-vecCurr; |
|
| 527 |
|
|
| 550 |
|
|
| 528 | 551 |
if( vecCurr>=0 && vecCurr<numPoints ) |
| 529 | 552 |
{
|
| 530 |
if( cacheDirty ) recomputeCache(); // recompute cache if we have added or remove vectors since last computation
|
|
| 531 |
else if( mVecCurr!= vecCurr ) // ...or if we have just passed a vector and the vector we are currently flying to has changed
|
|
| 553 |
if( cacheDirty ) recomputeCache(); // recompute cache if we have added or remove vectors since last computation |
|
| 554 |
else if( mSegment!= segment ) // ...or if we have just passed a vector and the vector we are currently flying to has changed
|
|
| 532 | 555 |
{
|
| 533 |
int vecNext; |
|
| 534 |
mVecCurr = vecCurr; |
|
| 535 |
|
|
| 556 |
int vecNext; |
|
| 557 |
|
|
| 536 | 558 |
switch(mMode) |
| 537 | 559 |
{
|
| 538 |
case MODE_LOOP: vecNext = vecCurr==numPoints-1 ? 0:vecCurr+1;
|
|
| 560 |
case MODE_LOOP: vecNext = vecCurr==numPoints-1 ? 0:vecCurr+1; |
|
| 539 | 561 |
break; |
| 540 |
case MODE_PATH: if( t<0.5f ) vecNext = vecCurr==numPoints-1 ? numPoints-2: vecCurr+1;
|
|
| 541 |
else vecNext = vecCurr==0 ? 1 : vecCurr-1;
|
|
| 562 |
case MODE_PATH: if( t<0.5f ) vecNext = vecCurr==numPoints-1 ? numPoints-2: vecCurr+1; |
|
| 563 |
else vecNext = vecCurr==0 ? 1 : vecCurr-1; |
|
| 542 | 564 |
break; |
| 543 | 565 |
case MODE_JUMP: vecNext = vecCurr==numPoints-1 ? 1:vecCurr+1; |
| 544 | 566 |
break; |
| 545 |
default : vecNext = 0;
|
|
| 567 |
default : vecNext = 0; |
|
| 546 | 568 |
} |
| 547 |
|
|
| 569 |
|
|
| 548 | 570 |
next = vv.elementAt(vecNext); |
| 549 | 571 |
tmp2 = vc.elementAt(vecNext); |
| 550 |
|
|
| 551 |
if( tmp2.cached[0]!=next.x || tmp2.cached[1]!=next.y || tmp2.cached[2]!=next.z || tmp2.cached[3]!=next.w || tmp2.cached[4]!=next.v ) recomputeCache();
|
|
| 572 |
|
|
| 573 |
if( tmp2.cached[0]!=next.x ) recomputeCache(); |
|
| 552 | 574 |
} |
| 575 |
|
|
| 576 |
if( mSegment!= segment && vn!=null ) vn.elementAt(vecCurr).computeNoise(); |
|
| 577 |
|
|
| 578 |
mSegment = segment; |
|
| 579 |
|
|
| 580 |
time = time-vecCurr; |
|
| 553 | 581 |
|
| 554 | 582 |
tmp1 = vc.elementAt(vecCurr); |
| 555 | 583 |
|
| src/main/res/raw/main_vertex_shader.glsl | ||
|---|---|---|
| 148 | 148 |
// else if v.z > hH then v.z = (-(1-h)^2 * H^2)/(v.z-(2h-1)H) +H (function satisfying f(+hH)=+hH, f'(+hH)=1, lim f(x) = +H) |
| 149 | 149 |
// else v.z = v.z |
| 150 | 150 |
|
| 151 |
void restrict(inout float v) |
|
| 151 |
void restrictZ(inout float v)
|
|
| 152 | 152 |
{
|
| 153 | 153 |
const float h = 0.7; |
| 154 | 154 |
float signV = 2.0*max(0.0,sign(v))-1.0; |
| ... | ... | |
| 496 | 496 |
else if( vType[i]==WAVE ) wave (3*i,v,n); |
| 497 | 497 |
} |
| 498 | 498 |
|
| 499 |
restrict(v.z);
|
|
| 499 |
restrictZ(v.z);
|
|
| 500 | 500 |
#endif |
| 501 | 501 |
|
| 502 | 502 |
v_Position = v.xyz; |
Also available in: Unified diff
re-generate noise after passing each Point.