Project

General

Profile

« Previous | Next » 

Revision 142c7236

Added by Leszek Koltunski about 5 years ago

Many things.

1) make the Dynamic.setDuration() able to be called AFTER the Dynamic has already been run. (and rename it to 'makeRunNowFor()' )
2) remove the automatic removal of zero Effects from EffectQueues.
3) adjust several Apps to cope with 2)
4) add post-rotation to Rubik (still not finished)

View differences:

src/main/java/org/distorted/library/type/Dynamic.java
154 154
  private static Random mRnd = new Random();
155 155
  private static final int NUM_NOISE = 5; // used iff mNoise>0.0. Number of intermediary points between each pair of adjacent vectors
156 156
                                          // where we randomize noise factors to make the way between the two vectors not so smooth.
157
  private long mTimeLastInterpolated;
158
  private long mTimeWhenSetDuration;
157 159

  
158 160
///////////////////////////////////////////////////////////////////////////////////////////////////
159 161
// hide this from Javadoc
......
179 181
    mLastPos   = -1;
180 182
    mAccessMode= ACCESS_RANDOM;
181 183

  
184
    mTimeLastInterpolated = 0;
185
    mTimeWhenSetDuration  = 0;
186

  
182 187
    baseV      = new float[mDimension][mDimension];
183 188
    buf        = new float[mDimension];
184 189
    old        = new float[mDimension];
......
484 489
        for(int k=0;k<mDimension; k++) baseV[i][k] *= tmp;                //
485 490
        }                                                                 /// End Normalize
486 491
      }
487

  
488
    //printBase("end");
489
    //checkBase();
490
    }
491

  
492
///////////////////////////////////////////////////////////////////////////////////////////////////
493
// internal debugging only!
494

  
495
  public String print()
496
    {
497
    return "duration="+mDuration+" count="+mCount+" Noise[0]="+mNoise[0]+" numVectors="+numPoints+" mMode="+mMode;
498 492
    }
499 493

  
500 494
///////////////////////////////////////////////////////////////////////////////////////////////////
......
552 546
/**
553 547
 * Sets the time it takes to do one full interpolation.
554 548
 * 
555
 * @param duration Time, in milliseconds, it takes to do one full interpolation, i.e. go from the first 
556
 *                 Point to the last and back. 
549
 * @param durationInMilliseconds time it takes to do one full interpolation, i.e. go from the first
550
 *                               Point to the last and back.
557 551
 */
558
  public void setDuration(long duration)
552
  public void makeRunNowFor(long durationInMilliseconds)
559 553
    {
560
    mDuration = duration;
554
    mDuration = durationInMilliseconds;
555
    mTimeWhenSetDuration = mTimeLastInterpolated;
561 556
    }
562 557

  
563 558
///////////////////////////////////////////////////////////////////////////////////////////////////
......
592 587
 */
593 588
  public void get(float[] buffer, int offset, long time)
594 589
    {
590
    mTimeLastInterpolated = time;
591

  
595 592
    if( mDuration<=0.0f )
596 593
      {
597 594
      interpolate(buffer,offset,mCount-(int)mCount);
598 595
      }
599 596
    else
600 597
      {
601
      double pos = (double)time/mDuration;
598
      double pos = (double)(time-mTimeWhenSetDuration)/mDuration;
602 599

  
603 600
      if( pos<=mCount || mCount<=0.0f )
604 601
        {
......
624 621
 */
625 622
  public boolean get(float[] buffer, int offset, long time, long step)
626 623
    {
624
    mTimeLastInterpolated = time;
625
    time -= mTimeWhenSetDuration;
626

  
627 627
    if( mDuration<=0.0f )
628 628
      {
629 629
      interpolate(buffer,offset,mCount-(int)mCount);

Also available in: Unified diff