Project

General

Profile

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

examples / src / main / java / org / distorted / examples / girl / GirlActivity.java @ de1c3c51

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

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

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

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

    
34
public class GirlActivity extends Activity  implements OnSeekBarChangeListener
35
{
36
    private SeekBar barSwing, barSize, barHips;
37
    private TextView textSwing, textSize, textHips;
38
   
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40
    
41
    @Override
42
    protected void onCreate(Bundle icicle) 
43
      {
44
      super.onCreate(icicle);
45
      
46
      setContentView(R.layout.girllayout);
47
           
48
      textSwing = (TextView)findViewById(R.id.girlTextSwing);
49
      textSize  = (TextView)findViewById(R.id.girlTextSize);
50
      textHips  = (TextView)findViewById(R.id.girlTextHips);
51

    
52
      barSwing = (SeekBar)findViewById(R.id.girlSeekSwing);
53
      barSize  = (SeekBar)findViewById(R.id.girlSeekSize);
54
      barHips  = (SeekBar)findViewById(R.id.girlSeekHips);
55
      
56
      barSwing.setOnSeekBarChangeListener(this); 
57
      barSize.setOnSeekBarChangeListener(this); 
58
      barHips.setOnSeekBarChangeListener(this); 
59
  
60
      barSwing.setProgress(0);
61
      barSize.setProgress(50);
62
      barHips.setProgress(0);
63
      
64
      textSwing.setText("Swing: 0");
65
      textSize.setText("Size: 1.0");
66
      textHips.setText("Hips: 0");
67
      }
68

    
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70
    
71
    @Override
72
    protected void onPause() 
73
      {
74
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.girlSurfaceView);
75
      mView.onPause();
76
      
77
      super.onPause();
78
      }
79

    
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81
    
82
    @Override
83
    protected void onResume() 
84
      {
85
      super.onResume();
86
      
87
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.girlSurfaceView);
88
      mView.onResume();
89
      }
90
 
91
///////////////////////////////////////////////////////////////////////////////////////////////////
92
    
93
    @Override
94
    protected void onDestroy() 
95
      {
96
      Distorted.onDestroy();  
97
      super.onDestroy();
98
      }
99
   
100
///////////////////////////////////////////////////////////////////
101
    
102
    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) 
103
      {
104
      int v;
105
      float s;
106
      
107
      switch (bar.getId()) 
108
        {
109
        case R.id.girlSeekSwing: v = progress/5;
110
                             GirlRenderer.setSwing(v);
111
                             textSwing.setText("Swing: "+v);
112
                             break;
113
        case R.id.girlSeekSize : if( progress> 50)
114
                               {
115
                            s = (progress-50)/16.0f + 1.0f;
116
                               }
117
                             else
118
                               {
119
                            s = 0.015f*progress + 0.25f;
120
                               }
121
                             GirlRenderer.setSize(s);
122
                             textSize.setText("Size: "+(((int)(s*10))/10.0f));
123
                             break;     
124
        case R.id.girlSeekHips : v = progress/5;
125
                             GirlRenderer.setHips(v);
126
                             textHips.setText("Hips: "+v);
127
                             break;
128
        
129
        }
130
      }
131

    
132
///////////////////////////////////////////////////////////////////
133

    
134
    public void onStartTrackingTouch(SeekBar bar) { }
135
    
136
///////////////////////////////////////////////////////////////////
137

    
138
    public void onStopTrackingTouch(SeekBar bar)  { }
139
     
140
}
(1-1/3)