1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2016 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Distorted. //
|
5
|
// //
|
6
|
// Distorted is free software: you can redistribute it and/or modify //
|
7
|
// it under the terms of the GNU General Public License as published by //
|
8
|
// the Free Software Foundation, either version 2 of the License, or //
|
9
|
// (at your option) any later version. //
|
10
|
// //
|
11
|
// Distorted is distributed in the hope that it will be useful, //
|
12
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14
|
// GNU General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU General Public License //
|
17
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
package org.distorted.examples.flag;
|
21
|
|
22
|
import android.app.Activity;
|
23
|
import android.opengl.GLSurfaceView;
|
24
|
import android.os.Bundle;
|
25
|
import android.widget.SeekBar;
|
26
|
import android.widget.TextView;
|
27
|
|
28
|
import org.distorted.examples.R;
|
29
|
import org.distorted.library.Distorted;
|
30
|
import org.distorted.library.type.Static5D;
|
31
|
|
32
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
33
|
|
34
|
public class FlagActivity extends Activity implements SeekBar.OnSeekBarChangeListener
|
35
|
{
|
36
|
private SeekBar barAmplitude, barLength, barAngleA, barAngleB;
|
37
|
private TextView textAmplitude, textLength, textAngleA, textAngleB;
|
38
|
private SeekBar barNoiseAmplitude, barNoiseLength, barNoiseAngleA, barNoiseAngleB;
|
39
|
private TextView textNoiseAmplitude, textNoiseLength, textNoiseAngleA, textNoiseAngleB;
|
40
|
|
41
|
private Static5D noise;
|
42
|
private String mStr;
|
43
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
44
|
|
45
|
@Override
|
46
|
protected void onCreate(Bundle savedState)
|
47
|
{
|
48
|
super.onCreate(savedState);
|
49
|
setContentView(R.layout.flaglayout);
|
50
|
|
51
|
noise = new Static5D(0,0,0,0,0);
|
52
|
mStr = new String();
|
53
|
|
54
|
textAmplitude = (TextView)findViewById(R.id.flagAmplitude);
|
55
|
textLength = (TextView)findViewById(R.id.flagLength);
|
56
|
textAngleA = (TextView)findViewById(R.id.flagAngleA);
|
57
|
textAngleB = (TextView)findViewById(R.id.flagAngleB);
|
58
|
|
59
|
barAmplitude = (SeekBar)findViewById(R.id.flagSeekAmplitude);
|
60
|
barLength = (SeekBar)findViewById(R.id.flagSeekLength);
|
61
|
barAngleA = (SeekBar)findViewById(R.id.flagSeekAngleA);
|
62
|
barAngleB = (SeekBar)findViewById(R.id.flagSeekAngleB);
|
63
|
|
64
|
barAmplitude.setOnSeekBarChangeListener(this);
|
65
|
barLength.setOnSeekBarChangeListener(this);
|
66
|
barAngleA.setOnSeekBarChangeListener(this);
|
67
|
barAngleB.setOnSeekBarChangeListener(this);
|
68
|
|
69
|
barAmplitude.setProgress(50);
|
70
|
barLength.setProgress(50);
|
71
|
barAngleA.setProgress(25);
|
72
|
barAngleB.setProgress(1);
|
73
|
|
74
|
textNoiseAmplitude = (TextView)findViewById(R.id.flagNoiseAmplitude);
|
75
|
textNoiseLength = (TextView)findViewById(R.id.flagNoiseLength);
|
76
|
textNoiseAngleA = (TextView)findViewById(R.id.flagNoiseAngleA);
|
77
|
textNoiseAngleB = (TextView)findViewById(R.id.flagNoiseAngleB);
|
78
|
|
79
|
barNoiseAmplitude = (SeekBar)findViewById(R.id.flagSeekNoiseAmplitude);
|
80
|
barNoiseLength = (SeekBar)findViewById(R.id.flagSeekNoiseLength);
|
81
|
barNoiseAngleA = (SeekBar)findViewById(R.id.flagSeekNoiseAngleA);
|
82
|
barNoiseAngleB = (SeekBar)findViewById(R.id.flagSeekNoiseAngleB);
|
83
|
|
84
|
barNoiseAmplitude.setOnSeekBarChangeListener(this);
|
85
|
barNoiseLength.setOnSeekBarChangeListener(this);
|
86
|
barNoiseAngleA.setOnSeekBarChangeListener(this);
|
87
|
barNoiseAngleB.setOnSeekBarChangeListener(this);
|
88
|
|
89
|
barNoiseAmplitude.setProgress( (int)noise.getX() );
|
90
|
barNoiseLength.setProgress ( (int)noise.getY() );
|
91
|
barNoiseAngleA.setProgress ( (int)noise.getW() );
|
92
|
barNoiseAngleB.setProgress ( (int)noise.getV() );
|
93
|
|
94
|
textNoiseAmplitude.setText("Noise 0.00");
|
95
|
textNoiseLength.setText("Noise 0.00");
|
96
|
textNoiseAngleA.setText("Noise 0.00");
|
97
|
textNoiseAngleB.setText("Noise 0.00");
|
98
|
}
|
99
|
|
100
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
101
|
|
102
|
@Override
|
103
|
protected void onPause()
|
104
|
{
|
105
|
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.flagSurfaceView);
|
106
|
mView.onPause();
|
107
|
|
108
|
super.onPause();
|
109
|
}
|
110
|
|
111
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
112
|
|
113
|
@Override
|
114
|
protected void onResume()
|
115
|
{
|
116
|
super.onResume();
|
117
|
|
118
|
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.flagSurfaceView);
|
119
|
mView.onResume();
|
120
|
}
|
121
|
|
122
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
123
|
|
124
|
@Override
|
125
|
protected void onDestroy()
|
126
|
{
|
127
|
Distorted.onDestroy();
|
128
|
super.onDestroy();
|
129
|
}
|
130
|
|
131
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
132
|
|
133
|
private void convert(int progress)
|
134
|
{
|
135
|
if( progress== 0 ) mStr="0.00";
|
136
|
else if( progress==100 ) mStr="1.00";
|
137
|
else if( progress< 10 ) mStr="0.0"+progress;
|
138
|
else mStr="0."+progress;
|
139
|
}
|
140
|
|
141
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
142
|
|
143
|
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
|
144
|
{
|
145
|
switch (bar.getId())
|
146
|
{
|
147
|
case R.id.flagSeekAmplitude : FlagRenderer.setAmplitude(progress);
|
148
|
textAmplitude.setText("Amplitude "+progress);
|
149
|
break;
|
150
|
case R.id.flagSeekNoiseAmplitude: noise.set( (float)progress, noise.getY(), noise.getZ(), noise.getW(), noise.getV() );
|
151
|
FlagRenderer.setNoise(noise);
|
152
|
convert(progress);
|
153
|
textNoiseAmplitude.setText("Noise "+mStr );
|
154
|
break;
|
155
|
case R.id.flagSeekLength : FlagRenderer.setLength(progress);
|
156
|
textLength.setText("Length "+(progress*2));
|
157
|
break;
|
158
|
case R.id.flagSeekNoiseLength : noise.set( noise.getX(), (float)progress, noise.getZ(), noise.getW(), noise.getV() );
|
159
|
FlagRenderer.setNoise(noise);
|
160
|
convert(progress);
|
161
|
textNoiseLength.setText("Noise "+mStr );
|
162
|
break;
|
163
|
case R.id.flagSeekAngleA : FlagRenderer.setAngleA(progress);
|
164
|
textAngleA.setText("Alpha "+((360*progress)/100));
|
165
|
break;
|
166
|
case R.id.flagSeekNoiseAngleA : noise.set( noise.getX(), noise.getY(), noise.getZ() ,(float)progress, noise.getV() );
|
167
|
FlagRenderer.setNoise(noise);
|
168
|
convert(progress);
|
169
|
textNoiseAngleA.setText("Noise "+mStr );
|
170
|
break;
|
171
|
case R.id.flagSeekAngleB : FlagRenderer.setAngleB(progress);
|
172
|
textAngleB.setText("Beta "+((360*progress)/100));
|
173
|
break;
|
174
|
case R.id.flagSeekNoiseAngleB : noise.set( noise.getX(), noise.getY(), noise.getZ(), noise.getW(), (float)progress );
|
175
|
FlagRenderer.setNoise(noise);
|
176
|
convert(progress);
|
177
|
textNoiseAngleB.setText("Noise "+mStr );
|
178
|
break;
|
179
|
}
|
180
|
}
|
181
|
|
182
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
183
|
|
184
|
public void onStartTrackingTouch(SeekBar bar) { }
|
185
|
|
186
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
187
|
|
188
|
public void onStopTrackingTouch(SeekBar bar) { }
|
189
|
|
190
|
}
|