1 |
42aa970f
|
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 |
|
|
package org.distorted.examples.meshfile;
|
21 |
|
|
|
22 |
|
|
import android.app.Activity;
|
23 |
|
|
import android.opengl.GLSurfaceView;
|
24 |
|
|
import android.os.Bundle;
|
25 |
71c7624f
|
Leszek Koltunski
|
import android.view.View;
|
26 |
|
|
import android.widget.AdapterView;
|
27 |
|
|
import android.widget.ArrayAdapter;
|
28 |
|
|
import android.widget.Spinner;
|
29 |
42aa970f
|
Leszek Koltunski
|
|
30 |
|
|
import org.distorted.examples.R;
|
31 |
|
|
import org.distorted.library.main.DistortedLibrary;
|
32 |
|
|
|
33 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34 |
|
|
|
35 |
71c7624f
|
Leszek Koltunski
|
public class MeshFileActivity extends Activity implements AdapterView.OnItemSelectedListener
|
36 |
42aa970f
|
Leszek Koltunski
|
{
|
37 |
71c7624f
|
Leszek Koltunski
|
private String mName;
|
38 |
|
|
private String[] mNames = new String[] { "deferredjob",
|
39 |
|
|
"meshjoin" ,
|
40 |
|
|
"predeform" ,
|
41 |
|
|
"singlemesh" ,
|
42 |
|
|
"cube2" ,
|
43 |
|
|
"cube3" ,
|
44 |
|
|
"cube4" ,
|
45 |
|
|
"cube5" ,
|
46 |
|
|
"pyra3" ,
|
47 |
|
|
"pyra4" ,
|
48 |
|
|
"pyra5"
|
49 |
|
|
};
|
50 |
|
|
|
51 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
52 |
|
|
|
53 |
42aa970f
|
Leszek Koltunski
|
@Override
|
54 |
|
|
protected void onCreate(Bundle icicle)
|
55 |
|
|
{
|
56 |
|
|
super.onCreate(icicle);
|
57 |
|
|
setContentView(R.layout.meshfilelayout);
|
58 |
71c7624f
|
Leszek Koltunski
|
|
59 |
|
|
Spinner meshSpinner = findViewById(R.id.meshfileSpinner);
|
60 |
|
|
meshSpinner.setOnItemSelectedListener(this);
|
61 |
|
|
|
62 |
|
|
ArrayAdapter<String> adapterBitmap = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, mNames);
|
63 |
|
|
adapterBitmap.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
64 |
|
|
meshSpinner.setAdapter(adapterBitmap);
|
65 |
42aa970f
|
Leszek Koltunski
|
}
|
66 |
|
|
|
67 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
68 |
|
|
|
69 |
|
|
@Override
|
70 |
|
|
protected void onPause()
|
71 |
|
|
{
|
72 |
|
|
GLSurfaceView view = this.findViewById(R.id.meshfileSurfaceView);
|
73 |
|
|
view.onPause();
|
74 |
|
|
DistortedLibrary.onPause();
|
75 |
|
|
super.onPause();
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
79 |
|
|
|
80 |
|
|
@Override
|
81 |
|
|
protected void onResume()
|
82 |
|
|
{
|
83 |
|
|
super.onResume();
|
84 |
|
|
GLSurfaceView view = this.findViewById(R.id.meshfileSurfaceView);
|
85 |
|
|
view.onResume();
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
89 |
|
|
|
90 |
|
|
@Override
|
91 |
|
|
protected void onDestroy()
|
92 |
|
|
{
|
93 |
|
|
DistortedLibrary.onDestroy();
|
94 |
|
|
super.onDestroy();
|
95 |
|
|
}
|
96 |
71c7624f
|
Leszek Koltunski
|
|
97 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
98 |
|
|
|
99 |
|
|
public void Open(View v)
|
100 |
|
|
{
|
101 |
|
|
MeshFileSurfaceView view = this.findViewById(R.id.meshfileSurfaceView);
|
102 |
|
|
MeshFileRenderer renderer = view.getRenderer();
|
103 |
|
|
|
104 |
|
|
renderer.open(mName);
|
105 |
|
|
}
|
106 |
|
|
|
107 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
108 |
|
|
|
109 |
|
|
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)
|
110 |
|
|
{
|
111 |
|
|
if( parent.getId()==R.id.meshfileSpinner )
|
112 |
|
|
{
|
113 |
|
|
mName = mNames[pos];
|
114 |
|
|
}
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
118 |
|
|
|
119 |
|
|
public void onNothingSelected(AdapterView<?> parent)
|
120 |
|
|
{
|
121 |
|
|
}
|
122 |
42aa970f
|
Leszek Koltunski
|
}
|