Project

General

Profile

« Previous | Next » 

Revision bddd4b2d

Added by Leszek Koltunski over 6 years ago

Add OIT to the Effects3D app.

View differences:

src/main/java/org/distorted/examples/effects3d/Effects3DActivity.java
88 88
  private static boolean mShowCenter = true;
89 89
  private static boolean mShowRegion = true;
90 90
  private static boolean mShowNormal = true;
91
  private static boolean mUseOIT     = false;
91 92

  
92 93
///////////////////////////////////////////////////////////////////////////////////////////////////
93 94

  
......
102 103

  
103 104
    setContentView(R.layout.objectpickerlayout);
104 105

  
105
    mLay = (LinearLayout)findViewById(R.id.objectpicker_buttongrid);
106
    mLay = findViewById(R.id.objectpicker_buttongrid);
106 107

  
107
    mColsPicker = (NumberPicker)findViewById(R.id.objectpicker_cols);
108
    mRowsPicker = (NumberPicker)findViewById(R.id.objectpicker_rows);
109
    mSlicPicker = (NumberPicker)findViewById(R.id.objectpicker_slices);
108
    mColsPicker = findViewById(R.id.objectpicker_cols);
109
    mRowsPicker = findViewById(R.id.objectpicker_rows);
110
    mSlicPicker = findViewById(R.id.objectpicker_slices);
110 111

  
111 112
    mColsPicker.setMaxValue(40);
112 113
    mColsPicker.setMinValue( 0);
......
145 146
    mObjectType = 0;
146 147
    mGridInitialized = false;
147 148

  
148
    Spinner typeSpinner  = (Spinner)findViewById(R.id.objectpicker_spinnerType);
149
    Spinner typeSpinner  = findViewById(R.id.objectpicker_spinnerType);
149 150
    typeSpinner.setOnItemSelectedListener(this);
150 151

  
151 152
    String[] objectType = new String[] {"Mesh: Cubes", "Mesh: Flat"};
......
154 155
    adapterType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
155 156
    typeSpinner.setAdapter(adapterType);
156 157

  
157
    Spinner bitmapSpinner  = (Spinner)findViewById(R.id.objectpicker_spinnerBitmap);
158
    Spinner bitmapSpinner  = findViewById(R.id.objectpicker_spinnerBitmap);
158 159
    bitmapSpinner.setOnItemSelectedListener(this);
159 160

  
160 161
    String[] objectBitmap = new String[] { "Texture: Grid", "Texture: Girl", "Texture: Dog", "Texture: Cat",
......
362 363
    mRegionY =-y;
363 364
    mRegionR = r;
364 365

  
365
    Effects3DSurfaceView view = (Effects3DSurfaceView)findViewById(R.id.effects3dSurfaceView);
366
    Effects3DSurfaceView view = findViewById(R.id.effects3dSurfaceView);
366 367
    view.getRenderer().setRegion(mRegionX, mRegionY, mRegionR);
367 368
    }
368 369

  
......
374 375
    mCenterY = y;
375 376
    mCenterZ = z;
376 377

  
377
    Effects3DSurfaceView view = (Effects3DSurfaceView)findViewById(R.id.effects3dSurfaceView);
378
    Effects3DSurfaceView view = findViewById(R.id.effects3dSurfaceView);
378 379
    view.getRenderer().setCenter( mCenterX, mCenterY, mCenterZ );
379 380
    }
380 381

  
......
454 455

  
455 456
    for(int i=0; i<mEffectNames.length; i++) effects[i] = mEffectNames[i].name();
456 457

  
457
    Spinner effectSpinner = (Spinner)findViewById(R.id.effects3dspinner );
458
    Spinner effectSpinner = findViewById(R.id.effects3dspinner );
458 459
    effectSpinner.setOnItemSelectedListener(this);
459 460

  
460 461
    ArrayAdapter<String> adapterEffect = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, effects);
......
541 542
    mSupportsRegion =false;
542 543
    mSupportsCenter =false;
543 544

  
544
    Effects3DSurfaceView view = (Effects3DSurfaceView)findViewById(R.id.effects3dSurfaceView);
545
    Effects3DSurfaceView view = findViewById(R.id.effects3dSurfaceView);
545 546
    view.getRenderer().showRegionAndCenter(false,false);
546 547
    }
547 548

  
......
553 554
    Effects3DEffect eff = new Effects3DEffect(mEffectNames[mEffectAdd], this);
554 555
    mList.add(eff);
555 556

  
556
    LinearLayout layout = (LinearLayout)findViewById(R.id.effects3dlayout);
557
    LinearLayout layout = findViewById(R.id.effects3dlayout);
557 558
    View view = eff.createView();
558 559
    layout.addView(view);
559 560

  
......
572 573
    eff.apply(mEffects);
573 574

  
574 575
    boolean show = (mEffectNames[mEffectAdd].getType()==EffectType.VERTEX);
575
    Effects3DSurfaceView sv = (Effects3DSurfaceView)findViewById(R.id.effects3dSurfaceView);
576
    Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView);
576 577
    sv.getRenderer().showRegionAndCenter( (show && mShowRegion) , (show && mShowCenter) );
577 578
    }
578 579

  
......
581 582
  public void removeAll(View v)
582 583
    {
583 584
    mList.clear();
584
    LinearLayout layout = (LinearLayout)findViewById(R.id.effects3dlayout);
585
    LinearLayout layout = findViewById(R.id.effects3dlayout);
585 586
    layout.removeAllViews();
586 587
    mEffects.abortByType(EffectType.VERTEX);
587 588
    mEffects.abortByType(EffectType.FRAGMENT);
588 589

  
589 590
    resetData();
590 591

  
591
    Effects3DSurfaceView view = (Effects3DSurfaceView)findViewById(R.id.effects3dSurfaceView);
592
    Effects3DSurfaceView view = findViewById(R.id.effects3dSurfaceView);
592 593
    Effects3DRenderer renderer= view.getRenderer();
593 594

  
594 595
    renderer.setCenter( mCenterX, mCenterY, mCenterZ );
......
605 606
      {
606 607
      if( effect.thisView(v) )
607 608
        {
608
        LinearLayout layout = (LinearLayout)findViewById(R.id.effects3dlayout);
609
        LinearLayout layout = findViewById(R.id.effects3dlayout);
609 610
        View view;
610 611

  
611 612
        view = effect.getEffect();
......
646 647
      CheckBox box = (CheckBox)view;
647 648
      mShowCenter = box.isChecked();
648 649

  
649
      Effects3DSurfaceView sv = (Effects3DSurfaceView)findViewById(R.id.effects3dSurfaceView);
650
      Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView);
650 651
      sv.getRenderer().showRegionAndCenter(mShowRegion,mShowCenter);
651 652
      }
652 653

  
......
657 658
      CheckBox box = (CheckBox)view;
658 659
      mShowRegion = box.isChecked();
659 660

  
660
      Effects3DSurfaceView sv = (Effects3DSurfaceView)findViewById(R.id.effects3dSurfaceView);
661
      Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView);
661 662
      sv.getRenderer().showRegionAndCenter(mShowRegion,mShowCenter);
662 663
      }
663 664

  
......
674 675
        }
675 676
      }
676 677

  
678
///////////////////////////////////////////////////////////////////////////////////////////////////
679

  
680
    public void triggerOIT(View view)
681
      {
682
      CheckBox box = (CheckBox)view;
683
      mUseOIT = box.isChecked();
684

  
685
      Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView);
686
      sv.getRenderer().useOIT(mUseOIT);
687
      }
688

  
677 689
///////////////////////////////////////////////////////////////////////////////////////////////////
678 690
// Overrides
679 691

  
680 692
  @Override
681 693
  protected void onPause()
682 694
    {
683
    GLSurfaceView mView = (GLSurfaceView)findViewById(R.id.effects3dSurfaceView);
695
    GLSurfaceView mView = findViewById(R.id.effects3dSurfaceView);
684 696
    if( mView!=null ) mView.onPause();
685 697

  
686 698
    Distorted.onPause();
......
693 705
  protected void onResume()
694 706
    {
695 707
    super.onResume();
696
    GLSurfaceView mView = (GLSurfaceView)findViewById(R.id.effects3dSurfaceView);
708
    GLSurfaceView mView = findViewById(R.id.effects3dSurfaceView);
697 709
    if( mView!=null ) mView.onResume();
698 710
    }
699 711

  
src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java
195 195
      mRegionScalePoint.set(mFactorReg,mFactorReg,mFactorReg);
196 196
      }
197 197

  
198
///////////////////////////////////////////////////////////////////////////////////////////////////
199

  
200
    void useOIT(boolean use)
201
      {
202
      mScreen.setOrderIndependentTransparency(use);
203
      }
204

  
198 205
///////////////////////////////////////////////////////////////////////////////////////////////////
199 206

  
200 207
    public void onDrawFrame(GL10 glUnused)
src/main/res/layout/effects3dlayout.xml
44 44
            android:onClick="showNormal"
45 45
            android:text="@string/show_normal"
46 46
            android:textSize="12sp"/>
47

  
48
        <CheckBox
49
            android:id="@+id/effects3dCheckBoxOIT"
50
            android:layout_width="wrap_content"
51
            android:layout_height="wrap_content"
52
            android:layout_weight="1"
53
            android:checked="false"
54
            android:onClick="triggerOIT"
55
            android:text="@string/oit"
56
            android:textSize="12sp"/>
47 57
    </LinearLayout>
48 58

  
49 59
    <LinearLayout
src/main/res/values/strings.xml
67 67
    <string name="quality1">High</string>
68 68
    <string name="quality2">Medium</string>
69 69
    <string name="quality3">Low</string>
70
    <string name="show_center">Show Center</string>
71
    <string name="show_region">Show Region</string>
72
    <string name="show_normal">Show Normals</string>
70
    <string name="show_center">Center</string>
71
    <string name="show_region">Region</string>
72
    <string name="show_normal">Normals</string>
73
    <string name="oit">OIT</string>
73 74
    <string name="screen">Screen</string>
74 75
    <string name="framebuffer">Framebuffer</string>
75 76

  

Also available in: Unified diff