Revision 1e22c248
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/library/type/Dynamic3D.java | ||
---|---|---|
379 | 379 |
|
380 | 380 |
if( vn!=null ) vn.removeAllElements(); |
381 | 381 |
} |
382 |
|
|
382 |
|
|
383 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
384 |
/** |
|
385 |
* Sets the 'smoothness' of interpolation. |
|
386 |
* <p> |
|
387 |
* When Noise=0 (the default), we interpolate between our Points through the most smooth path possible. |
|
388 |
* Increasing noise makes the Dynamic increasingly deviate from this path, pseudo-randomly speeding |
|
389 |
* up and slowing down, etc. |
|
390 |
* |
|
391 |
* @param noise The noise level. Permitted range: 0 <= noise <= 1. |
|
392 |
*/ |
|
393 |
|
|
394 |
public synchronized void setNoise(Static3D noise) |
|
395 |
{ |
|
396 |
if( vn==null ) |
|
397 |
{ |
|
398 |
vn = new Vector<>(); |
|
399 |
for(int i=0; i<numPoints; i++) vn.add(new VectorNoise(mDimension)); |
|
400 |
|
|
401 |
if( mDimension>=2 ) |
|
402 |
{ |
|
403 |
mFactor = new float[mDimension-1]; |
|
404 |
} |
|
405 |
|
|
406 |
mNoise = new float[mDimension]; |
|
407 |
} |
|
408 |
|
|
409 |
if( noise.x<0.0f ) noise.x = 0.0f; |
|
410 |
if( noise.x>1.0f ) noise.x = 1.0f; |
|
411 |
if( noise.y<0.0f ) noise.y = 0.0f; |
|
412 |
if( noise.y>1.0f ) noise.y = 1.0f; |
|
413 |
if( noise.z<0.0f ) noise.z = 0.0f; |
|
414 |
if( noise.z>1.0f ) noise.z = 1.0f; |
|
415 |
|
|
416 |
mNoise[0] = noise.x; |
|
417 |
mNoise[1] = noise.y; |
|
418 |
mNoise[2] = noise.z; |
|
419 |
} |
|
420 |
|
|
383 | 421 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
384 | 422 |
/** |
385 | 423 |
* Writes the results of interpolation between the Points at time 'time' to the passed float buffer. |
Also available in: Unified diff
Fix 4D and 5D noise, make noise N dimensional.