Revision 3f07bedc
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/effects2d/Effects2DSurfaceView.java | ||
---|---|---|
39 | 39 |
public class Effects2DSurfaceView extends GLSurfaceView |
40 | 40 |
{ |
41 | 41 |
private Effects2DRenderer mRenderer; |
42 |
private static int mCurrentEffect; |
|
43 |
private static int mDuration; |
|
44 |
private static float mCount; |
|
45 |
private static int mScrW, mScrH; |
|
42 |
private int mCurrentEffect; |
|
43 |
private int mScrW, mScrH; |
|
46 | 44 |
|
47 |
private static Static4D region; |
|
48 |
private static Static2D point; |
|
49 |
|
|
50 |
private static Static4D mRegion; |
|
51 |
private static Dynamic1D mInterA, mInterB, mInterC, mInterS; |
|
52 |
|
|
53 |
private static Dynamic3D mInterD; |
|
54 |
private static Static3D v0, v1, v2, v3; |
|
45 |
private Static4D mRegionV, mRegionF; |
|
46 |
private Static2D mPoint; |
|
47 |
private Dynamic1D mInterA, mInterB, mInterC, mInterS; |
|
48 |
private Dynamic3D mInterD; |
|
55 | 49 |
|
56 | 50 |
private final static Static3D mRED = new Static3D(1,0,0); |
57 | 51 |
|
... | ... | |
61 | 55 |
{ |
62 | 56 |
super(c, attrs); |
63 | 57 |
|
64 |
mDuration = 10000; |
|
65 |
mCount = 1.0f; |
|
66 |
|
|
67 |
mInterD = new Dynamic3D(mDuration,mCount); |
|
68 |
|
|
58 |
int duration = 10000; |
|
59 |
float count = 1.0f; |
|
69 | 60 |
int h = 30; |
70 | 61 |
int r = 20; |
71 | 62 |
|
72 |
v0 = new Static3D( 0, r, h ); |
|
73 |
v1 = new Static3D(-r, 0, h ); |
|
74 |
v2 = new Static3D( 0,-r, h ); |
|
75 |
v3 = new Static3D( r, 0, h ); |
|
63 |
mInterD = new Dynamic3D(duration,count); |
|
76 | 64 |
|
77 |
mInterD.add(v0);
|
|
78 |
mInterD.add(v1);
|
|
79 |
mInterD.add(v2);
|
|
80 |
mInterD.add(v3);
|
|
65 |
mInterD.add(new Static3D( 0, r, h ));
|
|
66 |
mInterD.add(new Static3D(-r, 0, h ));
|
|
67 |
mInterD.add(new Static3D( 0,-r, h ));
|
|
68 |
mInterD.add(new Static3D( r, 0, h ));
|
|
81 | 69 |
|
82 |
mInterA = new Dynamic1D(mDuration,mCount);
|
|
70 |
mInterA = new Dynamic1D(duration,count);
|
|
83 | 71 |
mInterA.add(new Static1D(1)); |
84 | 72 |
mInterA.add(new Static1D(0)); |
85 | 73 |
|
86 |
mInterS = new Dynamic1D(mDuration,mCount);
|
|
74 |
mInterS = new Dynamic1D(duration,count);
|
|
87 | 75 |
mInterS.add(new Static1D(1.0f)); |
88 | 76 |
mInterS.add(new Static1D(0.3f)); |
89 | 77 |
|
90 |
mInterC = new Dynamic1D(mDuration,mCount);
|
|
78 |
mInterC = new Dynamic1D(duration,count);
|
|
91 | 79 |
mInterC.add(new Static1D(1)); |
92 | 80 |
mInterC.add(new Static1D(0)); |
93 | 81 |
|
94 |
mInterB = new Dynamic1D(mDuration,mCount);
|
|
82 |
mInterB = new Dynamic1D(duration,count);
|
|
95 | 83 |
mInterB.add(new Static1D(0)); |
96 | 84 |
mInterB.add(new Static1D(1)); |
97 | 85 |
|
... | ... | |
110 | 98 |
mRenderer = new Effects2DRenderer(this); |
111 | 99 |
setRenderer(mRenderer); |
112 | 100 |
|
113 |
point = new Static2D(0,0);
|
|
114 |
region= new Static4D(0,0,60,60);
|
|
115 |
mRegion = new Static4D(0,0,60,60);
|
|
101 |
mPoint = new Static2D(0,0);
|
|
102 |
mRegionV= new Static4D(0,0,60,60);
|
|
103 |
mRegionF= new Static4D(0,0,60,60);
|
|
116 | 104 |
|
117 | 105 |
setEffect(0); |
118 | 106 |
} |
... | ... | |
120 | 108 |
|
121 | 109 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
122 | 110 |
|
123 |
public static void setScreenSize(int width, int height) |
|
111 |
Effects2DRenderer getRenderer() |
|
112 |
{ |
|
113 |
return mRenderer; |
|
114 |
} |
|
115 |
|
|
116 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
117 |
|
|
118 |
public void setScreenSize(int width, int height) |
|
124 | 119 |
{ |
125 | 120 |
mScrW = width; |
126 | 121 |
mScrH = height; |
... | ... | |
128 | 123 |
|
129 | 124 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
130 | 125 |
|
131 |
public static void setEffect(int effect)
|
|
126 |
public void setEffect(int effect) |
|
132 | 127 |
{ |
133 | 128 |
mCurrentEffect = effect; |
134 | 129 |
} |
... | ... | |
143 | 138 |
|
144 | 139 |
switch(action) |
145 | 140 |
{ |
146 |
case MotionEvent.ACTION_DOWN: x = (int)event.getX()* Effects2DRenderer.BWID/mScrW;
|
|
147 |
y = (int)event.getY()* Effects2DRenderer.BHEI/mScrH;
|
|
148 |
point.set(x,y);
|
|
149 |
mRegion.set(x,y,60,60); |
|
141 |
case MotionEvent.ACTION_DOWN: x = (int)event.getX()* mRenderer.BWID/mScrW;
|
|
142 |
y = (int)event.getY()* mRenderer.BHEI/mScrH;
|
|
143 |
mPoint.set(x,y);
|
|
144 |
mRegionF.set(x,y,60,60);
|
|
150 | 145 |
Effects2DActivity act = (Effects2DActivity)getContext(); |
151 | 146 |
|
152 | 147 |
switch(mCurrentEffect) |
153 | 148 |
{ |
154 |
case 0: id = Effects2DRenderer.mBackground.distort(mInterD, point, region);
|
|
149 |
case 0: id = mRenderer.mBackground.distort(mInterD, mPoint, mRegionV);
|
|
155 | 150 |
act.effectAdded(id, EffectNames.DISTORT, EffectTypes.VERTEX); |
156 | 151 |
break; |
157 |
case 1: id = Effects2DRenderer.mBackground.sink(mInterS, point, region);
|
|
152 |
case 1: id = mRenderer.mBackground.sink(mInterS, mPoint, mRegionV);
|
|
158 | 153 |
act.effectAdded(id, EffectNames.SINK, EffectTypes.VERTEX); |
159 | 154 |
break; |
160 |
case 2: id = Effects2DRenderer.mBackground.alpha(mInterA, mRegion, true);
|
|
155 |
case 2: id = mRenderer.mBackground.alpha(mInterA, mRegionF, true);
|
|
161 | 156 |
act.effectAdded(id, EffectNames.ALPHA, EffectTypes.FRAGMENT); |
162 | 157 |
break; |
163 |
case 3: id = Effects2DRenderer.mBackground.saturation(mInterB, mRegion, false);
|
|
158 |
case 3: id = mRenderer.mBackground.saturation(mInterB, mRegionF, false);
|
|
164 | 159 |
act.effectAdded(id, EffectNames.SATURATION, EffectTypes.FRAGMENT); |
165 | 160 |
break; |
166 |
case 4: id = Effects2DRenderer.mBackground.chroma(mInterC, mRED, mRegion, true);
|
|
161 |
case 4: id = mRenderer.mBackground.chroma(mInterC, mRED, mRegionF, true);
|
|
167 | 162 |
act.effectAdded(id, EffectNames.CHROMA, EffectTypes.FRAGMENT); |
168 | 163 |
break; |
169 | 164 |
} |
Also available in: Unified diff
Tidy up the 'Effects3D'