Project

General

Profile

« Previous | Next » 

Revision fc286c71

Added by Leszek Koltunski over 4 years ago

fix for centers of Matrix effects.

View differences:

src/main/java/org/distorted/examples/generic/GenericActivity2.java
198 198

  
199 199
  public int getScreenWidth()
200 200
    {
201
    GenericRenderer r = ((GenericSurfaceView)findViewById(R.id.genericSurfaceView)).getRenderer();
202
    return r.getWidth();
201
    GenericSurfaceView view = findViewById(R.id.genericSurfaceView);
202
    GenericRenderer renderer = view.getRenderer();
203
    return renderer.getWidth();
204
    }
205

  
206
///////////////////////////////////////////////////////////////////////////////////////////////////
207

  
208
  public float getScaleFactor()
209
    {
210
    GenericSurfaceView view = findViewById(R.id.genericSurfaceView);
211
    GenericRenderer renderer = view.getRenderer();
212
    return renderer.getScaleFactor();
203 213
    }
204 214

  
205 215
///////////////////////////////////////////////////////////////////////////////////////////////////
206 216

  
207
  void setCenter(Static3D center)
217
  void setCenter(float x, float y, float z)
208 218
    {
209 219
    GenericSurfaceView view = findViewById(R.id.genericSurfaceView);
210
    view.getRenderer().setCenter( center.get0(), center.get1(), center.get2() );
220
    GenericRenderer renderer = view.getRenderer();
221
    renderer.setCenter(x,y,z);
211 222
    }
212 223

  
213 224
///////////////////////////////////////////////////////////////////////////////////////////////////
......
215 226
  void setRegion(Static4D region)
216 227
    {
217 228
    GenericSurfaceView view = findViewById(R.id.genericSurfaceView);
218
    view.getRenderer().setRegion( region.get0(), region.get1(), region.get2(), region.get3() );
229
    GenericRenderer renderer = view.getRenderer();
230
    renderer.setRegion( region.get0(), region.get1(), region.get2(), region.get3() );
219 231
    }
220 232

  
221 233
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/generic/GenericEffect.java
352 352
    float y = (mInterCenter[1]*0.012f - 0.6f)*act.getHeight();
353 353
    float z = (mInterCenter[2]*0.012f - 0.6f)*act.getDepth();
354 354

  
355
    if( mName.getType() == EffectType.MATRIX )
356
      {
357
      float factor = act.getScaleFactor();
358
      x *= factor;
359
      y *= factor;
360
      z *= factor;
361
      }
362

  
355 363
    mCenterSta.set(x,y,z);
356 364
    }
357 365

  
......
430 438
      }
431 439
    }
432 440

  
441
///////////////////////////////////////////////////////////////////////////////////////////////////
442

  
443
  private void setCenter(GenericActivity2 act)
444
    {
445
    float factor = ( mName.getType() == EffectType.MATRIX ? act.getScaleFactor() : 1.0f);
446
    act.setCenter( mCenterSta.get0()/factor, mCenterSta.get1()/factor, mCenterSta.get2()/factor );
447
    }
448

  
433 449
///////////////////////////////////////////////////////////////////////////////////////////////////
434 450

  
435 451
  void setBackground(int pos)
......
707 723
      seek[i].setProgress( mInterCenter[i] );
708 724
      }
709 725

  
710
    act.setCenter(mCenterSta);
726
    setCenter(act);
711 727

  
712 728
    return mCenter;
713 729
    }
......
768 784
    if( fromUser )
769 785
      {
770 786
      GenericActivity2 act = mAct.get();
771
      act.setCenter(mCenterSta);
787
      setCenter(act);
772 788
      act.setRegion(mRegion4Sta);
773 789
      }
774 790
    }
src/main/java/org/distorted/examples/generic/GenericRenderer.java
203 203
      return mWidth;
204 204
      }
205 205

  
206
///////////////////////////////////////////////////////////////////////////////////////////////////
207

  
208
    float getScaleFactor()
209
      {
210
      return mFactorObj;
211
      }
212

  
206 213
///////////////////////////////////////////////////////////////////////////////////////////////////
207 214

  
208 215
    void setCenter(float x, float y, float z)

Also available in: Unified diff