Revision 0ab55f0c
Added by Leszek Koltunski about 7 years ago
src/main/java/org/distorted/examples/effects3d/Effects3DActivity.java | ||
---|---|---|
31 | 31 |
import android.widget.AdapterView; |
32 | 32 |
import android.widget.ArrayAdapter; |
33 | 33 |
import android.widget.Button; |
34 |
import android.widget.CheckBox; |
|
34 | 35 |
import android.widget.LinearLayout; |
35 | 36 |
import android.widget.NumberPicker; |
36 | 37 |
import android.widget.Spinner; |
... | ... | |
83 | 84 |
private static boolean mSupportsRegion; |
84 | 85 |
private static boolean mSupportsCenter; |
85 | 86 |
|
87 |
private static boolean mShowCenter = true; |
|
88 |
private static boolean mShowRegion = true; |
|
89 |
private static boolean mShowNormal = true; |
|
90 |
|
|
86 | 91 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
87 | 92 |
|
88 | 93 |
@Override |
... | ... | |
281 | 286 |
} |
282 | 287 |
else |
283 | 288 |
{ |
284 |
final int W = 640;
|
|
285 |
final int H = 640;
|
|
289 |
final int W = 64*mNumCols;
|
|
290 |
final int H = 64*mNumRows;
|
|
286 | 291 |
|
287 | 292 |
Paint paint = new Paint(); |
288 | 293 |
mBitmap = Bitmap.createBitmap(W,H, Bitmap.Config.ARGB_8888); |
... | ... | |
295 | 300 |
canvas.drawRect(0, 0, W, H, paint); |
296 | 301 |
paint.setColor(0xffffffff); |
297 | 302 |
|
298 |
for(int i=0; i<=mNumCols ; i++ ) |
|
299 |
{ |
|
300 |
canvas.drawRect(W*i/mNumCols - 1, 0, W*i/mNumCols + 1, H , paint); |
|
301 |
canvas.drawRect( 0, H *i/mNumCols -1, W , H*i/mNumCols + 1, paint); |
|
302 |
} |
|
303 |
for(int i=0; i<=mNumCols ; i++ ) canvas.drawRect(W*i/mNumCols-1, 0, W*i/mNumCols + 1, H, paint); |
|
304 |
for(int i=0; i<=mNumRows ; i++ ) canvas.drawRect( 0, H*i/mNumRows-1, W, H*i/mNumRows+1, paint); |
|
303 | 305 |
} |
304 | 306 |
} |
305 | 307 |
|
... | ... | |
426 | 428 |
mMesh = new MeshCubes(mNumCols, str, false); |
427 | 429 |
} |
428 | 430 |
|
431 |
mMesh.setShowNormals(mShowNormal); |
|
432 |
|
|
429 | 433 |
mEffects= new DistortedEffects(); |
430 | 434 |
mTexture= new DistortedTexture(mNumCols,mNumRows); |
431 | 435 |
|
... | ... | |
525 | 529 |
mSupportsCenter =false; |
526 | 530 |
|
527 | 531 |
Effects3DSurfaceView view = (Effects3DSurfaceView)findViewById(R.id.effects3dSurfaceView); |
528 |
view.getRenderer().showRegionAndCenter(false); |
|
532 |
view.getRenderer().showRegionAndCenter(false,false);
|
|
529 | 533 |
} |
530 | 534 |
|
531 | 535 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
554 | 558 |
|
555 | 559 |
eff.apply(mEffects); |
556 | 560 |
|
561 |
boolean show = (mEffectNames[mEffectAdd].getType()==EffectTypes.VERTEX); |
|
557 | 562 |
Effects3DSurfaceView sv = (Effects3DSurfaceView)findViewById(R.id.effects3dSurfaceView); |
558 |
sv.getRenderer().showRegionAndCenter(mEffectNames[mEffectAdd].getType()==EffectTypes.VERTEX);
|
|
563 |
sv.getRenderer().showRegionAndCenter( (show && mShowRegion) , (show && mShowCenter) );
|
|
559 | 564 |
} |
560 | 565 |
|
561 | 566 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
607 | 612 |
} |
608 | 613 |
} |
609 | 614 |
|
615 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
616 |
|
|
617 |
boolean getShowCenter() |
|
618 |
{ |
|
619 |
return mShowCenter; |
|
620 |
} |
|
621 |
|
|
622 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
623 |
|
|
624 |
boolean getShowRegion() |
|
625 |
{ |
|
626 |
return mShowRegion; |
|
627 |
} |
|
628 |
|
|
629 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
630 |
|
|
631 |
public void showCenter(View view) |
|
632 |
{ |
|
633 |
CheckBox box = (CheckBox)view; |
|
634 |
mShowCenter = box.isChecked(); |
|
635 |
|
|
636 |
Effects3DSurfaceView sv = (Effects3DSurfaceView)findViewById(R.id.effects3dSurfaceView); |
|
637 |
sv.getRenderer().showRegionAndCenter(mShowRegion,mShowCenter); |
|
638 |
} |
|
639 |
|
|
640 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
641 |
|
|
642 |
public void showRegion(View view) |
|
643 |
{ |
|
644 |
CheckBox box = (CheckBox)view; |
|
645 |
mShowRegion = box.isChecked(); |
|
646 |
|
|
647 |
Effects3DSurfaceView sv = (Effects3DSurfaceView)findViewById(R.id.effects3dSurfaceView); |
|
648 |
sv.getRenderer().showRegionAndCenter(mShowRegion,mShowCenter); |
|
649 |
} |
|
650 |
|
|
651 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
652 |
|
|
653 |
public void showNormal(View view) |
|
654 |
{ |
|
655 |
CheckBox box = (CheckBox)view; |
|
656 |
mShowNormal = box.isChecked(); |
|
657 |
|
|
658 |
if ( mMesh!=null ) |
|
659 |
{ |
|
660 |
mMesh.setShowNormals(mShowNormal); |
|
661 |
} |
|
662 |
} |
|
663 |
|
|
610 | 664 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
611 | 665 |
// Overrides |
612 | 666 |
|
Also available in: Unified diff
Use Transform Feedback to (optionally) display the Normal vectors.