Revision 1e22c248
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/library/type/Dynamic4D.java | ||
---|---|---|
395 | 395 |
|
396 | 396 |
if( vn!=null ) vn.removeAllElements(); |
397 | 397 |
} |
398 |
|
|
398 |
|
|
399 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
400 |
/** |
|
401 |
* Sets the 'smoothness' of interpolation. |
|
402 |
* <p> |
|
403 |
* When Noise=0 (the default), we interpolate between our Points through the most smooth path possible. |
|
404 |
* Increasing noise makes the Dynamic increasingly deviate from this path, pseudo-randomly speeding |
|
405 |
* up and slowing down, etc. |
|
406 |
* |
|
407 |
* @param noise The noise level. Permitted range: 0 <= noise <= 1. |
|
408 |
*/ |
|
409 |
|
|
410 |
public synchronized void setNoise(Static4D noise) |
|
411 |
{ |
|
412 |
if( vn==null ) |
|
413 |
{ |
|
414 |
vn = new Vector<>(); |
|
415 |
for(int i=0; i<numPoints; i++) vn.add(new VectorNoise(mDimension)); |
|
416 |
|
|
417 |
if( mDimension>=2 ) |
|
418 |
{ |
|
419 |
mFactor = new float[mDimension-1]; |
|
420 |
} |
|
421 |
|
|
422 |
mNoise = new float[mDimension]; |
|
423 |
} |
|
424 |
|
|
425 |
if( noise.x<0.0f ) noise.x = 0.0f; |
|
426 |
if( noise.x>1.0f ) noise.x = 1.0f; |
|
427 |
if( noise.y<0.0f ) noise.y = 0.0f; |
|
428 |
if( noise.y>1.0f ) noise.y = 1.0f; |
|
429 |
if( noise.z<0.0f ) noise.z = 0.0f; |
|
430 |
if( noise.z>1.0f ) noise.z = 1.0f; |
|
431 |
if( noise.w<0.0f ) noise.w = 0.0f; |
|
432 |
if( noise.w>1.0f ) noise.w = 1.0f; |
|
433 |
|
|
434 |
mNoise[0] = noise.x; |
|
435 |
mNoise[1] = noise.y; |
|
436 |
mNoise[2] = noise.z; |
|
437 |
mNoise[3] = noise.w; |
|
438 |
} |
|
439 |
|
|
399 | 440 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
400 | 441 |
/** |
401 | 442 |
* Writes the results of interpolation between the Points at time 'time' to the passed float buffer. |
... | ... | |
435 | 476 |
buffer[offset ] = (next.x-curr.x)*time + curr.x + (baseV[1][0]*mFactor[0] + baseV[2][0]*mFactor[1] + baseV[3][0]*mFactor[2]); |
436 | 477 |
buffer[offset+1] = (next.y-curr.y)*time + curr.y + (baseV[1][1]*mFactor[0] + baseV[2][1]*mFactor[1] + baseV[3][1]*mFactor[2]); |
437 | 478 |
buffer[offset+2] = (next.z-curr.z)*time + curr.z + (baseV[1][2]*mFactor[0] + baseV[2][2]*mFactor[1] + baseV[3][2]*mFactor[2]); |
438 |
buffer[offset+3] = (next.z-curr.z)*time + curr.z + (baseV[1][3]*mFactor[0] + baseV[2][3]*mFactor[1] + baseV[3][3]*mFactor[2]);
|
|
479 |
buffer[offset+3] = (next.w-curr.w)*time + curr.w + (baseV[1][3]*mFactor[0] + baseV[2][3]*mFactor[1] + baseV[3][3]*mFactor[2]);
|
|
439 | 480 |
} |
440 | 481 |
else |
441 | 482 |
{ |
Also available in: Unified diff
Fix 4D and 5D noise, make noise N dimensional.