Project

General

Profile

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

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

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.main.DistortedLibrary;
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 = findViewById(R.id.girlTextSwing);
48
      textSize  = findViewById(R.id.girlTextSize);
49
      textHips  = findViewById(R.id.girlTextHips);
50

    
51
      SeekBar barSwing = findViewById(R.id.girlSeekSwing);
52
      SeekBar barSize  = findViewById(R.id.girlSeekSize);
53
      SeekBar barHips  = 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));
66
      }
67

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

    
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80
    
81
    @Override
82
    protected void onResume() 
83
      {
84
      super.onResume();
85
      GLSurfaceView view = findViewById(R.id.girlSurfaceView);
86
      view.onResume();
87
      }
88
 
89
///////////////////////////////////////////////////////////////////////////////////////////////////
90
    
91
    @Override
92
    protected void onDestroy() 
93
      {
94
      DistortedLibrary.onDestroy();
95
      super.onDestroy();
96
      }
97

    
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99

    
100
    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) 
101
      {
102
      float v;
103
      int i;
104
      GirlSurfaceView view = findViewById(R.id.girlSurfaceView);
105

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

    
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125

    
126
    public void onStartTrackingTouch(SeekBar bar) { }
127

    
128
///////////////////////////////////////////////////////////////////////////////////////////////////
129

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