Revision 7edab735
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java | ||
---|---|---|
32 | 32 |
import org.distorted.library.effect.MatrixEffectScale; |
33 | 33 |
import org.distorted.library.effect.VertexEffectDeform; |
34 | 34 |
import org.distorted.library.effect.VertexEffectDisappear; |
35 |
import org.distorted.library.effect.VertexEffectMove; |
|
36 | 35 |
import org.distorted.library.effect.VertexEffectRotate; |
37 |
import org.distorted.library.effect.VertexEffectScale; |
|
38 | 36 |
import org.distorted.library.main.DistortedEffects; |
39 | 37 |
import org.distorted.library.main.DistortedLibrary; |
40 | 38 |
import org.distorted.library.main.DistortedScreen; |
41 | 39 |
import org.distorted.library.main.DistortedTexture; |
42 | 40 |
import org.distorted.library.mesh.MeshBase; |
43 | 41 |
import org.distorted.library.mesh.MeshFile; |
44 |
import org.distorted.library.mesh.MeshJoined; |
|
45 |
import org.distorted.library.mesh.MeshPolygon; |
|
46 | 42 |
import org.distorted.library.type.DynamicQuat; |
47 |
import org.distorted.library.type.Static1D; |
|
48 | 43 |
import org.distorted.library.type.Static3D; |
49 | 44 |
import org.distorted.library.type.Static4D; |
50 | 45 |
|
... | ... | |
61 | 56 |
|
62 | 57 |
class MeshFileRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener |
63 | 58 |
{ |
59 |
private static final float SQ2 = (float)Math.sqrt(2); |
|
60 |
private static final float SQ3 = (float)Math.sqrt(3); |
|
64 | 61 |
private final float DEFAULT_SCALE = 0.3f; |
65 | 62 |
|
66 | 63 |
private GLSurfaceView mView; |
... | ... | |
137 | 134 |
VertexEffectRotate.enable(); |
138 | 135 |
VertexEffectDeform.enable(); |
139 | 136 |
|
140 |
DistortedLibrary.setMax(EffectType.VERTEX, 14);
|
|
137 |
DistortedLibrary.setMax(EffectType.VERTEX, 16);
|
|
141 | 138 |
|
142 | 139 |
DistortedLibrary.onCreate(mView.getContext(), this); |
143 | 140 |
} |
... | ... | |
199 | 196 |
|
200 | 197 |
private Bitmap createTexture(int resourceID) |
201 | 198 |
{ |
199 |
TextureFactory factory = TextureFactory.getInstance(); |
|
200 |
|
|
201 |
float[] vertices; |
|
202 |
int[] colors; |
|
203 |
float F = 0.5f; |
|
204 |
float E = SQ3/2; |
|
205 |
float G = SQ2/4; |
|
206 |
|
|
202 | 207 |
switch(resourceID) |
203 | 208 |
{ |
204 | 209 |
case R.raw.deferredjob: |
205 |
case R.raw.meshjoin : final int[] TET_COLORS4 = new int[] { 0xffffff00, |
|
206 |
0xff00ff00, |
|
207 |
0xff0000ff, |
|
208 |
0xffff0000 }; |
|
209 |
return createTetrahedronTexture(TET_COLORS4); |
|
210 |
case R.raw.meshjoin : |
|
210 | 211 |
case PROCEDURAL : |
211 |
case R.raw.predeform : return createGridTexture(3); |
|
212 |
case R.raw.predeform : return createWhiteTexture(); |
|
213 |
|
|
212 | 214 |
case R.raw.cube2 : |
213 | 215 |
case R.raw.cube3 : |
214 | 216 |
case R.raw.cube4 : |
215 |
case R.raw.cube5 : final int[] CUBE_COLORS = new int[] { 0xffffff00, |
|
216 |
0xffffffff, |
|
217 |
0xff0000ff, |
|
218 |
0xff00ff00, |
|
219 |
0xffff0000, |
|
220 |
0xffb5651d }; |
|
221 |
return createCubeTexture(CUBE_COLORS); |
|
217 |
case R.raw.cube5 : colors = new int[] { 0xffffff00, 0xffffffff, 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffb5651d }; |
|
218 |
vertices = new float[] { -F,-F, +F,-F, +F,+F, -F,+F}; |
|
219 |
return factory.createTexture(vertices,colors,0.10f, 0.10f, true); |
|
222 | 220 |
case R.raw.pyra3 : |
223 | 221 |
case R.raw.pyra4 : |
224 |
case R.raw.pyra5 : final int[] TET_COLORS5 = new int[] { 0xffffff00, |
|
225 |
0xff00ff00, |
|
226 |
0xff0000ff, |
|
227 |
0xffff0000, |
|
228 |
0xff000000 }; |
|
229 |
return createTetrahedronTexture(TET_COLORS5); |
|
230 |
case R.raw.dino : final int[] DINO_COLORS = new int[] { 0xffffff00, |
|
231 |
0xffffffff, |
|
232 |
0xff0000ff, |
|
233 |
0xff00ff00, |
|
234 |
0xffff0000, |
|
235 |
0xffb5651d }; |
|
236 |
return createDinoTexture(DINO_COLORS); |
|
237 |
case R.raw.skewb : final int[] SKEW_COLORS = new int[] { 0xffffff00, |
|
238 |
0xffffffff, |
|
239 |
0xff0000ff, |
|
240 |
0xff00ff00, |
|
241 |
0xffff0000, |
|
242 |
0xffb5651d }; |
|
243 |
return createSkewbTexture(SKEW_COLORS); |
|
244 |
} |
|
245 |
|
|
246 |
return null; |
|
247 |
} |
|
248 |
|
|
249 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
222 |
case R.raw.pyra5 : colors = new int[] { 0xffffff00, 0xff00ff00, 0xff0000ff, 0xffff0000 }; |
|
223 |
vertices = new float[] { -F,-E/3, +F,-E/3, 0.0f,2*E/3}; |
|
224 |
return factory.createTexture(vertices,colors,0.05f, 0.05f, true); |
|
250 | 225 |
|
251 |
private Bitmap createCubeTexture(int[] faceColors) |
|
252 |
{ |
|
253 |
final int FACES=faceColors.length; |
|
254 |
int SIZE = 200; |
|
255 |
final float R = SIZE*0.10f; |
|
256 |
final float M = SIZE*0.05f; |
|
257 |
|
|
258 |
Bitmap bitmap; |
|
259 |
Paint paint = new Paint(); |
|
260 |
bitmap = Bitmap.createBitmap( (FACES+1)*SIZE, SIZE, Bitmap.Config.ARGB_8888); |
|
261 |
Canvas canvas = new Canvas(bitmap); |
|
226 |
case R.raw.dino : colors = new int[] { 0xffffff00, 0xffffffff, 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffb5651d }; |
|
227 |
vertices = new float[] { -F,F/3, 0,-2*F/3, +F,F/3 }; |
|
228 |
return factory.createTexture(vertices,colors,0.05f, 0.03f, true); |
|
262 | 229 |
|
263 |
paint.setStyle(Paint.Style.FILL); |
|
264 |
paint.setColor(0xff000000); |
|
265 |
canvas.drawRect(0, 0, (FACES+1)*SIZE, SIZE, paint); |
|
230 |
case R.raw.skewb : colors = new int[] { 0xffffff00, 0xffffffff, 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffb5651d }; |
|
231 |
//vertices = new float[] { -G,-G, +G,-G, +G,+G, -G,+G }; |
|
266 | 232 |
|
267 |
for(int face=0; face<FACES; face++) |
|
268 |
{ |
|
269 |
paint.setColor(faceColors[face]); |
|
270 |
canvas.drawRoundRect( face*SIZE+M, M, (face+1)*SIZE-M, SIZE-M, R, R, paint); |
|
271 |
} |
|
233 |
vertices = new float[] { -F+F/4,F/4, F/4,-F+F/4, F/4,F/4}; |
|
234 |
return factory.createTexture(vertices,colors,0.05f, 0.08f, true); |
|
235 |
} |
|
272 | 236 |
|
273 |
return bitmap;
|
|
237 |
return null;
|
|
274 | 238 |
} |
275 | 239 |
|
276 | 240 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
277 | 241 |
|
278 |
private Bitmap createGridTexture(int lines)
|
|
242 |
private Bitmap createWhiteTexture()
|
|
279 | 243 |
{ |
280 |
int SIZE = 200;
|
|
244 |
int SIZE = 1;
|
|
281 | 245 |
Bitmap bitmap = Bitmap.createBitmap(SIZE,SIZE, Bitmap.Config.ARGB_8888); |
282 | 246 |
Canvas canvas = new Canvas(bitmap); |
283 | 247 |
|
284 | 248 |
Paint paint = new Paint(); |
285 |
paint.setColor(0xff008800); |
|
286 |
paint.setStyle(Paint.Style.FILL); |
|
287 |
canvas.drawRect(0, 0, SIZE, SIZE, paint); |
|
288 | 249 |
paint.setColor(0xffffffff); |
289 |
|
|
290 |
for(int i=0; i<=lines ; i++ ) |
|
291 |
{ |
|
292 |
int x = (SIZE*i)/lines; |
|
293 |
canvas.drawRect(x-1, 0, x+1, SIZE, paint); |
|
294 |
canvas.drawRect( 0, x-1, SIZE, x+1, paint); |
|
295 |
} |
|
296 |
|
|
297 |
return bitmap; |
|
298 |
} |
|
299 |
|
|
300 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
301 |
|
|
302 |
private Bitmap createTetrahedronTexture(int[] faceColors) |
|
303 |
{ |
|
304 |
final float SQ3 = (float)Math.sqrt(3); |
|
305 |
final int FACES=faceColors.length; |
|
306 |
int SIZE = 256; |
|
307 |
float STROKE = 0.05f*SIZE; |
|
308 |
float OFF = STROKE/2 -1; |
|
309 |
float OFF2 = 0.5f*SIZE + OFF; |
|
310 |
float HEIGHT = SIZE - OFF; |
|
311 |
float RADIUS = SIZE/12.0f; |
|
312 |
float ARC1_H = 0.2f*SIZE; |
|
313 |
float ARC1_W = SIZE*0.5f; |
|
314 |
float ARC2_W = 0.153f*SIZE; |
|
315 |
float ARC2_H = 0.905f*SIZE; |
|
316 |
float ARC3_W = SIZE-ARC2_W; |
|
317 |
|
|
318 |
float M = SQ3/2; |
|
319 |
float D = (M/2 - 0.51f)*SIZE; |
|
320 |
|
|
321 |
Bitmap result = Bitmap.createBitmap(FACES*SIZE,SIZE, Bitmap.Config.ARGB_8888); |
|
322 |
Canvas canvas = new Canvas(result); |
|
323 |
Paint paint = new Paint(); |
|
324 |
paint.setAntiAlias(true); |
|
325 |
paint.setStrokeWidth(STROKE); |
|
326 |
|
|
327 |
for(int i=0; i<FACES; i++) |
|
328 |
{ |
|
329 |
paint.setColor(faceColors[i]); |
|
330 |
paint.setStyle(Paint.Style.FILL); |
|
331 |
|
|
332 |
canvas.drawRect(i*SIZE,0,(i+1)*SIZE,SIZE,paint); |
|
333 |
|
|
334 |
paint.setColor(0xff000000); |
|
335 |
paint.setStyle(Paint.Style.STROKE); |
|
336 |
|
|
337 |
canvas.drawLine( i*SIZE, M*HEIGHT+D, SIZE +i*SIZE, M*HEIGHT+D, paint); |
|
338 |
canvas.drawLine( OFF +i*SIZE, M*SIZE +D, OFF2 +i*SIZE, D, paint); |
|
339 |
canvas.drawLine((SIZE-OFF)+i*SIZE, M*SIZE +D, (SIZE-OFF2) +i*SIZE, D, paint); |
|
340 |
|
|
341 |
canvas.drawArc( ARC1_W-RADIUS+i*SIZE, M*(ARC1_H-RADIUS)+D, ARC1_W+RADIUS+i*SIZE, M*(ARC1_H+RADIUS)+D, 225, 90, false, paint); |
|
342 |
canvas.drawArc( ARC2_W-RADIUS+i*SIZE, M*(ARC2_H-RADIUS)+D, ARC2_W+RADIUS+i*SIZE, M*(ARC2_H+RADIUS)+D, 105, 90, false, paint); |
|
343 |
canvas.drawArc( ARC3_W-RADIUS+i*SIZE, M*(ARC2_H-RADIUS)+D, ARC3_W+RADIUS+i*SIZE, M*(ARC2_H+RADIUS)+D, 345, 90, false, paint); |
|
344 |
} |
|
345 |
|
|
346 |
return result; |
|
347 |
} |
|
348 |
|
|
349 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
350 |
|
|
351 |
void createSkewbFaceTexture(Canvas canvas, Paint paint, int[] faceColors, int face, int left, int top, int side) |
|
352 |
{ |
|
353 |
final int COLORS = 6; |
|
354 |
final float SQ2 = (float)Math.sqrt(2); |
|
355 |
|
|
356 |
if( face<COLORS ) |
|
357 |
{ |
|
358 |
float STROKE = 0.035f*side; |
|
359 |
float L= left+0.125f*side; |
|
360 |
float H= 0.375f*side; |
|
361 |
float LEN = 0.5f*side; |
|
362 |
|
|
363 |
paint.setAntiAlias(true); |
|
364 |
paint.setStrokeWidth(STROKE); |
|
365 |
paint.setColor(faceColors[face]); |
|
366 | 250 |
paint.setStyle(Paint.Style.FILL); |
367 |
|
|
368 |
canvas.drawRect(left,top,left+side,top+side,paint); |
|
369 |
|
|
370 |
paint.setColor(0xff000000); |
|
371 |
paint.setStyle(Paint.Style.STROKE); |
|
372 |
|
|
373 |
canvas.drawLine( L , H, L+LEN, H , paint); |
|
374 |
canvas.drawLine( L , H, L+LEN, H+LEN, paint); |
|
375 |
canvas.drawLine( L+LEN, H, L+LEN, H+LEN, paint); |
|
376 |
|
|
377 |
float S1 = 0.125f*side; |
|
378 |
float S2 = 0.070f*side; |
|
379 |
float X = 0.7f*S2; |
|
380 |
|
|
381 |
float LA = left+0.625f*side; |
|
382 |
float RA = left+0.125f*side; |
|
383 |
float TA = 0.375f*side; |
|
384 |
float BA = 0.875f*side; |
|
385 |
|
|
386 |
canvas.drawArc( LA-S1, TA , LA , TA+S1, 270, 90, false, paint); |
|
387 |
canvas.drawArc( RA+X , TA , RA+X+S2, TA+S2, 135,135, false, paint); |
|
388 |
canvas.drawArc( LA-S2, BA-X-S2, LA , BA-X , 0,135, false, paint); |
|
389 |
} |
|
390 |
else |
|
391 |
{ |
|
392 |
final float R = (SQ2/2)*side*0.10f; |
|
393 |
final float M = side*(0.5f-SQ2/4+0.018f); |
|
394 |
|
|
395 |
paint.setColor(faceColors[face-COLORS]); |
|
396 |
paint.setStyle(Paint.Style.FILL); |
|
397 |
canvas.drawRoundRect( left+M, top+M, left+side-M, top+side-M, R, R, paint); |
|
398 |
} |
|
399 |
} |
|
400 |
|
|
401 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
402 |
|
|
403 |
private Bitmap createSkewbTexture(int[] faceColors) |
|
404 |
{ |
|
405 |
final int TEXTURE_HEIGHT = 256; |
|
406 |
final int NUM_TEXTURES = 2*6; |
|
407 |
Bitmap bitmap; |
|
408 |
|
|
409 |
Paint paint = new Paint(); |
|
410 |
bitmap = Bitmap.createBitmap( (NUM_TEXTURES+1)*TEXTURE_HEIGHT, TEXTURE_HEIGHT, Bitmap.Config.ARGB_8888); |
|
411 |
Canvas canvas = new Canvas(bitmap); |
|
412 |
|
|
413 |
paint.setAntiAlias(true); |
|
414 |
paint.setTextAlign(Paint.Align.CENTER); |
|
415 |
paint.setStyle(Paint.Style.FILL); |
|
416 |
|
|
417 |
paint.setColor(0xff000000); |
|
418 |
canvas.drawRect(0, 0, (NUM_TEXTURES+1)*TEXTURE_HEIGHT, TEXTURE_HEIGHT, paint); |
|
419 |
|
|
420 |
for(int i=0; i<NUM_TEXTURES; i++) |
|
421 |
{ |
|
422 |
createSkewbFaceTexture(canvas, paint, faceColors, i, i*TEXTURE_HEIGHT, 0, TEXTURE_HEIGHT); |
|
423 |
} |
|
424 |
|
|
425 |
return bitmap; |
|
426 |
} |
|
427 |
|
|
428 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
429 |
|
|
430 |
void createDinoFaceTexture(Canvas canvas, Paint paint, int[] faceColors, int face, int left, int top, int side) |
|
431 |
{ |
|
432 |
float STROKE = 0.04f*side; |
|
433 |
float L= left; |
|
434 |
float H= 0.333f*side; |
|
435 |
float LEN = 0.5f*side; |
|
436 |
|
|
437 |
paint.setAntiAlias(true); |
|
438 |
paint.setStrokeWidth(STROKE); |
|
439 |
paint.setColor(faceColors[face]); |
|
440 |
paint.setStyle(Paint.Style.FILL); |
|
441 |
|
|
442 |
canvas.drawRect(left,top,left+side,top+side,paint); |
|
443 |
|
|
444 |
paint.setColor(0xff000000); |
|
445 |
paint.setStyle(Paint.Style.STROKE); |
|
446 |
|
|
447 |
canvas.drawLine( L , H, L+2*LEN, H , paint); |
|
448 |
canvas.drawLine( L , H, L+ LEN, H+LEN, paint); |
|
449 |
canvas.drawLine( L+2*LEN, H, L+ LEN, H+LEN, paint); |
|
450 |
|
|
451 |
float S1 = 0.150f*side; |
|
452 |
float S2 = 0.090f*side; |
|
453 |
float X = 0.7f*S2; |
|
454 |
float Y = 0.2f*S1; |
|
455 |
|
|
456 |
float LA = left+0.500f*side; |
|
457 |
float RA = left; |
|
458 |
float TA = 0.333f*side; |
|
459 |
float BA = 0.833f*side; |
|
460 |
|
|
461 |
canvas.drawArc( RA+X , TA , RA+X+S2 , TA+S2, 135,135, false, paint); |
|
462 |
canvas.drawArc( RA+side-S2-X, TA , RA+side-X, TA+S2, 270,135, false, paint); |
|
463 |
canvas.drawArc( LA-S1/2 , BA-S1-Y, LA+S1/2 , BA-Y , 45, 90, false, paint); |
|
464 |
} |
|
465 |
|
|
466 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
467 |
|
|
468 |
private Bitmap createDinoTexture(int[] faceColors) |
|
469 |
{ |
|
470 |
final int TEXTURE_HEIGHT = 256; |
|
471 |
final int NUM_TEXTURES = 6; |
|
472 |
Bitmap bitmap; |
|
473 |
|
|
474 |
Paint paint = new Paint(); |
|
475 |
bitmap = Bitmap.createBitmap( (NUM_TEXTURES+1)*TEXTURE_HEIGHT, TEXTURE_HEIGHT, Bitmap.Config.ARGB_8888); |
|
476 |
Canvas canvas = new Canvas(bitmap); |
|
477 |
|
|
478 |
paint.setAntiAlias(true); |
|
479 |
paint.setTextAlign(Paint.Align.CENTER); |
|
480 |
paint.setStyle(Paint.Style.FILL); |
|
481 |
|
|
482 |
paint.setColor(0xff000000); |
|
483 |
canvas.drawRect(0, 0, (NUM_TEXTURES+1)*TEXTURE_HEIGHT, TEXTURE_HEIGHT, paint); |
|
484 |
|
|
485 |
for(int i=0; i<NUM_TEXTURES; i++) |
|
486 |
{ |
|
487 |
createDinoFaceTexture(canvas, paint, faceColors, i, i*TEXTURE_HEIGHT, 0, TEXTURE_HEIGHT); |
|
488 |
} |
|
251 |
canvas.drawRect(0, 0, SIZE, SIZE, paint); |
|
489 | 252 |
|
490 | 253 |
return bitmap; |
491 | 254 |
} |
... | ... | |
494 | 257 |
|
495 | 258 |
private MeshBase createStaticMesh() |
496 | 259 |
{ |
497 |
final float SQ2 = (float)Math.sqrt(2); |
|
498 |
final float SQ3 = (float)Math.sqrt(3); |
|
499 |
final float ANGLE_FACES = (float)((180/Math.PI)*(Math.atan(SQ2))); |
|
500 |
|
|
501 |
final int MESHES=4; |
|
502 |
|
|
503 |
float D = 0.02f; |
|
504 |
float E = 0.5f*SQ2; |
|
505 |
float F = 0.5f; |
|
506 |
|
|
507 |
float[] bands0 = { 1.0f , 0, |
|
508 |
1.0f-2*D, D*0.25f, |
|
509 |
1.0f-4*D, D*0.35f, |
|
510 |
1.0f-8*D, D*0.6f, |
|
511 |
0.60f , D*1.0f, |
|
512 |
0.30f , D*1.375f, |
|
513 |
0.0f , D*1.4f }; |
|
514 |
|
|
515 |
float[] vertices0 = { -F,F/3, 0,-2*F/3, +F,F/3 }; |
|
516 |
|
|
517 |
MeshBase[] meshes = new MeshPolygon[MESHES]; |
|
518 |
meshes[0] = new MeshPolygon(vertices0, bands0, 2, 5); |
|
519 |
meshes[0].setEffectAssociation(0,1,0); |
|
520 |
meshes[1] = meshes[0].copy(true); |
|
521 |
meshes[1].setEffectAssociation(0,2,0); |
|
522 |
|
|
523 |
float[] bands1 = { 1.0f , 0, |
|
524 |
0.50f , 0, |
|
525 |
0.0f , 0 }; |
|
526 |
|
|
527 |
float[] vertices1 = { -E/2,-E*(SQ3/6), E/2,-E*(SQ3/6), 0,E*(SQ3/3) }; |
|
528 |
|
|
529 |
meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2); |
|
530 |
meshes[2].setEffectAssociation(0,4,0); |
|
531 |
meshes[3] = meshes[2].copy(true); |
|
532 |
meshes[3].setEffectAssociation(0,8,0); |
|
533 |
|
|
534 |
MeshBase result = new MeshJoined(meshes); |
|
535 |
|
|
536 |
Static3D a0 = new Static3D( 0,-3*F, 0 ); |
|
537 |
Static3D a1 = new Static3D( 0, 0, -3*F ); |
|
538 |
Static3D a2 = new Static3D( -3*F, 0, 0 ); |
|
539 |
Static3D a3 = new Static3D( +3*F, 0, 0 ); |
|
540 |
|
|
541 |
Static3D v0 = new Static3D( 0,-3*F/2, 3*F/2 ); |
|
542 |
Static3D v1 = new Static3D( 0, 3*F/2,-3*F/2 ); |
|
543 |
Static3D v2 = new Static3D( -3*F, 3*F/2, 3*F/2 ); |
|
544 |
Static3D v3 = new Static3D( +3*F, 3*F/2, 3*F/2 ); |
|
545 |
|
|
546 |
float d1 = 1.0f; |
|
547 |
float d2 =-0.10f; |
|
548 |
float d3 =-0.10f; |
|
549 |
float d4 = 0.40f; |
|
550 |
|
|
551 |
Static3D dCen0 = new Static3D( d1*a0.get0(), d1*a0.get1(), d1*a0.get2() ); |
|
552 |
Static3D dCen1 = new Static3D( d1*a1.get0(), d1*a1.get1(), d1*a1.get2() ); |
|
553 |
Static3D dCen2 = new Static3D( d1*a2.get0(), d1*a2.get1(), d1*a2.get2() ); |
|
554 |
Static3D dCen3 = new Static3D( d1*a3.get0(), d1*a3.get1(), d1*a3.get2() ); |
|
555 |
|
|
556 |
Static3D dVec0 = new Static3D( d3*v0.get0(), d3*v0.get1(), d3*v0.get2() ); |
|
557 |
Static3D dVec1 = new Static3D( d3*v1.get0(), d3*v1.get1(), d3*v1.get2() ); |
|
558 |
Static3D dVec2 = new Static3D( d2*v2.get0(), d2*v2.get1(), d2*v2.get2() ); |
|
559 |
Static3D dVec3 = new Static3D( d2*v3.get0(), d2*v3.get1(), d2*v3.get2() ); |
|
560 |
|
|
561 |
Static4D dReg = new Static4D(0,0,0,d4); |
|
562 |
Static1D dRad = new Static1D(1); |
|
563 |
|
|
564 |
Static1D angle1 = new Static1D(+ANGLE_FACES); |
|
565 |
Static1D angle2 = new Static1D(-ANGLE_FACES); |
|
566 |
|
|
567 |
Static3D axisX = new Static3D(1,0,0); |
|
568 |
Static3D axisY = new Static3D(0,1,0); |
|
569 |
Static3D axisZ = new Static3D(0,-1,1); |
|
570 |
|
|
571 |
Static3D center0= new Static3D(0,0,0); |
|
572 |
Static3D center1= new Static3D(0,-3*F,0); |
|
573 |
|
|
574 |
VertexEffectScale effect0 = new VertexEffectScale ( new Static3D(3,3,3) ); |
|
575 |
VertexEffectMove effect1 = new VertexEffectMove ( new Static3D(0,-F,0) ); |
|
576 |
VertexEffectRotate effect2 = new VertexEffectRotate( new Static1D(90), axisX, center0 ); |
|
577 |
VertexEffectScale effect3 = new VertexEffectScale ( new Static3D(1,-1,1) ); |
|
578 |
VertexEffectMove effect4 = new VertexEffectMove ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) ); |
|
579 |
VertexEffectRotate effect5 = new VertexEffectRotate( new Static1D(+90), axisY, center1 ); |
|
580 |
VertexEffectScale effect6 = new VertexEffectScale ( new Static3D(-1,1,1) ); |
|
581 |
VertexEffectRotate effect7 = new VertexEffectRotate( new Static1D( 45), axisX, center1 ); |
|
582 |
VertexEffectRotate effect8 = new VertexEffectRotate( angle1 , axisZ, center1 ); |
|
583 |
VertexEffectRotate effect9 = new VertexEffectRotate( angle2 , axisZ, center1 ); |
|
584 |
|
|
585 |
VertexEffectDeform effect10= new VertexEffectDeform(dVec0, dRad, dCen0, dReg); |
|
586 |
VertexEffectDeform effect11= new VertexEffectDeform(dVec1, dRad, dCen1, dReg); |
|
587 |
VertexEffectDeform effect12= new VertexEffectDeform(dVec2, dRad, dCen2, dReg); |
|
588 |
VertexEffectDeform effect13= new VertexEffectDeform(dVec3, dRad, dCen3, dReg); |
|
589 |
|
|
590 |
effect0.setMeshAssociation(15,-1); // apply to meshes 0,1,2,3 |
|
591 |
effect1.setMeshAssociation( 3,-1); // apply to meshes 0,1 |
|
592 |
effect2.setMeshAssociation( 2,-1); // apply to mesh 1 |
|
593 |
effect3.setMeshAssociation( 2,-1); // apply to mesh 0 |
|
594 |
effect4.setMeshAssociation(12,-1); // apply to meshes 2,3 |
|
595 |
effect5.setMeshAssociation(12,-1); // apply to meshes 2,3 |
|
596 |
effect6.setMeshAssociation( 8,-1); // apply to mesh 3 |
|
597 |
effect7.setMeshAssociation(12,-1); // apply to meshes 2,3 |
|
598 |
effect8.setMeshAssociation( 4,-1); // apply to mesh 2 |
|
599 |
effect9.setMeshAssociation( 8,-1); // apply to mesh 3 |
|
600 |
effect10.setMeshAssociation(15,-1); // apply to meshes 0,1,2,3 |
|
601 |
effect11.setMeshAssociation(15,-1); // apply to meshes 0,1,2,3 |
|
602 |
effect12.setMeshAssociation(15,-1); // apply to meshes 0,1,2,3 |
|
603 |
effect13.setMeshAssociation(15,-1); // apply to meshes 0,1,2,3 |
|
604 |
|
|
605 |
result.apply(effect0); |
|
606 |
result.apply(effect1); |
|
607 |
result.apply(effect2); |
|
608 |
result.apply(effect3); |
|
609 |
result.apply(effect4); |
|
610 |
result.apply(effect5); |
|
611 |
result.apply(effect6); |
|
612 |
result.apply(effect7); |
|
613 |
result.apply(effect8); |
|
614 |
result.apply(effect9); |
|
615 |
result.apply(effect10); |
|
616 |
result.apply(effect11); |
|
617 |
result.apply(effect12); |
|
618 |
result.apply(effect13); |
|
619 |
|
|
620 |
return result; |
|
260 |
CubitFactory factory = CubitFactory.getInstance(); |
|
261 |
return factory.createSkewbFaceMesh(); |
|
621 | 262 |
} |
622 | 263 |
|
623 | 264 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Some improvements to MeshFile.