Revision fe7fe83e
Added by Leszek Koltunski over 7 years ago
| build.gradle | ||
|---|---|---|
| 20 | 20 | dependencies {
 | 
| 21 | 21 |     api project(':distorted-library')
 | 
| 22 | 22 | implementation 'com.android.support:support-v4:27.1.1' | 
| 23 | implementation 'com.android.support:support-v13:27.1.1' | |
| 24 | implementation 'com.android.support:design:27.1.1' | |
| 23 | 25 | } | 
| src/main/java/org/distorted/examples/effects3d/Effects3DActivity.java | ||
|---|---|---|
| 26 | 26 | import android.graphics.Paint; | 
| 27 | 27 | import android.opengl.GLSurfaceView; | 
| 28 | 28 | import android.os.Bundle; | 
| 29 | import android.support.design.widget.TabLayout; | |
| 30 | import android.support.v4.view.ViewPager; | |
| 29 | 31 | import android.view.Gravity; | 
| 30 | 32 | import android.view.View; | 
| 31 | 33 | import android.widget.AdapterView; | 
| ... | ... | |
| 38 | 40 | import android.widget.TableRow; | 
| 39 | 41 |  | 
| 40 | 42 | import org.distorted.examples.R; | 
| 41 | import org.distorted.library.effect.EffectName; | |
| 42 | 43 | import org.distorted.library.effect.EffectType; | 
| 43 | 44 | import org.distorted.library.main.Distorted; | 
| 44 | 45 | import org.distorted.library.main.MeshCubes; | 
| ... | ... | |
| 49 | 50 |  | 
| 50 | 51 | import java.io.IOException; | 
| 51 | 52 | import java.io.InputStream; | 
| 52 | import java.util.ArrayList; | |
| 53 | 53 |  | 
| 54 | 54 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 55 | 55 |  | 
| 56 | 56 | public class Effects3DActivity extends Activity | 
| 57 | implements View.OnClickListener, | |
| 58 | AdapterView.OnItemSelectedListener | |
| 57 | implements View.OnClickListener, AdapterView.OnItemSelectedListener | |
| 59 | 58 |   {
 | 
| 60 | 59 | private static final int COLOR_OFF = 0xffffe81f; | 
| 61 | 60 | private static final int COLOR_ON = 0xff0000ff; | 
| ... | ... | |
| 68 | 67 | private NumberPicker mColsPicker, mRowsPicker, mSlicPicker; | 
| 69 | 68 | private boolean[] mShape; | 
| 70 | 69 | private DistortedTexture mTexture; | 
| 71 | private DistortedEffects mEffects; | |
| 72 | 70 | private MeshObject mMesh; | 
| 73 | 71 | private int mObjectType; | 
| 74 | 72 | private int mBitmapID; | 
| 75 | 73 | private Bitmap mBitmap; | 
| 76 | 74 | private LinearLayout mLay; | 
| 77 | 75 |  | 
| 78 | private ArrayList<Effects3DEffect> mList; | |
| 79 | private int mEffectAdd; | |
| 80 | 76 | private float mCenterX, mCenterY, mCenterZ; | 
| 81 | 77 | private float mRegionX, mRegionY, mRegionR; | 
| 82 |  | |
| 83 | private EffectName[] mEffectNames; | |
| 84 |  | |
| 85 | private static boolean mSupportsRegion; | |
| 86 | private static boolean mSupportsCenter; | |
| 78 | private DistortedEffects mEffects; | |
| 79 | private ViewPager mViewPager; | |
| 80 | private Effects3DTabViewPager mPager; | |
| 87 | 81 |  | 
| 88 | 82 | private static boolean mShowCenter = true; | 
| 89 | 83 | private static boolean mShowRegion = true; | 
| ... | ... | |
| 97 | 91 |     {
 | 
| 98 | 92 | super.onCreate(savedState); | 
| 99 | 93 |  | 
| 100 | mList = new ArrayList<>(); | |
| 101 |  | |
| 102 | createEffectNames(); | |
| 103 |  | |
| 104 | 94 | setContentView(R.layout.objectpickerlayout); | 
| 105 | 95 |  | 
| 106 | 96 | mLay = findViewById(R.id.objectpicker_buttongrid); | 
| ... | ... | |
| 166 | 156 | bitmapSpinner.setAdapter(adapterBitmap); | 
| 167 | 157 | } | 
| 168 | 158 |  | 
| 169 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 170 |  | |
| 171 | private void createEffectNames() | |
| 172 |     {
 | |
| 173 | EffectType type1 = EffectType.FRAGMENT; | |
| 174 | EffectType type2 = EffectType.VERTEX; | |
| 175 |  | |
| 176 | EffectName[] names = EffectName.values(); | |
| 177 |  | |
| 178 | int numEffects=0; | |
| 179 |  | |
| 180 | for(int i=0; i<names.length; i++) | |
| 181 | if( names[i].getType() == type1 || names[i].getType() == type2 ) numEffects++; | |
| 182 |  | |
| 183 | mEffectNames = new EffectName[numEffects]; | |
| 184 |  | |
| 185 | numEffects=0; | |
| 186 |  | |
| 187 | for(int i=0; i<names.length; i++) | |
| 188 | if( names[i].getType() == type1 || names[i].getType() == type2 ) | |
| 189 |         {
 | |
| 190 | mEffectNames[numEffects++] = names[i]; | |
| 191 | } | |
| 192 | } | |
| 193 |  | |
| 194 | 159 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 195 | 160 |  | 
| 196 | 161 | private void setGrid() | 
| ... | ... | |
| 247 | 212 | return mTexture; | 
| 248 | 213 | } | 
| 249 | 214 |  | 
| 250 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 251 |  | |
| 252 | public DistortedEffects getEffects() | |
| 253 |     {
 | |
| 254 | return mEffects; | |
| 255 | } | |
| 256 |  | |
| 257 | 215 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 258 | 216 |  | 
| 259 | 217 | public MeshObject getMesh() | 
| ... | ... | |
| 261 | 219 | return mMesh; | 
| 262 | 220 | } | 
| 263 | 221 |  | 
| 264 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 265 |  | |
| 266 | public void setSupportsRegion(boolean supports) | |
| 267 |     {
 | |
| 268 | mSupportsRegion = supports; | |
| 269 | } | |
| 270 |  | |
| 271 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 272 |  | |
| 273 | public void setSupportsCenter(boolean supports) | |
| 274 |     {
 | |
| 275 | mSupportsCenter = supports; | |
| 276 | } | |
| 277 |  | |
| 278 | 222 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 279 | 223 |  | 
| 280 | 224 | public Bitmap getBitmap() | 
| ... | ... | |
| 443 | 387 | } | 
| 444 | 388 |  | 
| 445 | 389 | mMesh.setShowNormals(mShowNormal); | 
| 446 |  | |
| 447 | mEffects= new DistortedEffects(); | |
| 448 | 390 | mTexture= new DistortedTexture(mNumCols,mNumRows); | 
| 391 | mEffects= new DistortedEffects(); | |
| 449 | 392 |  | 
| 450 | 393 | final View view = getLayoutInflater().inflate(R.layout.effects3dlayout, null); | 
| 451 | 394 |  | 
| 452 | 395 | setContentView(view); | 
| 453 | 396 |  | 
| 454 | String[] effects = new String[mEffectNames.length]; | |
| 455 |  | |
| 456 | for(int i=0; i<mEffectNames.length; i++) effects[i] = mEffectNames[i].name(); | |
| 457 |  | |
| 458 | Spinner effectSpinner = findViewById(R.id.effects3dspinner ); | |
| 459 | effectSpinner.setOnItemSelectedListener(this); | |
| 460 |  | |
| 461 | ArrayAdapter<String> adapterEffect = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, effects); | |
| 462 | adapterEffect.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); | |
| 463 | effectSpinner.setAdapter(adapterEffect); | |
| 397 | mViewPager = findViewById(R.id.effects3d_viewpager); | |
| 398 | mPager = new Effects3DTabViewPager(this, getFragmentManager() ); | |
| 399 | mViewPager.setAdapter(mPager); | |
| 400 | TabLayout tabLayout = findViewById(R.id.effects3d_sliding_tabs); | |
| 401 | tabLayout.setupWithViewPager(mViewPager); | |
| 464 | 402 |  | 
| 465 | 403 | resetData(); | 
| 466 |  | |
| 467 | mEffectAdd = 0; | |
| 468 | 404 | } | 
| 469 | 405 |  | 
| 470 | 406 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| ... | ... | |
| 490 | 426 | case 6: mBitmapID = R.raw.monalisa; break; | 
| 491 | 427 | } | 
| 492 | 428 | break; | 
| 493 | case R.id.effects3dspinner : mEffectAdd = pos; | |
| 494 | break; | |
| 495 | 429 | } | 
| 496 | 430 | } | 
| 497 | 431 |  | 
| ... | ... | |
| 531 | 465 |  | 
| 532 | 466 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 533 | 467 |  | 
| 534 |   private void resetData()
 | |
| 468 | void resetData() | |
| 535 | 469 |     {
 | 
| 536 | 470 | mCenterX = 0.5f*getWidth(); | 
| 537 | 471 | mCenterY = 0.5f*getHeight(); | 
| ... | ... | |
| 539 | 473 | mRegionY = 0; | 
| 540 | 474 | mRegionR = getWidth()/2; | 
| 541 | 475 |  | 
| 542 | mSupportsRegion =false; | |
| 543 | mSupportsCenter =false; | |
| 544 |  | |
| 545 | 476 | Effects3DSurfaceView view = findViewById(R.id.effects3dSurfaceView); | 
| 546 | view.getRenderer().showRegionAndCenter(false,false); | |
| 477 | Effects3DRenderer renderer= view.getRenderer(); | |
| 478 |  | |
| 479 | renderer.setCenter( mCenterX, mCenterY, mCenterZ ); | |
| 480 | renderer.setRegion( mRegionX, mRegionY, mRegionR ); | |
| 481 | renderer.mQuat1.set(0,0,0,1); | |
| 482 | renderer.mQuat2.set(0,0,0,1); | |
| 547 | 483 | } | 
| 548 | 484 |  | 
| 549 | 485 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 550 | 486 | // 'second screen' methods | 
| 487 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 551 | 488 |  | 
| 552 |   public void newEffect(View v)
 | |
| 489 |   public DistortedEffects getEffects()
 | |
| 553 | 490 |     {
 | 
| 554 | Effects3DEffect eff = new Effects3DEffect(mEffectNames[mEffectAdd], this); | |
| 555 | mList.add(eff); | |
| 556 |  | |
| 557 | LinearLayout layout = findViewById(R.id.effects3dlayout); | |
| 558 | View view = eff.createView(); | |
| 559 | layout.addView(view); | |
| 560 |  | |
| 561 | if( mSupportsCenter ) | |
| 562 |       {
 | |
| 563 | View center = eff.createCenter(); | |
| 564 | layout.addView(center); | |
| 565 | } | |
| 566 |  | |
| 567 | if( mSupportsRegion ) | |
| 568 |       {
 | |
| 569 | View region = eff.createRegion(); | |
| 570 | layout.addView(region); | |
| 571 | } | |
| 491 | return mEffects; | |
| 492 | } | |
| 572 | 493 |  | 
| 573 |     eff.apply(mEffects);
 | |
| 494 | ///////////////////////////////////////////////////////////////////////////////////////////////////
 | |
| 574 | 495 |  | 
| 575 |     boolean show = (mEffectNames[mEffectAdd].getType()==EffectType.VERTEX);
 | |
| 576 |     Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView);
 | |
| 577 |     sv.getRenderer().showRegionAndCenter( (show && mShowRegion) , (show && mShowCenter) );
 | |
| 496 |   public void newEffect(View v)
 | |
| 497 |     {
 | |
| 498 |     mPager.newEffect(v,mViewPager.getCurrentItem());
 | |
| 578 | 499 | } | 
| 579 | 500 |  | 
| 580 | 501 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 581 | 502 |  | 
| 582 | 503 | public void removeAll(View v) | 
| 583 | 504 |     {
 | 
| 584 | mList.clear(); | |
| 585 | LinearLayout layout = findViewById(R.id.effects3dlayout); | |
| 586 | layout.removeAllViews(); | |
| 587 | mEffects.abortByType(EffectType.VERTEX); | |
| 588 | mEffects.abortByType(EffectType.FRAGMENT); | |
| 589 |  | |
| 590 | resetData(); | |
| 591 |  | |
| 592 | Effects3DSurfaceView view = findViewById(R.id.effects3dSurfaceView); | |
| 593 | Effects3DRenderer renderer= view.getRenderer(); | |
| 594 |  | |
| 595 | renderer.setCenter( mCenterX, mCenterY, mCenterZ ); | |
| 596 | renderer.setRegion( mRegionX, mRegionY, mRegionR ); | |
| 597 | renderer.mQuat1.set(0,0,0,1); | |
| 598 | renderer.mQuat2.set(0,0,0,1); | |
| 505 | mPager.removeAll(v,mViewPager.getCurrentItem()); | |
| 599 | 506 | } | 
| 600 | 507 |  | 
| 601 | 508 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 602 | 509 |  | 
| 603 | 510 | public void remove(View v) | 
| 604 | 511 |     {
 | 
| 605 | for(Effects3DEffect effect: mList) | |
| 606 |       {
 | |
| 607 | if( effect.thisView(v) ) | |
| 608 |         {
 | |
| 609 | LinearLayout layout = findViewById(R.id.effects3dlayout); | |
| 610 | View view; | |
| 611 |  | |
| 612 | view = effect.getEffect(); | |
| 613 | if( view!=null ) layout.removeView(view); | |
| 614 | view = effect.getCenter(); | |
| 615 | if( view!=null ) layout.removeView(view); | |
| 616 | view = effect.getRegion(); | |
| 617 | if( view!=null ) layout.removeView(view); | |
| 618 |  | |
| 619 | mEffects.abortById(effect.getId()); | |
| 620 | mList.remove(effect); | |
| 621 |  | |
| 622 | resetData(); | |
| 623 |  | |
| 624 | break; | |
| 625 | } | |
| 626 | } | |
| 512 | mPager.remove(v,mViewPager.getCurrentItem()); | |
| 627 | 513 | } | 
| 628 | 514 |  | 
| 629 | 515 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 630 | 516 |  | 
| 631 |     boolean getShowCenter()
 | |
| 632 |       {
 | |
| 633 |       return mShowCenter;
 | |
| 634 |       }
 | |
| 517 | boolean getShowCenter() | |
| 518 |     {
 | |
| 519 | return mShowCenter; | |
| 520 | } | |
| 635 | 521 |  | 
| 636 | 522 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 637 | 523 |  | 
| 638 |     boolean getShowRegion()
 | |
| 639 |       {
 | |
| 640 |       return mShowRegion;
 | |
| 641 |       }
 | |
| 524 | boolean getShowRegion() | |
| 525 |     {
 | |
| 526 | return mShowRegion; | |
| 527 | } | |
| 642 | 528 |  | 
| 643 | 529 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 644 | 530 |  | 
| 645 |     public void showCenter(View view)
 | |
| 646 |       {
 | |
| 647 |       CheckBox box = (CheckBox)view;
 | |
| 648 |       mShowCenter = box.isChecked();
 | |
| 531 | public void showCenter(View view) | |
| 532 |     {
 | |
| 533 | CheckBox box = (CheckBox)view; | |
| 534 | mShowCenter = box.isChecked(); | |
| 649 | 535 |  | 
| 650 |       Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView);
 | |
| 651 |       sv.getRenderer().showRegionAndCenter(mShowRegion,mShowCenter);
 | |
| 652 |       }
 | |
| 536 | Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView); | |
| 537 | sv.getRenderer().showRegionAndCenter(mShowRegion,mShowCenter); | |
| 538 | } | |
| 653 | 539 |  | 
| 654 | 540 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 655 | 541 |  | 
| 656 |     public void showRegion(View view)
 | |
| 657 |       {
 | |
| 658 |       CheckBox box = (CheckBox)view;
 | |
| 659 |       mShowRegion = box.isChecked();
 | |
| 542 | public void showRegion(View view) | |
| 543 |     {
 | |
| 544 | CheckBox box = (CheckBox)view; | |
| 545 | mShowRegion = box.isChecked(); | |
| 660 | 546 |  | 
| 661 |       Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView);
 | |
| 662 |       sv.getRenderer().showRegionAndCenter(mShowRegion,mShowCenter);
 | |
| 663 |       }
 | |
| 547 | Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView); | |
| 548 | sv.getRenderer().showRegionAndCenter(mShowRegion,mShowCenter); | |
| 549 | } | |
| 664 | 550 |  | 
| 665 | 551 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 666 | 552 |  | 
| 667 |     public void showNormal(View view)
 | |
| 668 |       {
 | |
| 669 |       CheckBox box = (CheckBox)view;
 | |
| 670 |       mShowNormal = box.isChecked();
 | |
| 553 | public void showNormal(View view) | |
| 554 |     {
 | |
| 555 | CheckBox box = (CheckBox)view; | |
| 556 | mShowNormal = box.isChecked(); | |
| 671 | 557 |  | 
| 672 | if ( mMesh!=null ) | |
| 673 |         {
 | |
| 674 | mMesh.setShowNormals(mShowNormal); | |
| 675 | } | |
| 558 | if ( mMesh!=null ) | |
| 559 |       {
 | |
| 560 | mMesh.setShowNormals(mShowNormal); | |
| 676 | 561 | } | 
| 562 | } | |
| 677 | 563 |  | 
| 678 | 564 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 679 | 565 |  | 
| 680 |     public void triggerOIT(View view)
 | |
| 681 |       {
 | |
| 682 |       CheckBox box = (CheckBox)view;
 | |
| 683 |       mUseOIT = box.isChecked();
 | |
| 566 | public void triggerOIT(View view) | |
| 567 |     {
 | |
| 568 | CheckBox box = (CheckBox)view; | |
| 569 | mUseOIT = box.isChecked(); | |
| 684 | 570 |  | 
| 685 |       Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView);
 | |
| 686 |       sv.getRenderer().useOIT(mUseOIT);
 | |
| 687 |       }
 | |
| 571 | Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView); | |
| 572 | sv.getRenderer().useOIT(mUseOIT); | |
| 573 | } | |
| 688 | 574 |  | 
| 689 | 575 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 690 | 576 | // Overrides | 
| 577 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 691 | 578 |  | 
| 692 | 579 | @Override | 
| 693 | 580 | protected void onPause() | 
| src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java | ||
|---|---|---|
| 444 | 444 | switch(mDimension) | 
| 445 | 445 |       {
 | 
| 446 | 446 | case 1 : mEffect = act.getLayoutInflater().inflate(R.layout.effect1d, null); | 
| 447 |                mText      = (TextView)mEffect.findViewById(R.id.effect1dText);
 | |
| 448 |                seek[0]    = (SeekBar)mEffect.findViewById(R.id.effect1dbar1);
 | |
| 447 | mText = mEffect.findViewById(R.id.effect1dText); | |
| 448 | seek[0] = mEffect.findViewById(R.id.effect1dbar1); | |
| 449 | 449 | mSeekID[0] = seek[0].getId(); | 
| 450 | 450 | mButton = mEffect.findViewById(R.id.button1dRemove); | 
| 451 | 451 | break; | 
| 452 | 452 | case 2 : mEffect = act.getLayoutInflater().inflate(R.layout.effect2d, null); | 
| 453 |                mText      = (TextView)mEffect.findViewById(R.id.effect2dText);
 | |
| 454 |                seek[0]    = (SeekBar)mEffect.findViewById(R.id.effect2dbar1);
 | |
| 455 |                seek[1]    = (SeekBar)mEffect.findViewById(R.id.effect2dbar2);
 | |
| 453 | mText = mEffect.findViewById(R.id.effect2dText); | |
| 454 | seek[0] = mEffect.findViewById(R.id.effect2dbar1); | |
| 455 | seek[1] = mEffect.findViewById(R.id.effect2dbar2); | |
| 456 | 456 | mSeekID[0] = seek[0].getId(); | 
| 457 | 457 | mSeekID[1] = seek[1].getId(); | 
| 458 | 458 | mButton = mEffect.findViewById(R.id.button2dRemove); | 
| 459 | 459 | break; | 
| 460 | 460 | case 3 : mEffect = act.getLayoutInflater().inflate(R.layout.effect3d, null); | 
| 461 |                mText      = (TextView)mEffect.findViewById(R.id.effect3dText);
 | |
| 462 |                seek[0]    = (SeekBar)mEffect.findViewById(R.id.effect3dbar1);
 | |
| 463 |                seek[1]    = (SeekBar)mEffect.findViewById(R.id.effect3dbar2);
 | |
| 464 |                seek[2]    = (SeekBar)mEffect.findViewById(R.id.effect3dbar3);
 | |
| 461 | mText = mEffect.findViewById(R.id.effect3dText); | |
| 462 | seek[0] = mEffect.findViewById(R.id.effect3dbar1); | |
| 463 | seek[1] = mEffect.findViewById(R.id.effect3dbar2); | |
| 464 | seek[2] = mEffect.findViewById(R.id.effect3dbar3); | |
| 465 | 465 | mSeekID[0] = seek[0].getId(); | 
| 466 | 466 | mSeekID[1] = seek[1].getId(); | 
| 467 | 467 | mSeekID[2] = seek[2].getId(); | 
| 468 | 468 | mButton = mEffect.findViewById(R.id.button3dRemove); | 
| 469 | 469 | break; | 
| 470 | 470 | case 4 : mEffect = act.getLayoutInflater().inflate(R.layout.effect4d, null); | 
| 471 |                mText      = (TextView)mEffect.findViewById(R.id.effect4dText);
 | |
| 472 |                seek[0]    = (SeekBar)mEffect.findViewById(R.id.effect4dbar1);
 | |
| 473 |                seek[1]    = (SeekBar)mEffect.findViewById(R.id.effect4dbar2);
 | |
| 474 |                seek[2]    = (SeekBar)mEffect.findViewById(R.id.effect4dbar3);
 | |
| 475 |                seek[3]    = (SeekBar)mEffect.findViewById(R.id.effect4dbar4);
 | |
| 471 | mText = mEffect.findViewById(R.id.effect4dText); | |
| 472 | seek[0] = mEffect.findViewById(R.id.effect4dbar1); | |
| 473 | seek[1] = mEffect.findViewById(R.id.effect4dbar2); | |
| 474 | seek[2] = mEffect.findViewById(R.id.effect4dbar3); | |
| 475 | seek[3] = mEffect.findViewById(R.id.effect4dbar4); | |
| 476 | 476 | mSeekID[0] = seek[0].getId(); | 
| 477 | 477 | mSeekID[1] = seek[1].getId(); | 
| 478 | 478 | mSeekID[2] = seek[2].getId(); | 
| ... | ... | |
| 480 | 480 | mButton = mEffect.findViewById(R.id.button4dRemove); | 
| 481 | 481 | break; | 
| 482 | 482 | case 5 : mEffect = act.getLayoutInflater().inflate(R.layout.effect5d, null); | 
| 483 |                mText      = (TextView)mEffect.findViewById(R.id.effect5dText);
 | |
| 484 |                seek[0]    = (SeekBar)mEffect.findViewById(R.id.effect5dbar1);
 | |
| 485 |                seek[1]    = (SeekBar)mEffect.findViewById(R.id.effect5dbar2);
 | |
| 486 |                seek[2]    = (SeekBar)mEffect.findViewById(R.id.effect5dbar3);
 | |
| 487 |                seek[3]    = (SeekBar)mEffect.findViewById(R.id.effect5dbar4);
 | |
| 488 |                seek[4]    = (SeekBar)mEffect.findViewById(R.id.effect5dbar5);
 | |
| 483 | mText = mEffect.findViewById(R.id.effect5dText); | |
| 484 | seek[0] = mEffect.findViewById(R.id.effect5dbar1); | |
| 485 | seek[1] = mEffect.findViewById(R.id.effect5dbar2); | |
| 486 | seek[2] = mEffect.findViewById(R.id.effect5dbar3); | |
| 487 | seek[3] = mEffect.findViewById(R.id.effect5dbar4); | |
| 488 | seek[4] = mEffect.findViewById(R.id.effect5dbar5); | |
| 489 | 489 | mSeekID[0] = seek[0].getId(); | 
| 490 | 490 | mSeekID[1] = seek[1].getId(); | 
| 491 | 491 | mSeekID[2] = seek[2].getId(); | 
| ... | ... | |
| 505 | 505 | seek[i].setProgress( mInter[i] ); | 
| 506 | 506 | } | 
| 507 | 507 |  | 
| 508 | act.setSupportsCenter(mName.supportsCenter()); | |
| 509 | act.setSupportsRegion(mName.supportsRegion()); | |
| 510 |  | |
| 511 | 508 | return mEffect; | 
| 512 | 509 | } | 
| 513 | 510 |  | 
| ... | ... | |
| 521 | 518 |  | 
| 522 | 519 | SeekBar[] seek = new SeekBar[4]; | 
| 523 | 520 |  | 
| 524 |     seek[0] = (SeekBar)mRegion.findViewById(R.id.effectRegionBarX );
 | |
| 525 |     seek[1] = (SeekBar)mRegion.findViewById(R.id.effectRegionBarY );
 | |
| 526 |     seek[2] = (SeekBar)mRegion.findViewById(R.id.effectRegionBarRX);
 | |
| 527 |     seek[3] = (SeekBar)mRegion.findViewById(R.id.effectRegionBarRY);
 | |
| 521 | seek[0] = mRegion.findViewById(R.id.effectRegionBarX ); | |
| 522 | seek[1] = mRegion.findViewById(R.id.effectRegionBarY ); | |
| 523 | seek[2] = mRegion.findViewById(R.id.effectRegionBarRX); | |
| 524 | seek[3] = mRegion.findViewById(R.id.effectRegionBarRY); | |
| 528 | 525 |  | 
| 529 | 526 | mSeekRegionID[0] = seek[0].getId(); | 
| 530 | 527 | mSeekRegionID[1] = seek[1].getId(); | 
| 531 | 528 | mSeekRegionID[2] = seek[2].getId(); | 
| 532 | 529 | mSeekRegionID[3] = seek[3].getId(); | 
| 533 | 530 |  | 
| 534 |     mTextRegion = (TextView)mRegion.findViewById(R.id.effectRegionText);
 | |
| 531 | mTextRegion = mRegion.findViewById(R.id.effectRegionText); | |
| 535 | 532 |  | 
| 536 | 533 | setDefaultRegionInter(); | 
| 537 | 534 |  | 
| ... | ... | |
| 556 | 553 |  | 
| 557 | 554 | SeekBar[] seek = new SeekBar[3]; | 
| 558 | 555 |  | 
| 559 |     seek[0] = (SeekBar)mCenter.findViewById(R.id.effectCenterBarX );
 | |
| 560 |     seek[1] = (SeekBar)mCenter.findViewById(R.id.effectCenterBarY );
 | |
| 561 |     seek[2] = (SeekBar)mCenter.findViewById(R.id.effectCenterBarZ );
 | |
| 556 | seek[0] = mCenter.findViewById(R.id.effectCenterBarX ); | |
| 557 | seek[1] = mCenter.findViewById(R.id.effectCenterBarY ); | |
| 558 | seek[2] = mCenter.findViewById(R.id.effectCenterBarZ ); | |
| 562 | 559 |  | 
| 563 | 560 | mSeekCenterID[0] = seek[0].getId(); | 
| 564 | 561 | mSeekCenterID[1] = seek[1].getId(); | 
| 565 | 562 | mSeekCenterID[2] = seek[2].getId(); | 
| 566 | 563 |  | 
| 567 |     mTextCenter = (TextView)mCenter.findViewById(R.id.effectCenterText);
 | |
| 564 | mTextCenter = mCenter.findViewById(R.id.effectCenterText); | |
| 568 | 565 |  | 
| 569 | 566 | setDefaultCenterInter(); | 
| 570 | 567 |  | 
| ... | ... | |
| 666 | 663 | boolean showR= (show && act.getShowRegion()); | 
| 667 | 664 | boolean showC= (show && act.getShowCenter()); | 
| 668 | 665 |  | 
| 669 |       Effects3DSurfaceView view = (Effects3DSurfaceView)act.findViewById(R.id.effects3dSurfaceView);
 | |
| 666 | Effects3DSurfaceView view = act.findViewById(R.id.effects3dSurfaceView); | |
| 670 | 667 | view.getRenderer().showRegionAndCenter( showR,showC ); | 
| 671 | 668 |  | 
| 672 | act.setSupportsCenter(mName.supportsCenter()); | |
| 673 | act.setSupportsRegion(mName.supportsRegion()); | |
| 674 | 669 | act.setCenter(mCenterSta.get1(),mCenterSta.get2(),mCenterSta.get3()); | 
| 675 | 670 | act.setRegion(mRegionSta.get1(),mRegionSta.get2(),mRegionSta.get3()); | 
| 676 | 671 | } | 
| src/main/java/org/distorted/examples/effects3d/Effects3DTab.java | ||
|---|---|---|
| 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 2 | // Copyright 2018 Leszek Koltunski // | |
| 3 | // // | |
| 4 | // This file is part of Distorted. // | |
| 5 | // // | |
| 6 | // Distorted is free software: you can redistribute it and/or modify // | |
| 7 | // it under the terms of the GNU General Public License as published by // | |
| 8 | // the Free Software Foundation, either version 2 of the License, or // | |
| 9 | // (at your option) any later version. // | |
| 10 | // // | |
| 11 | // Distorted is distributed in the hope that it will be useful, // | |
| 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // | |
| 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // | |
| 14 | // GNU General Public License for more details. // | |
| 15 | // // | |
| 16 | // You should have received a copy of the GNU General Public License // | |
| 17 | // along with Distorted. If not, see <http://www.gnu.org/licenses/>. // | |
| 18 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 19 |  | |
| 20 | package org.distorted.examples.effects3d; | |
| 21 |  | |
| 22 | import android.os.Bundle; | |
| 23 | import android.app.Fragment; | |
| 24 | import android.view.LayoutInflater; | |
| 25 | import android.view.View; | |
| 26 | import android.view.ViewGroup; | |
| 27 | import android.widget.AdapterView; | |
| 28 | import android.widget.ArrayAdapter; | |
| 29 | import android.widget.LinearLayout; | |
| 30 | import android.widget.Spinner; | |
| 31 |  | |
| 32 | import org.distorted.examples.R; | |
| 33 | import org.distorted.library.effect.EffectName; | |
| 34 | import org.distorted.library.effect.EffectType; | |
| 35 | import org.distorted.library.main.DistortedEffects; | |
| 36 |  | |
| 37 | import java.util.ArrayList; | |
| 38 | import java.lang.ref.WeakReference; | |
| 39 |  | |
| 40 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 41 |  | |
| 42 | public class Effects3DTab extends Fragment implements AdapterView.OnItemSelectedListener | |
| 43 |   {
 | |
| 44 | private WeakReference<Effects3DActivity> mAct; | |
| 45 | private EffectType mType; | |
| 46 | private ArrayList<Effects3DEffect> mList; | |
| 47 | private int mEffectAdd; | |
| 48 | private EffectName[] mEffectNames; | |
| 49 | private DistortedEffects mEffects; | |
| 50 | private String[] mEffectStrings; | |
| 51 | private int mTab, mLayout, mSpinner; | |
| 52 |  | |
| 53 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 54 |  | |
| 55 | public Effects3DTab() | |
| 56 |     {
 | |
| 57 | mList = new ArrayList<>(); | |
| 58 | mEffectAdd = 0; | |
| 59 | } | |
| 60 |  | |
| 61 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 62 |  | |
| 63 | void setParams(EffectType type, WeakReference<Effects3DActivity> act, int tab, int layout, int spinner) | |
| 64 |     {
 | |
| 65 | mTab = tab; | |
| 66 | mLayout = layout; | |
| 67 | mSpinner = spinner; | |
| 68 | mType = type; | |
| 69 | mAct = act; | |
| 70 | mEffects = act.get().getEffects(); | |
| 71 |  | |
| 72 |     android.util.Log.e("tab", "setparams: "+type.name() );
 | |
| 73 |  | |
| 74 | createEffectNames(mType); | |
| 75 | mEffectStrings = new String[mEffectNames.length]; | |
| 76 |  | |
| 77 | for (int i = 0; i < mEffectNames.length; i++) | |
| 78 |       {
 | |
| 79 | mEffectStrings[i] = mEffectNames[i].name(); | |
| 80 |  | |
| 81 |       android.util.Log.d("tab", "  effect: "+mEffectStrings[i]);
 | |
| 82 | } | |
| 83 | } | |
| 84 |  | |
| 85 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 86 |  | |
| 87 | @Override | |
| 88 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) | |
| 89 |     {
 | |
| 90 | View rootView = inflater.inflate( mTab, container, false); | |
| 91 | return rootView; | |
| 92 | } | |
| 93 |  | |
| 94 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 95 |  | |
| 96 | @Override | |
| 97 | public void onStart() | |
| 98 |     {
 | |
| 99 | super.onStart(); | |
| 100 |  | |
| 101 |     android.util.Log.e("tab", "onStart, type="+mType.name());
 | |
| 102 |  | |
| 103 | Effects3DActivity act = mAct.get(); | |
| 104 |  | |
| 105 | ArrayAdapter<String> adapterEffect = new ArrayAdapter<>( act, android.R.layout.simple_spinner_item, mEffectStrings); | |
| 106 | adapterEffect.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); | |
| 107 |  | |
| 108 | Spinner effectSpinner = act.findViewById(mSpinner); | |
| 109 | effectSpinner.setOnItemSelectedListener(this); | |
| 110 | effectSpinner.setAdapter(adapterEffect); | |
| 111 |  | |
| 112 | resetData(); | |
| 113 | } | |
| 114 |  | |
| 115 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 116 |  | |
| 117 | public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) | |
| 118 |     {
 | |
| 119 | if( parent.getId() == mSpinner ) | |
| 120 |       {
 | |
| 121 | mEffectAdd = pos; | |
| 122 | } | |
| 123 | } | |
| 124 |  | |
| 125 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 126 |  | |
| 127 | public void onNothingSelected(AdapterView<?> parent) | |
| 128 |     {
 | |
| 129 | } | |
| 130 |  | |
| 131 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 132 |  | |
| 133 | private void resetData() | |
| 134 |     {
 | |
| 135 | Effects3DSurfaceView view = mAct.get().findViewById(R.id.effects3dSurfaceView); | |
| 136 | view.getRenderer().showRegionAndCenter(false,false); | |
| 137 | } | |
| 138 |  | |
| 139 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 140 |  | |
| 141 | void newEffect() | |
| 142 |     {
 | |
| 143 | Effects3DEffect eff = new Effects3DEffect(mEffectNames[mEffectAdd], mAct.get() ); | |
| 144 | mList.add(eff); | |
| 145 |  | |
| 146 | LinearLayout layout = mAct.get().findViewById(mLayout); | |
| 147 | View view = eff.createView(); | |
| 148 | layout.addView(view); | |
| 149 |  | |
| 150 | if( mEffectNames[mEffectAdd].supportsCenter() ) | |
| 151 |       {
 | |
| 152 | View center = eff.createCenter(); | |
| 153 | layout.addView(center); | |
| 154 | } | |
| 155 |  | |
| 156 | if( mEffectNames[mEffectAdd].supportsRegion() ) | |
| 157 |       {
 | |
| 158 | View region = eff.createRegion(); | |
| 159 | layout.addView(region); | |
| 160 | } | |
| 161 |  | |
| 162 | eff.apply(mEffects); | |
| 163 |  | |
| 164 | Effects3DActivity act = mAct.get(); | |
| 165 | boolean region = act.getShowRegion(); | |
| 166 | boolean center = act.getShowCenter(); | |
| 167 |  | |
| 168 | boolean show = (mEffectNames[mEffectAdd].getType()==EffectType.VERTEX); | |
| 169 | Effects3DSurfaceView sv = act.findViewById(R.id.effects3dSurfaceView); | |
| 170 | sv.getRenderer().showRegionAndCenter( (show && region) , (show && center) ); | |
| 171 | } | |
| 172 |  | |
| 173 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 174 |  | |
| 175 | private void createEffectNames(EffectType type) | |
| 176 |     {
 | |
| 177 | EffectName[] names = EffectName.values(); | |
| 178 |  | |
| 179 | int numEffects=0; | |
| 180 |  | |
| 181 | for(int i=0; i<names.length; i++) | |
| 182 | if( names[i].getType() == type ) numEffects++; | |
| 183 |  | |
| 184 | mEffectNames = new EffectName[numEffects]; | |
| 185 |  | |
| 186 | numEffects=0; | |
| 187 |  | |
| 188 | for(int i=0; i<names.length; i++) | |
| 189 | if( names[i].getType() == type ) | |
| 190 |         {
 | |
| 191 | mEffectNames[numEffects++] = names[i]; | |
| 192 | } | |
| 193 | } | |
| 194 |  | |
| 195 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 196 |  | |
| 197 | void removeAll() | |
| 198 |     {
 | |
| 199 | Effects3DActivity act = mAct.get(); | |
| 200 |  | |
| 201 | mList.clear(); | |
| 202 | LinearLayout layout = act.findViewById(mLayout); | |
| 203 | layout.removeAllViews(); | |
| 204 | mEffects.abortByType(mType); | |
| 205 |  | |
| 206 | resetData(); | |
| 207 | act.resetData(); | |
| 208 | } | |
| 209 |  | |
| 210 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 211 |  | |
| 212 | void remove(View v) | |
| 213 |     {
 | |
| 214 | for(Effects3DEffect effect: mList) | |
| 215 |       {
 | |
| 216 | if( effect.thisView(v) ) | |
| 217 |         {
 | |
| 218 | LinearLayout layout = mAct.get().findViewById(mLayout); | |
| 219 | View view; | |
| 220 |  | |
| 221 | view = effect.getEffect(); | |
| 222 | if( view!=null ) layout.removeView(view); | |
| 223 | view = effect.getCenter(); | |
| 224 | if( view!=null ) layout.removeView(view); | |
| 225 | view = effect.getRegion(); | |
| 226 | if( view!=null ) layout.removeView(view); | |
| 227 |  | |
| 228 | mEffects.abortById(effect.getId()); | |
| 229 | mList.remove(effect); | |
| 230 |  | |
| 231 | resetData(); | |
| 232 |  | |
| 233 | break; | |
| 234 | } | |
| 235 | } | |
| 236 | } | |
| 237 |  | |
| 238 | } | |
| src/main/java/org/distorted/examples/effects3d/Effects3DTabViewPager.java | ||
|---|---|---|
| 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 2 | // Copyright 2018 Leszek Koltunski // | |
| 3 | // // | |
| 4 | // This file is part of Distorted. // | |
| 5 | // // | |
| 6 | // Distorted is free software: you can redistribute it and/or modify // | |
| 7 | // it under the terms of the GNU General Public License as published by // | |
| 8 | // the Free Software Foundation, either version 2 of the License, or // | |
| 9 | // (at your option) any later version. // | |
| 10 | // // | |
| 11 | // Distorted is distributed in the hope that it will be useful, // | |
| 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // | |
| 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // | |
| 14 | // GNU General Public License for more details. // | |
| 15 | // // | |
| 16 | // You should have received a copy of the GNU General Public License // | |
| 17 | // along with Distorted. If not, see <http://www.gnu.org/licenses/>. // | |
| 18 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 19 |  | |
| 20 | package org.distorted.examples.effects3d; | |
| 21 |  | |
| 22 | import android.app.Fragment; | |
| 23 | import android.app.FragmentManager; | |
| 24 | import android.support.v13.app.FragmentPagerAdapter; | |
| 25 | import android.view.View; | |
| 26 |  | |
| 27 | import org.distorted.examples.R; | |
| 28 | import org.distorted.library.effect.EffectType; | |
| 29 |  | |
| 30 | import java.lang.ref.WeakReference; | |
| 31 |  | |
| 32 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 33 |  | |
| 34 | public class Effects3DTabViewPager extends FragmentPagerAdapter | |
| 35 |   {
 | |
| 36 | private static final int NUM_TABS = 3; | |
| 37 |  | |
| 38 | private WeakReference<Effects3DActivity> mAct; | |
| 39 | private Effects3DTab[] mTab; | |
| 40 |  | |
| 41 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 42 |  | |
| 43 | public Effects3DTabViewPager(Effects3DActivity act, FragmentManager fm) | |
| 44 |     {
 | |
| 45 | super(fm); | |
| 46 | mAct = new WeakReference<>(act); | |
| 47 | mTab = new Effects3DTab[NUM_TABS]; | |
| 48 | } | |
| 49 |  | |
| 50 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 51 |  | |
| 52 | void newEffect(View v, int pos) | |
| 53 |     {
 | |
| 54 | if( pos>=0 && pos<NUM_TABS ) mTab[pos].newEffect(); | |
| 55 | } | |
| 56 |  | |
| 57 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 58 |  | |
| 59 | void removeAll(View v, int pos) | |
| 60 |     {
 | |
| 61 | if( pos>=0 && pos<NUM_TABS ) mTab[pos].removeAll(); | |
| 62 | } | |
| 63 |  | |
| 64 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 65 |  | |
| 66 | void remove(View v, int pos) | |
| 67 |     {
 | |
| 68 | if( pos>=0 && pos<NUM_TABS ) mTab[pos].remove(v); | |
| 69 | } | |
| 70 |  | |
| 71 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 72 |  | |
| 73 | @Override | |
| 74 | public Fragment getItem(int position) | |
| 75 |     {
 | |
| 76 |     android.util.Log.e("viewPager","creating tab "+position);
 | |
| 77 |  | |
| 78 | switch(position) | |
| 79 |       {
 | |
| 80 | case 0: mTab[0] = new Effects3DTab(); | |
| 81 | mTab[0].setParams(EffectType.VERTEX , mAct, R.layout.effects3dtab1, R.id.effects3dlayout1, R.id.effects3dspinner1); | |
| 82 | return mTab[0]; | |
| 83 | case 1: mTab[1] = new Effects3DTab(); | |
| 84 | mTab[1].setParams(EffectType.FRAGMENT , mAct, R.layout.effects3dtab2, R.id.effects3dlayout2, R.id.effects3dspinner2); | |
| 85 | return mTab[1]; | |
| 86 | case 2: mTab[2] = new Effects3DTab(); | |
| 87 | mTab[2].setParams(EffectType.POSTPROCESS, mAct, R.layout.effects3dtab3, R.id.effects3dlayout3, R.id.effects3dspinner3); | |
| 88 | return mTab[2]; | |
| 89 | default: return null; | |
| 90 | } | |
| 91 | } | |
| 92 |  | |
| 93 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 94 |  | |
| 95 | @Override | |
| 96 | public int getCount() | |
| 97 |     {
 | |
| 98 | return NUM_TABS; | |
| 99 | } | |
| 100 |  | |
| 101 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 102 |  | |
| 103 | @Override | |
| 104 | public CharSequence getPageTitle(int position) | |
| 105 |     {
 | |
| 106 | switch (position) | |
| 107 |       {
 | |
| 108 | case 0 : return mAct.get().getString(R.string.type_vertex); | |
| 109 | case 1 : return mAct.get().getString(R.string.type_fragment); | |
| 110 | case 2 : return mAct.get().getString(R.string.type_postprocess); | |
| 111 | default: return null; | |
| 112 | } | |
| 113 | } | |
| 114 | } | |
| src/main/res/layout/effects3dlayout.xml | ||
|---|---|---|
| 2 | 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 
| 3 | 3 | android:layout_width="fill_parent" | 
| 4 | 4 | android:layout_height="fill_parent" | 
| 5 | android:layout_weight="1" | |
| 5 | 6 | android:orientation="vertical" > | 
| 6 | 7 |  | 
| 7 | 8 | <org.distorted.examples.effects3d.Effects3DSurfaceView | 
| ... | ... | |
| 54 | 55 | android:onClick="triggerOIT" | 
| 55 | 56 | android:text="@string/oit" | 
| 56 | 57 | android:textSize="12sp"/> | 
| 57 | </LinearLayout> | |
| 58 |  | |
| 59 | <LinearLayout | |
| 60 | android:layout_width="match_parent" | |
| 61 | android:layout_height="42dp" | |
| 62 | android:layout_gravity="center" | |
| 63 | android:orientation="horizontal"> | |
| 64 |  | |
| 65 | <Button | |
| 66 | android:id="@+id/buttonAdd" | |
| 67 | android:layout_width="wrap_content" | |
| 68 | android:layout_height="wrap_content" | |
| 69 | android:onClick="newEffect" | |
| 70 | android:text="@string/Add" | |
| 71 | /> | |
| 72 |  | |
| 73 | <TextView | |
| 74 | android:id="@+id/textView10" | |
| 75 | android:layout_width="wrap_content" | |
| 76 | android:layout_height="wrap_content" | |
| 77 | android:text="@string/New" | |
| 78 | android:textAppearance="?android:attr/textAppearanceMedium"/> | |
| 79 |  | |
| 80 | <Spinner | |
| 81 | android:id="@+id/effects3dspinner" | |
| 82 | android:layout_width="0dp" | |
| 83 | android:layout_height="wrap_content" | |
| 84 | android:layout_weight="0.5"/> | |
| 85 |  | |
| 86 | <Button | |
| 87 | android:id="@+id/buttonRemove" | |
| 88 | android:layout_width="wrap_content" | |
| 89 | android:layout_height="wrap_content" | |
| 90 | android:onClick="removeAll" | |
| 91 | android:text="@string/reset" | |
| 92 | /> | |
| 93 | 58 |  | 
| 94 | 59 | </LinearLayout> | 
| 95 | 60 |  | 
| 96 | <View | |
| 97 | android:layout_height="4dip" | |
| 98 | android:background="#777777" | |
| 61 | <android.support.design.widget.TabLayout | |
| 62 | android:id="@+id/effects3d_sliding_tabs" | |
| 99 | 63 | android:layout_width="match_parent" | 
| 100 | /> | |
| 64 | android:layout_height="32dp" | |
| 65 | android:theme="@style/Theme.AppCompat.NoActionBar"> | |
| 66 | </android.support.design.widget.TabLayout> | |
| 101 | 67 |  | 
| 102 |     <ScrollView
 | |
| 103 |         android:id="@+id/effects3dscrollView"
 | |
| 68 |     <android.support.v4.view.ViewPager
 | |
| 69 |         android:id="@+id/effects3d_viewpager"
 | |
| 104 | 70 | android:layout_width="match_parent" | 
| 105 | 71 | android:layout_height="0dp" | 
| 106 | android:layout_weight="0.80" | |
| 107 | > | |
| 108 |  | |
| 109 | <LinearLayout | |
| 110 | android:id="@+id/effects3dlayout" | |
| 111 | android:layout_width="match_parent" | |
| 112 | android:layout_height="wrap_content" | |
| 113 | android:orientation="vertical" > | |
| 114 | </LinearLayout> | |
| 115 |  | |
| 116 | </ScrollView> | |
| 72 | android:layout_weight="1" | |
| 73 | android:background="@android:color/black" /> | |
| 117 | 74 |  | 
| 118 | 75 | </LinearLayout> | 
| src/main/res/layout/effects3dtab1.xml | ||
|---|---|---|
| 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | android:layout_width="fill_parent" | |
| 4 | android:layout_height="fill_parent" | |
| 5 | android:orientation="vertical" > | |
| 6 |  | |
| 7 | <LinearLayout | |
| 8 | android:layout_width="match_parent" | |
| 9 | android:layout_height="42dp" | |
| 10 | android:layout_gravity="center" | |
| 11 | android:orientation="horizontal"> | |
| 12 |  | |
| 13 | <Button | |
| 14 | android:id="@+id/buttonAdd" | |
| 15 | android:layout_width="wrap_content" | |
| 16 | android:layout_height="wrap_content" | |
| 17 | android:onClick="newEffect" | |
| 18 | android:text="@string/Add" | |
| 19 | /> | |
| 20 |  | |
| 21 | <TextView | |
| 22 | android:id="@+id/textViewFragment" | |
| 23 | android:layout_width="wrap_content" | |
| 24 | android:layout_height="wrap_content" | |
| 25 | android:text="@string/New" | |
| 26 | android:textAppearance="?android:attr/textAppearanceMedium"/> | |
| 27 |  | |
| 28 | <Spinner | |
| 29 | android:id="@+id/effects3dspinner1" | |
| 30 | android:layout_width="0dp" | |
| 31 | android:layout_height="wrap_content" | |
| 32 | android:layout_weight="0.5"/> | |
| 33 |  | |
| 34 | <Button | |
| 35 | android:id="@+id/buttonRemove" | |
| 36 | android:layout_width="wrap_content" | |
| 37 | android:layout_height="wrap_content" | |
| 38 | android:onClick="removeAll" | |
| 39 | android:text="@string/reset" | |
| 40 | /> | |
| 41 |  | |
| 42 | </LinearLayout> | |
| 43 |  | |
| 44 | <View | |
| 45 | android:layout_height="4dip" | |
| 46 | android:background="#777777" | |
| 47 | android:layout_width="match_parent" | |
| 48 | /> | |
| 49 |  | |
| 50 | <ScrollView | |
| 51 | android:id="@+id/effects3dscrollView" | |
| 52 | android:layout_width="match_parent" | |
| 53 | android:layout_height="0dp" | |
| 54 | android:layout_weight="0.80" | |
| 55 | > | |
| 56 |  | |
| 57 | <LinearLayout | |
| 58 | android:id="@+id/effects3dlayout1" | |
| 59 | android:layout_width="match_parent" | |
| 60 | android:layout_height="wrap_content" | |
| 61 | android:orientation="vertical" > | |
| 62 | </LinearLayout> | |
| 63 |  | |
| 64 | </ScrollView> | |
| 65 |  | |
| 66 | </LinearLayout> | |
| src/main/res/layout/effects3dtab2.xml | ||
|---|---|---|
| 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | android:layout_width="fill_parent" | |
| 4 | android:layout_height="fill_parent" | |
| 5 | android:orientation="vertical" > | |
| 6 |  | |
| 7 | <LinearLayout | |
| 8 | android:layout_width="match_parent" | |
| 9 | android:layout_height="42dp" | |
| 10 | android:layout_gravity="center" | |
| 11 | android:orientation="horizontal"> | |
| 12 |  | |
| 13 | <Button | |
| 14 | android:id="@+id/buttonAdd" | |
| 15 | android:layout_width="wrap_content" | |
| 16 | android:layout_height="wrap_content" | |
| 17 | android:onClick="newEffect" | |
| 18 | android:text="@string/Add" | |
| 19 | /> | |
| 20 |  | |
| 21 | <TextView | |
| 22 | android:id="@+id/textViewFragment" | |
| 23 | android:layout_width="wrap_content" | |
| 24 | android:layout_height="wrap_content" | |
| 25 | android:text="@string/New" | |
| 26 | android:textAppearance="?android:attr/textAppearanceMedium"/> | |
| 27 |  | |
| 28 | <Spinner | |
| 29 | android:id="@+id/effects3dspinner2" | |
| 30 | android:layout_width="0dp" | |
| 31 | android:layout_height="wrap_content" | |
| 32 | android:layout_weight="0.5"/> | |
| 33 |  | |
| 34 | <Button | |
| 35 | android:id="@+id/buttonRemove" | |
| 36 | android:layout_width="wrap_content" | |
| 37 | android:layout_height="wrap_content" | |
| 38 | android:onClick="removeAll" | |
| 39 | android:text="@string/reset" | |
| 40 | /> | |
| 41 |  | |
| 42 | </LinearLayout> | |
| 43 |  | |
| 44 | <View | |
| 45 | android:layout_height="4dip" | |
| 46 | android:background="#777777" | |
| 47 | android:layout_width="match_parent" | |
| 48 | /> | |
| 49 |  | |
| 50 | <ScrollView | |
| 51 | android:id="@+id/effects3dscrollView" | |
| 52 | android:layout_width="match_parent" | |
| 53 | android:layout_height="0dp" | |
| 54 | android:layout_weight="0.80" | |
| 55 | > | |
| 56 |  | |
| 57 | <LinearLayout | |
| 58 | android:id="@+id/effects3dlayout2" | |
| 59 | android:layout_width="match_parent" | |
| 60 | android:layout_height="wrap_content" | |
| 61 | android:orientation="vertical" > | |
| 62 | </LinearLayout> | |
| 63 |  | |
| 64 | </ScrollView> | |
| 65 |  | |
| 66 | </LinearLayout> | |
| src/main/res/layout/effects3dtab3.xml | ||
|---|---|---|
| 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | android:layout_width="fill_parent" | |
| 4 | android:layout_height="fill_parent" | |
| 5 | android:orientation="vertical" > | |
| 6 |  | |
| 7 | <LinearLayout | |
| 8 | android:layout_width="match_parent" | |
| 9 | android:layout_height="42dp" | |
| 10 | android:layout_gravity="center" | |
| 11 | android:orientation="horizontal"> | |
| 12 |  | |
| 13 | <Button | |
| 14 | android:id="@+id/buttonAdd" | |
| 15 | android:layout_width="wrap_content" | |
| 16 | android:layout_height="wrap_content" | |
| 17 | android:onClick="newEffect" | |
| 18 | android:text="@string/Add" | |
| 19 | /> | |
| 20 |  | |
| 21 | <TextView | |
| 22 | android:id="@+id/textViewFragment" | |
| 23 | android:layout_width="wrap_content" | |
| 24 | android:layout_height="wrap_content" | |
| 25 | android:text="@string/New" | |
| 26 | android:textAppearance="?android:attr/textAppearanceMedium"/> | |
| 27 |  | |
| 28 | <Spinner | |
| 29 | android:id="@+id/effects3dspinner3" | |
| 30 | android:layout_width="0dp" | |
| 31 | android:layout_height="wrap_content" | |
| 32 | android:layout_weight="0.5"/> | |
| 33 |  | |
| 34 | <Button | |
| 35 | android:id="@+id/buttonRemove" | |
| 36 | android:layout_width="wrap_content" | |
| 37 | android:layout_height="wrap_content" | |
| 38 | android:onClick="removeAll" | |
| 39 | android:text="@string/reset" | |
| 40 | /> | |
| 41 |  | |
| 42 | </LinearLayout> | |
| 43 |  | |
| 44 | <View | |
| 45 | android:layout_height="4dip" | |
| 46 | android:background="#777777" | |
| 47 | android:layout_width="match_parent" | |
| 48 | /> | |
| 49 |  | |
| 50 | <ScrollView | |
| 51 | android:id="@+id/effects3dscrollView" | |
| 52 | android:layout_width="match_parent" | |
| 53 | android:layout_height="0dp" | |
| 54 | android:layout_weight="0.80" | |
| 55 | > | |
| 56 |  | |
| 57 | <LinearLayout | |
| 58 | android:id="@+id/effects3dlayout3" | |
| 59 | android:layout_width="match_parent" | |
| 60 | android:layout_height="wrap_content" | |
| 61 | android:orientation="vertical" > | |
| 62 | </LinearLayout> | |
| 63 |  | |
| 64 | </ScrollView> | |
| 65 |  | |
| 66 | </LinearLayout> | |
| src/main/res/values/strings.xml | ||
|---|---|---|
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> | 
| 2 | <resources>    
 | |
| 2 | <resources> | |
| 3 | 3 | <string name="app_name">Distorted Examples</string> | 
| 4 | 4 | <string name="tocHeader">Welcome to the Distorted Examples!\nCode, Tutorials, Wiki: http://distorted.org/</string> | 
| 5 |  | |
| 5 |  | |
| 6 | 6 | <string name="distort">Distort</string> | 
| 7 | 7 | <string name="deform">Deform</string> | 
| 8 | 8 | <string name="shear">Shear</string> | 
| ... | ... | |
| 14 | 14 | <string name="contrast">Contrast</string> | 
| 15 | 15 | <string name="swirl">Swirl</string> | 
| 16 | 16 | <string name="blur">Blur</string> | 
| 17 |  | |
| 18 | <string name="type_matrix">Matrix</string> | |
| 19 | <string name="type_vertex">Vertex</string> | |
| 20 | <string name="type_fragment">Fragment</string> | |
| 21 | <string name="type_postprocess">Postprocess</string> | |
| 22 |  | |
| 17 | 23 | <string name="glow_radius">Radius</string> | 
| 18 | 24 | <string name="glow_alpha">Alpha</string> | 
| 19 |  | |
| 20 | 25 | <string name="continu">Continue</string> | 
| 21 | 26 | <string name="rows">Rows</string> | 
| 22 | 27 | <string name="cols">Cols</string> | 
| ... | ... | |
| 63 | 68 | <string name="DepthYes">Depth</string> | 
| 64 | 69 | <string name="DepthNo">No Depth</string> | 
| 65 | 70 | <string name="mesh">Mesh</string> | 
| 66 | <string name="quality0">Highest</string> | |
| 67 | <string name="quality1">High</string> | |
| 68 | <string name="quality2">Medium</string> | |
| 69 | <string name="quality3">Low</string> | |
| 70 | 71 | <string name="show_center">Center</string> | 
| 71 | 72 | <string name="show_region">Region</string> | 
| 72 | 73 | <string name="show_normal">Normals</string> | 
| ... | ... | |
| 74 | 75 | <string name="screen">Screen</string> | 
| 75 | 76 | <string name="framebuffer">Framebuffer</string> | 
| 76 | 77 |  | 
| 78 | <string name="quality0">Highest</string> | |
| 79 | <string name="quality1">High</string> | |
| 80 | <string name="quality2">Medium</string> | |
| 81 | <string name="quality3">Low</string> | |
| 82 |  | |
| 77 | 83 | <string name="color_blue">Blue</string> | 
| 78 | 84 | <string name="color_black">Black</string> | 
| 79 | 85 | <string name="color_red">Red</string> | 
| ... | ... | |
| 98 | 104 | <string name="glow_radius_placeholder">Radius: %1$d</string> | 
| 99 | 105 | <string name="glow_alpha_placeholder">Alpha: %1$.2f</string> | 
| 100 | 106 |  | 
| 101 |     <string name="example_monalisa">Mona Lisa</string>  
 | |
| 107 | <string name="example_monalisa">Mona Lisa</string> | |
| 102 | 108 | <string name="example_monalisa_subtitle">The basics of Distortions.</string> | 
| 103 | 109 | <string name="example_sink">Sink</string> | 
| 104 | 110 | <string name="example_sink_subtitle">Learn about sinks.</string> | 
| 105 |     <string name="example_bean">Mr. Bean</string>  
 | |
| 111 | <string name="example_bean">Mr. Bean</string> | |
| 106 | 112 | <string name="example_bean_subtitle">Interpolation between more than two Points.</string> | 
| 107 | 113 | <string name="example_projection">Projection</string> | 
| 108 | 114 | <string name="example_projection_subtitle">Adjust the Projection Matrix.</string> | 
| 109 |     <string name="example_deform">Deformations and Distortions</string>  
 | |
| 115 | <string name="example_deform">Deformations and Distortions</string> | |
| 110 | 116 | <string name="example_deform_subtitle">Deform the whole bitmap or Distort a part of it.</string> | 
| 111 |     <string name="example_listener">DistortedListener</string>  
 | |
| 117 | <string name="example_listener">DistortedListener</string> | |
| 112 | 118 | <string name="example_listener_subtitle">Listen on effect events and react on them.</string> | 
| 113 | 119 | <string name="example_dynamic">Dynamics</string> | 
| 114 | 120 | <string name="example_dynamic_subtitle">Not an effect in itself, but rather a building block for other effects.</string> | 
| 115 |     <string name="example_girl">Girl</string>  
 | |
| 121 | <string name="example_girl">Girl</string> | |
| 116 | 122 | <string name="example_girl_subtitle">Distort, Sink and Swirl effects all in one.</string> | 
| 117 |     <string name="example_macroblock">Cat and Dog</string>  
 | |
| 123 | <string name="example_macroblock">Cat and Dog</string> | |
| 118 | 124 | <string name="example_macroblock_subtitle">Chroma, Transparency and Rotation effects.</string> | 
| 119 |     <string name="example_movingeffects">Moving Effects</string>  
 | |
| 125 | <string name="example_movingeffects">Moving Effects</string> | |
| 120 | 126 | <string name="example_movingeffects_subtitle">Use the Interpolator to move effects around.</string> | 
| 121 |     <string name="example_differenteffects">Different Effects</string>  
 | |
| 127 | <string name="example_differenteffects">Different Effects</string> | |
| 122 | 128 | <string name="example_differenteffects_subtitle">See how to draw the same bitmap multiple times, each time with different set of effects applied.</string> | 
| 123 |     <string name="example_differentbitmaps">Different Bitmaps</string>  
 | |
| 129 | <string name="example_differentbitmaps">Different Bitmaps</string> | |
| 124 | 130 | <string name="example_differentbitmaps_subtitle">Draw 3 different bitmaps, apply the same set of effects to each one in one go.</string> | 
| 125 | 131 | <string name="example_effectqueue">Effect Queue</string> | 
| 126 | 132 | <string name="example_effectqueue_subtitle">Add, remove and list all effects currently acting on a Bitmap.</string> | 
| 127 |     <string name="example_check">Check</string>  
 | |
| 133 | <string name="example_check">Check</string> | |
| 128 | 134 | <string name="example_check_subtitle">Check the maximum number of effects (separately for vertex and fragment shaders) we can apply to a single bitmap.</string> | 
| 129 | 135 | <string name="example_bitmaptree">Bitmap Tree</string> | 
| 130 | 136 | <string name="example_bitmaptree_subtitle">Render one bitmap on top of another.</string> | 
| 131 |     <string name="example_starwars">Star Wars</string>  
 | |
| 137 | <string name="example_starwars">Star Wars</string> | |
| 132 | 138 | <string name="example_starwars_subtitle">Shows how to create the opening crawl from Star Wars Episode IV.</string> | 
| 133 |     <string name="example_olimpic">Olimpic Rings</string>  
 | |
| 139 | <string name="example_olimpic">Olimpic Rings</string> | |
| 134 | 140 | <string name="example_olimpic_subtitle">Shows the Chroma effect and Node optimizations.</string> | 
| 135 |     <string name="example_cubes">Cubes</string>  
 | |
| 141 | <string name="example_cubes">Cubes</string> | |
| 136 | 142 | <string name="example_cubes_subtitle">Tests the DistortedCubes render target.</string> | 
| 137 |     <string name="example_quaternion">Quaternion</string>  
 | |
| 143 | <string name="example_quaternion">Quaternion</string> | |
| 138 | 144 | <string name="example_quaternion_subtitle">Random rotations using quaternions.</string> | 
| 139 | 145 | <string name="example_matrix3d">Matrix Effects</string> | 
| 140 | 146 | <string name="example_matrix3d_subtitle">Test results of Matrix effects on a 3D object.</string> | 
Also available in: Unified diff
Overhaul of the Effects3D generic test app.
Still not perfect (the 'postprocess' tab does not work; things crash when we rotate)