Project

General

Profile

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

examples / src / main / java / org / distorted / examples / girl / GirlActivity.java @ 6f3024ae

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 TextView textSwing, textSize, textHips;
37
   
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39
    
40
    @Override
41
    protected void onCreate(Bundle icicle) 
42
      {
43
      super.onCreate(icicle);
44
      
45
      setContentView(R.layout.girllayout);
46
           
47
      textSwing = (TextView)findViewById(R.id.girlTextSwing);
48
      textSize  = (TextView)findViewById(R.id.girlTextSize);
49
      textHips  = (TextView)findViewById(R.id.girlTextHips);
50

    
51
      SeekBar barSwing = (SeekBar)findViewById(R.id.girlSeekSwing);
52
      SeekBar barSize  = (SeekBar)findViewById(R.id.girlSeekSize);
53
      SeekBar barHips  = (SeekBar)findViewById(R.id.girlSeekHips);
54
      
55
      barSwing.setOnSeekBarChangeListener(this); 
56
      barSize.setOnSeekBarChangeListener(this); 
57
      barHips.setOnSeekBarChangeListener(this); 
58
  
59
      barSwing.setProgress(0);
60
      barSize.setProgress(50);
61
      barHips.setProgress(0);
62

    
63
      textSwing.setText(getString(R.string.swing_placeholder,0.0f));
64
      textSize.setText(getString(R.string.size_placeholder,1.0f));
65
      textHips.setText(getString(R.string.hips_placeholder,0.0f));
66
      }
67

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

    
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80
    
81
    @Override
82
    protected void onResume() 
83
      {
84
      super.onResume();
85
      
86
      GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.girlSurfaceView);
87
      view.onResume();
88
      }
89
 
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91
    
92
    @Override
93
    protected void onDestroy() 
94
      {
95
      Distorted.onDestroy();  
96
      super.onDestroy();
97
      }
98
   
99
///////////////////////////////////////////////////////////////////
100
    
101
    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) 
102
      {
103
      int v;
104
      float s;
105
      GirlSurfaceView view = (GirlSurfaceView) this.findViewById(R.id.girlSurfaceView);
106

    
107
      switch (bar.getId()) 
108
        {
109
        case R.id.girlSeekSwing: v = progress/5;
110
                                 view.getRenderer().setSwing(v);
111
                                 textSwing.setText(getString(R.string.swing_placeholder,v));
112
                                 break;
113
        case R.id.girlSeekSize : if( progress> 50) s = (progress-50)/16.0f + 1.0f;
114
                                 else              s = 0.015f*progress + 0.25f;
115
                                 view.getRenderer().setSize(s);
116
                                 textSize.setText(getString(R.string.size_placeholder,(((int)(s*10))/10.0f)));
117
                                 break;
118
        case R.id.girlSeekHips : v = progress/5;
119
                                 view.getRenderer().setHips(v);
120
                                 textHips.setText(getString(R.string.hips_placeholder,v));
121
                                 break;
122
        }
123
      }
124

    
125
///////////////////////////////////////////////////////////////////
126

    
127
    public void onStartTrackingTouch(SeekBar bar) { }
128
    
129
///////////////////////////////////////////////////////////////////
130

    
131
    public void onStopTrackingTouch(SeekBar bar)  { }
132
     
133
}
(1-1/3)