Revision 08f92d82
Added by Leszek Koltunski over 8 years ago
src/main/AndroidManifest.xml | ||
---|---|---|
35 | 35 |
<activity android:name=".cubes.CubesActivity" /> |
36 | 36 |
<activity android:name=".quaternion.QuaternionActivity" /> |
37 | 37 |
<activity android:name=".matrix3d.Matrix3DActivity" /> |
38 |
<activity android:name=".vertex3d.Vertex3DActivity" /> |
|
38 | 39 |
<activity android:name=".plainmonalisa.PlainMonaLisaActivity" /> |
39 | 40 |
<activity android:name=".save.SaveActivity"/> |
40 | 41 |
</application> |
src/main/java/org/distorted/examples/TableOfContents.java | ||
---|---|---|
54 | 54 |
import org.distorted.examples.cubes.CubesActivity; |
55 | 55 |
import org.distorted.examples.quaternion.QuaternionActivity; |
56 | 56 |
import org.distorted.examples.matrix3d.Matrix3DActivity; |
57 |
import org.distorted.examples.vertex3d.Vertex3DActivity; |
|
57 | 58 |
import org.distorted.examples.plainmonalisa.PlainMonaLisaActivity; |
58 | 59 |
import org.distorted.examples.save.SaveActivity; |
59 | 60 |
|
... | ... | |
258 | 259 |
activityMapping.put(i++, Matrix3DActivity.class); |
259 | 260 |
} |
260 | 261 |
|
262 |
{ |
|
263 |
final Map<String, Object> item = new HashMap<>(); |
|
264 |
item.put(ITEM_IMAGE, R.drawable.icon_example_vertex3d); |
|
265 |
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_vertex3d)); |
|
266 |
item.put(ITEM_SUBTITLE, getText(R.string.example_vertex3d_subtitle)); |
|
267 |
data.add(item); |
|
268 |
activityMapping.put(i++, Vertex3DActivity.class); |
|
269 |
} |
|
270 |
|
|
261 | 271 |
{ |
262 | 272 |
final Map<String, Object> item = new HashMap<>(); |
263 | 273 |
item.put(ITEM_IMAGE, R.drawable.icon_example_monalisa); |
src/main/java/org/distorted/examples/matrix3d/Matrix3DActivity.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import org.distorted.library.Distorted; |
23 | 23 |
import org.distorted.examples.R; |
24 |
import org.distorted.library.EffectNames; |
|
24 | 25 |
|
25 | 26 |
import android.app.Activity; |
26 | 27 |
import android.os.Bundle; |
... | ... | |
35 | 36 |
|
36 | 37 |
public class Matrix3DActivity extends Activity implements OnSeekBarChangeListener |
37 | 38 |
{ |
38 |
public static final int MOVE =0; |
|
39 |
public static final int SCALE =1; |
|
40 |
public static final int ROTATE =2; |
|
41 |
public static final int SHEAR =3; |
|
42 |
|
|
43 | 39 |
private SeekBar bar; |
44 | 40 |
private TextView textMove, textScale, textRotate, textShear; |
45 | 41 |
private int moveX, moveY, moveZ; |
... | ... | |
54 | 50 |
private float frotateX, frotateY, frotateZ, frotateA; |
55 | 51 |
private float fshearX, fshearY, fshearZ; |
56 | 52 |
|
57 |
private int[] effects = new int[4];
|
|
53 |
private EffectNames[] effects = new EffectNames[4];
|
|
58 | 54 |
|
59 | 55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
60 | 56 |
|
... | ... | |
70 | 66 |
|
71 | 67 |
public void Default(View view) |
72 | 68 |
{ |
73 |
effects[0] = MOVE; |
|
74 |
effects[1] = SCALE; |
|
75 |
effects[2] = ROTATE; |
|
76 |
effects[3] = SHEAR; |
|
69 |
effects[0] = EffectNames.MOVE;
|
|
70 |
effects[1] = EffectNames.SCALE;
|
|
71 |
effects[2] = EffectNames.ROTATE;
|
|
72 |
effects[3] = EffectNames.SHEAR;
|
|
77 | 73 |
|
78 | 74 |
moveX = 50; |
79 | 75 |
moveY = 50; |
... | ... | |
151 | 147 |
|
152 | 148 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
153 | 149 |
|
154 |
private void moveUp(int effect)
|
|
150 |
private void moveUp(EffectNames name)
|
|
155 | 151 |
{ |
156 | 152 |
int len = effects.length-1; |
157 | 153 |
int index = -1; |
158 | 154 |
|
159 | 155 |
for(int i=0; i<=len; i++) |
160 | 156 |
{ |
161 |
if( effects[i]==effect )
|
|
157 |
if( effects[i]==name )
|
|
162 | 158 |
{ |
163 | 159 |
index=i; |
164 | 160 |
break; |
... | ... | |
170 | 166 |
for(int i=0; i<len; i++) |
171 | 167 |
effects[i] = effects[i+1]; |
172 | 168 |
|
173 |
effects[len] = effect;
|
|
169 |
effects[len] = name;
|
|
174 | 170 |
} |
175 | 171 |
else if( index>0 ) |
176 | 172 |
{ |
177 | 173 |
effects[index] = effects[index-1]; |
178 |
effects[index-1] = effect;
|
|
174 |
effects[index-1] = name;
|
|
179 | 175 |
} |
180 | 176 |
|
181 | 177 |
addViews(); |
... | ... | |
185 | 181 |
|
186 | 182 |
public void ButtonMove(View v) |
187 | 183 |
{ |
188 |
moveUp(MOVE);
|
|
184 |
moveUp(EffectNames.MOVE);
|
|
189 | 185 |
} |
190 | 186 |
|
191 | 187 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
192 | 188 |
|
193 | 189 |
public void ButtonScale(View v) |
194 | 190 |
{ |
195 |
moveUp(SCALE);
|
|
191 |
moveUp(EffectNames.SCALE);
|
|
196 | 192 |
} |
197 | 193 |
|
198 | 194 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
199 | 195 |
|
200 | 196 |
public void ButtonRotate(View v) |
201 | 197 |
{ |
202 |
moveUp(ROTATE);
|
|
198 |
moveUp(EffectNames.ROTATE);
|
|
203 | 199 |
} |
204 | 200 |
|
205 | 201 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
206 | 202 |
|
207 | 203 |
public void ButtonShear(View v) |
208 | 204 |
{ |
209 |
moveUp(SHEAR);
|
|
205 |
moveUp(EffectNames.SHEAR);
|
|
210 | 206 |
} |
211 | 207 |
|
212 | 208 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/matrix3d/Matrix3DRenderer.java | ||
---|---|---|
28 | 28 |
import org.distorted.examples.R; |
29 | 29 |
|
30 | 30 |
import org.distorted.library.DistortedCubes; |
31 |
import org.distorted.library.EffectNames; |
|
31 | 32 |
import org.distorted.library.EffectTypes; |
32 | 33 |
import org.distorted.library.type.Dynamic3D; |
33 | 34 |
import org.distorted.library.type.Static3D; |
... | ... | |
49 | 50 |
private GLSurfaceView mView; |
50 | 51 |
private static DistortedCubes mCube; |
51 | 52 |
|
52 |
private static int[] order;
|
|
53 |
private static EffectNames[] order;
|
|
53 | 54 |
|
54 | 55 |
private static Dynamic3D mMoveInter, mScaleInter, mShearInter; |
55 | 56 |
private static Dynamic4D mDynamicRotate; |
... | ... | |
87 | 88 |
|
88 | 89 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
89 | 90 |
|
90 |
public static void setOrder(int[] effects)
|
|
91 |
public static void setOrder(EffectNames[] effects)
|
|
91 | 92 |
{ |
92 | 93 |
order = effects; |
93 | 94 |
setMatrixEffects(); |
... | ... | |
103 | 104 |
{ |
104 | 105 |
switch(order[i]) |
105 | 106 |
{ |
106 |
case Matrix3DActivity.MOVE : mCube.move(mMoveInter) ; break;
|
|
107 |
case Matrix3DActivity.SCALE : mCube.scale(mScaleInter) ; break;
|
|
108 |
case Matrix3DActivity.ROTATE: mCube.rotate(mDynamicRotate,mZeroPoint); break;
|
|
109 |
case Matrix3DActivity.SHEAR : mCube.shear(mShearInter, mZeroPoint) ; break;
|
|
107 |
case MOVE : mCube.move(mMoveInter) ; break; |
|
108 |
case SCALE : mCube.scale(mScaleInter) ; break; |
|
109 |
case ROTATE: mCube.rotate(mDynamicRotate,mZeroPoint); break; |
|
110 |
case SHEAR : mCube.shear(mShearInter, mZeroPoint) ; break; |
|
110 | 111 |
} |
111 | 112 |
} |
112 | 113 |
} |
... | ... | |
182 | 183 |
} |
183 | 184 |
catch(Exception ex) |
184 | 185 |
{ |
185 |
android.util.Log.e("Quaternion", ex.getMessage() );
|
|
186 |
android.util.Log.e("Matrix3D", ex.getMessage() );
|
|
186 | 187 |
} |
187 | 188 |
} |
188 | 189 |
} |
src/main/java/org/distorted/examples/vertex3d/Vertex3DActivity.java | ||
---|---|---|
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.vertex3d; |
|
21 |
|
|
22 |
import android.app.Activity; |
|
23 |
import android.opengl.GLSurfaceView; |
|
24 |
import android.os.Bundle; |
|
25 |
import android.view.View; |
|
26 |
import android.widget.LinearLayout; |
|
27 |
import android.widget.SeekBar; |
|
28 |
import android.widget.SeekBar.OnSeekBarChangeListener; |
|
29 |
import android.widget.TextView; |
|
30 |
|
|
31 |
import org.distorted.examples.R; |
|
32 |
import org.distorted.library.Distorted; |
|
33 |
import org.distorted.library.EffectNames; |
|
34 |
|
|
35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
36 |
|
|
37 |
public class Vertex3DActivity extends Activity implements OnSeekBarChangeListener |
|
38 |
{ |
|
39 |
private SeekBar bar; |
|
40 |
private TextView textDeform, textDistort, textSink, textSwirl; |
|
41 |
private int moveX, moveY, moveZ; |
|
42 |
private int scaleX, scaleY, scaleZ; |
|
43 |
private int rotateX, rotateY, rotateZ, rotateA; |
|
44 |
private int shearX, shearY, shearZ; |
|
45 |
|
|
46 |
private int maxX, maxY, maxZ; |
|
47 |
|
|
48 |
private float fmoveX, fmoveY, fmoveZ; |
|
49 |
private float fscaleX, fscaleY, fscaleZ; |
|
50 |
private float frotateX, frotateY, frotateZ, frotateA; |
|
51 |
private float fshearX, fshearY, fshearZ; |
|
52 |
|
|
53 |
private EffectNames[] effects = new EffectNames[4]; |
|
54 |
|
|
55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
56 |
|
|
57 |
@Override |
|
58 |
protected void onCreate(Bundle icicle) |
|
59 |
{ |
|
60 |
super.onCreate(icicle); |
|
61 |
setContentView(R.layout.vertex3dlayout); |
|
62 |
Default(null); |
|
63 |
} |
|
64 |
|
|
65 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
66 |
|
|
67 |
public void Default(View view) |
|
68 |
{ |
|
69 |
effects[0] = EffectNames.DEFORM; |
|
70 |
effects[1] = EffectNames.DISTORT; |
|
71 |
effects[2] = EffectNames.SINK; |
|
72 |
effects[3] = EffectNames.SWIRL; |
|
73 |
|
|
74 |
moveX = 50; |
|
75 |
moveY = 50; |
|
76 |
moveZ = 50; |
|
77 |
|
|
78 |
scaleX = 50; |
|
79 |
scaleY = 50; |
|
80 |
scaleZ = 50; |
|
81 |
|
|
82 |
rotateX = 100; |
|
83 |
rotateY = 50; |
|
84 |
rotateZ = 50; |
|
85 |
rotateA = 50; |
|
86 |
|
|
87 |
shearX = 50; |
|
88 |
shearY = 50; |
|
89 |
shearZ = 50; |
|
90 |
|
|
91 |
addViews(); |
|
92 |
} |
|
93 |
|
|
94 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
95 |
|
|
96 |
private void addViews() |
|
97 |
{ |
|
98 |
LinearLayout layout = (LinearLayout)findViewById(R.id.vertex3dlayout); |
|
99 |
|
|
100 |
layout.removeAllViews(); |
|
101 |
|
|
102 |
View deform = getLayoutInflater().inflate(R.layout.vertex3ddeform , null); |
|
103 |
View distort= getLayoutInflater().inflate(R.layout.vertex3ddistort, null); |
|
104 |
View sink = getLayoutInflater().inflate(R.layout.vertex3dsink , null); |
|
105 |
View swirl = getLayoutInflater().inflate(R.layout.vertex3dswirl , null); |
|
106 |
|
|
107 |
for( int i=effects.length-1 ; i>=0 ; i-- ) |
|
108 |
{ |
|
109 |
switch(effects[i]) |
|
110 |
{ |
|
111 |
case DEFORM : layout.addView(deform , 0); break; |
|
112 |
case DISTORT: layout.addView(distort, 0); break; |
|
113 |
case SINK : layout.addView(sink , 0); break; |
|
114 |
case SWIRL : layout.addView(swirl , 0); break; |
|
115 |
} |
|
116 |
} |
|
117 |
|
|
118 |
textDeform = (TextView)findViewById(R.id.vertex3ddeformText); |
|
119 |
textDistort= (TextView)findViewById(R.id.vertex3ddistortText); |
|
120 |
textSink = (TextView)findViewById(R.id.vertex3dsinkText); |
|
121 |
textSwirl = (TextView)findViewById(R.id.vertex3dswirlText); |
|
122 |
|
|
123 |
setDeformText(); |
|
124 |
setDistortText(); |
|
125 |
setSinkText(); |
|
126 |
setSwirlText(); |
|
127 |
|
|
128 |
setBar(R.id.vertex3ddeformBar1, moveX); |
|
129 |
setBar(R.id.vertex3ddeformBar2, moveY); |
|
130 |
setBar(R.id.vertex3ddeformBar3, moveZ); |
|
131 |
|
|
132 |
setBar(R.id.vertex3ddistortBar1, scaleX); |
|
133 |
setBar(R.id.vertex3ddistortBar2, scaleY); |
|
134 |
setBar(R.id.vertex3ddistortBar3, scaleZ); |
|
135 |
|
|
136 |
setBar(R.id.vertex3dsinkBar1, rotateX); |
|
137 |
setBar(R.id.vertex3dsinkBar2, rotateY); |
|
138 |
setBar(R.id.vertex3dsinkBar3, rotateZ); |
|
139 |
|
|
140 |
setBar(R.id.vertex3dswirlBar1, shearX); |
|
141 |
setBar(R.id.vertex3dswirlBar2, shearY); |
|
142 |
setBar(R.id.vertex3dswirlBar3, shearZ); |
|
143 |
|
|
144 |
Vertex3DRenderer.setOrder(effects); |
|
145 |
} |
|
146 |
|
|
147 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
148 |
|
|
149 |
private void moveUp(EffectNames name) |
|
150 |
{ |
|
151 |
int len = effects.length-1; |
|
152 |
int index = -1; |
|
153 |
|
|
154 |
for(int i=0; i<=len; i++) |
|
155 |
{ |
|
156 |
if( effects[i]==name ) |
|
157 |
{ |
|
158 |
index=i; |
|
159 |
break; |
|
160 |
} |
|
161 |
} |
|
162 |
|
|
163 |
if( index==0 ) |
|
164 |
{ |
|
165 |
for(int i=0; i<len; i++) |
|
166 |
effects[i] = effects[i+1]; |
|
167 |
|
|
168 |
effects[len] = name; |
|
169 |
} |
|
170 |
else if( index>0 ) |
|
171 |
{ |
|
172 |
effects[index] = effects[index-1]; |
|
173 |
effects[index-1] = name; |
|
174 |
} |
|
175 |
|
|
176 |
addViews(); |
|
177 |
} |
|
178 |
|
|
179 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
180 |
|
|
181 |
public void ButtonDeform(View v) |
|
182 |
{ |
|
183 |
moveUp(EffectNames.DEFORM); |
|
184 |
} |
|
185 |
|
|
186 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
187 |
|
|
188 |
public void ButtonDistort(View v) |
|
189 |
{ |
|
190 |
moveUp(EffectNames.DISTORT); |
|
191 |
} |
|
192 |
|
|
193 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
194 |
|
|
195 |
public void ButtonSink(View v) |
|
196 |
{ |
|
197 |
moveUp(EffectNames.SINK); |
|
198 |
} |
|
199 |
|
|
200 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
201 |
|
|
202 |
public void ButtonSwirl(View v) |
|
203 |
{ |
|
204 |
moveUp(EffectNames.SWIRL); |
|
205 |
} |
|
206 |
|
|
207 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
208 |
|
|
209 |
private void setBar(int id, int value) |
|
210 |
{ |
|
211 |
bar = (SeekBar)findViewById(id); |
|
212 |
bar.setOnSeekBarChangeListener(this); |
|
213 |
bar.setProgress(value); |
|
214 |
} |
|
215 |
|
|
216 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
217 |
|
|
218 |
private void computeDeform() |
|
219 |
{ |
|
220 |
fmoveX = (moveX-50)*maxX/50.0f; |
|
221 |
fmoveY = (moveY-50)*maxY/50.0f; |
|
222 |
fmoveZ = (moveZ-50)*maxZ/50.0f; |
|
223 |
|
|
224 |
Vertex3DRenderer.setDeform( fmoveX, fmoveY, fmoveZ); |
|
225 |
} |
|
226 |
|
|
227 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
228 |
|
|
229 |
private void setDeformText() |
|
230 |
{ |
|
231 |
fmoveX = ((int)(100*fmoveX))/100.0f; |
|
232 |
fmoveY = ((int)(100*fmoveY))/100.0f; |
|
233 |
fmoveZ = ((int)(100*fmoveZ))/100.0f; |
|
234 |
|
|
235 |
textDeform.setText("deform("+fmoveX+" , "+fmoveY+" , "+fmoveZ+")"); |
|
236 |
} |
|
237 |
|
|
238 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
239 |
|
|
240 |
private void computeDistort() |
|
241 |
{ |
|
242 |
fscaleX = (scaleX>50 ? 0.18f : 0.018f)*(scaleX-50)+1; |
|
243 |
fscaleY = (scaleY>50 ? 0.18f : 0.018f)*(scaleY-50)+1; |
|
244 |
fscaleZ = (scaleZ>50 ? 0.18f : 0.018f)*(scaleZ-50)+1; |
|
245 |
|
|
246 |
Vertex3DRenderer.setDistort(fscaleX, fscaleY, fscaleZ); |
|
247 |
} |
|
248 |
|
|
249 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
250 |
|
|
251 |
private void setDistortText() |
|
252 |
{ |
|
253 |
fscaleX = ((int)(100*fscaleX))/100.0f; |
|
254 |
fscaleY = ((int)(100*fscaleY))/100.0f; |
|
255 |
fscaleZ = ((int)(100*fscaleZ))/100.0f; |
|
256 |
|
|
257 |
textDistort.setText("distort("+fscaleX+" , "+fscaleY+" , "+fscaleZ+")"); |
|
258 |
} |
|
259 |
|
|
260 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
261 |
|
|
262 |
private void computeSink() |
|
263 |
{ |
|
264 |
frotateX = (rotateX-50)/50.0f; |
|
265 |
frotateY = (rotateY-50)/50.0f; |
|
266 |
frotateZ = (rotateZ-50)/50.0f; |
|
267 |
|
|
268 |
Vertex3DRenderer.setSink( frotateA, frotateX, frotateY, frotateZ ); |
|
269 |
} |
|
270 |
|
|
271 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
272 |
|
|
273 |
private void setSinkText() |
|
274 |
{ |
|
275 |
frotateX = ((int)(100*frotateX))/100.0f; |
|
276 |
frotateY = ((int)(100*frotateY))/100.0f; |
|
277 |
frotateZ = ((int)(100*frotateZ))/100.0f; |
|
278 |
|
|
279 |
frotateA = ((rotateA-50)*180)/50; |
|
280 |
|
|
281 |
textSink.setText("sink( "+frotateA+" ("+frotateX+","+frotateY+","+frotateZ+") )"); |
|
282 |
} |
|
283 |
|
|
284 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
285 |
|
|
286 |
private void computeSwirl() |
|
287 |
{ |
|
288 |
fshearX = (shearX-50)/25.0f; |
|
289 |
fshearY = (shearY-50)/25.0f; |
|
290 |
fshearZ = (shearZ-50)/25.0f; |
|
291 |
|
|
292 |
Vertex3DRenderer.setSwirl( fshearX, fshearY, fshearZ ); |
|
293 |
} |
|
294 |
|
|
295 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
296 |
|
|
297 |
private void setSwirlText() |
|
298 |
{ |
|
299 |
fshearX = ((int)(100*fshearX))/100.0f; |
|
300 |
fshearY = ((int)(100*fshearY))/100.0f; |
|
301 |
fshearZ = ((int)(100*fshearZ))/100.0f; |
|
302 |
|
|
303 |
textSwirl.setText("swirl("+fshearX+" , "+fshearY+" , "+fshearZ+")"); |
|
304 |
} |
|
305 |
|
|
306 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
307 |
|
|
308 |
@Override |
|
309 |
protected void onPause() |
|
310 |
{ |
|
311 |
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.vertex3dSurfaceView); |
|
312 |
mView.onPause(); |
|
313 |
super.onPause(); |
|
314 |
} |
|
315 |
|
|
316 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
317 |
|
|
318 |
@Override |
|
319 |
protected void onResume() |
|
320 |
{ |
|
321 |
super.onResume(); |
|
322 |
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.vertex3dSurfaceView); |
|
323 |
mView.onResume(); |
|
324 |
} |
|
325 |
|
|
326 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
327 |
|
|
328 |
@Override |
|
329 |
public void onWindowFocusChanged(boolean hasFocus) |
|
330 |
{ |
|
331 |
super.onWindowFocusChanged(hasFocus); |
|
332 |
|
|
333 |
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.vertex3dSurfaceView); |
|
334 |
|
|
335 |
maxX = mView.getWidth(); |
|
336 |
maxY = mView.getHeight(); |
|
337 |
maxZ = (maxX+maxY)/2; |
|
338 |
} |
|
339 |
|
|
340 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
341 |
|
|
342 |
@Override |
|
343 |
protected void onDestroy() |
|
344 |
{ |
|
345 |
Distorted.onDestroy(); |
|
346 |
super.onDestroy(); |
|
347 |
} |
|
348 |
|
|
349 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
350 |
|
|
351 |
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) |
|
352 |
{ |
|
353 |
switch (bar.getId()) |
|
354 |
{ |
|
355 |
case R.id.vertex3ddeformBar1 : moveX = progress; computeDeform() ; setDeformText() ; break; |
|
356 |
case R.id.vertex3ddeformBar2 : moveY = progress; computeDeform() ; setDeformText() ; break; |
|
357 |
case R.id.vertex3ddeformBar3 : moveZ = progress; computeDeform() ; setDeformText() ; break; |
|
358 |
|
|
359 |
case R.id.vertex3ddistortBar1 : scaleX= progress; computeDistort() ; setDistortText() ; break; |
|
360 |
case R.id.vertex3ddistortBar2 : scaleY= progress; computeDistort() ; setDistortText() ; break; |
|
361 |
case R.id.vertex3ddistortBar3 : scaleZ= progress; computeDistort() ; setDistortText() ; break; |
|
362 |
|
|
363 |
case R.id.vertex3dsinkBar1 : rotateX=progress; computeSink() ; setSinkText() ; break; |
|
364 |
case R.id.vertex3dsinkBar2 : rotateY=progress; computeSink() ; setSinkText() ; break; |
|
365 |
case R.id.vertex3dsinkBar3 : rotateZ=progress; computeSink() ; setSinkText() ; break; |
|
366 |
|
|
367 |
case R.id.vertex3dswirlBar1 : shearX= progress; computeSwirl() ; setSwirlText() ; break; |
|
368 |
case R.id.vertex3dswirlBar2 : shearY= progress; computeSwirl() ; setSwirlText() ; break; |
|
369 |
case R.id.vertex3dswirlBar3 : shearZ= progress; computeSwirl() ; setSwirlText() ; break; |
|
370 |
} |
|
371 |
} |
|
372 |
|
|
373 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
374 |
|
|
375 |
public void onStartTrackingTouch(SeekBar bar) { } |
|
376 |
|
|
377 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
378 |
|
|
379 |
public void onStopTrackingTouch(SeekBar bar) { } |
|
380 |
|
|
381 |
} |
src/main/java/org/distorted/examples/vertex3d/Vertex3DRenderer.java | ||
---|---|---|
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.vertex3d; |
|
21 |
|
|
22 |
import android.graphics.Bitmap; |
|
23 |
import android.graphics.BitmapFactory; |
|
24 |
import android.opengl.GLES20; |
|
25 |
import android.opengl.GLSurfaceView; |
|
26 |
|
|
27 |
import org.distorted.examples.R; |
|
28 |
import org.distorted.library.Distorted; |
|
29 |
import org.distorted.library.DistortedCubes; |
|
30 |
import org.distorted.library.EffectNames; |
|
31 |
import org.distorted.library.EffectTypes; |
|
32 |
import org.distorted.library.type.Dynamic3D; |
|
33 |
import org.distorted.library.type.Dynamic4D; |
|
34 |
import org.distorted.library.type.Static3D; |
|
35 |
import org.distorted.library.type.Static4D; |
|
36 |
|
|
37 |
import java.io.IOException; |
|
38 |
import java.io.InputStream; |
|
39 |
|
|
40 |
import javax.microedition.khronos.egl.EGLConfig; |
|
41 |
import javax.microedition.khronos.opengles.GL10; |
|
42 |
|
|
43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
44 |
|
|
45 |
class Vertex3DRenderer implements GLSurfaceView.Renderer |
|
46 |
{ |
|
47 |
private static final int SIZE = 100; |
|
48 |
|
|
49 |
private GLSurfaceView mView; |
|
50 |
private static DistortedCubes mCube; |
|
51 |
|
|
52 |
private static EffectNames[] order; |
|
53 |
|
|
54 |
private static Dynamic3D mMoveInter, mScaleInter, mShearInter; |
|
55 |
private static Dynamic4D mDynamicRotate; |
|
56 |
|
|
57 |
private static Static3D mZeroPoint, mMovePoint, mScalePoint, mShearPoint; |
|
58 |
private static Static4D mRotatePoint; |
|
59 |
|
|
60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
61 |
|
|
62 |
public static void setDeform(float x, float y, float z) |
|
63 |
{ |
|
64 |
mMovePoint.set(x, y, z); |
|
65 |
} |
|
66 |
|
|
67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
68 |
|
|
69 |
public static void setDistort(float x, float y, float z) |
|
70 |
{ |
|
71 |
mScalePoint.set(x, y, z); |
|
72 |
} |
|
73 |
|
|
74 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
75 |
|
|
76 |
public static void setSink(float a, float x, float y, float z) |
|
77 |
{ |
|
78 |
mRotatePoint.set(a,x,y,z); |
|
79 |
} |
|
80 |
|
|
81 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
82 |
|
|
83 |
public static void setSwirl(float x, float y, float z) |
|
84 |
{ |
|
85 |
mShearPoint.set(x, y, z); |
|
86 |
} |
|
87 |
|
|
88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
89 |
|
|
90 |
public static void setOrder(EffectNames[] effects) |
|
91 |
{ |
|
92 |
order = effects; |
|
93 |
setMatrixEffects(); |
|
94 |
} |
|
95 |
|
|
96 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
97 |
|
|
98 |
public static void setMatrixEffects() |
|
99 |
{ |
|
100 |
mCube.abortEffects(EffectTypes.MATRIX); |
|
101 |
|
|
102 |
for( int i=0; i<=order.length-1 ; i++ ) |
|
103 |
{ |
|
104 |
switch(order[i]) |
|
105 |
{ |
|
106 |
case MOVE : mCube.move(mMoveInter) ; break; |
|
107 |
case SCALE : mCube.scale(mScaleInter) ; break; |
|
108 |
case ROTATE: mCube.rotate(mDynamicRotate,mZeroPoint); break; |
|
109 |
case SHEAR : mCube.shear(mShearInter, mZeroPoint) ; break; |
|
110 |
} |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
115 |
|
|
116 |
public Vertex3DRenderer(GLSurfaceView v) |
|
117 |
{ |
|
118 |
mView = v; |
|
119 |
mCube = new DistortedCubes( 1, "1", SIZE); |
|
120 |
|
|
121 |
mZeroPoint = new Static3D(0,0,0); |
|
122 |
mMovePoint = new Static3D(0,0,0); |
|
123 |
mScalePoint = new Static3D(1,1,1); |
|
124 |
mShearPoint = new Static3D(0,0,0); |
|
125 |
mRotatePoint = new Static4D(0,1,0,0); |
|
126 |
|
|
127 |
mMoveInter = new Dynamic3D(); |
|
128 |
mScaleInter = new Dynamic3D(); |
|
129 |
mShearInter = new Dynamic3D(); |
|
130 |
mDynamicRotate= new Dynamic4D(); |
|
131 |
|
|
132 |
mMoveInter.add(mMovePoint); |
|
133 |
mScaleInter.add(mScalePoint); |
|
134 |
mShearInter.add(mShearPoint); |
|
135 |
mDynamicRotate.add(mRotatePoint); |
|
136 |
} |
|
137 |
|
|
138 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
139 |
|
|
140 |
public void onDrawFrame(GL10 glUnused) |
|
141 |
{ |
|
142 |
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
|
143 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
|
144 |
|
|
145 |
mCube.draw(System.currentTimeMillis()); |
|
146 |
} |
|
147 |
|
|
148 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
149 |
|
|
150 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
|
151 |
{ |
|
152 |
setMatrixEffects(); |
|
153 |
|
|
154 |
Distorted.onSurfaceChanged(width, height); |
|
155 |
} |
|
156 |
|
|
157 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
158 |
|
|
159 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
|
160 |
{ |
|
161 |
InputStream is = mView.getContext().getResources().openRawResource(R.raw.grid); |
|
162 |
Bitmap bitmap; |
|
163 |
|
|
164 |
try |
|
165 |
{ |
|
166 |
bitmap = BitmapFactory.decodeStream(is); |
|
167 |
} |
|
168 |
finally |
|
169 |
{ |
|
170 |
try |
|
171 |
{ |
|
172 |
is.close(); |
|
173 |
} |
|
174 |
catch(IOException e) { } |
|
175 |
} |
|
176 |
|
|
177 |
mCube.setBitmap(bitmap); |
|
178 |
|
|
179 |
try |
|
180 |
{ |
|
181 |
Distorted.onSurfaceCreated(mView.getContext()); |
|
182 |
} |
|
183 |
catch(Exception ex) |
|
184 |
{ |
|
185 |
android.util.Log.e("Vertex3D", ex.getMessage() ); |
|
186 |
} |
|
187 |
} |
|
188 |
} |
src/main/java/org/distorted/examples/vertex3d/Vertex3DSurfaceView.java | ||
---|---|---|
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.vertex3d; |
|
21 |
|
|
22 |
import android.content.Context; |
|
23 |
import android.opengl.GLSurfaceView; |
|
24 |
import android.os.Build; |
|
25 |
import android.util.AttributeSet; |
|
26 |
|
|
27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
28 |
|
|
29 |
class Vertex3DSurfaceView extends GLSurfaceView |
|
30 |
{ |
|
31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
32 |
|
|
33 |
public Vertex3DSurfaceView(Context c, AttributeSet attrs) |
|
34 |
{ |
|
35 |
super(c, attrs); |
|
36 |
|
|
37 |
if(!isInEditMode()) |
|
38 |
{ |
|
39 |
setEGLContextClientVersion(2); |
|
40 |
|
|
41 |
if( Build.FINGERPRINT.startsWith("generic") ) |
|
42 |
{ |
|
43 |
setEGLConfigChooser(8, 8, 8, 8, 16, 0); |
|
44 |
} |
|
45 |
|
|
46 |
setRenderer(new Vertex3DRenderer(this)); |
|
47 |
} |
|
48 |
} |
|
49 |
} |
|
50 |
|
src/main/res/layout/vertex3ddeform.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:id="@+id/vertex3dRowDeform" |
|
4 |
android:orientation="horizontal" |
|
5 |
android:layout_width="match_parent" |
|
6 |
android:layout_height="wrap_content" > |
|
7 |
|
|
8 |
<LinearLayout |
|
9 |
android:layout_width="0dp" |
|
10 |
android:layout_height="match_parent" |
|
11 |
android:layout_weight="0.70" |
|
12 |
android:orientation="vertical" > |
|
13 |
|
|
14 |
<TextView |
|
15 |
android:id="@+id/vertex3ddeformText" |
|
16 |
android:layout_width="wrap_content" |
|
17 |
android:layout_height="wrap_content" |
|
18 |
android:layout_marginEnd="5dp" |
|
19 |
android:layout_marginStart="5dp" |
|
20 |
android:layout_marginTop="3dp" |
|
21 |
android:textAppearance="?android:attr/textAppearanceLarge" /> |
|
22 |
|
|
23 |
<SeekBar |
|
24 |
android:id="@+id/vertex3ddeformBar4" |
|
25 |
android:layout_width="fill_parent" |
|
26 |
android:layout_height="wrap_content" |
|
27 |
android:layout_marginEnd="5dp" |
|
28 |
android:layout_marginLeft="5dp" |
|
29 |
android:layout_marginRight="5dp" /> |
|
30 |
|
|
31 |
<SeekBar |
|
32 |
android:id="@+id/vertex3ddeformBar1" |
|
33 |
android:layout_width="fill_parent" |
|
34 |
android:layout_height="wrap_content" |
|
35 |
android:layout_gravity="end" |
|
36 |
android:layout_marginEnd="5dp" |
|
37 |
android:layout_marginLeft="5dp" |
|
38 |
android:layout_marginRight="5dp" /> |
|
39 |
|
|
40 |
<SeekBar |
|
41 |
android:id="@+id/vertex3ddeformBar2" |
|
42 |
android:layout_width="fill_parent" |
|
43 |
android:layout_height="wrap_content" |
|
44 |
android:layout_gravity="end" |
|
45 |
android:layout_marginEnd="5dp" |
|
46 |
android:layout_marginLeft="5dp" |
|
47 |
android:layout_marginRight="5dp" /> |
|
48 |
|
|
49 |
<SeekBar |
|
50 |
android:id="@+id/vertex3ddeformBar3" |
|
51 |
android:layout_width="fill_parent" |
|
52 |
android:layout_height="wrap_content" |
|
53 |
android:layout_gravity="end" |
|
54 |
android:layout_marginEnd="5dp" |
|
55 |
android:layout_marginLeft="5dp" |
|
56 |
android:layout_marginRight="5dp" /> |
|
57 |
|
|
58 |
</LinearLayout> |
|
59 |
|
|
60 |
<Button |
|
61 |
android:id="@+id/vertex3dUpDeform" |
|
62 |
android:layout_width="60dp" |
|
63 |
android:layout_height="fill_parent" |
|
64 |
android:onClick="ButtonDeform" |
|
65 |
android:text="@string/Up" /> |
|
66 |
|
|
67 |
</LinearLayout> |
src/main/res/layout/vertex3ddistort.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
|
|
3 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
4 |
android:id="@+id/vertex3dRowDistort" |
|
5 |
android:layout_width="match_parent" |
|
6 |
android:layout_height="wrap_content" |
|
7 |
android:orientation="horizontal" > |
|
8 |
|
|
9 |
<LinearLayout |
|
10 |
android:layout_width="0dp" |
|
11 |
android:layout_height="wrap_content" |
|
12 |
android:layout_weight="0.8" |
|
13 |
android:orientation="vertical" > |
|
14 |
|
|
15 |
<TextView |
|
16 |
android:id="@+id/vertex3ddistortText" |
|
17 |
android:layout_width="wrap_content" |
|
18 |
android:layout_height="wrap_content" |
|
19 |
android:layout_marginEnd="5dp" |
|
20 |
android:layout_marginStart="5dp" |
|
21 |
android:layout_marginTop="3dp" |
|
22 |
android:textAppearance="?android:attr/textAppearanceLarge" /> |
|
23 |
|
|
24 |
<SeekBar |
|
25 |
android:id="@+id/vertex3ddistortBar1" |
|
26 |
android:layout_width="fill_parent" |
|
27 |
android:layout_height="wrap_content" |
|
28 |
android:layout_marginEnd="5dp" |
|
29 |
android:layout_marginLeft="5dp" |
|
30 |
android:layout_marginRight="5dp" /> |
|
31 |
|
|
32 |
<SeekBar |
|
33 |
android:id="@+id/vertex3ddistortBar2" |
|
34 |
android:layout_width="fill_parent" |
|
35 |
android:layout_height="wrap_content" |
|
36 |
android:layout_marginEnd="5dp" |
|
37 |
android:layout_marginLeft="5dp" |
|
38 |
android:layout_marginRight="5dp" /> |
|
39 |
|
|
40 |
<SeekBar |
|
41 |
android:id="@+id/vertex3ddistortBar3" |
|
42 |
android:layout_width="fill_parent" |
|
43 |
android:layout_height="wrap_content" |
|
44 |
android:layout_marginEnd="5dp" |
|
45 |
android:layout_marginLeft="5dp" |
|
46 |
android:layout_marginRight="5dp" /> |
|
47 |
|
|
48 |
</LinearLayout> |
|
49 |
|
|
50 |
<Button |
|
51 |
android:id="@+id/vertex3dUpDistort" |
|
52 |
android:layout_width="60dp" |
|
53 |
android:layout_height="fill_parent" |
|
54 |
android:onClick="ButtonDistort" |
|
55 |
android:text="@string/Up" /> |
|
56 |
|
|
57 |
</LinearLayout> |
src/main/res/layout/vertex3dlayout.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:layout_width="fill_parent" |
|
4 |
android:layout_height="fill_parent" |
|
5 |
android:orientation="vertical" > |
|
6 |
|
|
7 |
<org.distorted.examples.vertex3d.Vertex3DSurfaceView |
|
8 |
android:id="@+id/vertex3dSurfaceView" |
|
9 |
android:layout_width="fill_parent" |
|
10 |
android:layout_height="0dp" |
|
11 |
android:layout_weight="1" /> |
|
12 |
|
|
13 |
<Button |
|
14 |
android:id="@+id/button1" |
|
15 |
android:layout_width="fill_parent" |
|
16 |
android:layout_height="wrap_content" |
|
17 |
android:onClick="Default" |
|
18 |
android:text="@string/Default" /> |
|
19 |
|
|
20 |
<ScrollView |
|
21 |
android:id="@+id/vertex3dscrollView" |
|
22 |
android:layout_width="match_parent" |
|
23 |
android:layout_height="0dp" |
|
24 |
android:layout_weight="0.82" > |
|
25 |
|
|
26 |
<LinearLayout |
|
27 |
android:id="@+id/vertex3dlayout" |
|
28 |
android:layout_width="match_parent" |
|
29 |
android:layout_height="wrap_content" |
|
30 |
android:orientation="vertical" > |
|
31 |
</LinearLayout> |
|
32 |
|
|
33 |
</ScrollView> |
|
34 |
|
|
35 |
</LinearLayout> |
src/main/res/layout/vertex3dsink.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
|
|
3 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
4 |
android:id="@+id/vertex3dRowSink" |
|
5 |
android:orientation="horizontal" |
|
6 |
android:layout_width="match_parent" |
|
7 |
android:layout_height="wrap_content" > |
|
8 |
|
|
9 |
<LinearLayout |
|
10 |
android:layout_width="0dp" |
|
11 |
android:layout_height="match_parent" |
|
12 |
android:layout_weight="0.70" |
|
13 |
android:orientation="vertical" > |
|
14 |
|
|
15 |
<TextView |
|
16 |
android:id="@+id/vertex3dsinkText" |
|
17 |
android:layout_width="wrap_content" |
|
18 |
android:layout_height="wrap_content" |
|
19 |
android:layout_marginEnd="5dp" |
|
20 |
android:layout_marginStart="5dp" |
|
21 |
android:layout_marginTop="3dp" |
|
22 |
android:textAppearance="?android:attr/textAppearanceLarge" /> |
|
23 |
|
|
24 |
<SeekBar |
|
25 |
android:id="@+id/vertex3dsinkBar1" |
|
26 |
android:layout_width="fill_parent" |
|
27 |
android:layout_height="wrap_content" |
|
28 |
android:layout_gravity="end" |
|
29 |
android:layout_marginEnd="5dp" |
|
30 |
android:layout_marginLeft="5dp" |
|
31 |
android:layout_marginRight="5dp" /> |
|
32 |
|
|
33 |
<SeekBar |
|
34 |
android:id="@+id/vertex3dsinkBar2" |
|
35 |
android:layout_width="fill_parent" |
|
36 |
android:layout_height="wrap_content" |
|
37 |
android:layout_gravity="end" |
|
38 |
android:layout_marginEnd="5dp" |
|
39 |
android:layout_marginLeft="5dp" |
|
40 |
android:layout_marginRight="5dp" /> |
|
41 |
|
|
42 |
<SeekBar |
|
43 |
android:id="@+id/vertex3dsinkBar3" |
|
44 |
android:layout_width="fill_parent" |
|
45 |
android:layout_height="wrap_content" |
|
46 |
android:layout_gravity="end" |
|
47 |
android:layout_marginEnd="5dp" |
|
48 |
android:layout_marginLeft="5dp" |
|
49 |
android:layout_marginRight="5dp" /> |
|
50 |
|
|
51 |
</LinearLayout> |
|
52 |
|
|
53 |
<Button |
|
54 |
android:id="@+id/vertex3dUpSink" |
|
55 |
android:layout_width="60dp" |
|
56 |
android:layout_height="fill_parent" |
|
57 |
android:onClick="ButtonSink" |
|
58 |
android:text="@string/Up" /> |
|
59 |
|
|
60 |
</LinearLayout> |
|
61 |
|
src/main/res/layout/vertex3dswirl.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:id="@+id/vertex3dRowSwirl" |
|
4 |
android:orientation="horizontal" |
|
5 |
android:layout_width="match_parent" |
|
6 |
android:layout_height="wrap_content" > |
|
7 |
|
|
8 |
<LinearLayout |
|
9 |
android:layout_width="0dp" |
|
10 |
android:layout_height="match_parent" |
|
11 |
android:layout_weight="0.70" |
|
12 |
android:orientation="vertical" > |
|
13 |
|
|
14 |
<TextView |
|
15 |
android:id="@+id/vertex3dswirlText" |
|
16 |
android:layout_width="wrap_content" |
|
17 |
android:layout_height="wrap_content" |
|
18 |
android:layout_marginEnd="5dp" |
|
19 |
android:layout_marginStart="5dp" |
|
20 |
android:layout_marginTop="3dp" |
|
21 |
android:textAppearance="?android:attr/textAppearanceLarge" /> |
|
22 |
|
|
23 |
<SeekBar |
|
24 |
android:id="@+id/vertex3dswirlBar1" |
|
25 |
android:layout_width="fill_parent" |
|
26 |
android:layout_height="wrap_content" |
|
27 |
android:layout_gravity="end" |
|
28 |
android:layout_marginEnd="5dp" |
|
29 |
android:layout_marginLeft="5dp" |
|
30 |
android:layout_marginRight="5dp" /> |
|
31 |
|
|
32 |
<SeekBar |
|
33 |
android:id="@+id/vertex3dswirlBar2" |
|
34 |
android:layout_width="fill_parent" |
|
35 |
android:layout_height="wrap_content" |
|
36 |
android:layout_gravity="end" |
|
37 |
android:layout_marginEnd="5dp" |
|
38 |
android:layout_marginLeft="5dp" |
|
39 |
android:layout_marginRight="5dp" /> |
|
40 |
|
|
41 |
<SeekBar |
|
42 |
android:id="@+id/vertex3dswirlBar3" |
|
43 |
android:layout_width="fill_parent" |
|
44 |
android:layout_height="wrap_content" |
|
45 |
android:layout_gravity="end" |
|
46 |
android:layout_marginEnd="5dp" |
|
47 |
android:layout_marginLeft="5dp" |
|
48 |
android:layout_marginRight="5dp" /> |
|
49 |
|
|
50 |
</LinearLayout> |
|
51 |
|
|
52 |
<Button |
|
53 |
android:id="@+id/vertex3dUpSwirl" |
|
54 |
android:layout_width="60dp" |
|
55 |
android:layout_height="fill_parent" |
|
56 |
android:onClick="ButtonSwirl" |
|
57 |
android:text="@string/Up" /> |
|
58 |
|
|
59 |
</LinearLayout> |
src/main/res/values/strings.xml | ||
---|---|---|
86 | 86 |
<string name="example_quaternion_subtitle">Random rotations using quaternions.</string> |
87 | 87 |
<string name="example_matrix3d">3D Matrix Effects</string> |
88 | 88 |
<string name="example_matrix3d_subtitle">Test results of Matrix effects on a 3D object.</string> |
89 |
<string name="example_plainmonalisa">PlainMonaLisa</string> |
|
89 |
<string name="example_vertex3d">3D Vertex Effects</string> |
|
90 |
<string name="example_vertex3d_subtitle">Test results of Vertex effects on a 3D object.</string> |
|
91 |
<string name="example_plainmonalisa">PlainMonaLisa</string> |
|
90 | 92 |
<string name="example_plainmonalisa_subtitle">MonaLisa rendered on a plain SurfaceView</string> |
91 | 93 |
<string name="example_save">Save to PNG</string> |
92 | 94 |
<string name="example_save_subtitle">Saving the output to a PNG file.</string> |
Also available in: Unified diff
Skeleton of the new App: Vertex3D. So far just a copy of Matrix3D.