22 |
22 |
import android.app.Activity;
|
23 |
23 |
import android.opengl.GLSurfaceView;
|
24 |
24 |
import android.os.Bundle;
|
|
25 |
import android.view.Gravity;
|
25 |
26 |
import android.view.View;
|
|
27 |
import android.widget.Button;
|
26 |
28 |
import android.widget.LinearLayout;
|
|
29 |
import android.widget.NumberPicker;
|
27 |
30 |
import android.widget.SeekBar;
|
28 |
31 |
import android.widget.SeekBar.OnSeekBarChangeListener;
|
|
32 |
import android.widget.TableRow;
|
29 |
33 |
import android.widget.TextView;
|
30 |
34 |
|
31 |
35 |
import org.distorted.examples.R;
|
... | ... | |
34 |
38 |
|
35 |
39 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
36 |
40 |
|
37 |
|
public class Vertex3DActivity extends Activity implements OnSeekBarChangeListener
|
38 |
|
{
|
39 |
|
private SeekBar bar;
|
40 |
|
private TextView textDeform, textDistort, textSink, textSwirl;
|
41 |
|
private int deformX, deformY, deformZ;
|
42 |
|
private int distortX, distortY, distortZ;
|
43 |
|
private int sinkA;
|
44 |
|
private int swirlA;
|
|
41 |
public class Vertex3DActivity extends Activity implements OnSeekBarChangeListener, View.OnClickListener
|
|
42 |
{
|
|
43 |
private boolean firstScreen;
|
|
44 |
|
|
45 |
// fields needed for the first 'pick-a-shape' screen
|
|
46 |
//
|
|
47 |
private static int mNumCols = 3;
|
|
48 |
private static int mNumRows = 3;
|
|
49 |
|
|
50 |
private static final int COLOR_OFF = 0xffffe81f;
|
|
51 |
private static final int COLOR_ON = 0xff0000ff;
|
|
52 |
|
|
53 |
private NumberPicker mColsPicker, mRowsPicker;
|
|
54 |
private LinearLayout mLay;
|
|
55 |
private static boolean[] mShape;
|
|
56 |
|
|
57 |
// fields needed for the second 'apply vertex effects' screen
|
|
58 |
//
|
|
59 |
private SeekBar bar;
|
|
60 |
private TextView textDeform, textDistort, textSink, textSwirl;
|
|
61 |
private int deformX, deformY, deformZ;
|
|
62 |
private int distortX, distortY, distortZ;
|
|
63 |
private int sinkA;
|
|
64 |
private int swirlA;
|
45 |
65 |
|
46 |
|
private int maxX, maxY, maxZ;
|
47 |
|
|
48 |
|
private float fdeformX, fdeformY, fdeformZ;
|
49 |
|
private float fdistortX, fdistortY, fdistortZ;
|
50 |
|
private float fsinkA;
|
51 |
|
private float fswirlA;
|
|
66 |
private int maxX, maxY, maxZ;
|
|
67 |
|
|
68 |
private float fdeformX, fdeformY, fdeformZ;
|
|
69 |
private float fdistortX, fdistortY, fdistortZ;
|
|
70 |
private float fsinkA;
|
|
71 |
private float fswirlA;
|
52 |
72 |
|
53 |
|
private EffectNames[] effects = new EffectNames[4];
|
|
73 |
private EffectNames[] effects = new EffectNames[4];
|
54 |
74 |
|
55 |
75 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
56 |
76 |
|
57 |
|
@Override
|
58 |
|
protected void onCreate(Bundle icicle)
|
|
77 |
@Override
|
|
78 |
protected void onCreate(Bundle savedState)
|
|
79 |
{
|
|
80 |
super.onCreate(savedState);
|
|
81 |
|
|
82 |
setContentView(R.layout.cubes1layout);
|
|
83 |
|
|
84 |
mLay = (LinearLayout)findViewById(R.id.buttongrid);
|
|
85 |
|
|
86 |
mColsPicker = (NumberPicker)findViewById(R.id.colsPicker);
|
|
87 |
mRowsPicker = (NumberPicker)findViewById(R.id.rowsPicker);
|
|
88 |
|
|
89 |
mColsPicker.setMaxValue(10);
|
|
90 |
mColsPicker.setMinValue( 0);
|
|
91 |
mRowsPicker.setMaxValue(10);
|
|
92 |
mRowsPicker.setMinValue( 0);
|
|
93 |
|
|
94 |
mColsPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener()
|
59 |
95 |
{
|
60 |
|
super.onCreate(icicle);
|
61 |
|
setContentView(R.layout.vertex3dlayout);
|
62 |
|
Default(null);
|
63 |
|
}
|
|
96 |
@Override
|
|
97 |
public void onValueChange(NumberPicker picker, int oldVal, int newVal)
|
|
98 |
{
|
|
99 |
setGrid();
|
|
100 |
}
|
|
101 |
});
|
|
102 |
|
|
103 |
mRowsPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener()
|
|
104 |
{
|
|
105 |
@Override
|
|
106 |
public void onValueChange(NumberPicker picker, int oldVal, int newVal)
|
|
107 |
{
|
|
108 |
setGrid();
|
|
109 |
}
|
|
110 |
});
|
|
111 |
|
|
112 |
firstScreen = true;
|
|
113 |
}
|
|
114 |
|
|
115 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
116 |
// 'first screen' methods
|
|
117 |
|
|
118 |
public static int getCols()
|
|
119 |
{
|
|
120 |
return mNumCols;
|
|
121 |
}
|
64 |
122 |
|
65 |
123 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
66 |
124 |
|
67 |
|
public void Default(View view)
|
|
125 |
public static String getShape()
|
|
126 |
{
|
|
127 |
String str = "";
|
|
128 |
|
|
129 |
for(int i=0; i<mNumRows*mNumCols; i++)
|
|
130 |
str += mShape[i] ? "1" : "0";
|
|
131 |
|
|
132 |
//android.util.Log.d("CUBES", str);
|
|
133 |
|
|
134 |
return str;
|
|
135 |
}
|
|
136 |
|
|
137 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
138 |
|
|
139 |
public void setGrid()
|
|
140 |
{
|
|
141 |
mNumCols = mColsPicker.getValue();
|
|
142 |
mNumRows = mRowsPicker.getValue();
|
|
143 |
|
|
144 |
int width = mLay.getWidth();
|
|
145 |
int height= mLay.getHeight();
|
|
146 |
int w = mNumCols>0 ? (width / mNumCols) -10 : 0;
|
|
147 |
int h = mNumRows>0 ? (height/ mNumRows) -10 : 0;
|
|
148 |
int size= w<h ? w:h;
|
|
149 |
int pad = size/20;
|
|
150 |
|
|
151 |
mLay.removeAllViews();
|
|
152 |
|
|
153 |
mShape = new boolean[mNumRows*mNumCols];
|
|
154 |
|
|
155 |
TableRow.LayoutParams p = new android.widget.TableRow.LayoutParams();
|
|
156 |
|
|
157 |
p.rightMargin = pad;
|
|
158 |
p.leftMargin = pad;
|
|
159 |
p.topMargin = pad;
|
|
160 |
p.bottomMargin = pad;
|
|
161 |
p.height = size;
|
|
162 |
p.width = size;
|
|
163 |
|
|
164 |
for (int rows=0; rows<mNumRows; rows++)
|
68 |
165 |
{
|
69 |
|
effects[0] = EffectNames.DEFORM;
|
70 |
|
effects[1] = EffectNames.DISTORT;
|
71 |
|
effects[2] = EffectNames.SINK;
|
72 |
|
effects[3] = EffectNames.SWIRL;
|
|
166 |
TableRow tr = new TableRow(this);
|
|
167 |
tr.setGravity(Gravity.CENTER);
|
|
168 |
|
|
169 |
for(int cols=0; cols<mNumCols; cols++)
|
|
170 |
{
|
|
171 |
Button b = new Button(this);
|
|
172 |
b.setOnClickListener(this);
|
|
173 |
b.setId(rows*mNumCols+cols);
|
|
174 |
b.setLayoutParams(p);
|
|
175 |
b.setBackgroundColor(COLOR_OFF);
|
|
176 |
tr.addView(b, p);
|
|
177 |
mShape[rows*mNumCols+cols] = false;
|
|
178 |
}
|
|
179 |
|
|
180 |
mLay.addView(tr);
|
|
181 |
}
|
|
182 |
}
|
|
183 |
|
|
184 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
185 |
|
|
186 |
public void onClick(View view)
|
|
187 |
{
|
|
188 |
Button tmp = (Button)view;
|
|
189 |
int id = tmp.getId();
|
|
190 |
mShape[id] = !mShape[id];
|
|
191 |
tmp.setBackgroundColor(mShape[id] ? COLOR_ON:COLOR_OFF);
|
|
192 |
}
|
|
193 |
|
|
194 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
195 |
|
|
196 |
public void Continue(View v)
|
|
197 |
{
|
|
198 |
firstScreen = false;
|
|
199 |
setContentView(R.layout.vertex3dlayout);
|
|
200 |
Default(null);
|
|
201 |
}
|
|
202 |
|
|
203 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
204 |
// 'second screen' methods
|
|
205 |
|
|
206 |
public void Default(View view)
|
|
207 |
{
|
|
208 |
effects[0] = EffectNames.DEFORM;
|
|
209 |
effects[1] = EffectNames.DISTORT;
|
|
210 |
effects[2] = EffectNames.SINK;
|
|
211 |
effects[3] = EffectNames.SWIRL;
|
73 |
212 |
|
74 |
|
deformX = 50;
|
75 |
|
deformY = 50;
|
76 |
|
deformZ = 50;
|
|
213 |
deformX = 50;
|
|
214 |
deformY = 50;
|
|
215 |
deformZ = 50;
|
77 |
216 |
|
78 |
|
distortX = 50;
|
79 |
|
distortY = 50;
|
80 |
|
distortZ = 50;
|
|
217 |
distortX = 50;
|
|
218 |
distortY = 50;
|
|
219 |
distortZ = 50;
|
81 |
220 |
|
82 |
|
sinkA = 50;
|
83 |
|
swirlA = 50;
|
|
221 |
sinkA = 50;
|
|
222 |
swirlA = 50;
|
84 |
223 |
|
85 |
|
addViews();
|
86 |
|
}
|
|
224 |
addViews();
|
|
225 |
}
|
87 |
226 |
|
88 |
227 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
89 |
228 |
|
90 |
|
private void addViews()
|
91 |
|
{
|
92 |
|
LinearLayout layout = (LinearLayout)findViewById(R.id.vertex3dlayout);
|
|
229 |
private void addViews()
|
|
230 |
{
|
|
231 |
LinearLayout layout = (LinearLayout)findViewById(R.id.vertex3dlayout);
|
93 |
232 |
|
94 |
|
layout.removeAllViews();
|
|
233 |
layout.removeAllViews();
|
95 |
234 |
|
96 |
|
View deform = getLayoutInflater().inflate(R.layout.vertex3ddeform , null);
|
97 |
|
View distort= getLayoutInflater().inflate(R.layout.vertex3ddistort, null);
|
98 |
|
View sink = getLayoutInflater().inflate(R.layout.vertex3dsink , null);
|
99 |
|
View swirl = getLayoutInflater().inflate(R.layout.vertex3dswirl , null);
|
|
235 |
View deform = getLayoutInflater().inflate(R.layout.vertex3ddeform , null);
|
|
236 |
View distort= getLayoutInflater().inflate(R.layout.vertex3ddistort, null);
|
|
237 |
View sink = getLayoutInflater().inflate(R.layout.vertex3dsink , null);
|
|
238 |
View swirl = getLayoutInflater().inflate(R.layout.vertex3dswirl , null);
|
100 |
239 |
|
101 |
|
for( int i=effects.length-1 ; i>=0 ; i-- )
|
|
240 |
for( int i=effects.length-1 ; i>=0 ; i-- )
|
|
241 |
{
|
|
242 |
switch(effects[i])
|
102 |
243 |
{
|
103 |
|
switch(effects[i])
|
104 |
|
{
|
105 |
|
case DEFORM : layout.addView(deform , 0); break;
|
106 |
|
case DISTORT: layout.addView(distort, 0); break;
|
107 |
|
case SINK : layout.addView(sink , 0); break;
|
108 |
|
case SWIRL : layout.addView(swirl , 0); break;
|
109 |
|
}
|
|
244 |
case DEFORM : layout.addView(deform , 0); break;
|
|
245 |
case DISTORT: layout.addView(distort, 0); break;
|
|
246 |
case SINK : layout.addView(sink , 0); break;
|
|
247 |
case SWIRL : layout.addView(swirl , 0); break;
|
110 |
248 |
}
|
|
249 |
}
|
111 |
250 |
|
112 |
|
textDeform = (TextView)findViewById(R.id.vertex3ddeformText);
|
113 |
|
textDistort= (TextView)findViewById(R.id.vertex3ddistortText);
|
114 |
|
textSink = (TextView)findViewById(R.id.vertex3dsinkText);
|
115 |
|
textSwirl = (TextView)findViewById(R.id.vertex3dswirlText);
|
|
251 |
textDeform = (TextView)findViewById(R.id.vertex3ddeformText);
|
|
252 |
textDistort= (TextView)findViewById(R.id.vertex3ddistortText);
|
|
253 |
textSink = (TextView)findViewById(R.id.vertex3dsinkText);
|
|
254 |
textSwirl = (TextView)findViewById(R.id.vertex3dswirlText);
|
116 |
255 |
|
117 |
|
setDeformText();
|
118 |
|
setDistortText();
|
119 |
|
setSinkText();
|
120 |
|
setSwirlText();
|
|
256 |
setDeformText();
|
|
257 |
setDistortText();
|
|
258 |
setSinkText();
|
|
259 |
setSwirlText();
|
121 |
260 |
|
122 |
|
setBar(R.id.vertex3ddeformBar1, deformX);
|
123 |
|
setBar(R.id.vertex3ddeformBar2, deformY);
|
124 |
|
setBar(R.id.vertex3ddeformBar3, deformZ);
|
|
261 |
setBar(R.id.vertex3ddeformBar1, deformX);
|
|
262 |
setBar(R.id.vertex3ddeformBar2, deformY);
|
|
263 |
setBar(R.id.vertex3ddeformBar3, deformZ);
|
125 |
264 |
|
126 |
|
setBar(R.id.vertex3ddistortBar1, distortX);
|
127 |
|
setBar(R.id.vertex3ddistortBar2, distortY);
|
128 |
|
setBar(R.id.vertex3ddistortBar3, distortZ);
|
|
265 |
setBar(R.id.vertex3ddistortBar1, distortX);
|
|
266 |
setBar(R.id.vertex3ddistortBar2, distortY);
|
|
267 |
setBar(R.id.vertex3ddistortBar3, distortZ);
|
129 |
268 |
|
130 |
|
setBar(R.id.vertex3dsinkBar1, sinkA);
|
|
269 |
setBar(R.id.vertex3dsinkBar1, sinkA);
|
131 |
270 |
|
132 |
|
setBar(R.id.vertex3dswirlBar1, swirlA);
|
|
271 |
setBar(R.id.vertex3dswirlBar1, swirlA);
|
133 |
272 |
|
134 |
|
Vertex3DRenderer.setOrder(effects);
|
135 |
|
}
|
|
273 |
Vertex3DRenderer.setOrder(effects);
|
|
274 |
}
|
136 |
275 |
|
137 |
276 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
138 |
277 |
|
139 |
|
private void moveUp(EffectNames name)
|
140 |
|
{
|
141 |
|
int len = effects.length-1;
|
142 |
|
int index = -1;
|
|
278 |
private void moveUp(EffectNames name)
|
|
279 |
{
|
|
280 |
int len = effects.length-1;
|
|
281 |
int index = -1;
|
143 |
282 |
|
144 |
|
for(int i=0; i<=len; i++)
|
|
283 |
for(int i=0; i<=len; i++)
|
|
284 |
{
|
|
285 |
if( effects[i]==name )
|
145 |
286 |
{
|
146 |
|
if( effects[i]==name )
|
147 |
|
{
|
148 |
|
index=i;
|
149 |
|
break;
|
150 |
|
}
|
|
287 |
index=i;
|
|
288 |
break;
|
151 |
289 |
}
|
|
290 |
}
|
152 |
291 |
|
153 |
|
if( index==0 )
|
154 |
|
{
|
155 |
|
for(int i=0; i<len; i++)
|
156 |
|
effects[i] = effects[i+1];
|
157 |
|
|
158 |
|
effects[len] = name;
|
159 |
|
}
|
160 |
|
else if( index>0 )
|
161 |
|
{
|
162 |
|
effects[index] = effects[index-1];
|
163 |
|
effects[index-1] = name;
|
164 |
|
}
|
|
292 |
if( index==0 )
|
|
293 |
{
|
|
294 |
for(int i=0; i<len; i++)
|
|
295 |
effects[i] = effects[i+1];
|
165 |
296 |
|
166 |
|
addViews();
|
|
297 |
effects[len] = name;
|
167 |
298 |
}
|
|
299 |
else if( index>0 )
|
|
300 |
{
|
|
301 |
effects[index] = effects[index-1];
|
|
302 |
effects[index-1] = name;
|
|
303 |
}
|
|
304 |
|
|
305 |
addViews();
|
|
306 |
}
|
168 |
307 |
|
169 |
308 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
170 |
309 |
|
171 |
|
public void ButtonDeform(View v)
|
172 |
|
{
|
173 |
|
moveUp(EffectNames.DEFORM);
|
174 |
|
}
|
|
310 |
public void ButtonDeform(View v)
|
|
311 |
{
|
|
312 |
moveUp(EffectNames.DEFORM);
|
|
313 |
}
|
175 |
314 |
|
176 |
315 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
177 |
316 |
|
178 |
|
public void ButtonDistort(View v)
|
179 |
|
{
|
180 |
|
moveUp(EffectNames.DISTORT);
|
181 |
|
}
|
|
317 |
public void ButtonDistort(View v)
|
|
318 |
{
|
|
319 |
moveUp(EffectNames.DISTORT);
|
|
320 |
}
|
182 |
321 |
|
183 |
322 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
184 |
323 |
|
185 |
|
public void ButtonSink(View v)
|
186 |
|
{
|
187 |
|
moveUp(EffectNames.SINK);
|
188 |
|
}
|
|
324 |
public void ButtonSink(View v)
|
|
325 |
{
|
|
326 |
moveUp(EffectNames.SINK);
|
|
327 |
}
|
189 |
328 |
|
190 |
329 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
191 |
330 |
|
192 |
|
public void ButtonSwirl(View v)
|
193 |
|
{
|
194 |
|
moveUp(EffectNames.SWIRL);
|
195 |
|
}
|
|
331 |
public void ButtonSwirl(View v)
|
|
332 |
{
|
|
333 |
moveUp(EffectNames.SWIRL);
|
|
334 |
}
|
196 |
335 |
|
197 |
336 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
198 |
337 |
|
199 |
|
private void setBar(int id, int value)
|
200 |
|
{
|
201 |
|
bar = (SeekBar)findViewById(id);
|
202 |
|
bar.setOnSeekBarChangeListener(this);
|
203 |
|
bar.setProgress(value);
|
204 |
|
}
|
|
338 |
private void setBar(int id, int value)
|
|
339 |
{
|
|
340 |
bar = (SeekBar)findViewById(id);
|
|
341 |
bar.setOnSeekBarChangeListener(this);
|
|
342 |
bar.setProgress(value);
|
|
343 |
}
|
205 |
344 |
|
206 |
345 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
207 |
346 |
|
208 |
|
private void computeDeform()
|
209 |
|
{
|
210 |
|
fdeformX = (deformX-50)*maxX/50.0f;
|
211 |
|
fdeformY = (deformY-50)*maxY/50.0f;
|
212 |
|
fdeformZ = (deformZ-50)*maxZ/50.0f;
|
|
347 |
private void computeDeform()
|
|
348 |
{
|
|
349 |
fdeformX = (deformX-50)*maxX/50.0f;
|
|
350 |
fdeformY = (deformY-50)*maxY/50.0f;
|
|
351 |
fdeformZ = (deformZ-50)*maxZ/50.0f;
|
213 |
352 |
|
214 |
|
Vertex3DRenderer.setDeform( fdeformX, fdeformY, fdeformZ );
|
215 |
|
}
|
|
353 |
Vertex3DRenderer.setDeform( fdeformX, fdeformY, fdeformZ );
|
|
354 |
}
|
216 |
355 |
|
217 |
356 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
218 |
357 |
|
219 |
|
private void setDeformText()
|
220 |
|
{
|
221 |
|
fdeformX = ((int)(100*fdeformX))/100.0f;
|
222 |
|
fdeformY = ((int)(100*fdeformY))/100.0f;
|
223 |
|
fdeformZ = ((int)(100*fdeformZ))/100.0f;
|
|
358 |
private void setDeformText()
|
|
359 |
{
|
|
360 |
fdeformX = ((int)(100*fdeformX))/100.0f;
|
|
361 |
fdeformY = ((int)(100*fdeformY))/100.0f;
|
|
362 |
fdeformZ = ((int)(100*fdeformZ))/100.0f;
|
224 |
363 |
|
225 |
|
textDeform.setText("deform("+fdeformX+" , "+fdeformY+" , "+fdeformZ+")");
|
226 |
|
}
|
|
364 |
textDeform.setText("deform("+fdeformX+" , "+fdeformY+" , "+fdeformZ+")");
|
|
365 |
}
|
227 |
366 |
|
228 |
367 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
229 |
368 |
|
230 |
|
private void computeDistort()
|
231 |
|
{
|
232 |
|
fdistortX = (distortX-50)*maxX/50.0f;
|
233 |
|
fdistortY = (distortY-50)*maxY/50.0f;
|
234 |
|
fdistortZ = (distortZ-50)*maxZ/50.0f;
|
|
369 |
private void computeDistort()
|
|
370 |
{
|
|
371 |
fdistortX = (distortX-50)*maxX/50.0f;
|
|
372 |
fdistortY = (distortY-50)*maxY/50.0f;
|
|
373 |
fdistortZ = (distortZ-50)*maxZ/50.0f;
|
235 |
374 |
|
236 |
|
Vertex3DRenderer.setDistort(fdistortX, fdistortY, fdistortZ);
|
237 |
|
}
|
|
375 |
Vertex3DRenderer.setDistort(fdistortX, fdistortY, fdistortZ);
|
|
376 |
}
|
238 |
377 |
|
239 |
378 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
240 |
379 |
|
241 |
|
private void setDistortText()
|
242 |
|
{
|
243 |
|
fdistortX = ((int)(100*fdistortX))/100.0f;
|
244 |
|
fdistortY = ((int)(100*fdistortY))/100.0f;
|
245 |
|
fdistortZ = ((int)(100*fdistortZ))/100.0f;
|
|
380 |
private void setDistortText()
|
|
381 |
{
|
|
382 |
fdistortX = ((int)(100*fdistortX))/100.0f;
|
|
383 |
fdistortY = ((int)(100*fdistortY))/100.0f;
|
|
384 |
fdistortZ = ((int)(100*fdistortZ))/100.0f;
|
246 |
385 |
|
247 |
|
textDistort.setText("distort("+fdistortX+" , "+fdistortY+" , "+fdistortZ+")");
|
248 |
|
}
|
|
386 |
textDistort.setText("distort("+fdistortX+" , "+fdistortY+" , "+fdistortZ+")");
|
|
387 |
}
|
249 |
388 |
|
250 |
389 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
251 |
390 |
|
252 |
|
private void computeSink()
|
253 |
|
{
|
254 |
|
fsinkA = (sinkA>= 50 ? sinkA-49 : 1/(51-sinkA));
|
|
391 |
private void computeSink()
|
|
392 |
{
|
|
393 |
fsinkA = (sinkA>= 50 ? sinkA-49 : 1/(51-sinkA));
|
255 |
394 |
|
256 |
|
Vertex3DRenderer.setSink( fsinkA );
|
257 |
|
}
|
|
395 |
Vertex3DRenderer.setSink( fsinkA );
|
|
396 |
}
|
258 |
397 |
|
259 |
398 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
260 |
399 |
|
261 |
|
private void setSinkText()
|
262 |
|
{
|
263 |
|
fsinkA = ((int)(100*fsinkA))/100.0f;
|
|
400 |
private void setSinkText()
|
|
401 |
{
|
|
402 |
fsinkA = ((int)(100*fsinkA))/100.0f;
|
264 |
403 |
|
265 |
|
textSink.setText("sink("+fsinkA+")");
|
266 |
|
}
|
|
404 |
textSink.setText("sink("+fsinkA+")");
|
|
405 |
}
|
267 |
406 |
|
268 |
407 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
269 |
408 |
|
270 |
|
private void computeSwirl()
|
271 |
|
{
|
272 |
|
fswirlA = (swirlA-50)*3.6f;
|
|
409 |
private void computeSwirl()
|
|
410 |
{
|
|
411 |
fswirlA = (swirlA-50)*3.6f;
|
273 |
412 |
|
274 |
|
Vertex3DRenderer.setSwirl( fswirlA );
|
275 |
|
}
|
|
413 |
Vertex3DRenderer.setSwirl( fswirlA );
|
|
414 |
}
|
276 |
415 |
|
277 |
416 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
278 |
417 |
|
279 |
|
private void setSwirlText()
|
280 |
|
{
|
281 |
|
fswirlA = ((int)(100*fswirlA))/100.0f;
|
|
418 |
private void setSwirlText()
|
|
419 |
{
|
|
420 |
fswirlA = ((int)(100*fswirlA))/100.0f;
|
282 |
421 |
|
283 |
|
textSwirl.setText("swirl("+fswirlA+")");
|
284 |
|
}
|
|
422 |
textSwirl.setText("swirl("+fswirlA+")");
|
|
423 |
}
|
285 |
424 |
|
286 |
425 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
287 |
|
|
288 |
|
@Override
|
289 |
|
protected void onPause()
|
290 |
|
{
|
291 |
|
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.vertex3dSurfaceView);
|
292 |
|
mView.onPause();
|
293 |
|
super.onPause();
|
294 |
|
}
|
|
426 |
// Overrides
|
|
427 |
|
|
428 |
@Override
|
|
429 |
protected void onPause()
|
|
430 |
{
|
|
431 |
GLSurfaceView mView = (GLSurfaceView)findViewById(R.id.vertex3dSurfaceView);
|
|
432 |
if( mView!=null ) mView.onPause();
|
|
433 |
super.onPause();
|
|
434 |
}
|
295 |
435 |
|
296 |
436 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
297 |
437 |
|
298 |
|
@Override
|
299 |
|
protected void onResume()
|
300 |
|
{
|
301 |
|
super.onResume();
|
302 |
|
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.vertex3dSurfaceView);
|
303 |
|
mView.onResume();
|
304 |
|
}
|
|
438 |
@Override
|
|
439 |
protected void onResume()
|
|
440 |
{
|
|
441 |
super.onResume();
|
|
442 |
GLSurfaceView mView = (GLSurfaceView)findViewById(R.id.vertex3dSurfaceView);
|
|
443 |
if( mView!=null ) mView.onResume();
|
|
444 |
}
|
305 |
445 |
|
306 |
446 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
307 |
447 |
|
308 |
|
@Override
|
309 |
|
public void onWindowFocusChanged(boolean hasFocus)
|
|
448 |
@Override
|
|
449 |
public void onWindowFocusChanged(boolean hasFocus)
|
|
450 |
{
|
|
451 |
super.onWindowFocusChanged(hasFocus);
|
|
452 |
|
|
453 |
if( firstScreen )
|
|
454 |
{
|
|
455 |
mColsPicker.setValue(mNumCols);
|
|
456 |
mRowsPicker.setValue(mNumRows);
|
|
457 |
|
|
458 |
if( hasFocus ) setGrid();
|
|
459 |
}
|
|
460 |
else
|
310 |
461 |
{
|
311 |
|
super.onWindowFocusChanged(hasFocus);
|
312 |
|
|
313 |
462 |
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.vertex3dSurfaceView);
|
314 |
463 |
|
315 |
464 |
maxX = mView.getWidth();
|
316 |
465 |
maxY = mView.getHeight();
|
317 |
466 |
maxZ = (maxX+maxY)/2;
|
318 |
467 |
}
|
|
468 |
}
|
319 |
469 |
|
320 |
470 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
321 |
471 |
|
322 |
|
@Override
|
323 |
|
protected void onDestroy()
|
324 |
|
{
|
325 |
|
Distorted.onDestroy();
|
326 |
|
super.onDestroy();
|
327 |
|
}
|
|
472 |
@Override
|
|
473 |
protected void onDestroy()
|
|
474 |
{
|
|
475 |
Distorted.onDestroy();
|
|
476 |
super.onDestroy();
|
|
477 |
}
|
328 |
478 |
|
329 |
479 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
330 |
480 |
|
331 |
|
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
|
|
481 |
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
|
|
482 |
{
|
|
483 |
switch (bar.getId())
|
332 |
484 |
{
|
333 |
|
switch (bar.getId())
|
334 |
|
{
|
335 |
|
case R.id.vertex3ddeformBar1 : deformX= progress; computeDeform() ; setDeformText() ; break;
|
336 |
|
case R.id.vertex3ddeformBar2 : deformY= progress; computeDeform() ; setDeformText() ; break;
|
337 |
|
case R.id.vertex3ddeformBar3 : deformZ= progress; computeDeform() ; setDeformText() ; break;
|
338 |
|
|
339 |
|
case R.id.vertex3ddistortBar1 : distortX= progress; computeDistort(); setDistortText() ; break;
|
340 |
|
case R.id.vertex3ddistortBar2 : distortY= progress; computeDistort(); setDistortText() ; break;
|
341 |
|
case R.id.vertex3ddistortBar3 : distortZ= progress; computeDistort(); setDistortText() ; break;
|
342 |
|
|
343 |
|
case R.id.vertex3dsinkBar1 : sinkA = progress; computeSink() ; setSinkText() ; break;
|
344 |
|
|
345 |
|
case R.id.vertex3dswirlBar1 : swirlA = progress; computeSwirl() ; setSwirlText() ; break;
|
346 |
|
}
|
|
485 |
case R.id.vertex3ddeformBar1 : deformX = progress; computeDeform() ; setDeformText() ; break;
|
|
486 |
case R.id.vertex3ddeformBar2 : deformY = progress; computeDeform() ; setDeformText() ; break;
|
|
487 |
case R.id.vertex3ddeformBar3 : deformZ = progress; computeDeform() ; setDeformText() ; break;
|
|
488 |
case R.id.vertex3ddistortBar1 : distortX= progress; computeDistort(); setDistortText() ; break;
|
|
489 |
case R.id.vertex3ddistortBar2 : distortY= progress; computeDistort(); setDistortText() ; break;
|
|
490 |
case R.id.vertex3ddistortBar3 : distortZ= progress; computeDistort(); setDistortText() ; break;
|
|
491 |
case R.id.vertex3dsinkBar1 : sinkA = progress; computeSink() ; setSinkText() ; break;
|
|
492 |
case R.id.vertex3dswirlBar1 : swirlA = progress; computeSwirl() ; setSwirlText() ; break;
|
347 |
493 |
}
|
|
494 |
}
|
348 |
495 |
|
349 |
496 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
350 |
497 |
|
351 |
|
public void onStartTrackingTouch(SeekBar bar) { }
|
|
498 |
public void onStartTrackingTouch(SeekBar bar) { }
|
352 |
499 |
|
353 |
500 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
354 |
501 |
|
355 |
|
public void onStopTrackingTouch(SeekBar bar) { }
|
356 |
|
|
357 |
|
}
|
|
502 |
public void onStopTrackingTouch(SeekBar bar) { }
|
|
503 |
}
|
Progress with Vertex3D