Revision 0dc8ffef
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/examples/predeform/PredeformActivity.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import android.app.Activity; |
23 | 23 |
import android.content.Intent; |
24 |
import android.graphics.Bitmap; |
|
25 |
import android.graphics.BitmapFactory; |
|
26 |
import android.graphics.Canvas; |
|
27 |
import android.graphics.Paint; |
|
24 | 28 |
import android.os.Bundle; |
25 |
import android.view.Gravity; |
|
26 | 29 |
import android.view.View; |
27 | 30 |
import android.widget.AdapterView; |
28 | 31 |
import android.widget.ArrayAdapter; |
29 |
import android.widget.Button; |
|
30 |
import android.widget.LinearLayout; |
|
31 | 32 |
import android.widget.NumberPicker; |
32 | 33 |
import android.widget.Spinner; |
33 |
import android.widget.TableRow; |
|
34 | 34 |
|
35 | 35 |
import org.distorted.examples.R; |
36 |
import org.distorted.library.mesh.MeshBase; |
|
37 |
|
|
38 |
import java.io.IOException; |
|
39 |
import java.io.InputStream; |
|
36 | 40 |
|
37 | 41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
38 | 42 |
|
39 |
public class PredeformActivity extends Activity |
|
40 |
implements View.OnClickListener, AdapterView.OnItemSelectedListener |
|
43 |
public class PredeformActivity extends Activity implements AdapterView.OnItemSelectedListener |
|
41 | 44 |
{ |
42 |
private static final int COLOR_OFF = 0xffffe81f; |
|
43 |
private static final int COLOR_ON = 0xff0000ff; |
|
44 |
private static final int COLOR_INAC= 0xff999999; |
|
45 |
|
|
46 |
private int mNumCols = 1; |
|
47 |
private int mNumRows = 1; |
|
48 |
private int mNumSlic = 1; |
|
49 |
private boolean mGridInitialized; |
|
50 |
private NumberPicker mColsPicker, mRowsPicker, mSlicPicker; |
|
51 |
private boolean[] mShape; |
|
45 |
private int mNumCols; |
|
46 |
private int mNumRows; |
|
47 |
private int mNumSlic; |
|
52 | 48 |
private int mObjectType; |
53 | 49 |
private int mBitmapID; |
54 |
private LinearLayout mLay; |
|
50 |
|
|
51 |
private NumberPicker mColsPicker, mRowsPicker, mSlicPicker; |
|
52 |
private boolean[] mShape; |
|
53 |
private MeshBase mMesh; |
|
55 | 54 |
|
56 | 55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
57 | 56 |
|
... | ... | |
60 | 59 |
{ |
61 | 60 |
super.onCreate(savedState); |
62 | 61 |
|
63 |
setContentView(R.layout.objectpickerlayout); |
|
62 |
mNumCols = 1; |
|
63 |
mNumRows = 1; |
|
64 |
mNumSlic = 1; |
|
65 |
mBitmapID=-1; |
|
66 |
resetShape(); |
|
64 | 67 |
|
65 |
mLay = findViewById(R.id.objectpicker_buttongrid);
|
|
68 |
setContentView(R.layout.object_picker_layout);
|
|
66 | 69 |
|
67 | 70 |
mColsPicker = findViewById(R.id.objectpicker_cols); |
68 | 71 |
mRowsPicker = findViewById(R.id.objectpicker_rows); |
... | ... | |
80 | 83 |
@Override |
81 | 84 |
public void onValueChange(NumberPicker picker, int oldVal, int newVal) |
82 | 85 |
{ |
83 |
setGrid(); |
|
86 |
mNumCols = newVal; |
|
87 |
resetShape(); |
|
84 | 88 |
} |
85 | 89 |
}); |
86 | 90 |
|
... | ... | |
89 | 93 |
@Override |
90 | 94 |
public void onValueChange(NumberPicker picker, int oldVal, int newVal) |
91 | 95 |
{ |
92 |
setGrid(); |
|
96 |
mNumRows = newVal; |
|
97 |
resetShape(); |
|
93 | 98 |
} |
94 | 99 |
}); |
95 | 100 |
|
... | ... | |
98 | 103 |
@Override |
99 | 104 |
public void onValueChange(NumberPicker picker, int oldVal, int newVal) |
100 | 105 |
{ |
101 |
mNumSlic = mSlicPicker.getValue(); |
|
106 |
mNumSlic = newVal; |
|
107 |
resetShape(); |
|
102 | 108 |
} |
103 | 109 |
}); |
104 | 110 |
|
105 | 111 |
mObjectType = 0; |
106 |
mGridInitialized = false; |
|
107 | 112 |
|
108 | 113 |
Spinner typeSpinner = findViewById(R.id.objectpicker_spinnerType); |
109 | 114 |
typeSpinner.setOnItemSelectedListener(this); |
... | ... | |
130 | 135 |
bitmapSpinner.setAdapter(adapterBitmap); |
131 | 136 |
} |
132 | 137 |
|
138 |
|
|
133 | 139 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
134 | 140 |
|
135 |
private void setGrid()
|
|
141 |
private void resetShape()
|
|
136 | 142 |
{ |
137 |
mGridInitialized = true;
|
|
143 |
mShape = new boolean[mNumRows*mNumCols];
|
|
138 | 144 |
|
139 |
mNumCols = mColsPicker.getValue(); |
|
140 |
mNumRows = mRowsPicker.getValue(); |
|
145 |
for (int rows=0; rows<mNumRows; rows++) |
|
146 |
{ |
|
147 |
for(int cols=0; cols<mNumCols; cols++) |
|
148 |
{ |
|
149 |
mShape[rows*mNumCols+cols] = true; |
|
150 |
} |
|
151 |
} |
|
141 | 152 |
|
142 |
int width = mLay.getWidth(); |
|
143 |
int height= mLay.getHeight(); |
|
144 |
int w = mNumCols>0 ? (int)( 0.9f*width / mNumCols) : 0; |
|
145 |
int h = mNumRows>0 ? (int)( 0.9f*height/ mNumRows) : 0; |
|
146 |
int size= Math.min(w, h); |
|
147 |
int pad = size<20 ? 1 : size/20; |
|
153 |
recreateObject(); |
|
154 |
} |
|
148 | 155 |
|
149 |
mLay.removeAllViews();
|
|
156 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
150 | 157 |
|
151 |
mShape = new boolean[mNumRows*mNumCols]; |
|
158 |
MeshBase getMesh() |
|
159 |
{ |
|
160 |
return mMesh; |
|
161 |
} |
|
152 | 162 |
|
153 |
TableRow.LayoutParams p = new TableRow.LayoutParams();
|
|
163 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
154 | 164 |
|
155 |
p.rightMargin = pad; |
|
156 |
p.leftMargin = pad; |
|
157 |
p.topMargin = pad; |
|
158 |
p.bottomMargin = pad; |
|
159 |
p.height = size; |
|
160 |
p.width = size; |
|
165 |
Bitmap getBitmap() |
|
166 |
{ |
|
167 |
return createBitmap(mBitmapID); |
|
168 |
} |
|
161 | 169 |
|
162 |
for (int rows=0; rows<mNumRows; rows++) |
|
170 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
171 |
|
|
172 |
private void recreateObject() |
|
173 |
{ |
|
174 |
String str = PredeformMeshList.getString(mObjectType, mNumCols, mNumRows, mShape); |
|
175 |
mMesh = PredeformMeshList.createMesh(mObjectType, mNumCols, mNumRows, mNumSlic, mBitmapID, str); |
|
176 |
} |
|
177 |
|
|
178 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
179 |
|
|
180 |
private Bitmap createBitmap(int bitmapID) |
|
181 |
{ |
|
182 |
int size = mNumCols > mNumRows ? (Math.max(mNumCols, mNumSlic)) : (Math.max(mNumRows, mNumSlic)); |
|
183 |
|
|
184 |
if( bitmapID!=-1) |
|
185 |
{ |
|
186 |
try (InputStream is = getResources().openRawResource(bitmapID)) |
|
187 |
{ |
|
188 |
return BitmapFactory.decodeStream(is); |
|
189 |
} |
|
190 |
catch( IOException ex ) { android.util.Log.e("act", "failed to open resource "+bitmapID); } |
|
191 |
} |
|
192 |
else |
|
163 | 193 |
{ |
164 |
TableRow tr = new TableRow(this);
|
|
165 |
tr.setGravity(Gravity.CENTER);
|
|
194 |
final int T = 64;
|
|
195 |
final int S = T*size;
|
|
166 | 196 |
|
167 |
for(int cols=0; cols<mNumCols; cols++) |
|
197 |
Paint paint = new Paint(); |
|
198 |
Bitmap bmp = Bitmap.createBitmap(S,S, Bitmap.Config.ARGB_8888); |
|
199 |
Canvas canvas = new Canvas(bmp); |
|
200 |
|
|
201 |
paint.setAntiAlias(true); |
|
202 |
paint.setTextAlign(Paint.Align.CENTER); |
|
203 |
paint.setColor(0xff008800); |
|
204 |
paint.setStyle(Paint.Style.FILL); |
|
205 |
canvas.drawRect(0, 0, S, S, paint); |
|
206 |
paint.setColor(0xffffffff); |
|
207 |
|
|
208 |
for(int i=0; i<=size ; i++ ) |
|
168 | 209 |
{ |
169 |
Button b = new Button(this); |
|
170 |
b.setOnClickListener(this); |
|
171 |
b.setId(rows*mNumCols+cols); |
|
172 |
b.setLayoutParams(p); |
|
173 |
b.setBackgroundColor(mObjectType==0 ? COLOR_ON:COLOR_INAC); |
|
174 |
tr.addView(b, p); |
|
175 |
mShape[rows*mNumCols+cols] = true; |
|
210 |
canvas.drawRect( T*i-1, 0, T*i+1, S, paint); |
|
211 |
canvas.drawRect( 0, T*i-1, S, T*i+1, paint); |
|
176 | 212 |
} |
177 | 213 |
|
178 |
mLay.addView(tr);
|
|
214 |
return bmp;
|
|
179 | 215 |
} |
216 |
|
|
217 |
return null; |
|
180 | 218 |
} |
181 | 219 |
|
182 | 220 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
183 | 221 |
|
184 |
public void onClick(View view)
|
|
222 |
void click(int row, int col)
|
|
185 | 223 |
{ |
186 | 224 |
if( mObjectType==0 ) // cubes |
187 | 225 |
{ |
188 |
Button tmp = (Button)view; |
|
189 |
int id = tmp.getId(); |
|
226 |
int id = row*mNumCols+col; |
|
190 | 227 |
mShape[id] = !mShape[id]; |
191 |
tmp.setBackgroundColor(mShape[id] ? COLOR_ON:COLOR_OFF);
|
|
228 |
recreateObject();
|
|
192 | 229 |
} |
193 | 230 |
} |
194 | 231 |
|
... | ... | |
196 | 233 |
|
197 | 234 |
private void uncheckAll() |
198 | 235 |
{ |
199 |
TableRow tr; |
|
200 |
Button butt; |
|
201 |
|
|
202 |
for (int row=0; row<mNumRows; row++) |
|
236 |
if( mObjectType==0 ) // cubes |
|
203 | 237 |
{ |
204 |
tr = (TableRow)mLay.getChildAt(row); |
|
238 |
for (int row=0; row<mNumRows; row++) |
|
239 |
for(int col=0; col<mNumCols; col++) |
|
240 |
mShape[row*mNumCols+col] = true; |
|
205 | 241 |
|
206 |
for(int col=0; col<mNumCols; col++) |
|
207 |
{ |
|
208 |
butt = (Button)tr.getVirtualChildAt(col); |
|
209 |
butt.setBackgroundColor(mObjectType==0 ? COLOR_ON : COLOR_INAC); |
|
210 |
mShape[row*mNumCols+col] = true; |
|
211 |
} |
|
242 |
recreateObject(); |
|
212 | 243 |
} |
213 | 244 |
} |
214 | 245 |
|
... | ... | |
247 | 278 |
mRowsPicker.setEnabled(dim>=1); |
248 | 279 |
mColsPicker.setEnabled(dim>=2); |
249 | 280 |
mSlicPicker.setEnabled(dim>=3); |
281 |
|
|
282 |
recreateObject(); |
|
250 | 283 |
} |
251 | 284 |
break; |
252 | 285 |
case R.id.objectpicker_spinnerBitmap: switch(pos) |
... | ... | |
260 | 293 |
case 6: mBitmapID = R.raw.monalisa; break; |
261 | 294 |
case 7: mBitmapID = R.raw.world ; break; |
262 | 295 |
} |
296 |
|
|
297 |
PredeformSurfaceView v = findViewById(R.id.predeformSurfaceView); |
|
298 |
v.getRenderer().setTexture( createBitmap(mBitmapID) ); |
|
263 | 299 |
break; |
264 | 300 |
} |
265 | 301 |
} |
... | ... | |
283 | 319 |
mRowsPicker.setValue(mNumRows); |
284 | 320 |
mSlicPicker.setValue(mNumSlic); |
285 | 321 |
|
286 |
if( !mGridInitialized ) setGrid();
|
|
322 |
resetShape();
|
|
287 | 323 |
} |
288 | 324 |
} |
src/main/java/org/distorted/examples/predeform/PredeformActivity2.java | ||
---|---|---|
56 | 56 |
@Override |
57 | 57 |
protected void onPause() |
58 | 58 |
{ |
59 |
GLSurfaceView mView = this.findViewById(R.id.predeformSurfaceView);
|
|
59 |
GLSurfaceView mView = findViewById(R.id.predeform2SurfaceView);
|
|
60 | 60 |
if( mView!=null ) mView.onPause(); |
61 | 61 |
|
62 | 62 |
DistortedLibrary.onPause(); |
... | ... | |
70 | 70 |
{ |
71 | 71 |
super.onResume(); |
72 | 72 |
|
73 |
GLSurfaceView mView = this.findViewById(R.id.predeformSurfaceView);
|
|
73 |
GLSurfaceView mView = findViewById(R.id.predeform2SurfaceView);
|
|
74 | 74 |
if( mView!=null ) mView.onResume(); |
75 | 75 |
} |
76 | 76 |
|
... | ... | |
107 | 107 |
|
108 | 108 |
setContentView(R.layout.predeformlayout); |
109 | 109 |
|
110 |
Spinner renderSpinner = findViewById(R.id.predeformSpinnerMode); |
|
110 |
Spinner renderSpinner = findViewById(R.id.predeform2SpinnerMode);
|
|
111 | 111 |
renderSpinner.setOnItemSelectedListener(this); |
112 | 112 |
|
113 | 113 |
String[] objectBitmap = new String[] { "Render: Normal", "Render: OIT" }; |
... | ... | |
116 | 116 |
adapterBitmap.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
117 | 117 |
renderSpinner.setAdapter(adapterBitmap); |
118 | 118 |
|
119 |
mTextLevel = findViewById(R.id.predeformInflateText); |
|
119 |
mTextLevel = findViewById(R.id.predeform2InflateText);
|
|
120 | 120 |
|
121 |
SeekBar transparencyBar = findViewById(R.id.predeformTransparency); |
|
121 |
SeekBar transparencyBar = findViewById(R.id.predeform2Transparency);
|
|
122 | 122 |
transparencyBar.setOnSeekBarChangeListener(this); |
123 | 123 |
transparencyBar.setProgress(50); |
124 | 124 |
|
125 |
SeekBar inflateBar = findViewById(R.id.predeformInflateLevel); |
|
125 |
SeekBar inflateBar = findViewById(R.id.predeform2InflateLevel);
|
|
126 | 126 |
inflateBar.setOnSeekBarChangeListener(this); |
127 | 127 |
inflateBar.setProgress(50); |
128 | 128 |
} |
... | ... | |
195 | 195 |
|
196 | 196 |
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) |
197 | 197 |
{ |
198 |
PredeformSurfaceView v = this.findViewById(R.id.predeformSurfaceView);
|
|
199 |
PredeformRenderer renderer = v.getRenderer(); |
|
198 |
PredeformSurfaceView2 v = findViewById(R.id.predeform2SurfaceView);
|
|
199 |
PredeformRenderer2 renderer = v.getRenderer();
|
|
200 | 200 |
|
201 |
if( parent.getId()==R.id.predeformSpinnerMode) |
|
201 |
if( parent.getId()==R.id.predeform2SpinnerMode)
|
|
202 | 202 |
{ |
203 | 203 |
renderer.setRenderModeToOIT(pos==1); |
204 | 204 |
} |
... | ... | |
216 | 216 |
{ |
217 | 217 |
switch (bar.getId()) |
218 | 218 |
{ |
219 |
case R.id.predeformTransparency: PredeformSurfaceView v1 = this.findViewById(R.id.predeformSurfaceView);
|
|
220 |
v1.getRenderer().setTransparency(progress); |
|
221 |
break; |
|
222 |
case R.id.predeformInflateLevel: PredeformSurfaceView v2 = this.findViewById(R.id.predeformSurfaceView);
|
|
223 |
float level = v2.getRenderer().setLevel(progress); |
|
224 |
mTextLevel.setText(getString(R.string.inflate_placeholder, level)); |
|
225 |
break; |
|
219 |
case R.id.predeform2Transparency: PredeformSurfaceView2 v1 = findViewById(R.id.predeform2SurfaceView);
|
|
220 |
v1.getRenderer().setTransparency(progress);
|
|
221 |
break;
|
|
222 |
case R.id.predeform2InflateLevel: PredeformSurfaceView2 v2 = findViewById(R.id.predeform2SurfaceView);
|
|
223 |
float level = v2.getRenderer().setLevel(progress);
|
|
224 |
mTextLevel.setText(getString(R.string.inflate_placeholder, level));
|
|
225 |
break;
|
|
226 | 226 |
} |
227 | 227 |
} |
228 | 228 |
|
src/main/java/org/distorted/examples/predeform/PredeformRenderer.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.predeform; |
21 | 21 |
|
22 |
import android.graphics.Bitmap; |
|
22 | 23 |
import android.opengl.GLSurfaceView; |
23 | 24 |
|
24 |
import org.distorted.library.effect.FragmentEffectAlpha; |
|
25 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
|
26 | 25 |
import org.distorted.library.effect.MatrixEffectScale; |
27 |
import org.distorted.library.effect.VertexEffectScale; |
|
28 | 26 |
import org.distorted.library.main.DistortedEffects; |
29 | 27 |
import org.distorted.library.main.DistortedLibrary; |
30 | 28 |
import org.distorted.library.main.DistortedScreen; |
31 | 29 |
import org.distorted.library.main.DistortedTexture; |
32 | 30 |
import org.distorted.library.mesh.MeshBase; |
33 |
import org.distorted.library.type.DynamicQuat; |
|
34 |
import org.distorted.library.type.Static1D; |
|
35 | 31 |
import org.distorted.library.type.Static3D; |
36 |
import org.distorted.library.type.Static4D; |
|
37 | 32 |
|
38 | 33 |
import javax.microedition.khronos.egl.EGLConfig; |
39 | 34 |
import javax.microedition.khronos.opengles.GL10; |
... | ... | |
42 | 37 |
|
43 | 38 |
class PredeformRenderer implements GLSurfaceView.Renderer |
44 | 39 |
{ |
45 |
private static final float FOV = 30.0f;
|
|
40 |
private static final float FOV = 0.0f;
|
|
46 | 41 |
private static final float NEAR = 0.1f; |
47 | 42 |
|
48 | 43 |
private GLSurfaceView mView; |
... | ... | |
50 | 45 |
private DistortedEffects mEffects; |
51 | 46 |
private MeshBase mMesh; |
52 | 47 |
private DistortedScreen mScreen; |
53 |
private float mObjWidth, mObjHeight, mObjDepth; |
|
54 | 48 |
private Static3D mScale; |
55 |
private Static1D mAlpha; |
|
56 |
|
|
57 |
Static4D mQuat1, mQuat2; |
|
58 |
int mScreenMin; |
|
59 | 49 |
|
60 | 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
61 | 51 |
|
... | ... | |
63 | 53 |
{ |
64 | 54 |
mView = v; |
65 | 55 |
|
66 |
mAlpha = new Static1D(1.0f); |
|
67 | 56 |
mScale= new Static3D(1,1,1); |
68 |
|
|
69 |
Static3D center=new Static3D(0,0,0); |
|
70 |
|
|
71 |
PredeformActivity2 act = (PredeformActivity2)v.getContext(); |
|
72 |
|
|
73 |
mTexture = act.getTexture(); |
|
74 |
mMesh = act.getMesh(); |
|
75 |
|
|
76 |
mObjWidth = act.getCols(); |
|
77 |
mObjHeight= act.getRows(); |
|
78 |
mObjDepth = act.getSlic(); |
|
79 |
|
|
80 |
mQuat1 = new Static4D(0,0,0,1); // unity |
|
81 |
mQuat2 = new Static4D(0,0,0,1); // quaternions |
|
82 |
|
|
83 |
DynamicQuat quatInt1 = new DynamicQuat(0,0.5f); |
|
84 |
DynamicQuat quatInt2 = new DynamicQuat(0,0.5f); |
|
85 |
|
|
86 |
quatInt1.add(mQuat1); |
|
87 |
quatInt2.add(mQuat2); |
|
88 |
|
|
57 |
mTexture = new DistortedTexture(); |
|
89 | 58 |
mEffects = new DistortedEffects(); |
90 |
mEffects.apply( new VertexEffectScale(new Static3D(mObjWidth,mObjHeight,mObjDepth) ) ); |
|
91 | 59 |
mEffects.apply( new MatrixEffectScale(mScale)); |
92 |
mEffects.apply( new MatrixEffectQuaternion(quatInt2, center) ); |
|
93 |
mEffects.apply( new MatrixEffectQuaternion(quatInt1, center) ); |
|
94 |
mEffects.apply( new FragmentEffectAlpha(mAlpha)); |
|
95 | 60 |
|
96 | 61 |
mScreen = new DistortedScreen(); |
97 | 62 |
mScreen.glClearColor(1.0f,1.0f,1.0f,0.0f); |
... | ... | |
99 | 64 |
} |
100 | 65 |
|
101 | 66 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
102 |
|
|
103 |
public void onDrawFrame(GL10 glUnused) |
|
104 |
{ |
|
105 |
mScreen.render( System.currentTimeMillis() ); |
|
106 |
} |
|
107 | 67 |
|
108 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
109 |
|
|
110 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
|
68 |
void setMesh(MeshBase mesh) |
|
111 | 69 |
{ |
112 |
final float SCALE = 0.75f; |
|
113 |
|
|
114 |
mScreenMin = Math.min(width, height); |
|
115 |
float factor = ( width*mObjHeight > height*mObjWidth ) ? (SCALE*height)/mObjHeight : (SCALE*width)/mObjWidth; |
|
116 |
mScale.set(factor,factor,factor); |
|
117 |
mScreen.resize(width, height); |
|
70 |
mMesh = mesh; |
|
118 | 71 |
} |
119 | 72 |
|
120 | 73 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
121 | 74 |
|
122 |
void setRenderModeToOIT(boolean oit)
|
|
75 |
void setTexture(Bitmap bmp)
|
|
123 | 76 |
{ |
124 |
mScreen.setOrderIndependentTransparency(oit);
|
|
77 |
mTexture.setTexture(bmp);
|
|
125 | 78 |
} |
126 | 79 |
|
127 | 80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
128 | 81 |
|
129 |
void setTransparency(int level)
|
|
82 |
public void onDrawFrame(GL10 glUnused)
|
|
130 | 83 |
{ |
131 |
mAlpha.set((float)level/100.0f);
|
|
84 |
mScreen.render( System.currentTimeMillis() );
|
|
132 | 85 |
} |
133 | 86 |
|
134 | 87 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
135 |
|
|
136 |
float setLevel(int level)
|
|
88 |
|
|
89 |
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
|
137 | 90 |
{ |
138 |
float inflateLevel = (level-50)/50.0f; |
|
139 |
mMesh.setInflate(inflateLevel); |
|
91 |
final float SCALE = 0.75f; |
|
140 | 92 |
|
141 |
return inflateLevel; |
|
93 |
float factor = ( width > height ) ? SCALE*height : SCALE*width; |
|
94 |
mScale.set(factor,factor,factor); |
|
95 |
mScreen.resize(width, height); |
|
142 | 96 |
} |
143 | 97 |
|
144 | 98 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
145 | 99 |
|
146 | 100 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
147 | 101 |
{ |
148 |
PredeformActivity2 act = (PredeformActivity2)mView.getContext();
|
|
102 |
PredeformActivity act = (PredeformActivity)mView.getContext();
|
|
149 | 103 |
|
104 |
mMesh = act.getMesh(); |
|
150 | 105 |
mTexture.setTexture( act.getBitmap() ); |
151 | 106 |
mScreen.detachAll(); |
152 | 107 |
mScreen.attach(mTexture,mEffects,mMesh); |
153 | 108 |
|
154 |
VertexEffectScale.enable(); |
|
155 |
FragmentEffectAlpha.enable(); |
|
156 |
|
|
157 | 109 |
try |
158 | 110 |
{ |
159 | 111 |
DistortedLibrary.onCreate(act); |
src/main/java/org/distorted/examples/predeform/PredeformRenderer2.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.predeform; |
|
21 |
|
|
22 |
import android.opengl.GLSurfaceView; |
|
23 |
|
|
24 |
import org.distorted.library.effect.FragmentEffectAlpha; |
|
25 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
|
26 |
import org.distorted.library.effect.MatrixEffectScale; |
|
27 |
import org.distorted.library.effect.VertexEffectScale; |
|
28 |
import org.distorted.library.main.DistortedEffects; |
|
29 |
import org.distorted.library.main.DistortedLibrary; |
|
30 |
import org.distorted.library.main.DistortedScreen; |
|
31 |
import org.distorted.library.main.DistortedTexture; |
|
32 |
import org.distorted.library.mesh.MeshBase; |
|
33 |
import org.distorted.library.type.DynamicQuat; |
|
34 |
import org.distorted.library.type.Static1D; |
|
35 |
import org.distorted.library.type.Static3D; |
|
36 |
import org.distorted.library.type.Static4D; |
|
37 |
|
|
38 |
import javax.microedition.khronos.egl.EGLConfig; |
|
39 |
import javax.microedition.khronos.opengles.GL10; |
|
40 |
|
|
41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
42 |
|
|
43 |
class PredeformRenderer2 implements GLSurfaceView.Renderer |
|
44 |
{ |
|
45 |
private static final float FOV = 30.0f; |
|
46 |
private static final float NEAR = 0.1f; |
|
47 |
|
|
48 |
private GLSurfaceView mView; |
|
49 |
private DistortedTexture mTexture; |
|
50 |
private DistortedEffects mEffects; |
|
51 |
private MeshBase mMesh; |
|
52 |
private DistortedScreen mScreen; |
|
53 |
private float mObjWidth, mObjHeight, mObjDepth; |
|
54 |
private Static3D mScale; |
|
55 |
private Static1D mAlpha; |
|
56 |
|
|
57 |
Static4D mQuat1, mQuat2; |
|
58 |
int mScreenMin; |
|
59 |
|
|
60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
61 |
|
|
62 |
PredeformRenderer2(GLSurfaceView v) |
|
63 |
{ |
|
64 |
mView = v; |
|
65 |
|
|
66 |
mAlpha = new Static1D(1.0f); |
|
67 |
mScale= new Static3D(1,1,1); |
|
68 |
|
|
69 |
Static3D center=new Static3D(0,0,0); |
|
70 |
|
|
71 |
PredeformActivity2 act = (PredeformActivity2)v.getContext(); |
|
72 |
|
|
73 |
mTexture = act.getTexture(); |
|
74 |
mMesh = act.getMesh(); |
|
75 |
|
|
76 |
mObjWidth = act.getCols(); |
|
77 |
mObjHeight= act.getRows(); |
|
78 |
mObjDepth = act.getSlic(); |
|
79 |
|
|
80 |
mQuat1 = new Static4D(0,0,0,1); // unity |
|
81 |
mQuat2 = new Static4D(0,0,0,1); // quaternions |
|
82 |
|
|
83 |
DynamicQuat quatInt1 = new DynamicQuat(0,0.5f); |
|
84 |
DynamicQuat quatInt2 = new DynamicQuat(0,0.5f); |
|
85 |
|
|
86 |
quatInt1.add(mQuat1); |
|
87 |
quatInt2.add(mQuat2); |
|
88 |
|
|
89 |
mEffects = new DistortedEffects(); |
|
90 |
mEffects.apply( new VertexEffectScale(new Static3D(mObjWidth,mObjHeight,mObjDepth) ) ); |
|
91 |
mEffects.apply( new MatrixEffectScale(mScale)); |
|
92 |
mEffects.apply( new MatrixEffectQuaternion(quatInt2, center) ); |
|
93 |
mEffects.apply( new MatrixEffectQuaternion(quatInt1, center) ); |
|
94 |
mEffects.apply( new FragmentEffectAlpha(mAlpha)); |
|
95 |
|
|
96 |
mScreen = new DistortedScreen(); |
|
97 |
mScreen.glClearColor(1.0f,1.0f,1.0f,0.0f); |
|
98 |
mScreen.setProjection(FOV, NEAR); |
|
99 |
} |
|
100 |
|
|
101 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
102 |
|
|
103 |
public void onDrawFrame(GL10 glUnused) |
|
104 |
{ |
|
105 |
mScreen.render( System.currentTimeMillis() ); |
|
106 |
} |
|
107 |
|
|
108 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
109 |
|
|
110 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
|
111 |
{ |
|
112 |
final float SCALE = 0.75f; |
|
113 |
|
|
114 |
mScreenMin = Math.min(width, height); |
|
115 |
float factor = ( width*mObjHeight > height*mObjWidth ) ? (SCALE*height)/mObjHeight : (SCALE*width)/mObjWidth; |
|
116 |
mScale.set(factor,factor,factor); |
|
117 |
mScreen.resize(width, height); |
|
118 |
} |
|
119 |
|
|
120 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
121 |
|
|
122 |
void setRenderModeToOIT(boolean oit) |
|
123 |
{ |
|
124 |
mScreen.setOrderIndependentTransparency(oit); |
|
125 |
} |
|
126 |
|
|
127 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
128 |
|
|
129 |
void setTransparency(int level) |
|
130 |
{ |
|
131 |
mAlpha.set((float)level/100.0f); |
|
132 |
} |
|
133 |
|
|
134 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
135 |
|
|
136 |
float setLevel(int level) |
|
137 |
{ |
|
138 |
float inflateLevel = (level-50)/50.0f; |
|
139 |
mMesh.setInflate(inflateLevel); |
|
140 |
|
|
141 |
return inflateLevel; |
|
142 |
} |
|
143 |
|
|
144 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
145 |
|
|
146 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
|
147 |
{ |
|
148 |
PredeformActivity2 act = (PredeformActivity2)mView.getContext(); |
|
149 |
|
|
150 |
mTexture.setTexture( act.getBitmap() ); |
|
151 |
mScreen.detachAll(); |
|
152 |
mScreen.attach(mTexture,mEffects,mMesh); |
|
153 |
|
|
154 |
VertexEffectScale.enable(); |
|
155 |
FragmentEffectAlpha.enable(); |
|
156 |
|
|
157 |
try |
|
158 |
{ |
|
159 |
DistortedLibrary.onCreate(act); |
|
160 |
} |
|
161 |
catch(Exception ex) |
|
162 |
{ |
|
163 |
android.util.Log.e("Inflate", ex.getMessage() ); |
|
164 |
} |
|
165 |
} |
|
166 |
} |
src/main/java/org/distorted/examples/predeform/PredeformSurfaceView.java | ||
---|---|---|
24 | 24 |
import android.content.pm.ConfigurationInfo; |
25 | 25 |
import android.opengl.GLSurfaceView; |
26 | 26 |
import android.util.AttributeSet; |
27 |
import android.view.MotionEvent; |
|
28 |
import android.widget.Toast; |
|
29 |
|
|
30 |
import org.distorted.examples.R; |
|
31 | 27 |
|
32 | 28 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
33 | 29 |
|
34 | 30 |
class PredeformSurfaceView extends GLSurfaceView |
35 | 31 |
{ |
36 |
private final static int DIRECTION_SENSITIVITY= 12; |
|
37 |
private int mX, mY; |
|
38 | 32 |
private PredeformRenderer mRenderer; |
39 | 33 |
|
40 | 34 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
43 | 37 |
{ |
44 | 38 |
super(context,attrs); |
45 | 39 |
|
46 |
mX = -1; |
|
47 |
mY = -1; |
|
48 |
|
|
49 | 40 |
if(!isInEditMode()) |
50 | 41 |
{ |
51 | 42 |
mRenderer = new PredeformRenderer(this); |
... | ... | |
53 | 44 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
54 | 45 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
55 | 46 |
setRenderer(mRenderer); |
56 |
Toast.makeText(context, R.string.example_rotate_toast , Toast.LENGTH_SHORT).show(); |
|
57 | 47 |
} |
58 | 48 |
} |
59 | 49 |
|
... | ... | |
63 | 53 |
{ |
64 | 54 |
return mRenderer; |
65 | 55 |
} |
66 |
|
|
67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
68 |
|
|
69 |
private void resetQuats() |
|
70 |
{ |
|
71 |
float qx = mRenderer.mQuat1.get0(); |
|
72 |
float qy = mRenderer.mQuat1.get1(); |
|
73 |
float qz = mRenderer.mQuat1.get2(); |
|
74 |
float qw = mRenderer.mQuat1.get3(); |
|
75 |
|
|
76 |
float rx = mRenderer.mQuat2.get0(); |
|
77 |
float ry = mRenderer.mQuat2.get1(); |
|
78 |
float rz = mRenderer.mQuat2.get2(); |
|
79 |
float rw = mRenderer.mQuat2.get3(); |
|
80 |
|
|
81 |
float tx = rw*qx - rz*qy + ry*qz + rx*qw; |
|
82 |
float ty = rw*qy + rz*qx + ry*qw - rx*qz; |
|
83 |
float tz = rw*qz + rz*qw - ry*qx + rx*qy; |
|
84 |
float tw = rw*qw - rz*qz - ry*qy - rx*qx; |
|
85 |
|
|
86 |
mRenderer.mQuat1.set(0f, 0f, 0f, 1f); |
|
87 |
mRenderer.mQuat2.set(tx, ty, tz, tw); |
|
88 |
} |
|
89 |
|
|
90 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
91 |
|
|
92 |
@Override public boolean onTouchEvent(MotionEvent event) |
|
93 |
{ |
|
94 |
int action = event.getAction(); |
|
95 |
int x = (int)event.getX(); |
|
96 |
int y = (int)event.getY(); |
|
97 |
|
|
98 |
switch(action) |
|
99 |
{ |
|
100 |
case MotionEvent.ACTION_DOWN: mX = x; |
|
101 |
mY = y; |
|
102 |
break; |
|
103 |
|
|
104 |
case MotionEvent.ACTION_MOVE: if( mX>=0 && mY>= 0 ) |
|
105 |
{ |
|
106 |
float px = mY-y; |
|
107 |
float py = mX-x; |
|
108 |
float pz = 0; |
|
109 |
float plen = (float)Math.sqrt(px*px + py*py + pz*pz); |
|
110 |
|
|
111 |
if( plen>0 ) |
|
112 |
{ |
|
113 |
px /= plen; |
|
114 |
py /= plen; |
|
115 |
pz /= plen; |
|
116 |
|
|
117 |
float cosA = (float)Math.cos(plen*3.14f/mRenderer.mScreenMin); |
|
118 |
float sinA = (float)Math.sqrt(1-cosA*cosA); |
|
119 |
|
|
120 |
mRenderer.mQuat1.set(px*sinA, py*sinA, pz*sinA, cosA); |
|
121 |
} |
|
122 |
} |
|
123 |
if( (mX-x)*(mX-x) + (mY-y)*(mY-y) > mRenderer.mScreenMin*mRenderer.mScreenMin/(DIRECTION_SENSITIVITY*DIRECTION_SENSITIVITY) ) |
|
124 |
{ |
|
125 |
mX = x; |
|
126 |
mY = y; |
|
127 |
resetQuats(); |
|
128 |
} |
|
129 |
break; |
|
130 |
|
|
131 |
case MotionEvent.ACTION_UP : mX = -1; |
|
132 |
mY = -1; |
|
133 |
resetQuats(); |
|
134 |
break; |
|
135 |
} |
|
136 |
|
|
137 |
return true; |
|
138 |
} |
|
139 |
|
|
140 | 56 |
} |
141 | 57 |
|
src/main/java/org/distorted/examples/predeform/PredeformSurfaceView2.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.predeform; |
|
21 |
|
|
22 |
import android.app.ActivityManager; |
|
23 |
import android.content.Context; |
|
24 |
import android.content.pm.ConfigurationInfo; |
|
25 |
import android.opengl.GLSurfaceView; |
|
26 |
import android.util.AttributeSet; |
|
27 |
import android.view.MotionEvent; |
|
28 |
import android.widget.Toast; |
|
29 |
|
|
30 |
import org.distorted.examples.R; |
|
31 |
|
|
32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
33 |
|
|
34 |
class PredeformSurfaceView2 extends GLSurfaceView |
|
35 |
{ |
|
36 |
private final static int DIRECTION_SENSITIVITY= 12; |
|
37 |
private int mX, mY; |
|
38 |
private PredeformRenderer2 mRenderer; |
|
39 |
|
|
40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
41 |
|
|
42 |
public PredeformSurfaceView2(Context context, AttributeSet attrs) |
|
43 |
{ |
|
44 |
super(context,attrs); |
|
45 |
|
|
46 |
mX = -1; |
|
47 |
mY = -1; |
|
48 |
|
|
49 |
if(!isInEditMode()) |
|
50 |
{ |
|
51 |
mRenderer = new PredeformRenderer2(this); |
|
52 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
53 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
54 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
55 |
setRenderer(mRenderer); |
|
56 |
Toast.makeText(context, R.string.example_rotate_toast , Toast.LENGTH_SHORT).show(); |
|
57 |
} |
|
58 |
} |
|
59 |
|
|
60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
61 |
|
|
62 |
public PredeformRenderer2 getRenderer() |
|
63 |
{ |
|
64 |
return mRenderer; |
|
65 |
} |
|
66 |
|
|
67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
68 |
|
|
69 |
private void resetQuats() |
|
70 |
{ |
|
71 |
float qx = mRenderer.mQuat1.get0(); |
|
72 |
float qy = mRenderer.mQuat1.get1(); |
|
73 |
float qz = mRenderer.mQuat1.get2(); |
|
74 |
float qw = mRenderer.mQuat1.get3(); |
|
75 |
|
|
76 |
float rx = mRenderer.mQuat2.get0(); |
|
77 |
float ry = mRenderer.mQuat2.get1(); |
|
78 |
float rz = mRenderer.mQuat2.get2(); |
|
79 |
float rw = mRenderer.mQuat2.get3(); |
|
80 |
|
|
81 |
float tx = rw*qx - rz*qy + ry*qz + rx*qw; |
|
82 |
float ty = rw*qy + rz*qx + ry*qw - rx*qz; |
|
83 |
float tz = rw*qz + rz*qw - ry*qx + rx*qy; |
|
84 |
float tw = rw*qw - rz*qz - ry*qy - rx*qx; |
|
85 |
|
|
86 |
mRenderer.mQuat1.set(0f, 0f, 0f, 1f); |
|
87 |
mRenderer.mQuat2.set(tx, ty, tz, tw); |
|
88 |
} |
|
89 |
|
|
90 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
91 |
|
|
92 |
@Override public boolean onTouchEvent(MotionEvent event) |
|
93 |
{ |
|
94 |
int action = event.getAction(); |
|
95 |
int x = (int)event.getX(); |
|
96 |
int y = (int)event.getY(); |
|
97 |
|
|
98 |
switch(action) |
|
99 |
{ |
|
100 |
case MotionEvent.ACTION_DOWN: mX = x; |
|
101 |
mY = y; |
|
102 |
break; |
|
103 |
|
|
104 |
case MotionEvent.ACTION_MOVE: if( mX>=0 && mY>= 0 ) |
|
105 |
{ |
|
106 |
float px = mY-y; |
|
107 |
float py = mX-x; |
|
108 |
float pz = 0; |
|
109 |
float plen = (float)Math.sqrt(px*px + py*py + pz*pz); |
|
110 |
|
|
111 |
if( plen>0 ) |
|
112 |
{ |
|
113 |
px /= plen; |
|
114 |
py /= plen; |
|
115 |
pz /= plen; |
|
116 |
|
|
117 |
float cosA = (float)Math.cos(plen*3.14f/mRenderer.mScreenMin); |
|
118 |
float sinA = (float)Math.sqrt(1-cosA*cosA); |
|
119 |
|
|
120 |
mRenderer.mQuat1.set(px*sinA, py*sinA, pz*sinA, cosA); |
|
121 |
} |
|
122 |
} |
|
123 |
if( (mX-x)*(mX-x) + (mY-y)*(mY-y) > mRenderer.mScreenMin*mRenderer.mScreenMin/(DIRECTION_SENSITIVITY*DIRECTION_SENSITIVITY) ) |
|
124 |
{ |
|
125 |
mX = x; |
|
126 |
mY = y; |
|
127 |
resetQuats(); |
|
128 |
} |
|
129 |
break; |
|
130 |
|
|
131 |
case MotionEvent.ACTION_UP : mX = -1; |
|
132 |
mY = -1; |
|
133 |
resetQuats(); |
|
134 |
break; |
|
135 |
} |
|
136 |
|
|
137 |
return true; |
|
138 |
} |
|
139 |
|
|
140 |
} |
|
141 |
|
src/main/res/layout/object_picker_layout.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
|
|
3 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
4 |
android:orientation="vertical" |
|
5 |
android:layout_width="match_parent" |
|
6 |
android:layout_height="match_parent"> |
|
7 |
|
|
8 |
<LinearLayout |
|
9 |
android:orientation="horizontal" |
|
10 |
android:layout_width="match_parent" |
|
11 |
android:layout_height="wrap_content"> |
|
12 |
|
|
13 |
<Spinner |
|
14 |
android:layout_width="0dp" |
|
15 |
android:layout_height="50dp" |
|
16 |
android:layout_weight="0.5" |
|
17 |
android:id="@+id/objectpicker_spinnerType" |
|
18 |
/> |
|
19 |
|
|
20 |
<Spinner |
|
21 |
android:layout_width="0dp" |
|
22 |
android:layout_height="50dp" |
|
23 |
android:layout_weight="0.5" |
|
24 |
android:id="@+id/objectpicker_spinnerBitmap" |
|
25 |
/> |
|
26 |
</LinearLayout> |
|
27 |
|
|
28 |
<LinearLayout |
|
29 |
android:orientation="horizontal" |
|
30 |
android:layout_width="match_parent" |
|
31 |
android:layout_height="wrap_content"> |
|
32 |
|
|
33 |
<NumberPicker |
|
34 |
android:id="@+id/objectpicker_rows" |
|
35 |
android:layout_width="wrap_content" |
|
36 |
android:layout_height="wrap_content" |
|
37 |
android:orientation="vertical" |
|
38 |
android:descendantFocusability="blocksDescendants" |
|
39 |
/> |
|
40 |
|
|
41 |
<NumberPicker |
|
42 |
android:id="@+id/objectpicker_cols" |
|
43 |
android:layout_width="wrap_content" |
|
44 |
android:layout_height="wrap_content" |
|
45 |
android:orientation="vertical" |
|
46 |
android:descendantFocusability="blocksDescendants" |
|
47 |
/> |
|
48 |
|
|
49 |
<NumberPicker |
|
50 |
android:id="@+id/objectpicker_slices" |
|
51 |
android:layout_width="wrap_content" |
|
52 |
android:layout_height="wrap_content" |
|
53 |
android:orientation="vertical" |
|
54 |
android:descendantFocusability="blocksDescendants" |
|
55 |
/> |
|
56 |
|
|
57 |
<Button |
|
58 |
android:id="@+id/objectpicker_create" |
|
59 |
android:onClick="Create" |
|
60 |
android:text="@string/Create" |
|
61 |
android:layout_width="match_parent" |
|
62 |
android:layout_height="fill_parent" |
|
63 |
/> |
|
64 |
</LinearLayout> |
|
65 |
|
|
66 |
<org.distorted.examples.predeform.PredeformSurfaceView |
|
67 |
android:id="@+id/predeformSurfaceView" |
|
68 |
android:layout_width="fill_parent" |
|
69 |
android:layout_height="0dp" |
|
70 |
android:layout_weight="0.80" /> |
|
71 |
|
|
72 |
</LinearLayout> |
src/main/res/layout/predeformlayout.xml | ||
---|---|---|
5 | 5 |
android:gravity="center_horizontal" |
6 | 6 |
android:orientation="vertical" > |
7 | 7 |
|
8 |
<org.distorted.examples.predeform.PredeformSurfaceView |
|
9 |
android:id="@+id/predeformSurfaceView" |
|
8 |
<org.distorted.examples.predeform.PredeformSurfaceView2
|
|
9 |
android:id="@+id/predeform2SurfaceView"
|
|
10 | 10 |
android:layout_width="match_parent" |
11 | 11 |
android:layout_height="0dp" |
12 | 12 |
android:layout_weight="1.00" /> |
... | ... | |
20 | 20 |
android:background="@color/blue"> |
21 | 21 |
|
22 | 22 |
<TextView |
23 |
android:id="@+id/predeformInflateText" |
|
23 |
android:id="@+id/predeform2InflateText"
|
|
24 | 24 |
android:layout_width="0dp" |
25 | 25 |
android:layout_height="wrap_content" |
26 | 26 |
android:layout_weight="0.3" |
... | ... | |
28 | 28 |
android:text="@string/inflate" /> |
29 | 29 |
|
30 | 30 |
<SeekBar |
31 |
android:id="@+id/predeformInflateLevel" |
|
31 |
android:id="@+id/predeform2InflateLevel"
|
|
32 | 32 |
android:layout_weight="0.7" |
33 | 33 |
android:layout_width="0dp" |
34 | 34 |
android:layout_height="50dp" |
... | ... | |
46 | 46 |
android:background="@color/blue"> |
47 | 47 |
|
48 | 48 |
<SeekBar |
49 |
android:id="@+id/predeformTransparency" |
|
49 |
android:id="@+id/predeform2Transparency"
|
|
50 | 50 |
android:layout_weight="0.50" |
51 | 51 |
android:layout_width="0dp" |
52 | 52 |
android:layout_height="50dp" |
... | ... | |
57 | 57 |
android:layout_width="0dp" |
58 | 58 |
android:layout_height="50dp" |
59 | 59 |
android:layout_weight="0.5" |
60 |
android:id="@+id/predeformSpinnerMode" |
|
60 |
android:id="@+id/predeform2SpinnerMode"
|
|
61 | 61 |
/> |
62 | 62 |
</LinearLayout> |
63 | 63 |
|
Also available in: Unified diff
Progress with Predeform.