Revision a418b421
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/effects3d/Effects3DActivity.java | ||
---|---|---|
38 | 38 |
import android.widget.TableRow; |
39 | 39 |
|
40 | 40 |
import org.distorted.examples.R; |
41 |
import org.distorted.library.effect.EffectName; |
|
42 |
import org.distorted.library.effect.EffectType; |
|
41 | 43 |
import org.distorted.library.main.Distorted; |
42 | 44 |
import org.distorted.library.main.MeshCubes; |
43 | 45 |
import org.distorted.library.main.MeshFlat; |
... | ... | |
78 | 80 |
private float mCenterX, mCenterY, mCenterZ; |
79 | 81 |
private float mRegionX, mRegionY, mRegionR; |
80 | 82 |
|
81 |
private EffectNames[] mEffectNames;
|
|
83 |
private EffectName[] mEffectNames; |
|
82 | 84 |
|
83 | 85 |
private static boolean mSupportsRegion; |
84 | 86 |
private static boolean mSupportsCenter; |
... | ... | |
167 | 169 |
|
168 | 170 |
private void createEffectNames() |
169 | 171 |
{ |
170 |
EffectTypes type1 = EffectTypes.FRAGMENT;
|
|
171 |
EffectTypes type2 = EffectTypes.VERTEX;
|
|
172 |
EffectType type1 = EffectType.FRAGMENT;
|
|
173 |
EffectType type2 = EffectType.VERTEX;
|
|
172 | 174 |
|
173 |
EffectNames[] names = EffectNames.values();
|
|
175 |
EffectName[] names = EffectName.values();
|
|
174 | 176 |
|
175 | 177 |
int numEffects=0; |
176 | 178 |
|
177 | 179 |
for(int i=0; i<names.length; i++) |
178 | 180 |
if( names[i].getType() == type1 || names[i].getType() == type2 ) numEffects++; |
179 | 181 |
|
180 |
mEffectNames = new EffectNames[numEffects];
|
|
182 |
mEffectNames = new EffectName[numEffects]; |
|
181 | 183 |
|
182 | 184 |
numEffects=0; |
183 | 185 |
|
... | ... | |
569 | 571 |
|
570 | 572 |
eff.apply(mEffects); |
571 | 573 |
|
572 |
boolean show = (mEffectNames[mEffectAdd].getType()==EffectTypes.VERTEX);
|
|
574 |
boolean show = (mEffectNames[mEffectAdd].getType()==EffectType.VERTEX); |
|
573 | 575 |
Effects3DSurfaceView sv = (Effects3DSurfaceView)findViewById(R.id.effects3dSurfaceView); |
574 | 576 |
sv.getRenderer().showRegionAndCenter( (show && mShowRegion) , (show && mShowCenter) ); |
575 | 577 |
} |
... | ... | |
581 | 583 |
mList.clear(); |
582 | 584 |
LinearLayout layout = (LinearLayout)findViewById(R.id.effects3dlayout); |
583 | 585 |
layout.removeAllViews(); |
584 |
mEffects.abortEffects(EffectTypes.VERTEX);
|
|
585 |
mEffects.abortEffects(EffectTypes.FRAGMENT);
|
|
586 |
mEffects.abortByType(EffectType.VERTEX);
|
|
587 |
mEffects.abortByType(EffectType.FRAGMENT);
|
|
586 | 588 |
|
587 | 589 |
resetData(); |
588 | 590 |
|
... | ... | |
613 | 615 |
view = effect.getRegion(); |
614 | 616 |
if( view!=null ) layout.removeView(view); |
615 | 617 |
|
616 |
mEffects.abortEffect(effect.getId());
|
|
618 |
mEffects.abortById(effect.getId());
|
|
617 | 619 |
mList.remove(effect); |
618 | 620 |
|
619 | 621 |
resetData(); |
src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java | ||
---|---|---|
24 | 24 |
import android.widget.TextView; |
25 | 25 |
|
26 | 26 |
import org.distorted.examples.R; |
27 |
import org.distorted.library.effect.EffectName; |
|
28 |
import org.distorted.library.effect.EffectType; |
|
27 | 29 |
import org.distorted.library.main.DistortedEffects; |
28 | 30 |
import org.distorted.library.type.Dynamic1D; |
29 | 31 |
import org.distorted.library.type.Dynamic2D; |
... | ... | |
44 | 46 |
{ |
45 | 47 |
private WeakReference<Effects3DActivity> mAct; |
46 | 48 |
|
47 |
private EffectNames mName;
|
|
49 |
private EffectName mName; |
|
48 | 50 |
private int[] mInter; |
49 | 51 |
private int[] mInterRegion; |
50 | 52 |
private int[] mInterCenter; |
... | ... | |
203 | 205 |
case 1: mInter[0] = 50; |
204 | 206 |
} |
205 | 207 |
|
206 |
if( mName==EffectNames.ROTATE || mName==EffectNames.QUATERNION ) mInter[1]= 100;
|
|
208 |
if( mName==EffectName.ROTATE || mName==EffectName.QUATERNION ) mInter[1]= 100;
|
|
207 | 209 |
} |
208 | 210 |
|
209 | 211 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
297 | 299 |
float factorX = act.getWidth() / 100.0f; |
298 | 300 |
float factorY = act.getHeight()/ 100.0f; |
299 | 301 |
|
300 |
int deduct = (mName.getType() == EffectTypes.VERTEX ? 50:0);
|
|
302 |
int deduct = (mName.getType() == EffectType.VERTEX ? 50:0); |
|
301 | 303 |
|
302 | 304 |
float x = (mInterRegion[0]-deduct)*factorX; |
303 | 305 |
float y = (mInterRegion[1]-deduct)*factorY; |
... | ... | |
331 | 333 |
|
332 | 334 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
333 | 335 |
|
334 |
Effects3DEffect(EffectNames name, Effects3DActivity act)
|
|
336 |
Effects3DEffect(EffectName name, Effects3DActivity act) |
|
335 | 337 |
{ |
336 | 338 |
mAct = new WeakReference<>(act); |
337 | 339 |
mName = name; |
... | ... | |
363 | 365 |
mSta3 = new Static3D(0,0,0); |
364 | 366 |
mDyn3.add(mSta3); |
365 | 367 |
break; |
366 |
case 4 : if( mName == EffectNames.ROTATE || mName == EffectNames.QUATERNION )
|
|
368 |
case 4 : if( mName == EffectName.ROTATE || mName == EffectName.QUATERNION )
|
|
367 | 369 |
{ |
368 | 370 |
mDyn4 = new Dynamic4D(); |
369 | 371 |
mSta4 = new Static4D(0,0,0,0); |
... | ... | |
636 | 638 |
{ |
637 | 639 |
Effects3DActivity act = mAct.get(); |
638 | 640 |
|
639 |
boolean show = (mName.getType()==EffectTypes.VERTEX);
|
|
641 |
boolean show = (mName.getType()==EffectType.VERTEX); |
|
640 | 642 |
boolean showR= (show && act.getShowRegion()); |
641 | 643 |
boolean showC= (show && act.getShowCenter()); |
642 | 644 |
|
src/main/java/org/distorted/examples/matrix3d/Matrix3DActivity.java | ||
---|---|---|
31 | 31 |
import android.widget.Spinner; |
32 | 32 |
|
33 | 33 |
import org.distorted.examples.R; |
34 |
import org.distorted.library.effect.EffectName; |
|
35 |
import org.distorted.library.effect.EffectType; |
|
34 | 36 |
import org.distorted.library.main.Distorted; |
35 | 37 |
import org.distorted.library.main.DistortedEffects; |
36 | 38 |
import org.distorted.library.main.MeshCubes; |
... | ... | |
52 | 54 |
private ArrayList<Matrix3DEffect> mList; |
53 | 55 |
private int mEffectAdd; |
54 | 56 |
|
55 |
private EffectNames[] mEffectNames;
|
|
57 |
private EffectName[] mEffectNames; |
|
56 | 58 |
|
57 | 59 |
private static boolean mSupportsCenter; |
58 | 60 |
|
... | ... | |
78 | 80 |
|
79 | 81 |
private void createEffectNames() |
80 | 82 |
{ |
81 |
EffectTypes type = EffectTypes.MATRIX;
|
|
83 |
EffectType type = EffectType.MATRIX;
|
|
82 | 84 |
|
83 |
EffectNames[] names = EffectNames.values();
|
|
85 |
EffectName[] names = EffectName.values();
|
|
84 | 86 |
|
85 | 87 |
int numEffects=0; |
86 | 88 |
|
87 | 89 |
for(int i=0; i<names.length; i++) |
88 | 90 |
if( names[i].getType() == type ) numEffects++; |
89 | 91 |
|
90 |
mEffectNames = new EffectNames[numEffects];
|
|
92 |
mEffectNames = new EffectName[numEffects]; |
|
91 | 93 |
|
92 | 94 |
numEffects=0; |
93 | 95 |
|
... | ... | |
275 | 277 |
mList.clear(); |
276 | 278 |
LinearLayout layout = (LinearLayout)findViewById(R.id.matrix3dlayout); |
277 | 279 |
layout.removeAllViews(); |
278 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
280 |
mEffects.abortByType(EffectType.MATRIX);
|
|
279 | 281 |
|
280 | 282 |
resetData(); |
281 | 283 |
} |
... | ... | |
298 | 300 |
view = effect.getRegion(); |
299 | 301 |
if( view!=null ) layout.removeView(view); |
300 | 302 |
|
301 |
mEffects.abortEffect(effect.getId());
|
|
303 |
mEffects.abortById(effect.getId());
|
|
302 | 304 |
mList.remove(effect); |
303 | 305 |
|
304 | 306 |
resetData(); |
src/main/java/org/distorted/examples/matrix3d/Matrix3DEffect.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import org.distorted.examples.R; |
27 | 27 |
import org.distorted.library.effect.EffectName; |
28 |
import org.distorted.library.effect.EffectType; |
|
28 | 29 |
import org.distorted.library.main.DistortedEffects; |
29 | 30 |
import org.distorted.library.type.Dynamic1D; |
30 | 31 |
import org.distorted.library.type.Dynamic2D; |
... | ... | |
204 | 205 |
case 1: mInter[0] = 50; |
205 | 206 |
} |
206 | 207 |
|
207 |
if( mName==EffectNames.ROTATE || mName==EffectNames.QUATERNION )
|
|
208 |
if( mName==EffectName.ROTATE || mName==EffectName.QUATERNION )
|
|
208 | 209 |
{ |
209 | 210 |
mInter[1]= 100; |
210 | 211 |
} |
211 |
if( mName==EffectNames.SCALE )
|
|
212 |
if( mName==EffectName.SCALE ) |
|
212 | 213 |
{ |
213 | 214 |
mInter[0]= 60; |
214 | 215 |
mInter[1]= 60; |
... | ... | |
307 | 308 |
float factorX = act.getWidth() / 100.0f; |
308 | 309 |
float factorY = act.getHeight()/ 100.0f; |
309 | 310 |
|
310 |
int deduct = (mName.getType() == EffectTypes.VERTEX ? 50:0);
|
|
311 |
int deduct = (mName.getType() == EffectType.VERTEX ? 50:0); |
|
311 | 312 |
|
312 | 313 |
float x = (mInterRegion[0]-deduct)*factorX; |
313 | 314 |
float y = (mInterRegion[1]-deduct)*factorY; |
... | ... | |
341 | 342 |
|
342 | 343 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
343 | 344 |
|
344 |
Matrix3DEffect(EffectNames name, Matrix3DActivity act)
|
|
345 |
Matrix3DEffect(EffectName name, Matrix3DActivity act) |
|
345 | 346 |
{ |
346 | 347 |
mAct = new WeakReference<>(act); |
347 | 348 |
mName = name; |
... | ... | |
373 | 374 |
mSta3 = new Static3D(0,0,0); |
374 | 375 |
mDyn3.add(mSta3); |
375 | 376 |
break; |
376 |
case 4 : if( mName == EffectNames.ROTATE || mName == EffectNames.QUATERNION )
|
|
377 |
case 4 : if( mName == EffectName.ROTATE || mName == EffectName.QUATERNION )
|
|
377 | 378 |
{ |
378 | 379 |
mDyn4 = new Dynamic4D(); |
379 | 380 |
mSta4 = new Static4D(0,0,0,0); |
Also available in: Unified diff
Progress with the last 2 APPs.