31 |
31 |
import android.widget.TextView;
|
32 |
32 |
import android.widget.SeekBar.OnSeekBarChangeListener;
|
33 |
33 |
|
34 |
|
///////////////////////////////////////////////////////////////////
|
|
34 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
35 |
35 |
|
36 |
36 |
public class DynamicActivity extends Activity implements OnSeekBarChangeListener
|
37 |
37 |
{
|
38 |
38 |
private TextView textD, textN;
|
39 |
|
private int progress0, progress1, progress2;
|
|
39 |
private int p0,p1,p2;
|
|
40 |
private int mDim, mMode;
|
40 |
41 |
|
41 |
|
///////////////////////////////////////////////////////////////////
|
|
42 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
42 |
43 |
@Override
|
43 |
|
protected void onCreate(Bundle savedInstanceState)
|
|
44 |
protected void onCreate(Bundle savedState)
|
44 |
45 |
{
|
45 |
|
super.onCreate(savedInstanceState);
|
|
46 |
super.onCreate(savedState);
|
46 |
47 |
setContentView(R.layout.dynamicslayout);
|
47 |
48 |
|
48 |
49 |
textD = (TextView)findViewById(R.id.dynamicTextDuration);
|
49 |
50 |
textN = (TextView)findViewById(R.id.dynamicTextNoise);
|
50 |
51 |
|
51 |
|
SeekBar bar = (SeekBar)findViewById(R.id.dynamicSeekDuration);
|
52 |
|
bar.setOnSeekBarChangeListener(this);
|
53 |
|
bar.setProgress(50);
|
54 |
|
|
55 |
|
progress0=0;
|
56 |
|
progress1=0;
|
57 |
|
progress2=0;
|
58 |
|
|
59 |
|
bar = (SeekBar)findViewById(R.id.dynamicSeekNoise0);
|
60 |
|
bar.setProgress(0);
|
61 |
|
bar.setOnSeekBarChangeListener(this);
|
62 |
|
bar = (SeekBar)findViewById(R.id.dynamicSeekNoise1);
|
63 |
|
bar.setProgress(0);
|
64 |
|
bar.setOnSeekBarChangeListener(this);
|
65 |
|
bar = (SeekBar)findViewById(R.id.dynamicSeekNoise2);
|
66 |
|
bar.setProgress(0);
|
67 |
|
bar.setOnSeekBarChangeListener(this);
|
|
52 |
p0=p1=p2=0;
|
|
53 |
mDim = DynamicSurfaceView.DIM_2D;
|
|
54 |
mMode= Dynamic1D.MODE_LOOP;
|
|
55 |
|
|
56 |
SeekBar barD = (SeekBar)findViewById(R.id.dynamicSeekDuration);
|
|
57 |
barD.setOnSeekBarChangeListener(this);
|
|
58 |
SeekBar bar0 = (SeekBar)findViewById(R.id.dynamicSeekNoise0);
|
|
59 |
bar0.setOnSeekBarChangeListener(this);
|
|
60 |
SeekBar bar1 = (SeekBar)findViewById(R.id.dynamicSeekNoise1);
|
|
61 |
bar1.setOnSeekBarChangeListener(this);
|
|
62 |
SeekBar bar2 = (SeekBar)findViewById(R.id.dynamicSeekNoise2);
|
|
63 |
bar2.setOnSeekBarChangeListener(this);
|
|
64 |
|
|
65 |
if( savedState==null )
|
|
66 |
{
|
|
67 |
barD.setProgress(50);
|
|
68 |
bar0.setProgress(0);
|
|
69 |
bar1.setProgress(0);
|
|
70 |
bar2.setProgress(0);
|
|
71 |
}
|
68 |
72 |
}
|
69 |
73 |
|
70 |
|
///////////////////////////////////////////////////////////////////
|
|
74 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
71 |
75 |
@Override
|
72 |
76 |
protected void onResume()
|
73 |
77 |
{
|
... | ... | |
77 |
81 |
view.onResume();
|
78 |
82 |
}
|
79 |
83 |
|
80 |
|
///////////////////////////////////////////////////////////////////
|
|
84 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
81 |
85 |
@Override
|
82 |
86 |
protected void onPause()
|
83 |
87 |
{
|
... | ... | |
87 |
91 |
super.onPause();
|
88 |
92 |
}
|
89 |
93 |
|
90 |
|
///////////////////////////////////////////////////////////////////
|
|
94 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
91 |
95 |
@Override
|
92 |
96 |
public void onStop()
|
93 |
97 |
{
|
94 |
98 |
super.onStop();
|
95 |
99 |
}
|
96 |
100 |
|
97 |
|
///////////////////////////////////////////////////////////////////
|
|
101 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
98 |
102 |
@Override
|
99 |
103 |
public void onDestroy()
|
100 |
104 |
{
|
... | ... | |
102 |
106 |
super.onDestroy();
|
103 |
107 |
}
|
104 |
108 |
|
105 |
|
///////////////////////////////////////////////////////////////////
|
|
109 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
106 |
110 |
|
107 |
111 |
public void Loop(View v)
|
108 |
112 |
{
|
109 |
113 |
DynamicSurfaceView view = (DynamicSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
|
110 |
114 |
view.setMode(Dynamic1D.MODE_LOOP);
|
|
115 |
mMode = Dynamic1D.MODE_LOOP;
|
111 |
116 |
}
|
112 |
117 |
|
113 |
|
///////////////////////////////////////////////////////////////////
|
|
118 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
114 |
119 |
|
115 |
120 |
public void Path(View v)
|
116 |
121 |
{
|
117 |
122 |
DynamicSurfaceView view = (DynamicSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
|
118 |
123 |
view.setMode(Dynamic1D.MODE_PATH);
|
|
124 |
mMode = Dynamic1D.MODE_PATH;
|
119 |
125 |
}
|
120 |
126 |
|
121 |
|
///////////////////////////////////////////////////////////////////
|
|
127 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
122 |
128 |
|
123 |
129 |
public void Jump(View v)
|
124 |
130 |
{
|
125 |
131 |
DynamicSurfaceView view = (DynamicSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
|
126 |
132 |
view.setMode(Dynamic1D.MODE_JUMP);
|
|
133 |
mMode = Dynamic1D.MODE_JUMP;
|
127 |
134 |
}
|
128 |
135 |
|
129 |
|
///////////////////////////////////////////////////////////////////
|
|
136 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
130 |
137 |
|
131 |
138 |
public void Dim1D(View v)
|
132 |
139 |
{
|
133 |
140 |
DynamicSurfaceView view = (DynamicSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
|
134 |
141 |
view.setDimension(DynamicSurfaceView.DIM_1D);
|
|
142 |
mDim = DynamicSurfaceView.DIM_1D;
|
135 |
143 |
}
|
136 |
144 |
|
137 |
|
///////////////////////////////////////////////////////////////////
|
|
145 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
138 |
146 |
|
139 |
147 |
public void Dim2D(View v)
|
140 |
148 |
{
|
141 |
149 |
DynamicSurfaceView view = (DynamicSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
|
142 |
150 |
view.setDimension(DynamicSurfaceView.DIM_2D);
|
|
151 |
mDim = DynamicSurfaceView.DIM_2D;
|
143 |
152 |
}
|
144 |
153 |
|
145 |
|
///////////////////////////////////////////////////////////////////
|
|
154 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
146 |
155 |
|
147 |
156 |
public void Dim3DXY(View v)
|
148 |
157 |
{
|
149 |
158 |
DynamicSurfaceView view = (DynamicSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
|
150 |
159 |
view.setDimension(DynamicSurfaceView.DIM_3DXY);
|
|
160 |
mDim = DynamicSurfaceView.DIM_3DXY;
|
151 |
161 |
}
|
152 |
162 |
|
153 |
|
///////////////////////////////////////////////////////////////////
|
|
163 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
154 |
164 |
|
155 |
165 |
public void Dim3DXZ(View v)
|
156 |
166 |
{
|
157 |
167 |
DynamicSurfaceView view = (DynamicSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
|
158 |
168 |
view.setDimension(DynamicSurfaceView.DIM_3DXZ);
|
|
169 |
mDim = DynamicSurfaceView.DIM_3DXZ;
|
159 |
170 |
}
|
160 |
|
|
|
171 |
|
|
172 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
173 |
|
|
174 |
@Override
|
|
175 |
public void onSaveInstanceState(Bundle savedInstanceState)
|
|
176 |
{
|
|
177 |
super.onSaveInstanceState(savedInstanceState);
|
|
178 |
|
|
179 |
savedInstanceState.putInt("dim" , mDim );
|
|
180 |
savedInstanceState.putInt("mode", mMode);
|
|
181 |
}
|
|
182 |
|
|
183 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
184 |
|
|
185 |
@Override
|
|
186 |
public void onRestoreInstanceState(Bundle savedInstanceState)
|
|
187 |
{
|
|
188 |
super.onRestoreInstanceState(savedInstanceState);
|
|
189 |
|
|
190 |
mDim = savedInstanceState.getInt("dim");
|
|
191 |
mMode= savedInstanceState.getInt("mode");
|
|
192 |
|
|
193 |
switch(mDim)
|
|
194 |
{
|
|
195 |
case DynamicSurfaceView.DIM_1D : Dim1D(null) ; break;
|
|
196 |
case DynamicSurfaceView.DIM_2D : Dim2D(null) ; break;
|
|
197 |
case DynamicSurfaceView.DIM_3DXY: Dim3DXY(null); break;
|
|
198 |
case DynamicSurfaceView.DIM_3DXZ: Dim3DXZ(null); break;
|
|
199 |
}
|
|
200 |
|
|
201 |
switch(mMode)
|
|
202 |
{
|
|
203 |
case Dynamic1D.MODE_JUMP: Jump(null); break;
|
|
204 |
case Dynamic1D.MODE_PATH: Path(null); break;
|
|
205 |
case Dynamic1D.MODE_LOOP: Loop(null); break;
|
|
206 |
}
|
|
207 |
}
|
|
208 |
|
161 |
209 |
///////////////////////////////////////////////////////////////////
|
162 |
210 |
|
163 |
211 |
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
|
... | ... | |
177 |
225 |
{
|
178 |
226 |
switch(id)
|
179 |
227 |
{
|
180 |
|
case R.id.dynamicSeekNoise0 : progress0 = progress; break;
|
181 |
|
case R.id.dynamicSeekNoise1 : progress1 = progress; break;
|
182 |
|
case R.id.dynamicSeekNoise2 : progress2 = progress; break;
|
|
228 |
case R.id.dynamicSeekNoise0 : p0 = progress; break;
|
|
229 |
case R.id.dynamicSeekNoise1 : p1 = progress; break;
|
|
230 |
case R.id.dynamicSeekNoise2 : p2 = progress; break;
|
183 |
231 |
}
|
184 |
232 |
|
185 |
|
view.setNoise(progress0/100.0f,progress1/100.0f,progress2/100.0f);
|
186 |
|
textN.setText("Noise: "+(progress0/100.f)+" "+(progress1/100.f)+" "+(progress2/100.f));
|
|
233 |
view.setNoise(p0/100.0f,p1/100.0f,p2/100.0f);
|
|
234 |
textN.setText("Noise: "+(p0/100.f)+" "+(p1/100.f)+" "+(p2/100.f));
|
187 |
235 |
}
|
188 |
236 |
}
|
189 |
237 |
|
Improve Dynamic and FBO apps.