Project

General

Profile

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

examples / src / main / java / org / distorted / examples / dynamic / DynamicActivity.java @ 97dadfe5

1 bc0a685b Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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 f988589e Leszek Koltunski
package org.distorted.examples.dynamic;
21 427ab7bf Leszek Koltunski
22 5068fa06 Leszek Koltunski
import org.distorted.library.Distorted;
23 7589635e Leszek Koltunski
import org.distorted.library.type.Dynamic1D;
24 5068fa06 Leszek Koltunski
import org.distorted.examples.R;
25 427ab7bf Leszek Koltunski
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 f988589e Leszek Koltunski
public class DynamicActivity extends Activity implements OnSeekBarChangeListener
37 427ab7bf Leszek Koltunski
    {
38
    private TextView textD, textN;
39 8b7c0ab3 Leszek Koltunski
    private int progress0, progress1, progress2;
40
41 427ab7bf Leszek Koltunski
///////////////////////////////////////////////////////////////////
42
    @Override
43
    protected void onCreate(Bundle savedInstanceState) 
44
      {
45
      super.onCreate(savedInstanceState);
46 8b7c0ab3 Leszek Koltunski
      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
      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);
68 427ab7bf Leszek Koltunski
      }
69
70
///////////////////////////////////////////////////////////////////
71
    @Override
72
    protected void onResume() 
73
      {
74
      super.onResume();
75
      
76 8b7c0ab3 Leszek Koltunski
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
77 427ab7bf Leszek Koltunski
      mView.onResume();
78
      }
79
80
///////////////////////////////////////////////////////////////////
81
    @Override
82
    protected void onPause() 
83
      {
84 8b7c0ab3 Leszek Koltunski
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
85 427ab7bf Leszek Koltunski
      mView.onPause();
86
         
87
      super.onPause();
88
      }
89
    
90
///////////////////////////////////////////////////////////////////
91
    @Override
92
    public void onStop()
93
      {
94
      super.onStop();
95
      }
96
97
///////////////////////////////////////////////////////////////////
98
    @Override
99
    public void onDestroy()
100
      {  
101
      Distorted.onDestroy();
102
      super.onDestroy();
103
      }     
104
 
105
///////////////////////////////////////////////////////////////////
106
    
107
    public void Loop(View v)
108
      {
109 f988589e Leszek Koltunski
      DynamicSurfaceView.setMode(Dynamic1D.MODE_LOOP);
110 427ab7bf Leszek Koltunski
      }     
111
    
112
///////////////////////////////////////////////////////////////////
113
114
    public void Path(View v)
115
      {
116 f988589e Leszek Koltunski
      DynamicSurfaceView.setMode(Dynamic1D.MODE_PATH);
117 427ab7bf Leszek Koltunski
      }  
118
119
///////////////////////////////////////////////////////////////////
120
121
    public void Jump(View v)
122
      {
123 f988589e Leszek Koltunski
      DynamicSurfaceView.setMode(Dynamic1D.MODE_JUMP);
124 427ab7bf Leszek Koltunski
      }  
125
    
126
///////////////////////////////////////////////////////////////////
127
128
    public void Dim1D(View v)
129
      {
130 f988589e Leszek Koltunski
      DynamicSurfaceView.setDimension(DynamicSurfaceView.DIM_1D);
131 427ab7bf Leszek Koltunski
      }  
132
133
///////////////////////////////////////////////////////////////////
134
135
    public void Dim2D(View v)
136
      {
137 f988589e Leszek Koltunski
      DynamicSurfaceView.setDimension(DynamicSurfaceView.DIM_2D);
138 427ab7bf Leszek Koltunski
      }  
139
    
140
///////////////////////////////////////////////////////////////////
141
142
    public void Dim3DXY(View v)
143
      {
144 f988589e Leszek Koltunski
      DynamicSurfaceView.setDimension(DynamicSurfaceView.DIM_3DXY);
145 427ab7bf Leszek Koltunski
      }  
146
147
///////////////////////////////////////////////////////////////////
148
149
    public void Dim3DXZ(View v)
150
      {
151 f988589e Leszek Koltunski
      DynamicSurfaceView.setDimension(DynamicSurfaceView.DIM_3DXZ);
152 427ab7bf Leszek Koltunski
      }  
153
    
154
///////////////////////////////////////////////////////////////////
155
    
156
    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) 
157
      {
158 8b7c0ab3 Leszek Koltunski
      int id = bar.getId();
159
160
      if( id == R.id.dynamicSeekDuration )
161
        {
162
        float v = progress*200;
163
        int i = (int)(v/100);
164
        float t = i/10.0f;
165
        DynamicSurfaceView.setDuration((int)v);
166
        textD.setText("Duration: "+(int)t+" s");
167
        }
168
      else
169 427ab7bf Leszek Koltunski
        {
170 8b7c0ab3 Leszek Koltunski
        switch(id)
171
          {
172
          case R.id.dynamicSeekNoise0  : progress0 = progress; break;
173
          case R.id.dynamicSeekNoise1  : progress1 = progress; break;
174
          case R.id.dynamicSeekNoise2  : progress2 = progress; break;
175
          }
176
177
        DynamicSurfaceView.setNoise(progress0/100.0f,progress1/100.0f,progress2/100.0f);
178
        textN.setText("Noise: "+(progress0/100.f)+" "+(progress1/100.f)+" "+(progress2/100.f));
179 427ab7bf Leszek Koltunski
        }
180
      }
181
182
///////////////////////////////////////////////////////////////////
183
184
    public void onStartTrackingTouch(SeekBar bar) { }
185
    
186
///////////////////////////////////////////////////////////////////
187
188
    public void onStopTrackingTouch(SeekBar bar)  { }
189
    
190
///////////////////////////////////////////////////////////////////
191
// end of file
192
}