Project

General

Profile

« Previous | Next » 

Revision 1e22c248

Added by Leszek Koltunski over 7 years ago

Fix 4D and 5D noise, make noise N dimensional.

View differences:

src/main/java/org/distorted/library/type/Dynamic2D.java
360 360
    if( vn!=null ) vn.removeAllElements();
361 361
    }
362 362

  
363
///////////////////////////////////////////////////////////////////////////////////////////////////
364
/**
365
 * Sets the 'smoothness' of interpolation.
366
 * <p>
367
 * When Noise=0 (the default), we interpolate between our Points through the most smooth path possible.
368
 * Increasing noise makes the Dynamic increasingly deviate from this path, pseudo-randomly speeding
369
 * up and slowing down, etc.
370
 *
371
 * @param noise The noise level. Permitted range: 0 <= noise <= 1.
372
 */
373

  
374
  public synchronized void setNoise(Static2D noise)
375
    {
376
    if( vn==null )
377
      {
378
      vn = new Vector<>();
379
      for(int i=0; i<numPoints; i++) vn.add(new VectorNoise(mDimension));
380

  
381
      if( mDimension>=2 )
382
        {
383
        mFactor = new float[mDimension-1];
384
        }
385

  
386
      mNoise = new float[mDimension];
387
      }
388

  
389
    if( noise.x<0.0f ) noise.x = 0.0f;
390
    if( noise.x>1.0f ) noise.x = 1.0f;
391
    if( noise.y<0.0f ) noise.y = 0.0f;
392
    if( noise.y>1.0f ) noise.y = 1.0f;
393

  
394
    mNoise[0] = noise.x;
395
    mNoise[1] = noise.y;
396
    }
397

  
363 398
///////////////////////////////////////////////////////////////////////////////////////////////////
364 399
/**
365 400
 * Writes the results of interpolation between the Points at time 'time' to the passed float buffer.

Also available in: Unified diff