Revision 6cc818f6
Added by Leszek Koltunski over 5 years ago
src/main/java/org/distorted/examples/generic/GenericActivity2.java | ||
---|---|---|
32 | 32 |
import android.widget.CheckBox; |
33 | 33 |
|
34 | 34 |
import org.distorted.examples.R; |
35 |
import org.distorted.library.effect.EffectType; |
|
35 | 36 |
import org.distorted.library.main.Distorted; |
36 | 37 |
import org.distorted.library.main.DistortedEffects; |
37 | 38 |
import org.distorted.library.main.DistortedTexture; |
... | ... | |
64 | 65 |
private boolean mShowRegion; |
65 | 66 |
private boolean mShowNormal; |
66 | 67 |
private boolean mUseOIT ; |
68 |
private EffectType mCurrentType; |
|
67 | 69 |
|
68 | 70 |
private GenericTab[] mTab; |
69 | 71 |
|
... | ... | |
92 | 94 |
mShowNormal = false; |
93 | 95 |
mUseOIT = false; |
94 | 96 |
|
97 |
mCurrentType = EffectType.MATRIX; |
|
98 |
|
|
95 | 99 |
int maxsize = numCols > numRows ? (numCols>numSlic ? numCols:numSlic) : (numRows>numSlic ? numRows:numSlic) ; |
96 | 100 |
|
97 | 101 |
createBitmap(maxsize, bitmapID); |
... | ... | |
205 | 209 |
|
206 | 210 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
207 | 211 |
|
208 |
public void setRegion(float x, float y, float z, float r)
|
|
212 |
void setRegion(float x, float y, float z, float r) |
|
209 | 213 |
{ |
210 | 214 |
mRegionX = x; |
211 | 215 |
mRegionY =-y; |
212 | 216 |
mRegionZ = z; |
213 | 217 |
mRegionR = r; |
214 | 218 |
|
219 |
setRendererRegion(); |
|
220 |
} |
|
221 |
|
|
222 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
223 |
|
|
224 |
void setRendererRegion() |
|
225 |
{ |
|
215 | 226 |
GenericSurfaceView view = findViewById(R.id.genericSurfaceView); |
216 | 227 |
view.getRenderer().setRegion(mRegionX, mRegionY, mRegionZ, mRegionR); |
217 | 228 |
} |
218 | 229 |
|
219 | 230 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
220 | 231 |
|
221 |
public void setCenter(float x, float y, float z)
|
|
232 |
void setCenter(float x, float y, float z) |
|
222 | 233 |
{ |
223 | 234 |
mCenterX = x; |
224 | 235 |
mCenterY = y; |
225 | 236 |
mCenterZ = z; |
226 | 237 |
|
238 |
setRendererCenter(); |
|
239 |
} |
|
240 |
|
|
241 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
242 |
|
|
243 |
void setRendererCenter() |
|
244 |
{ |
|
227 | 245 |
GenericSurfaceView view = findViewById(R.id.genericSurfaceView); |
228 | 246 |
view.getRenderer().setCenter( mCenterX, mCenterY, mCenterZ ); |
229 | 247 |
} |
... | ... | |
327 | 345 |
renderer.resetMatrixEffects(); |
328 | 346 |
} |
329 | 347 |
|
348 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
349 |
|
|
350 |
void setCurrentEffectType(EffectType type) |
|
351 |
{ |
|
352 |
mCurrentType = type; |
|
353 |
} |
|
354 |
|
|
330 | 355 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
331 | 356 |
|
332 | 357 |
public DistortedEffects getEffects() |
... | ... | |
389 | 414 |
CheckBox box = (CheckBox)view; |
390 | 415 |
mShowCenter = box.isChecked(); |
391 | 416 |
|
417 |
boolean showR=supportsRegion(mCurrentType); |
|
418 |
boolean showC=supportsCenter(mCurrentType); |
|
419 |
|
|
392 | 420 |
GenericSurfaceView sv = findViewById(R.id.genericSurfaceView); |
393 |
sv.getRenderer().showRegionAndCenter(mShowRegion,mShowCenter);
|
|
421 |
sv.getRenderer().showRegionAndCenter( (mShowRegion&&showR) , (mShowCenter&&showC) );
|
|
394 | 422 |
} |
395 | 423 |
|
396 | 424 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
400 | 428 |
CheckBox box = (CheckBox)view; |
401 | 429 |
mShowRegion = box.isChecked(); |
402 | 430 |
|
431 |
boolean showR=supportsRegion(mCurrentType); |
|
432 |
boolean showC=supportsCenter(mCurrentType); |
|
433 |
|
|
403 | 434 |
GenericSurfaceView sv = findViewById(R.id.genericSurfaceView); |
404 |
sv.getRenderer().showRegionAndCenter(mShowRegion,mShowCenter); |
|
435 |
sv.getRenderer().showRegionAndCenter( (mShowRegion&&showR) , (mShowCenter&&showC) ); |
|
436 |
} |
|
437 |
|
|
438 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
439 |
|
|
440 |
boolean supportsCenter(EffectType type) |
|
441 |
{ |
|
442 |
switch(type) |
|
443 |
{ |
|
444 |
case MATRIX : return true; |
|
445 |
case VERTEX : return true; |
|
446 |
case FRAGMENT : return true; |
|
447 |
case POSTPROCESS: return false; |
|
448 |
} |
|
449 |
|
|
450 |
return false; |
|
451 |
} |
|
452 |
|
|
453 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
454 |
|
|
455 |
boolean supportsRegion(EffectType type) |
|
456 |
{ |
|
457 |
switch(type) |
|
458 |
{ |
|
459 |
case MATRIX : return false; |
|
460 |
case VERTEX : return true; |
|
461 |
case FRAGMENT : return false; |
|
462 |
case POSTPROCESS: return false; |
|
463 |
} |
|
464 |
|
|
465 |
return false; |
|
405 | 466 |
} |
406 | 467 |
|
407 | 468 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/generic/GenericEffect.java | ||
---|---|---|
769 | 769 |
if( fromUser ) |
770 | 770 |
{ |
771 | 771 |
GenericActivity2 act = mAct.get(); |
772 |
|
|
773 |
boolean show = (mName.getType()==EffectType.VERTEX); |
|
774 |
boolean showR= (show && act.getShowRegion()); |
|
775 |
boolean showC= (show && act.getShowCenter()); |
|
776 |
|
|
777 |
GenericSurfaceView view = act.findViewById(R.id.genericSurfaceView); |
|
778 |
view.getRenderer().showRegionAndCenter( showR,showC ); |
|
779 |
|
|
780 | 772 |
act.setCenter(mCenterSta.get1(),mCenterSta.get2(),mCenterSta.get3()); |
781 | 773 |
act.setRegion(mRegion4Sta.get1(),mRegion4Sta.get2(),mRegion4Sta.get3(), mRegion4Sta.get4()); |
782 | 774 |
} |
src/main/java/org/distorted/examples/generic/GenericTab.java | ||
---|---|---|
126 | 126 |
|
127 | 127 |
effectSpinner.setOnItemSelectedListener(this); |
128 | 128 |
effectSpinner.setAdapter(adapterEffect); |
129 |
|
|
130 |
resetData(); |
|
131 | 129 |
} |
132 | 130 |
|
131 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
132 |
|
|
133 |
@Override |
|
134 |
public void setUserVisibleHint(boolean isVisibleToUser) |
|
135 |
{ |
|
136 |
super.setUserVisibleHint(isVisibleToUser); |
|
137 |
|
|
138 |
if (isVisibleToUser) |
|
139 |
{ |
|
140 |
if( mType!=null ) |
|
141 |
{ |
|
142 |
GenericActivity2 act = (GenericActivity2)getActivity(); |
|
143 |
boolean region = act.getShowRegion(); |
|
144 |
boolean center = act.getShowCenter(); |
|
145 |
boolean showR = act.supportsRegion(mType); |
|
146 |
boolean showC = act.supportsCenter(mType); |
|
147 |
|
|
148 |
GenericSurfaceView sv = act.findViewById(R.id.genericSurfaceView); |
|
149 |
sv.getRenderer().showRegionAndCenter( (showR && region) , (showC && center) ); |
|
150 |
|
|
151 |
act.setCurrentEffectType(mType); |
|
152 |
} |
|
153 |
} |
|
154 |
} |
|
155 |
|
|
133 | 156 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
134 | 157 |
|
135 | 158 |
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) |
... | ... | |
146 | 169 |
{ |
147 | 170 |
} |
148 | 171 |
|
149 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
150 |
|
|
151 |
private void resetData() |
|
152 |
{ |
|
153 |
GenericActivity2 act = (GenericActivity2)getActivity(); |
|
154 |
GenericSurfaceView view = act.findViewById(R.id.genericSurfaceView); |
|
155 |
view.getRenderer().showRegionAndCenter(false,false); |
|
156 |
} |
|
157 |
|
|
158 | 172 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
159 | 173 |
|
160 | 174 |
void newEffect() |
... | ... | |
182 | 196 |
} |
183 | 197 |
|
184 | 198 |
eff.apply(mEffects); |
185 |
|
|
186 |
boolean region = act.getShowRegion(); |
|
187 |
boolean center = act.getShowCenter(); |
|
188 |
|
|
189 |
boolean show = (mEffectNames[mEffectAdd].getType()==EffectType.VERTEX); |
|
190 |
GenericSurfaceView sv = act.findViewById(R.id.genericSurfaceView); |
|
191 |
sv.getRenderer().showRegionAndCenter( (show && region) , (show && center) ); |
|
192 | 199 |
} |
193 | 200 |
|
194 | 201 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
226 | 233 |
layout.removeAllViews(); |
227 | 234 |
mEffects.abortByType(mType); |
228 | 235 |
|
229 |
resetData(); |
|
230 | 236 |
act.resetData(); |
231 | 237 |
|
232 | 238 |
if( mType==EffectType.MATRIX ) |
... | ... | |
267 | 273 |
mList.remove(effect); |
268 | 274 |
mChildren--; |
269 | 275 |
|
270 |
resetData(); |
|
271 |
|
|
272 | 276 |
break; |
273 | 277 |
} |
274 | 278 |
} |
Also available in: Unified diff
Improve the way Center & Region bitmaps are shown in the Generic app.