Project

General

Profile

Download (6.74 KB) Statistics
| Branch: | Revision:

examples / src / main / java / org / distorted / examples / dynamic / DynamicActivity.java @ 8b7c0ab3

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.dynamic;
21

    
22
import org.distorted.library.Distorted;
23
import org.distorted.library.type.Dynamic1D;
24
import org.distorted.examples.R;
25

    
26
import android.app.Activity;
27
import android.opengl.GLSurfaceView;
28
import android.os.Bundle;
29
import android.view.View;
30
import android.widget.SeekBar;
31
import android.widget.TextView;
32
import android.widget.SeekBar.OnSeekBarChangeListener;
33

    
34
///////////////////////////////////////////////////////////////////
35

    
36
public class DynamicActivity extends Activity implements OnSeekBarChangeListener
37
    {
38
    private TextView textD, textN;
39
    private int progress0, progress1, progress2;
40

    
41
///////////////////////////////////////////////////////////////////
42
    @Override
43
    protected void onCreate(Bundle savedInstanceState) 
44
      {
45
      super.onCreate(savedInstanceState);
46
      setContentView(R.layout.dynamicslayout);
47

    
48
      textD = (TextView)findViewById(R.id.dynamicTextDuration);
49
      textN = (TextView)findViewById(R.id.dynamicTextNoise);
50

    
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

    
60
      //textD.setText("Duration: 10 s");
61
      //textN.setText("Noise: 0.0");
62

    
63
      bar = (SeekBar)findViewById(R.id.dynamicSeekNoise0);
64
      bar.setProgress(0);
65
      bar.setOnSeekBarChangeListener(this);
66
      bar = (SeekBar)findViewById(R.id.dynamicSeekNoise1);
67
      bar.setProgress(0);
68
      bar.setOnSeekBarChangeListener(this);
69
      bar = (SeekBar)findViewById(R.id.dynamicSeekNoise2);
70
      bar.setProgress(0);
71
      bar.setOnSeekBarChangeListener(this);
72
      }
73

    
74
///////////////////////////////////////////////////////////////////
75
    @Override
76
    protected void onResume() 
77
      {
78
      super.onResume();
79
      
80
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
81
      mView.onResume();
82
      }
83

    
84
///////////////////////////////////////////////////////////////////
85
    @Override
86
    protected void onPause() 
87
      {
88
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
89
      mView.onPause();
90
         
91
      super.onPause();
92
      }
93
    
94
///////////////////////////////////////////////////////////////////
95
    @Override
96
    public void onStop()
97
      {
98
      super.onStop();
99
      }
100

    
101
///////////////////////////////////////////////////////////////////
102
    @Override
103
    public void onDestroy()
104
      {  
105
      Distorted.onDestroy();
106
      super.onDestroy();
107
      }     
108
 
109
///////////////////////////////////////////////////////////////////
110
    
111
    public void Loop(View v)
112
      {
113
      DynamicSurfaceView.setMode(Dynamic1D.MODE_LOOP);
114
      }     
115
    
116
///////////////////////////////////////////////////////////////////
117

    
118
    public void Path(View v)
119
      {
120
      DynamicSurfaceView.setMode(Dynamic1D.MODE_PATH);
121
      }  
122

    
123
///////////////////////////////////////////////////////////////////
124

    
125
    public void Jump(View v)
126
      {
127
      DynamicSurfaceView.setMode(Dynamic1D.MODE_JUMP);
128
      }  
129
    
130
///////////////////////////////////////////////////////////////////
131

    
132
    public void Dim1D(View v)
133
      {
134
      DynamicSurfaceView.setDimension(DynamicSurfaceView.DIM_1D);
135
      }  
136

    
137
///////////////////////////////////////////////////////////////////
138

    
139
    public void Dim2D(View v)
140
      {
141
      DynamicSurfaceView.setDimension(DynamicSurfaceView.DIM_2D);
142
      }  
143
    
144
///////////////////////////////////////////////////////////////////
145

    
146
    public void Dim3DXY(View v)
147
      {
148
      DynamicSurfaceView.setDimension(DynamicSurfaceView.DIM_3DXY);
149
      }  
150

    
151
///////////////////////////////////////////////////////////////////
152

    
153
    public void Dim3DXZ(View v)
154
      {
155
      DynamicSurfaceView.setDimension(DynamicSurfaceView.DIM_3DXZ);
156
      }  
157
    
158
///////////////////////////////////////////////////////////////////
159
    
160
    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) 
161
      {
162
      int id = bar.getId();
163

    
164
      if( id == R.id.dynamicSeekDuration )
165
        {
166
        float v = progress*200;
167
        int i = (int)(v/100);
168
        float t = i/10.0f;
169
        DynamicSurfaceView.setDuration((int)v);
170
        textD.setText("Duration: "+(int)t+" s");
171
        }
172
      else
173
        {
174
        switch(id)
175
          {
176
          case R.id.dynamicSeekNoise0  : progress0 = progress; break;
177
          case R.id.dynamicSeekNoise1  : progress1 = progress; break;
178
          case R.id.dynamicSeekNoise2  : progress2 = progress; break;
179
          }
180

    
181
        DynamicSurfaceView.setNoise(progress0/100.0f,progress1/100.0f,progress2/100.0f);
182
        textN.setText("Noise: "+(progress0/100.f)+" "+(progress1/100.f)+" "+(progress2/100.f));
183
        }
184
      }
185

    
186
///////////////////////////////////////////////////////////////////
187

    
188
    public void onStartTrackingTouch(SeekBar bar) { }
189
    
190
///////////////////////////////////////////////////////////////////
191

    
192
    public void onStopTrackingTouch(SeekBar bar)  { }
193
    
194
///////////////////////////////////////////////////////////////////
195
// end of file
196
}
(1-1/3)