Revision 8dfa45c4
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
import org.distorted.examples.R; |
29 | 29 |
|
30 |
import org.distorted.library.effect.EffectName; |
|
31 |
import org.distorted.library.effect.MatrixEffectMove; |
|
32 |
import org.distorted.library.effect.MatrixEffectScale; |
|
33 |
import org.distorted.library.effect.VertexEffectDistort; |
|
34 |
import org.distorted.library.effect.VertexEffectSink; |
|
30 | 35 |
import org.distorted.library.main.Distorted; |
31 | 36 |
import org.distorted.library.main.DistortedScreen; |
32 | 37 |
import org.distorted.library.main.DistortedTexture; |
33 | 38 |
import org.distorted.library.main.DistortedEffects; |
34 |
import org.distorted.library.EffectNames; |
|
35 | 39 |
import org.distorted.library.main.MeshFlat; |
36 |
import org.distorted.library.EffectTypes; |
|
37 | 40 |
import org.distorted.library.type.Dynamic3D; |
38 | 41 |
import org.distorted.library.type.Static1D; |
39 | 42 |
import org.distorted.library.type.Static3D; |
... | ... | |
55 | 58 |
private MeshFlat mMesh; |
56 | 59 |
private DistortedScreen mScreen; |
57 | 60 |
private int bmpHeight, bmpWidth; |
58 |
|
|
61 |
private Static3D mScale; |
|
62 |
private Static3D[] mMove; |
|
63 |
|
|
59 | 64 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
60 | 65 |
|
61 | 66 |
DifferentBitmapsRenderer(GLSurfaceView v) |
... | ... | |
74 | 79 |
|
75 | 80 |
// Add the effects only to the first queue - all VERTEX and FRAGMENT effects are shared! |
76 | 81 |
// (Matrix effect cannot be shared as we have to display each Texture in a different location) |
77 |
mEffects[0].sink( new Static1D(8), mPoint, new Static4D(0,0,80,80)); // enlarge the nose |
|
78 |
mEffects[0].distort(dDistort,mPoint); // keep moving the whole bitmap left and right. |
|
82 |
VertexEffectSink sink = new VertexEffectSink(new Static1D(8), mPoint, new Static4D(0,0,80,80)); |
|
83 |
VertexEffectDistort distort = new VertexEffectDistort(dDistort,mPoint); |
|
84 |
mEffects[0].apply(sink); // enlarge the nose |
|
85 |
mEffects[0].apply(distort); // keep moving the whole bitmap left and right. |
|
86 |
|
|
87 |
// Now the Matrix effects |
|
88 |
mScale = new Static3D(1,1,1); |
|
89 |
MatrixEffectScale scaleEffect = new MatrixEffectScale(mScale); |
|
90 |
mMove = new Static3D[NUM]; |
|
91 |
MatrixEffectMove[] moveEffect = new MatrixEffectMove[NUM]; |
|
92 |
|
|
93 |
for(int i=0; i<NUM; i++) |
|
94 |
{ |
|
95 |
mMove[i] = new Static3D(0,0,0); |
|
96 |
moveEffect[i] = new MatrixEffectMove(mMove[i]); |
|
97 |
mEffects[i].apply(moveEffect[i]); |
|
98 |
mEffects[i].apply(scaleEffect); |
|
99 |
} |
|
79 | 100 |
|
80 | 101 |
mScreen = new DistortedScreen(mView); |
81 | 102 |
mScreen.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); |
... | ... | |
114 | 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
115 | 136 |
|
116 | 137 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
117 |
{ |
|
118 |
for(int i=NUM-1; i>=0; i--) |
|
119 |
{ |
|
120 |
mEffects[i].abortEffects(EffectTypes.MATRIX); |
|
121 |
} |
|
122 |
|
|
138 |
{ |
|
123 | 139 |
if( (float)bmpHeight/(NUM*bmpWidth) > (float)height/width ) |
124 | 140 |
{ |
125 | 141 |
int w = (height*bmpWidth)/bmpHeight; |
126 | 142 |
float factor = (float)height/bmpHeight; |
143 |
mScale.set(factor,factor,factor); |
|
127 | 144 |
|
128 | 145 |
for(int i=NUM-1; i>=0; i--) |
129 | 146 |
{ |
130 |
mEffects[i].move( new Static3D((width-NUM*w)/2 +i*w ,0,0) ); |
|
131 |
mEffects[i].scale(factor); |
|
147 |
mMove[i].set((width-NUM*w)/2 +i*w ,0,0); |
|
132 | 148 |
} |
133 | 149 |
} |
134 | 150 |
else |
... | ... | |
136 | 152 |
int w = width/NUM; |
137 | 153 |
int h = (width*bmpHeight)/(bmpWidth*NUM); |
138 | 154 |
float factor = (float)width/(bmpWidth*NUM); |
155 |
mScale.set(factor,factor,factor); |
|
139 | 156 |
|
140 | 157 |
for(int i=NUM-1; i>=0; i--) |
141 | 158 |
{ |
142 |
mEffects[i].move( new Static3D(i*w,(height-h)/2,0) ); |
|
143 |
mEffects[i].scale(factor); |
|
159 |
mMove[i].set(i*w,(height-h)/2,0); |
|
144 | 160 |
} |
145 | 161 |
} |
146 |
|
|
162 |
|
|
163 |
|
|
147 | 164 |
mScreen.resize(width, height); |
148 | 165 |
} |
149 | 166 |
|
... | ... | |
175 | 192 |
mScreen.detachAll(); |
176 | 193 |
for(int i=NUM-1; i>=0; i--) mScreen.attach(mTexture[i], mEffects[i], mMesh); |
177 | 194 |
|
178 |
DistortedEffects.enableEffect(EffectNames.SINK);
|
|
179 |
DistortedEffects.enableEffect(EffectNames.DISTORT);
|
|
195 |
DistortedEffects.enableEffect(EffectName.SINK); |
|
196 |
DistortedEffects.enableEffect(EffectName.DISTORT); |
|
180 | 197 |
|
181 | 198 |
try |
182 | 199 |
{ |
src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
import org.distorted.examples.R; |
29 | 29 |
|
30 |
import org.distorted.library.effect.EffectName; |
|
31 |
import org.distorted.library.effect.FragmentEffectChroma; |
|
32 |
import org.distorted.library.effect.MatrixEffectMove; |
|
33 |
import org.distorted.library.effect.MatrixEffectScale; |
|
34 |
import org.distorted.library.effect.VertexEffectDistort; |
|
35 |
import org.distorted.library.effect.VertexEffectSink; |
|
30 | 36 |
import org.distorted.library.main.Distorted; |
31 | 37 |
import org.distorted.library.main.DistortedEffects; |
32 | 38 |
import org.distorted.library.main.DistortedScreen; |
33 |
import org.distorted.library.EffectNames; |
|
34 | 39 |
import org.distorted.library.main.MeshFlat; |
35 | 40 |
import org.distorted.library.main.DistortedTexture; |
36 |
import org.distorted.library.EffectTypes; |
|
37 | 41 |
import org.distorted.library.type.Dynamic1D; |
38 | 42 |
import org.distorted.library.type.Dynamic3D; |
39 | 43 |
import org.distorted.library.type.Static1D; |
... | ... | |
56 | 60 |
private MeshFlat mMesh; |
57 | 61 |
private DistortedScreen mScreen; |
58 | 62 |
private int bmpHeight, bmpWidth; |
59 |
|
|
63 |
private Static3D mScale; |
|
64 |
private Static3D[] mMove; |
|
65 |
|
|
60 | 66 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
61 | 67 |
|
62 | 68 |
DifferentEffectsRenderer(GLSurfaceView v) |
... | ... | |
84 | 90 |
sink.add(new Static1D( 1)); |
85 | 91 |
sink.add(new Static1D(10)); |
86 | 92 |
|
87 |
mEffects[0].sink(sink, pLeft, RegionEye); |
|
88 |
mEffects[0].sink(sink, pRight,RegionEye); |
|
89 |
mEffects[1].distort(dyn, pNose1); |
|
93 |
VertexEffectSink sinkL = new VertexEffectSink(sink, pLeft , RegionEye); |
|
94 |
VertexEffectSink sinkR = new VertexEffectSink(sink, pRight, RegionEye); |
|
95 |
VertexEffectDistort distort = new VertexEffectDistort(dyn,pNose1); |
|
96 |
|
|
97 |
mEffects[0].apply(sinkL); |
|
98 |
mEffects[0].apply(sinkR); |
|
99 |
mEffects[1].apply(distort); |
|
90 | 100 |
|
91 | 101 |
Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f); |
92 | 102 |
chromaDyn.add(new Static1D(0)); |
93 | 103 |
chromaDyn.add(new Static1D(1)); |
94 | 104 |
|
95 |
mEffects[2].chroma(chromaDyn, new Static3D(0,1,0) ); |
|
105 |
FragmentEffectChroma chroma = new FragmentEffectChroma(chromaDyn, new Static3D(0,1,0)); |
|
106 |
mEffects[2].apply(chroma); |
|
107 |
|
|
108 |
mScale = new Static3D(1,1,1); |
|
109 |
MatrixEffectScale scaleEffect = new MatrixEffectScale(mScale); |
|
110 |
mMove = new Static3D[NUM]; |
|
111 |
MatrixEffectMove[] moveEffect = new MatrixEffectMove[NUM]; |
|
112 |
|
|
113 |
for(int i=0; i<NUM; i++) |
|
114 |
{ |
|
115 |
mMove[i] = new Static3D(0,0,0); |
|
116 |
moveEffect[i] = new MatrixEffectMove(mMove[i]); |
|
117 |
mEffects[i].apply(moveEffect[i]); |
|
118 |
mEffects[i].apply(scaleEffect); |
|
119 |
} |
|
96 | 120 |
|
97 | 121 |
mScreen = new DistortedScreen(mView); |
98 | 122 |
} |
... | ... | |
108 | 132 |
|
109 | 133 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
110 | 134 |
{ |
111 |
for(int i=NUM-1; i>=0; i--) |
|
112 |
{ |
|
113 |
mEffects[i].abortEffects(EffectTypes.MATRIX); |
|
114 |
} |
|
115 |
|
|
116 | 135 |
if( (float)bmpHeight/(NUM*bmpWidth) > (float)height/width ) |
117 | 136 |
{ |
118 | 137 |
int w = (height*bmpWidth)/bmpHeight; |
119 | 138 |
float factor = (float)height/bmpHeight; |
139 |
mScale.set(factor,factor,factor); |
|
120 | 140 |
|
121 | 141 |
for(int i=NUM-1; i>=0; i--) |
122 | 142 |
{ |
123 |
mEffects[i].move( new Static3D((width-NUM*w)/2 +i*w , 0, 0) ); |
|
124 |
mEffects[i].scale(factor); |
|
143 |
mMove[i].set((width-NUM*w)/2 +i*w , 0, 0); |
|
125 | 144 |
} |
145 |
|
|
126 | 146 |
} |
127 | 147 |
else |
128 | 148 |
{ |
129 | 149 |
int w = width/NUM; |
130 | 150 |
int h = (width*bmpHeight)/(bmpWidth*NUM); |
131 | 151 |
float factor = (float)width/(bmpWidth*NUM); |
152 |
mScale.set(factor,factor,factor); |
|
132 | 153 |
|
133 | 154 |
for(int i=NUM-1; i>=0; i--) |
134 | 155 |
{ |
135 |
mEffects[i].move( new Static3D(i*w, (height-h)/2, 0) ); |
|
136 |
mEffects[i].scale(factor); |
|
156 |
mMove[i].set(i*w, (height-h)/2, 0); |
|
137 | 157 |
} |
138 | 158 |
} |
139 | 159 |
|
... | ... | |
170 | 190 |
mScreen.detachAll(); |
171 | 191 |
for(int i=NUM-1; i>=0; i--) mScreen.attach(mTexture, mEffects[i], mMesh); |
172 | 192 |
|
173 |
DistortedEffects.enableEffect(EffectNames.SINK);
|
|
174 |
DistortedEffects.enableEffect(EffectNames.DISTORT);
|
|
175 |
DistortedEffects.enableEffect(EffectNames.CHROMA);
|
|
193 |
DistortedEffects.enableEffect(EffectName.SINK); |
|
194 |
DistortedEffects.enableEffect(EffectName.DISTORT); |
|
195 |
DistortedEffects.enableEffect(EffectName.CHROMA); |
|
176 | 196 |
|
177 | 197 |
try |
178 | 198 |
{ |
src/main/java/org/distorted/examples/effectqueue/EffectQueueActivity.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.effectqueue; |
21 | 21 |
|
22 |
import org.distorted.library.effect.Effect; |
|
23 |
import org.distorted.library.effect.EffectName; |
|
24 |
import org.distorted.library.effect.EffectType; |
|
22 | 25 |
import org.distorted.library.main.Distorted; |
23 | 26 |
import org.distorted.examples.R; |
24 |
import org.distorted.library.EffectNames; |
|
25 |
import org.distorted.library.EffectTypes; |
|
26 | 27 |
|
27 | 28 |
import android.app.Activity; |
28 | 29 |
import android.opengl.GLSurfaceView; |
... | ... | |
44 | 45 |
public class EffectQueueActivity extends Activity implements AdapterView.OnItemSelectedListener |
45 | 46 |
{ |
46 | 47 |
private Spinner mAdd, mID, mName, mType; |
47 |
private static ArrayAdapter<Long> mAdapterID;
|
|
48 |
private static ArrayAdapter<Effect> mAdapterID;
|
|
48 | 49 |
|
49 | 50 |
private int mPosID, mPosName, mPosType; |
50 | 51 |
private TableLayout mLayoutList; |
51 | 52 |
|
52 |
private HashMap<Long,TableRow> mMap = new HashMap<>();
|
|
53 |
private HashMap<Effect,TableRow> mMap = new HashMap<>();
|
|
53 | 54 |
|
54 | 55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
55 | 56 |
|
... | ... | |
74 | 75 |
mName.setOnItemSelectedListener(this); |
75 | 76 |
mType.setOnItemSelectedListener(this); |
76 | 77 |
|
77 |
ArrayList<Long> itemsID = new ArrayList<>();
|
|
78 |
ArrayList<Effect> itemsEffect = new ArrayList<>();
|
|
78 | 79 |
|
79 | 80 |
String[] itemsName = new String[] { getText(R.string.distort ).toString(), |
80 | 81 |
getText(R.string.sink ).toString(), |
... | ... | |
84 | 85 |
|
85 | 86 |
String[] itemsType = new String[] {"VERTEX", "FRAGMENT"}; |
86 | 87 |
|
87 |
mAdapterID = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, itemsID);
|
|
88 |
mAdapterID = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, itemsEffect);
|
|
88 | 89 |
mAdapterID.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
89 | 90 |
mID.setAdapter(mAdapterID); |
90 | 91 |
|
... | ... | |
169 | 170 |
{ |
170 | 171 |
try |
171 | 172 |
{ |
172 |
Long currID = (Long)mID.getItemAtPosition(mPosID);
|
|
173 |
Effect currEffect = (Effect)mID.getItemAtPosition(mPosID);
|
|
173 | 174 |
EffectQueueSurfaceView v = (EffectQueueSurfaceView) this.findViewById(R.id.effects2dSurfaceView); |
174 |
v.getRenderer().getEffects().abortEffect(currID);
|
|
175 |
v.getRenderer().getEffects().abortEffect(currEffect);
|
|
175 | 176 |
} |
176 | 177 |
catch(IndexOutOfBoundsException ex) |
177 | 178 |
{ |
... | ... | |
183 | 184 |
|
184 | 185 |
public void removeByName(View view) |
185 | 186 |
{ |
186 |
EffectNames name;
|
|
187 |
EffectName name; |
|
187 | 188 |
|
188 | 189 |
switch(mPosName) |
189 | 190 |
{ |
190 |
case 0: name = EffectNames.DISTORT ; break;
|
|
191 |
case 1: name = EffectNames.SINK ; break;
|
|
192 |
case 2: name = EffectNames.SMOOTH_ALPHA ; break;
|
|
193 |
case 3: name = EffectNames.SATURATION ; break;
|
|
194 |
case 4: name = EffectNames.SMOOTH_CHROMA; break;
|
|
195 |
default: name = EffectNames.CONTRAST ;
|
|
191 |
case 0: name = EffectName.DISTORT ; break; |
|
192 |
case 1: name = EffectName.SINK ; break; |
|
193 |
case 2: name = EffectName.SMOOTH_ALPHA ; break; |
|
194 |
case 3: name = EffectName.SATURATION ; break; |
|
195 |
case 4: name = EffectName.SMOOTH_CHROMA; break; |
|
196 |
default: name = EffectName.CONTRAST ; |
|
196 | 197 |
} |
197 | 198 |
|
198 | 199 |
EffectQueueSurfaceView v = (EffectQueueSurfaceView) this.findViewById(R.id.effects2dSurfaceView); |
199 |
v.getRenderer().getEffects().abortEffects(name);
|
|
200 |
v.getRenderer().getEffects().abortByName(name);
|
|
200 | 201 |
} |
201 | 202 |
|
202 | 203 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
203 | 204 |
|
204 | 205 |
public void removeByType(View view) |
205 | 206 |
{ |
206 |
EffectTypes type;
|
|
207 |
EffectType type; |
|
207 | 208 |
|
208 | 209 |
switch(mPosType) |
209 | 210 |
{ |
210 |
case 0: type = EffectTypes.VERTEX ; break;
|
|
211 |
case 1: type = EffectTypes.FRAGMENT; break;
|
|
212 |
default: type = EffectTypes.MATRIX;
|
|
211 |
case 0: type = EffectType.VERTEX ; break; |
|
212 |
case 1: type = EffectType.FRAGMENT; break; |
|
213 |
default: type = EffectType.MATRIX; |
|
213 | 214 |
} |
214 | 215 |
|
215 | 216 |
EffectQueueSurfaceView v = (EffectQueueSurfaceView) this.findViewById(R.id.effects2dSurfaceView); |
216 |
v.getRenderer().getEffects().abortEffects(type);
|
|
217 |
v.getRenderer().getEffects().abortByType(type);
|
|
217 | 218 |
} |
218 | 219 |
|
219 | 220 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
220 | 221 |
|
221 |
public void effectAdded(final long id, final EffectNames name, final EffectTypes type)
|
|
222 |
public void effectAdded(boolean success, final Effect effect)
|
|
222 | 223 |
{ |
223 |
if( id>=0 ) // we really added a new effect
|
|
224 |
if( success ) // we really added a new effect
|
|
224 | 225 |
{ |
225 |
mAdapterID.add(id);
|
|
226 |
mAdapterID.add(effect);
|
|
226 | 227 |
mAdapterID.notifyDataSetChanged(); |
227 | 228 |
|
228 | 229 |
TableRow tr = new TableRow(this); |
229 | 230 |
tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); |
230 | 231 |
|
231 | 232 |
TextView b1 = new TextView(this); |
232 |
b1.setText("ID: "+id);
|
|
233 |
b1.setText("ID: "+effect.getID());
|
|
233 | 234 |
b1.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); |
234 | 235 |
tr.addView(b1); |
235 | 236 |
|
236 | 237 |
TextView b2 = new TextView(this); |
237 |
b2.setText(name.name());
|
|
238 |
b2.setText(effect.getName().name());
|
|
238 | 239 |
b2.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); |
239 | 240 |
tr.addView(b2); |
240 | 241 |
|
241 | 242 |
TextView b3 = new TextView(this); |
242 |
b3.setText(type.name());
|
|
243 |
b3.setText(effect.getType().name());
|
|
243 | 244 |
b3.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); |
244 | 245 |
tr.addView(b3); |
245 | 246 |
|
... | ... | |
248 | 249 |
b4.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); |
249 | 250 |
tr.addView(b4); |
250 | 251 |
|
251 |
mMap.put(id,tr);
|
|
252 |
mMap.put(effect,tr);
|
|
252 | 253 |
|
253 | 254 |
mLayoutList.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT)); |
254 | 255 |
} |
... | ... | |
260 | 261 |
|
261 | 262 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
262 | 263 |
|
263 |
public void effectRemoved(final long id)
|
|
264 |
public void effectRemoved(final Effect effect)
|
|
264 | 265 |
{ |
265 | 266 |
runOnUiThread(new Runnable() |
266 | 267 |
{ |
267 | 268 |
public void run() |
268 | 269 |
{ |
269 |
mAdapterID.remove(id);
|
|
270 |
mAdapterID.remove(effect);
|
|
270 | 271 |
mAdapterID.notifyDataSetChanged(); |
271 | 272 |
|
272 |
TableRow row = mMap.remove(id);
|
|
273 |
TableRow row = mMap.remove(effect);
|
|
273 | 274 |
|
274 | 275 |
if( row!=null ) |
275 | 276 |
{ |
... | ... | |
277 | 278 |
} |
278 | 279 |
else |
279 | 280 |
{ |
280 |
android.util.Log.e("EFFECTS2D", "Impossible: id="+id+" not in the map!");
|
|
281 |
android.util.Log.e("EFFECTS2D", "Impossible: id="+effect.getID()+" not in the map!");
|
|
281 | 282 |
} |
282 | 283 |
} |
283 | 284 |
}); |
... | ... | |
285 | 286 |
|
286 | 287 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
287 | 288 |
|
288 |
public void effectFinished(final long id)
|
|
289 |
public void effectFinished(final Effect effect)
|
|
289 | 290 |
{ |
290 | 291 |
runOnUiThread(new Runnable() |
291 | 292 |
{ |
292 | 293 |
public void run() |
293 | 294 |
{ |
294 |
TableRow row = mMap.get(id);
|
|
295 |
TableRow row = mMap.get(effect);
|
|
295 | 296 |
|
296 | 297 |
if( row!=null ) |
297 | 298 |
{ |
src/main/java/org/distorted/examples/effectqueue/EffectQueueRenderer.java | ||
---|---|---|
28 | 28 |
import android.graphics.Paint.Style; |
29 | 29 |
import android.opengl.GLSurfaceView; |
30 | 30 |
|
31 |
import org.distorted.library.effect.EffectName; |
|
32 |
import org.distorted.library.effect.MatrixEffectScale; |
|
31 | 33 |
import org.distorted.library.main.DistortedEffects; |
32 | 34 |
import org.distorted.library.main.DistortedScreen; |
33 | 35 |
import org.distorted.library.main.MeshFlat; |
34 | 36 |
import org.distorted.library.main.DistortedTexture; |
35 | 37 |
import org.distorted.library.main.Distorted; |
36 |
import org.distorted.library.EffectNames; |
|
37 |
import org.distorted.library.EffectTypes; |
|
38 | 38 |
import org.distorted.library.message.EffectListener; |
39 | 39 |
import org.distorted.library.message.EffectMessage; |
40 | 40 |
import org.distorted.library.type.Static3D; |
... | ... | |
50 | 50 |
private EffectQueueSurfaceView mView; |
51 | 51 |
private Paint mPaint; |
52 | 52 |
private int texWidth, texHeight; |
53 |
private Static3D mScale; |
|
53 | 54 |
|
54 | 55 |
private DistortedTexture mTexture; |
55 | 56 |
private MeshFlat mMesh; |
... | ... | |
69 | 70 |
|
70 | 71 |
texWidth = BWID; |
71 | 72 |
texHeight= BHEI; |
73 |
mScale = new Static3D(1,1,1); |
|
74 |
MatrixEffectScale scaleEffect = new MatrixEffectScale(mScale); |
|
72 | 75 |
|
73 | 76 |
mMesh = new MeshFlat(80,80*texHeight/texWidth); |
74 | 77 |
mTexture = new DistortedTexture(texWidth,texHeight); |
75 | 78 |
mEffects = new DistortedEffects(); |
76 |
|
|
79 |
mEffects.apply(scaleEffect); |
|
77 | 80 |
mEffects.registerForMessages(this); |
78 | 81 |
|
79 | 82 |
mScreen = new DistortedScreen(mView); |
... | ... | |
107 | 110 |
mScreen.detachAll(); |
108 | 111 |
mScreen.attach(mTexture,mEffects,mMesh); |
109 | 112 |
|
110 |
DistortedEffects.enableEffect(EffectNames.DISTORT);
|
|
111 |
DistortedEffects.enableEffect(EffectNames.SINK);
|
|
112 |
DistortedEffects.enableEffect(EffectNames.SMOOTH_ALPHA);
|
|
113 |
DistortedEffects.enableEffect(EffectNames.SATURATION);
|
|
114 |
DistortedEffects.enableEffect(EffectNames.SMOOTH_CHROMA);
|
|
113 |
DistortedEffects.enableEffect(EffectName.DISTORT); |
|
114 |
DistortedEffects.enableEffect(EffectName.SINK); |
|
115 |
DistortedEffects.enableEffect(EffectName.SMOOTH_ALPHA); |
|
116 |
DistortedEffects.enableEffect(EffectName.SATURATION); |
|
117 |
DistortedEffects.enableEffect(EffectName.SMOOTH_CHROMA); |
|
115 | 118 |
|
116 | 119 |
try |
117 | 120 |
{ |
... | ... | |
127 | 130 |
|
128 | 131 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
129 | 132 |
{ |
130 |
mEffects.abortEffects(EffectTypes.MATRIX); |
|
131 |
mEffects.scale( new Static3D((float)width/texWidth,(float)height/texHeight,1) ); |
|
133 |
mScale.set((float)width/texWidth,(float)height/texHeight,1); |
|
132 | 134 |
mScreen.resize(width,height); |
133 | 135 |
mView.setScreenSize(width,height); |
134 | 136 |
} |
... | ... | |
143 | 145 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
144 | 146 |
// the library sending messages to us. This is running on a library 'MessageSender' thread. |
145 | 147 |
|
146 |
public void effectMessage(final EffectMessage em, final long effectID, final EffectNames effectName, final long objectID)
|
|
148 |
public void effectMessage(final EffectMessage em, final long effectID, final long objectID) |
|
147 | 149 |
{ |
148 | 150 |
EffectQueueActivity act = (EffectQueueActivity)mView.getContext(); |
149 | 151 |
|
src/main/java/org/distorted/examples/effectqueue/EffectQueueSurfaceView.java | ||
---|---|---|
24 | 24 |
import android.view.MotionEvent; |
25 | 25 |
import android.util.AttributeSet; |
26 | 26 |
|
27 |
import org.distorted.library.EffectNames; |
|
28 |
import org.distorted.library.EffectTypes; |
|
27 |
import org.distorted.library.effect.EffectName; |
|
28 |
import org.distorted.library.effect.EffectType; |
|
29 |
import org.distorted.library.effect.FragmentEffectAlpha; |
|
30 |
import org.distorted.library.effect.FragmentEffectChroma; |
|
31 |
import org.distorted.library.effect.FragmentEffectSaturation; |
|
32 |
import org.distorted.library.effect.VertexEffectDistort; |
|
33 |
import org.distorted.library.effect.VertexEffectSink; |
|
29 | 34 |
import org.distorted.library.type.Dynamic1D; |
30 | 35 |
import org.distorted.library.type.Static1D; |
31 | 36 |
import org.distorted.library.type.Static3D; |
... | ... | |
123 | 128 |
|
124 | 129 |
@Override public boolean onTouchEvent(MotionEvent event) |
125 | 130 |
{ |
126 |
int action = event.getAction(); |
|
127 |
int x, y; |
|
128 |
long id; |
|
131 |
int x,y,action = event.getAction(); |
|
132 |
boolean success; |
|
129 | 133 |
|
130 | 134 |
switch(action) |
131 | 135 |
{ |
... | ... | |
137 | 141 |
|
138 | 142 |
switch(mCurrentEffect) |
139 | 143 |
{ |
140 |
case 0: id = mRenderer.getEffects().distort(mInterD, mPoint, mRegionV); |
|
141 |
act.effectAdded(id, EffectNames.DISTORT, EffectTypes.VERTEX); |
|
144 |
case 0: VertexEffectDistort distort = new VertexEffectDistort(mInterD, mPoint, mRegionV); |
|
145 |
success = mRenderer.getEffects().apply(distort); |
|
146 |
act.effectAdded(success,distort); |
|
142 | 147 |
break; |
143 |
case 1: id = mRenderer.getEffects().sink(mInterS, mPoint, mRegionV); |
|
144 |
act.effectAdded(id, EffectNames.SINK, EffectTypes.VERTEX); |
|
148 |
case 1: VertexEffectSink sink = new VertexEffectSink(mInterS, mPoint, mRegionV); |
|
149 |
success = mRenderer.getEffects().apply(sink); |
|
150 |
act.effectAdded(success,sink); |
|
145 | 151 |
break; |
146 |
case 2: id = mRenderer.getEffects().alpha(mInterA, mRegionF, true); |
|
147 |
act.effectAdded(id, EffectNames.ALPHA, EffectTypes.FRAGMENT); |
|
152 |
case 2: FragmentEffectAlpha alpha = new FragmentEffectAlpha(mInterA, mRegionF, true); |
|
153 |
success = mRenderer.getEffects().apply(alpha); |
|
154 |
act.effectAdded(success,alpha); |
|
148 | 155 |
break; |
149 |
case 3: id = mRenderer.getEffects().saturation(mInterB, mRegionF, false); |
|
150 |
act.effectAdded(id, EffectNames.SATURATION, EffectTypes.FRAGMENT); |
|
156 |
case 3: FragmentEffectSaturation saturation = new FragmentEffectSaturation(mInterB, mRegionF, false); |
|
157 |
success = mRenderer.getEffects().apply(saturation); |
|
158 |
act.effectAdded(success,saturation); |
|
151 | 159 |
break; |
152 |
case 4: id = mRenderer.getEffects().chroma(mInterC, mRED, mRegionF, true); |
|
153 |
act.effectAdded(id, EffectNames.CHROMA, EffectTypes.FRAGMENT); |
|
160 |
case 4: FragmentEffectChroma chroma = new FragmentEffectChroma(mInterC, mRED, mRegionF, true); |
|
161 |
success = mRenderer.getEffects().apply(chroma); |
|
162 |
act.effectAdded(success,chroma); |
|
154 | 163 |
break; |
155 | 164 |
} |
156 | 165 |
|
src/main/java/org/distorted/examples/matrix3d/Matrix3DActivity.java | ||
---|---|---|
36 | 36 |
import org.distorted.library.main.MeshCubes; |
37 | 37 |
import org.distorted.library.main.MeshObject; |
38 | 38 |
import org.distorted.library.main.DistortedTexture; |
39 |
import org.distorted.library.EffectNames; |
|
40 |
import org.distorted.library.EffectTypes; |
|
41 | 39 |
|
42 | 40 |
import java.io.IOException; |
43 | 41 |
import java.io.InputStream; |
src/main/java/org/distorted/examples/save/SaveRenderer.java | ||
---|---|---|
30 | 30 |
|
31 | 31 |
import org.distorted.examples.R; |
32 | 32 |
|
33 |
import org.distorted.library.effect.Effect; |
|
34 |
import org.distorted.library.effect.VertexEffectSink; |
|
33 | 35 |
import org.distorted.library.main.Distorted; |
34 | 36 |
import org.distorted.library.main.DistortedEffects; |
35 | 37 |
import org.distorted.library.main.DistortedScreen; |
36 | 38 |
import org.distorted.library.main.DistortedTexture; |
37 |
import org.distorted.library.EffectNames; |
|
38 | 39 |
import org.distorted.library.main.MeshFlat; |
39 | 40 |
import org.distorted.library.main.DistortedFramebuffer; |
40 |
import org.distorted.library.EffectTypes; |
|
41 | 41 |
import org.distorted.library.type.Dynamic1D; |
42 | 42 |
import org.distorted.library.type.Dynamic3D; |
43 | 43 |
import org.distorted.library.type.Static1D; |
... | ... | |
155 | 155 |
|
156 | 156 |
if( isSaving ) // render to an offscreen buffer and read pixels |
157 | 157 |
{ |
158 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
158 |
mEffects.abortByType(Effect.MATRIX);
|
|
159 | 159 |
mEffects.scale(mScaleFactor); |
160 | 160 |
mOffscreen.render(time); |
161 | 161 |
applyMatrixEffects(scrWidth,scrHeight); |
... | ... | |
188 | 188 |
|
189 | 189 |
private void applyMatrixEffects(int width, int height) |
190 | 190 |
{ |
191 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
191 |
mEffects.abortByType(Effect.MATRIX);
|
|
192 | 192 |
|
193 | 193 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
194 | 194 |
{ |
... | ... | |
254 | 254 |
mScreen.detachAll(); |
255 | 255 |
mScreen.attach(mTexture,mEffects,mMesh); |
256 | 256 |
|
257 |
DistortedEffects.enableEffect(EffectNames.SINK);
|
|
257 |
DistortedEffects.enableEffect(org.distorted.library.effect.VertexEffectSink.class);
|
|
258 | 258 |
|
259 | 259 |
try |
260 | 260 |
{ |
Also available in: Unified diff
Some progress with Effect classes.
10 apps compile now.