Revision 302e40d1
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java | ||
---|---|---|
44 | 44 |
final static int PROCEDURAL = -1; |
45 | 45 |
final static int POLYGON = -2; |
46 | 46 |
final static int MULTIGON = -3; |
47 |
final static int TRIANGLE = -4; |
|
47 | 48 |
|
48 | 49 |
private LinearLayout mLayout; |
49 | 50 |
private int mResource; |
50 |
private String[] mNames = new String[] { "procedural" , |
|
51 |
private String[] mNames = new String[] { "triangle" , |
|
52 |
"procedural" , |
|
51 | 53 |
"polygon" , |
52 | 54 |
"multigon" , |
53 | 55 |
"deferredjob", |
... | ... | |
198 | 200 |
{ |
199 | 201 |
switch(pos) |
200 | 202 |
{ |
201 |
case 0: mResource = PROCEDURAL ; break; |
|
202 |
case 1: mResource = POLYGON ; break; |
|
203 |
case 2: mResource = MULTIGON ; break; |
|
204 |
case 3: mResource = R.raw.deferredjob; break; |
|
205 |
case 4: mResource = R.raw.meshjoin ; break; |
|
206 |
case 5: mResource = R.raw.predeform ; break; |
|
207 |
case 6: mResource = R.raw.cube2 ; break; |
|
208 |
case 7: mResource = R.raw.cube3 ; break; |
|
209 |
case 8: mResource = R.raw.cube4 ; break; |
|
210 |
case 9: mResource = R.raw.cube5 ; break; |
|
211 |
case 10: mResource = R.raw.pyra3 ; break; |
|
212 |
case 11: mResource = R.raw.pyra4 ; break; |
|
213 |
case 12: mResource = R.raw.pyra5 ; break; |
|
214 |
case 13: mResource = R.raw.dino ; break; |
|
215 |
case 14: mResource = R.raw.skewb ; break; |
|
203 |
case 0: mResource = TRIANGLE ; break; |
|
204 |
case 1: mResource = PROCEDURAL ; break; |
|
205 |
case 2: mResource = POLYGON ; break; |
|
206 |
case 3: mResource = MULTIGON ; break; |
|
207 |
case 4: mResource = R.raw.deferredjob; break; |
|
208 |
case 5: mResource = R.raw.meshjoin ; break; |
|
209 |
case 6: mResource = R.raw.predeform ; break; |
|
210 |
case 7: mResource = R.raw.cube2 ; break; |
|
211 |
case 8: mResource = R.raw.cube3 ; break; |
|
212 |
case 9: mResource = R.raw.cube4 ; break; |
|
213 |
case 10: mResource = R.raw.cube5 ; break; |
|
214 |
case 11: mResource = R.raw.pyra3 ; break; |
|
215 |
case 12: mResource = R.raw.pyra4 ; break; |
|
216 |
case 13: mResource = R.raw.pyra5 ; break; |
|
217 |
case 14: mResource = R.raw.dino ; break; |
|
218 |
case 15: mResource = R.raw.skewb ; break; |
|
216 | 219 |
} |
217 | 220 |
} |
218 | 221 |
} |
src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java | ||
---|---|---|
36 | 36 |
import org.distorted.library.main.DistortedLibrary; |
37 | 37 |
import org.distorted.library.main.DistortedScreen; |
38 | 38 |
import org.distorted.library.main.DistortedTexture; |
39 |
import org.distorted.library.mesh.MeshBandedTriangle; |
|
39 | 40 |
import org.distorted.library.mesh.MeshBase; |
40 | 41 |
import org.distorted.library.mesh.MeshFile; |
41 | 42 |
import org.distorted.library.mesh.MeshMultigon; |
... | ... | |
59 | 60 |
import static org.distorted.examples.meshfile.MeshFileActivity.MULTIGON; |
60 | 61 |
import static org.distorted.examples.meshfile.MeshFileActivity.POLYGON; |
61 | 62 |
import static org.distorted.examples.meshfile.MeshFileActivity.PROCEDURAL; |
63 |
import static org.distorted.examples.meshfile.MeshFileActivity.TRIANGLE; |
|
62 | 64 |
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE; |
63 | 65 |
|
64 | 66 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
198 | 200 |
{ |
199 | 201 |
createMultigon(); |
200 | 202 |
} |
203 |
else if( resourceID==TRIANGLE ) |
|
204 |
{ |
|
205 |
createTriangle(); |
|
206 |
} |
|
201 | 207 |
else |
202 | 208 |
{ |
203 | 209 |
openMesh(resourceID); |
... | ... | |
222 | 228 |
float F = 0.5f; |
223 | 229 |
float E = SQ3/2; |
224 | 230 |
|
225 |
if( resourceID == R.raw.deferredjob || |
|
226 |
resourceID == R.raw.meshjoin || |
|
227 |
resourceID == PROCEDURAL || |
|
228 |
resourceID == POLYGON || |
|
229 |
resourceID == MULTIGON || |
|
231 |
if( resourceID == R.raw.deferredjob || resourceID == R.raw.meshjoin || |
|
232 |
resourceID == PROCEDURAL || resourceID == POLYGON || |
|
233 |
resourceID == MULTIGON || resourceID == TRIANGLE || |
|
230 | 234 |
resourceID == R.raw.predeform ) return createWhiteTexture(); |
231 | 235 |
|
232 | 236 |
if( resourceID == R.raw.cube2 || |
... | ... | |
278 | 282 |
return bitmap; |
279 | 283 |
} |
280 | 284 |
|
285 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
286 |
|
|
287 |
private void createTriangle() |
|
288 |
{ |
|
289 |
float[] vL = {-1.0f, -0.5f}; |
|
290 |
float[] vR = { 1.0f, -0.5f}; |
|
291 |
float[] vT = { 0.0f, 1.0f}; |
|
292 |
float C = 2f; |
|
293 |
float[] bands = { 1.0f, 0.00f*C, /*0.9f, 0.05f*C,*/ 0.8f, 0.06f*C, 0.5f, 0.09f*C, 0.0f, 0.10f*C}; |
|
294 |
float[] normL = { vL[0]-vT[0], vL[1]-vT[1] }; |
|
295 |
float[] normR = { vR[0]-vT[0], vR[1]-vT[1] }; |
|
296 |
int mode = MeshBandedTriangle.MODE_NORMAL; |
|
297 |
int extraBands = 2; |
|
298 |
int extraVertices = 1; |
|
299 |
|
|
300 |
mMesh = new MeshBandedTriangle(vL,vR,vT,bands,normL,normR,mode,extraBands,extraVertices); |
|
301 |
mMesh.setEffectAssociation(0,0,0); |
|
302 |
} |
|
303 |
|
|
281 | 304 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
282 | 305 |
|
283 | 306 |
private void createPolygon() |
... | ... | |
287 | 310 |
|
288 | 311 |
int extraIndex = 0; |
289 | 312 |
int extraVertices = 0; |
290 |
float[] vertices = new float[] { -A,-A, A,-A, A,A, -A,A };
|
|
313 |
float[] vertices = { -A,-A, A,-A, A,A, -A,A }; |
|
291 | 314 |
|
292 | 315 |
float C = 2f; |
293 |
float[] bands = new float[] { 1.0f, 0.00f*C, 0.9f, 0.04f*C, 0.8f, 0.07f*C, 0.5f, 0.09f*C, 0.0f, 0.10f*C};
|
|
316 |
float[] bands = { 1.0f, 0.00f*C, 0.9f, 0.04f*C, 0.8f, 0.07f*C, 0.5f, 0.09f*C, 0.0f, 0.10f*C}; |
|
294 | 317 |
|
295 | 318 |
/* |
296 | 319 |
int numBands = 5; |
Also available in: Unified diff
MeshBandedTriangle implemented