Revision 61420934
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/examples/generic/GenericActivity.java | ||
---|---|---|
216 | 216 |
|
217 | 217 |
public void Create(View v) |
218 | 218 |
{ |
219 |
Intent mainInt = new Intent( getApplicationContext(), GenericActivity2.class); |
|
219 |
Intent mainInt = new Intent( getApplicationContext(), GenericActivity2.class);
|
|
220 | 220 |
Bundle b = new Bundle(); |
221 | 221 |
|
222 |
int rows,cols; |
|
223 |
|
|
224 |
switch( GenericMeshList.getDimension(mObjectType) ) |
|
225 |
{ |
|
226 |
case 0: rows = 1; // a quad |
|
227 |
cols = 1; |
|
228 |
break; |
|
229 |
case 1: rows = mNumRows; // Triangles, Sphere |
|
230 |
cols = mNumRows; |
|
231 |
break; |
|
232 |
default:rows = mNumRows; |
|
233 |
cols = mNumCols; |
|
234 |
break; |
|
235 |
} |
|
236 |
|
|
237 |
b.putInt("type", mObjectType); |
|
238 |
b.putInt("cols", cols); |
|
239 |
b.putInt("rows", rows); |
|
240 |
b.putInt("slices", mNumSlic); |
|
222 |
b.putInt("type" , mObjectType); |
|
223 |
b.putInt("cols" , GenericMeshList.getCols(mObjectType, mNumCols, mNumRows, mNumSlic) ); |
|
224 |
b.putInt("rows" , GenericMeshList.getRows(mObjectType, mNumCols, mNumRows, mNumSlic) ); |
|
225 |
b.putInt("slices", GenericMeshList.getSlic(mObjectType, mNumCols, mNumRows, mNumSlic) ); |
|
241 | 226 |
b.putInt("bitmap", mBitmapID); |
242 | 227 |
|
243 |
if( mObjectType==0 ) // cubes |
|
244 |
{ |
|
245 |
String str = ""; |
|
246 |
|
|
247 |
for(int i=0; i<mNumRows*mNumCols; i++) |
|
248 |
str += mShape[i] ? "1" : "0"; |
|
249 |
|
|
250 |
b.putString("string", str); |
|
251 |
} |
|
252 |
else |
|
253 |
{ |
|
254 |
b.putString("string", ""); |
|
255 |
} |
|
228 |
b.putString("string", GenericMeshList.getString(mObjectType, mNumCols, mNumRows, mShape)); |
|
256 | 229 |
|
257 | 230 |
mainInt.putExtras(b); |
258 | 231 |
startActivity(mainInt); |
src/main/java/org/distorted/examples/generic/GenericActivity2.java | ||
---|---|---|
76 | 76 |
mShowNormal = false; |
77 | 77 |
mUseOIT = false; |
78 | 78 |
|
79 |
int maxsize = numCols > numRows ? (numCols>numSlic ? numCols:numSlic) : (numRows>numSlic ? numRows:numSlic);
|
|
79 |
int maxsize = numCols > numRows ? (Math.max(numCols, numSlic)) : (Math.max(numRows, numSlic));
|
|
80 | 80 |
createBitmap(maxsize, bitmapID); |
81 | 81 |
mMesh = GenericMeshList.createMesh(objectType, numCols, numRows, numSlic, bitmapID, str); |
82 |
mMesh.setStretch(numCols, numRows, numSlic); |
|
82 | 83 |
|
83 | 84 |
mMesh.setShowNormals(mShowNormal); |
84 | 85 |
mTexture= new DistortedTexture(); |
src/main/java/org/distorted/examples/generic/GenericMeshList.java | ||
---|---|---|
74 | 74 |
return meshes[ordinal].mDimension; |
75 | 75 |
} |
76 | 76 |
|
77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
78 |
|
|
79 |
static int getRows(int ordinal, int cols, int rows, int slic) |
|
80 |
{ |
|
81 |
switch(ordinal) |
|
82 |
{ |
|
83 |
case 0: return rows; // cubes |
|
84 |
case 1: return rows; // rectangles |
|
85 |
case 2: return rows; // sphere |
|
86 |
case 3: return 1; // quad |
|
87 |
case 4: return rows; // triangles |
|
88 |
} |
|
89 |
|
|
90 |
return 0; |
|
91 |
} |
|
92 |
|
|
93 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
94 |
|
|
95 |
static int getCols(int ordinal, int cols, int rows, int slic) |
|
96 |
{ |
|
97 |
switch(ordinal) |
|
98 |
{ |
|
99 |
case 0: return cols; // cubes |
|
100 |
case 1: return cols; // rectangles |
|
101 |
case 2: return rows; // sphere |
|
102 |
case 3: return 1; // quad |
|
103 |
case 4: return rows; // triangles |
|
104 |
} |
|
105 |
|
|
106 |
return 0; |
|
107 |
} |
|
108 |
|
|
109 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
110 |
|
|
111 |
static int getSlic(int ordinal, int cols, int rows, int slic) |
|
112 |
{ |
|
113 |
switch(ordinal) |
|
114 |
{ |
|
115 |
case 0: return slic; // cubes |
|
116 |
case 1: return 0; // rectangles |
|
117 |
case 2: return rows; // sphere |
|
118 |
case 3: return 0; // quad |
|
119 |
case 4: return 0; // triangles |
|
120 |
} |
|
121 |
|
|
122 |
return 0; |
|
123 |
} |
|
124 |
|
|
125 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
126 |
|
|
127 |
static String getString(int ordinal, int cols, int rows, boolean[] shape) |
|
128 |
{ |
|
129 |
if( ordinal==0 ) |
|
130 |
{ |
|
131 |
String str = ""; |
|
132 |
|
|
133 |
for(int i=0; i<rows*cols; i++) |
|
134 |
str += shape[i] ? "1" : "0"; |
|
135 |
|
|
136 |
return str; |
|
137 |
} |
|
138 |
|
|
139 |
return ""; |
|
140 |
} |
|
141 |
|
|
77 | 142 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
78 | 143 |
|
79 | 144 |
static MeshBase createMesh(int ordinal, int cols, int rows, int slic, int bitmapID, String str) |
80 | 145 |
{ |
81 | 146 |
MeshBase mesh; |
82 | 147 |
|
83 |
int maxsize = cols > rows ? (cols>slic ? cols:slic) : (rows>slic ? rows:slic) ;
|
|
148 |
int maxsize = cols > rows ? (Math.max(cols, slic)) : (Math.max(rows, slic)) ;
|
|
84 | 149 |
|
85 | 150 |
switch( meshes[ordinal] ) |
86 | 151 |
{ |
... | ... | |
96 | 161 |
|
97 | 162 |
mesh = new MeshCubes(cols, str, slic, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB); |
98 | 163 |
} |
99 |
mesh.setStretch(cols,rows,slic); |
|
100 | 164 |
break; |
101 | 165 |
case Rectangles: mesh = new MeshRectangles(cols,rows); |
102 |
mesh.setStretch(cols,rows,0); |
|
103 | 166 |
break; |
104 | 167 |
case Sphere : mesh = new MeshSphere(rows); |
105 |
mesh.setStretch(rows,rows,rows); |
|
106 | 168 |
break; |
107 | 169 |
case Quad : mesh = new MeshQuad(); |
108 |
mesh.setStretch(1,1,0); |
|
109 | 170 |
break; |
110 | 171 |
case Triangles : mesh = new MeshTriangles(rows); |
111 |
mesh.setStretch(rows,rows,0); |
|
112 | 172 |
break; |
113 | 173 |
default: mesh = null; |
114 | 174 |
android.util.Log.e("Meshes", "Error: unimplemented Mesh!"); |
src/main/java/org/distorted/examples/inflate/InflateMeshList.java | ||
---|---|---|
113 | 113 |
switch(ordinal) |
114 | 114 |
{ |
115 | 115 |
case 0: return slic; // cubes |
116 |
case 1: return rows; // rectangles
|
|
116 |
case 1: return 0; // rectangles
|
|
117 | 117 |
case 2: return rows; // sphere |
118 |
case 3: return 1; // quad
|
|
119 |
case 4: return rows; // triangles
|
|
118 |
case 3: return 0; // quad
|
|
119 |
case 4: return 0; // triangles
|
|
120 | 120 |
} |
121 | 121 |
|
122 | 122 |
return 0; |
Also available in: Unified diff
Prepare Generic for the stretchless API.