Revision 0ab55f0c
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/TableOfContents.java | ||
---|---|---|
86 | 86 |
|
87 | 87 |
int i = 0; |
88 | 88 |
|
89 |
{ |
|
90 |
final Map<String, Object> item = new HashMap<>(); |
|
91 |
item.put(ITEM_IMAGE, R.drawable.icon_example_feedback); |
|
92 |
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_feedback)); |
|
93 |
item.put(ITEM_SUBTITLE, getText(R.string.example_feedback_subtitle)); |
|
94 |
data.add(item); |
|
95 |
activityMapping.put(i++, FeedbackActivity.class); |
|
96 |
} |
|
97 |
|
|
98 | 89 |
{ |
99 | 90 |
final Map<String, Object> item = new HashMap<>(); |
100 | 91 |
item.put(ITEM_IMAGE, R.drawable.icon_example_monalisa); |
... | ... | |
356 | 347 |
activityMapping.put(i++, MultiblurActivity.class); |
357 | 348 |
} |
358 | 349 |
|
350 |
{ |
|
351 |
final Map<String, Object> item = new HashMap<>(); |
|
352 |
item.put(ITEM_IMAGE, R.drawable.icon_example_feedback); |
|
353 |
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_feedback)); |
|
354 |
item.put(ITEM_SUBTITLE, getText(R.string.example_feedback_subtitle)); |
|
355 |
data.add(item); |
|
356 |
activityMapping.put(i++, FeedbackActivity.class); |
|
357 |
} |
|
358 |
|
|
359 | 359 |
final SimpleAdapter dataAdapter = new SimpleAdapter(this, data, R.layout.toc_item, new String[] {ITEM_IMAGE, ITEM_TITLE, ITEM_SUBTITLE}, new int[] {R.id.Image, R.id.Title, R.id.SubTitle}); |
360 | 360 |
setListAdapter(dataAdapter); |
361 | 361 |
|
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 |
|
src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java | ||
---|---|---|
637 | 637 |
if( fromUser ) |
638 | 638 |
{ |
639 | 639 |
Effects3DActivity act = mAct.get(); |
640 |
|
|
641 |
boolean show = (mName.getType()==EffectTypes.VERTEX); |
|
642 |
boolean showR= (show && act.getShowRegion()); |
|
643 |
boolean showC= (show && act.getShowCenter()); |
|
644 |
|
|
640 | 645 |
Effects3DSurfaceView view = (Effects3DSurfaceView)act.findViewById(R.id.effects3dSurfaceView); |
641 |
view.getRenderer().showRegionAndCenter(mName.getType()==EffectTypes.VERTEX);
|
|
646 |
view.getRenderer().showRegionAndCenter( showR,showC );
|
|
642 | 647 |
|
643 | 648 |
act.setSupportsCenter(mName.supportsCenter()); |
644 | 649 |
act.setSupportsRegion(mName.supportsRegion()); |
src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java | ||
---|---|---|
68 | 68 |
|
69 | 69 |
Static4D mQuat1, mQuat2; |
70 | 70 |
int mScreenMin; |
71 |
private boolean mShowing=false; |
|
71 |
private boolean mShowingCenter=false; |
|
72 |
private boolean mShowingRegion=false; |
|
72 | 73 |
|
73 | 74 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
74 | 75 |
|
... | ... | |
126 | 127 |
|
127 | 128 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
128 | 129 |
|
129 |
void showRegionAndCenter(boolean show) |
|
130 |
void showRegionAndCenter(boolean showRegion, boolean showCenter)
|
|
130 | 131 |
{ |
131 |
if( mShowing!=show )
|
|
132 |
if( mShowingCenter!=showCenter )
|
|
132 | 133 |
{ |
133 |
if( show )
|
|
134 |
{
|
|
135 |
mScreen.attach(mCenterNode); |
|
136 |
mScreen.attach(mRegionNode);
|
|
137 |
}
|
|
138 |
else |
|
139 |
{
|
|
140 |
mScreen.detach(mCenterNode);
|
|
141 |
mScreen.detach(mRegionNode);
|
|
142 |
}
|
|
134 |
if( showCenter ) mScreen.attach(mCenterNode);
|
|
135 |
else mScreen.detach(mCenterNode);
|
|
136 |
|
|
137 |
mShowingCenter = showCenter;
|
|
138 |
} |
|
139 |
|
|
140 |
if( mShowingRegion!=showRegion )
|
|
141 |
{
|
|
142 |
if( showRegion ) mScreen.attach(mRegionNode);
|
|
143 |
else mScreen.detach(mRegionNode);
|
|
143 | 144 |
|
144 |
mShowing = show;
|
|
145 |
mShowingRegion = showRegion;
|
|
145 | 146 |
} |
146 | 147 |
} |
147 | 148 |
|
... | ... | |
214 | 215 |
mCenterEffects.quaternion(mQuatInt2, rotateCen); |
215 | 216 |
|
216 | 217 |
mCenterEffects.move( new Static3D( (width -factorCen*centerSize-mFactorObj*mObjWidth )/2 , |
217 |
(height-factorCen*centerSize-mFactorObj*mObjHeight)/2 , 10) );
|
|
218 |
(height-factorCen*centerSize-mFactorObj*mObjHeight)/2 , 15) );
|
|
218 | 219 |
mCenterEffects.move(mCenterInter); |
219 | 220 |
mCenterEffects.scale(factorCen); |
220 | 221 |
|
src/main/res/layout/effects3dlayout.xml | ||
---|---|---|
11 | 11 |
android:layout_weight="1" /> |
12 | 12 |
|
13 | 13 |
<LinearLayout |
14 |
android:orientation="horizontal" |
|
15 | 14 |
android:layout_width="match_parent" |
16 |
android:layout_height="50dp"
|
|
17 |
android:layout_gravity="center">
|
|
15 |
android:layout_height="32dp"
|
|
16 |
android:orientation="horizontal">
|
|
18 | 17 |
|
19 |
<Button |
|
18 |
<CheckBox |
|
19 |
android:id="@+id/effects3dCheckBoxCenter" |
|
20 | 20 |
android:layout_width="wrap_content" |
21 | 21 |
android:layout_height="wrap_content" |
22 |
android:text="@string/Add" |
|
22 |
android:layout_weight="1" |
|
23 |
android:checked="true" |
|
24 |
android:onClick="showCenter" |
|
25 |
android:text="@string/show_center" |
|
26 |
android:textSize="12sp"/> |
|
27 |
|
|
28 |
<CheckBox |
|
29 |
android:id="@+id/effects3dCheckBoxRegion" |
|
30 |
android:layout_width="wrap_content" |
|
31 |
android:layout_height="wrap_content" |
|
32 |
android:layout_weight="1" |
|
33 |
android:checked="true" |
|
34 |
android:onClick="showRegion" |
|
35 |
android:text="@string/show_region" |
|
36 |
android:textSize="12sp"/> |
|
37 |
|
|
38 |
<CheckBox |
|
39 |
android:id="@+id/effects3dCheckBoxNormal" |
|
40 |
android:layout_width="wrap_content" |
|
41 |
android:layout_height="wrap_content" |
|
42 |
android:layout_weight="1" |
|
43 |
android:checked="true" |
|
44 |
android:onClick="showNormal" |
|
45 |
android:text="@string/show_normal" |
|
46 |
android:textSize="12sp"/> |
|
47 |
</LinearLayout> |
|
48 |
|
|
49 |
<LinearLayout |
|
50 |
android:layout_width="match_parent" |
|
51 |
android:layout_height="42dp" |
|
52 |
android:layout_gravity="center" |
|
53 |
android:orientation="horizontal"> |
|
54 |
|
|
55 |
<Button |
|
23 | 56 |
android:id="@+id/buttonAdd" |
57 |
android:layout_width="wrap_content" |
|
58 |
android:layout_height="wrap_content" |
|
24 | 59 |
android:onClick="newEffect" |
60 |
android:text="@string/Add" |
|
25 | 61 |
/> |
26 | 62 |
|
27 | 63 |
<TextView |
64 |
android:id="@+id/textView10" |
|
28 | 65 |
android:layout_width="wrap_content" |
29 | 66 |
android:layout_height="wrap_content" |
30 |
android:textAppearance="?android:attr/textAppearanceMedium" |
|
31 | 67 |
android:text="@string/New" |
32 |
android:id="@+id/textView10"/>
|
|
68 |
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
|
33 | 69 |
|
34 | 70 |
<Spinner |
71 |
android:id="@+id/effects3dspinner" |
|
35 | 72 |
android:layout_width="wrap_content" |
36 | 73 |
android:layout_height="wrap_content" |
37 |
android:id="@+id/effects3dspinner" |
|
38 | 74 |
android:layout_weight="0.5"/> |
39 | 75 |
|
40 | 76 |
<Button |
77 |
android:id="@+id/buttonRemove" |
|
41 | 78 |
android:layout_width="wrap_content" |
42 | 79 |
android:layout_height="wrap_content" |
43 |
android:text="@string/reset" |
|
44 |
android:id="@+id/buttonRemove" |
|
45 | 80 |
android:onClick="removeAll" |
81 |
android:text="@string/reset" |
|
46 | 82 |
/> |
47 | 83 |
|
48 | 84 |
</LinearLayout> |
src/main/res/values/strings.xml | ||
---|---|---|
65 | 65 |
<string name="quality1">High</string> |
66 | 66 |
<string name="quality2">Medium</string> |
67 | 67 |
<string name="quality3">Low</string> |
68 |
<string name="show_center">Show Center</string> |
|
69 |
<string name="show_region">Show Region</string> |
|
70 |
<string name="show_normal">Show Normals</string> |
|
68 | 71 |
|
69 | 72 |
<string name="radius_placeholder">Radius: %1$s</string> |
70 | 73 |
<string name="noise_placeholder">Noise %1$s</string> |
Also available in: Unified diff
Use Transform Feedback to (optionally) display the Normal vectors.