Project

General

Profile

Download (38.9 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / objects / CubitFactory.java @ 8d3cfe99

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube 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
// Magic Cube 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 Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.objects;
21

    
22
import org.distorted.library.effect.VertexEffect;
23
import org.distorted.library.effect.VertexEffectDeform;
24
import org.distorted.library.effect.VertexEffectMove;
25
import org.distorted.library.effect.VertexEffectRotate;
26
import org.distorted.library.effect.VertexEffectScale;
27
import org.distorted.library.mesh.MeshBase;
28
import org.distorted.library.mesh.MeshJoined;
29
import org.distorted.library.mesh.MeshPolygon;
30
import org.distorted.library.mesh.MeshTriangle;
31
import org.distorted.library.type.Static1D;
32
import org.distorted.library.type.Static3D;
33
import org.distorted.library.type.Static4D;
34

    
35
///////////////////////////////////////////////////////////////////////////////////////////////////
36

    
37
public class CubitFactory
38
  {
39
  private static final float SQ2 = (float)Math.sqrt(2);
40
  private static final float SQ3 = (float)Math.sqrt(3);
41
  private static final float SQ6 = (float)Math.sqrt(6);
42

    
43
  private static final Static1D RADIUS = new Static1D(1);
44

    
45
  private static CubitFactory mThis;
46

    
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48

    
49
  private CubitFactory()
50
    {
51

    
52
    }
53

    
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55

    
56
  public static CubitFactory getInstance()
57
    {
58
    if( mThis==null ) mThis = new CubitFactory();
59

    
60
    return mThis;
61
    }
62

    
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64

    
65
  private void roundCorners(MeshBase mesh, Static3D center, Static3D[] vertices, float strength, float regionRadius)
66
    {
67
    Static4D reg= new Static4D(0,0,0,regionRadius);
68

    
69
    float centX = center.get0();
70
    float centY = center.get1();
71
    float centZ = center.get2();
72

    
73
    for (Static3D vertex : vertices)
74
      {
75
      float x = strength*(centX - vertex.get0());
76
      float y = strength*(centY - vertex.get1());
77
      float z = strength*(centZ - vertex.get2());
78

    
79
      VertexEffect effect = new VertexEffectDeform(new Static3D(x,y,z), RADIUS, vertex, reg);
80
      mesh.apply(effect);
81
      }
82
    }
83

    
84
///////////////////////////////////////////////////////////////////////////////////////////////////
85
// CUBE
86

    
87
  MeshBase createCubeMesh(int index)
88
    {
89
    final int MESHES=6;
90
    MeshBase[] meshes = new MeshPolygon[MESHES];
91
    int association = 1;
92

    
93
    float[] bands;
94
    float D = 0.027f;
95
    float E = 0.5f-D;
96
    float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E };
97
    int extraI, extraV;
98

    
99
    switch(index)
100
      {
101
      case 0 : bands = new float[] { 1.0f    ,-D,
102
                                     1.0f-D/2,-D*0.55f,
103
                                     1.0f-D  ,-D*0.25f,
104
                                     1.0f-2*D, 0.0f,
105
                                     0.50f, 0.040f,
106
                                     0.0f, 0.048f };
107
               extraI = 2;
108
               extraV = 2;
109
               break;
110
      case 1 : bands = new float[] { 1.0f    ,-D,
111
                                     1.0f-D*1.2f,-D*0.55f,
112
                                     1.0f-2*D, 0.0f,
113
                                     0.50f, 0.040f,
114
                                     0.0f, 0.048f };
115
               extraI = 2;
116
               extraV = 2;
117
               break;
118
      case 2 : bands = new float[] { 1.0f    ,-D,
119
                                     1.0f-D*1.2f,-D*0.55f,
120
                                     1.0f-2*D, 0.0f,
121
                                     0.50f, 0.040f,
122
                                     0.0f, 0.048f };
123
               extraI = 1;
124
               extraV = 2;
125
               break;
126
      default: bands = new float[] { 1.0f    ,-D,
127
                                     1.0f-2*D, 0.0f,
128
                                     0.50f, 0.025f,
129
                                     0.0f, 0.030f };
130
               extraI = 1;
131
               extraV = 1;
132
               break;
133
      }
134

    
135
    meshes[0] = new MeshPolygon(vertices,bands,extraI,extraV);
136
    meshes[0].setEffectAssociation(0,association,0);
137

    
138
    for(int i=1; i<MESHES; i++)
139
      {
140
      association <<=1;
141
      meshes[i] = meshes[0].copy(true);
142
      meshes[i].setEffectAssociation(0,association,0);
143
      }
144

    
145
    MeshBase mesh = new MeshJoined(meshes);
146

    
147
    Static3D axisY   = new Static3D(0,1,0);
148
    Static3D axisX   = new Static3D(1,0,0);
149
    Static3D center  = new Static3D(0,0,0);
150
    Static1D angle90 = new Static1D(90);
151
    Static1D angle180= new Static1D(180);
152
    Static1D angle270= new Static1D(270);
153

    
154
    VertexEffect effect0 = new VertexEffectMove(new Static3D(0,0,+0.5f));
155
    VertexEffect effect1 = new VertexEffectRotate( angle180, axisX, center );
156
    VertexEffect effect2 = new VertexEffectRotate( angle90 , axisX, center );
157
    VertexEffect effect3 = new VertexEffectRotate( angle270, axisX, center );
158
    VertexEffect effect4 = new VertexEffectRotate( angle270, axisY, center );
159
    VertexEffect effect5 = new VertexEffectRotate( angle90 , axisY, center );
160

    
161
    effect0.setMeshAssociation(63,-1);  // all 6 sides
162
    effect1.setMeshAssociation(32,-1);  // back
163
    effect2.setMeshAssociation( 8,-1);  // bottom
164
    effect3.setMeshAssociation( 4,-1);  // top
165
    effect4.setMeshAssociation( 2,-1);  // left
166
    effect5.setMeshAssociation( 1,-1);  // right
167

    
168
    mesh.apply(effect0);
169
    mesh.apply(effect1);
170
    mesh.apply(effect2);
171
    mesh.apply(effect3);
172
    mesh.apply(effect4);
173
    mesh.apply(effect5);
174

    
175
    Static3D[] verticesCubit = new Static3D[8];
176
    verticesCubit[0] = new Static3D(+0.5f,+0.5f,+0.5f);
177
    verticesCubit[1] = new Static3D(+0.5f,+0.5f,-0.5f);
178
    verticesCubit[2] = new Static3D(+0.5f,-0.5f,+0.5f);
179
    verticesCubit[3] = new Static3D(+0.5f,-0.5f,-0.5f);
180
    verticesCubit[4] = new Static3D(-0.5f,+0.5f,+0.5f);
181
    verticesCubit[5] = new Static3D(-0.5f,+0.5f,-0.5f);
182
    verticesCubit[6] = new Static3D(-0.5f,-0.5f,+0.5f);
183
    verticesCubit[7] = new Static3D(-0.5f,-0.5f,-0.5f);
184

    
185
    roundCorners(mesh,center,verticesCubit,0.06f,0.12f);
186

    
187
    mesh.mergeEffComponents();
188

    
189
    return mesh;
190
    }
191

    
192
///////////////////////////////////////////////////////////////////////////////////////////////////
193
// SKEWB
194

    
195
  MeshBase createSkewbCornerMesh()
196
    {
197
    float D = 0.02f;
198
    float E = 0.5f;
199
    float F = SQ2/2;
200

    
201
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
202

    
203
    float[] bands0 = { 1.0f    , 0,
204
                       1.0f-2*D, D*0.25f,
205
                       1.0f-4*D, D*0.35f,
206
                       1.0f-8*D, D*0.6f,
207
                       0.60f   , D*1.0f,
208
                       0.30f   , D*1.375f,
209
                       0.0f    , D*1.4f };
210

    
211
    MeshBase[] meshes = new MeshBase[6];
212

    
213
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
214
    meshes[0].setEffectAssociation(0,1,0);
215
    meshes[1] = meshes[0].copy(true);
216
    meshes[1].setEffectAssociation(0,2,0);
217
    meshes[2] = meshes[0].copy(true);
218
    meshes[2].setEffectAssociation(0,4,0);
219

    
220
    float[] vertices1 = { 0,0, F,0, F/2,(SQ3/2)*F };
221
    float[] bands1 = { 1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f };
222

    
223
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
224
    meshes[3].setEffectAssociation(0,8,0);
225
    meshes[4] = meshes[3].copy(true);
226
    meshes[4].setEffectAssociation(0,16,0);
227
    meshes[5] = meshes[3].copy(true);
228
    meshes[5].setEffectAssociation(0,32,0);
229

    
230
    MeshBase mesh = new MeshJoined(meshes);
231

    
232
    Static3D axisX  = new Static3D(1,0,0);
233
    Static3D axisY  = new Static3D(0,1,0);
234
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
235
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
236
    Static1D angle1 = new Static1D(+90);
237
    Static1D angle2 = new Static1D(-90);
238
    Static1D angle3 = new Static1D(-15);
239
    Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
240
    Static1D angle5 = new Static1D(120);
241
    Static1D angle6 = new Static1D(240);
242
    Static3D center1= new Static3D(0,0,0);
243
    Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
244
    Static3D move1  = new Static3D(-E/4,-E/4,0);
245
    Static3D move2  = new Static3D(-0.5f,-0.5f,-0.5f);
246

    
247
    VertexEffect effect0 = new VertexEffectMove(move1);
248
    VertexEffect effect1 = new VertexEffectScale(new Static3D(1,1,-1));
249
    VertexEffect effect2 = new VertexEffectRotate(angle1,axisX,center1);
250
    VertexEffect effect3 = new VertexEffectRotate(angle2,axisY,center1);
251
    VertexEffect effect4 = new VertexEffectMove(move2);
252
    VertexEffect effect5 = new VertexEffectRotate(angle1,axisX,center2);
253
    VertexEffect effect6 = new VertexEffectRotate(angle3,axisY,center2);
254
    VertexEffect effect7 = new VertexEffectRotate(angle4,axis0,center2);
255
    VertexEffect effect8 = new VertexEffectRotate(angle5,axis1,center2);
256
    VertexEffect effect9 = new VertexEffectRotate(angle6,axis1,center2);
257

    
258
    effect0.setMeshAssociation( 7,-1);  // meshes 0,1,2
259
    effect1.setMeshAssociation( 6,-1);  // meshes 1,2
260
    effect2.setMeshAssociation( 2,-1);  // mesh 1
261
    effect3.setMeshAssociation( 4,-1);  // mesh 2
262
    effect4.setMeshAssociation(56,-1);  // meshes 3,4,5
263
    effect5.setMeshAssociation(56,-1);  // meshes 3,4,5
264
    effect6.setMeshAssociation(56,-1);  // meshes 3,4,5
265
    effect7.setMeshAssociation(56,-1);  // meshes 3,4,5
266
    effect8.setMeshAssociation(16,-1);  // mesh 4
267
    effect9.setMeshAssociation(32,-1);  // mesh 5
268

    
269
    mesh.apply(effect0);
270
    mesh.apply(effect1);
271
    mesh.apply(effect2);
272
    mesh.apply(effect3);
273
    mesh.apply(effect4);
274
    mesh.apply(effect5);
275
    mesh.apply(effect6);
276
    mesh.apply(effect7);
277
    mesh.apply(effect8);
278
    mesh.apply(effect9);
279

    
280
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
281

    
282
    Static3D[] verticesType1 = new Static3D[1];
283
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
284
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
285

    
286
    Static3D[] verticesType2 = new Static3D[3];
287
    verticesType2[0] = new Static3D(-E, 0, 0);
288
    verticesType2[1] = new Static3D( 0,-E, 0);
289
    verticesType2[2] = new Static3D( 0, 0,-E);
290
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
291

    
292
    mesh.mergeEffComponents();
293

    
294
    return mesh;
295
    }
296

    
297
///////////////////////////////////////////////////////////////////////////////////////////////////
298

    
299
  MeshBase createSkewbFaceMesh()
300
    {
301
    float D = 0.03f;
302
    float E = SQ2/4;
303
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
304

    
305
    float[] bands0 = { 1.0f    , 0,
306
                       1.0f-D/2, D*0.30f,
307
                       1.0f- D , D*0.50f,
308
                       1.0f-2*D, D*0.80f,
309
                       0.60f   , D*1.40f,
310
                       0.30f   , D*1.60f,
311
                       0.0f    , D*1.70f };
312

    
313
    MeshBase[] meshes = new MeshBase[5];
314
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
315
    meshes[0].setEffectAssociation(0,1,0);
316

    
317
    float[] vertices1 = { -E,-SQ3*E, +E,-SQ3*E, 0,0 };
318
    float[] bands1 = { 1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f };
319

    
320
    meshes[1] = new MeshPolygon(vertices1,bands1,0,0);
321
    meshes[1].setEffectAssociation(0,2,0);
322
    meshes[2] = meshes[1].copy(true);
323
    meshes[2].setEffectAssociation(0,4,0);
324
    meshes[3] = meshes[1].copy(true);
325
    meshes[3].setEffectAssociation(0,8,0);
326
    meshes[4] = meshes[1].copy(true);
327
    meshes[4].setEffectAssociation(0,16,0);
328

    
329
    MeshBase mesh = new MeshJoined(meshes);
330

    
331
    Static3D center = new Static3D(0,0,0);
332
    Static3D axisX  = new Static3D(1,0,0);
333
    Static3D axisZ  = new Static3D(0,0,1);
334
    float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
335

    
336
    VertexEffect effect0 = new VertexEffectRotate( new Static1D(angle), axisX, center);
337
    VertexEffect effect1 = new VertexEffectRotate( new Static1D(  135), axisZ, center);
338
    VertexEffect effect2 = new VertexEffectRotate( new Static1D(   45), axisZ, center);
339
    VertexEffect effect3 = new VertexEffectRotate( new Static1D(  -45), axisZ, center);
340
    VertexEffect effect4 = new VertexEffectRotate( new Static1D( -135), axisZ, center);
341
    VertexEffect effect5 = new VertexEffectMove( new Static3D(0,0,-0.5f) );
342

    
343
    effect0.setMeshAssociation(30,-1);  // meshes 1,2,3,4
344
    effect1.setMeshAssociation( 2,-1);  // mesh 1
345
    effect2.setMeshAssociation( 5,-1);  // meshes 0,2
346
    effect3.setMeshAssociation( 8,-1);  // mesh 3
347
    effect4.setMeshAssociation(16,-1);  // mesh 4
348
    effect5.setMeshAssociation(30,-1);  // meshes 1,2,3,4
349

    
350
    mesh.apply(effect0);
351
    mesh.apply(effect1);
352
    mesh.apply(effect2);
353
    mesh.apply(effect3);
354
    mesh.apply(effect4);
355
    mesh.apply(effect5);
356

    
357
    Static3D roundingCenter = new Static3D(0,0,-0.2f);
358

    
359
    Static3D[] vertices = new Static3D[4];
360
    vertices[0] = new Static3D(-E*SQ2,      0, 0);
361
    vertices[1] = new Static3D(+E*SQ2,      0, 0);
362
    vertices[2] = new Static3D(     0, -E*SQ2, 0);
363
    vertices[3] = new Static3D(     0, +E*SQ2, 0);
364
    roundCorners(mesh,roundingCenter,vertices,0.10f,0.10f);
365

    
366
    mesh.mergeEffComponents();
367
    mesh.addEmptyTexComponent();
368

    
369
    return mesh;
370
    }
371

    
372
///////////////////////////////////////////////////////////////////////////////////////////////////
373
// SKEWB DIAMOND / PYRAMINX
374

    
375
  MeshBase createOctaMesh()
376
    {
377
    int association = 1;
378

    
379
    float C = 0.06f;
380
    float D = 0.031f;
381
    float E = SQ3/2;
382
    float F = 0.5f;
383

    
384
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
385

    
386
    float[] bands = new float[] { 1.0f    , 0,
387
                                  1.0f  -C, D*0.55f,
388
                                  1.0f-2*C, D*0.85f,
389
                                  1.0f-4*C, D*1.20f,
390
                                  0.5f    , D*1.40f,
391
                                  0.0f    , D*1.50f };
392

    
393
    MeshBase[] meshes = new MeshPolygon[8];
394
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
395
    meshes[0].setEffectAssociation(0,association,0);
396

    
397
    for(int i=1; i<8; i++)
398
      {
399
      association <<= 1;
400
      meshes[i] = meshes[0].copy(true);
401
      meshes[i].setEffectAssociation(0,association,0);
402
      }
403

    
404
    MeshBase mesh = new MeshJoined(meshes);
405

    
406
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
407
    Static1D angle1= new Static1D( 90);
408
    Static1D angle2= new Static1D(180);
409
    Static1D angle3= new Static1D(270);
410

    
411
    Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
412

    
413
    Static3D axisX = new Static3D(1,0,0);
414
    Static3D axisY = new Static3D(0,1,0);
415

    
416
    Static3D cent0 = new Static3D(0,0,0);
417
    Static3D cent1 = new Static3D(0,SQ2/2,0);
418

    
419
    Static3D flipY = new Static3D( 1,-1, 1);
420

    
421
    VertexEffect effect0 = new VertexEffectMove(move1);
422
    VertexEffect effect1 = new VertexEffectRotate(alpha , axisX, cent1);
423
    VertexEffect effect2 = new VertexEffectRotate(angle1, axisY, cent0);
424
    VertexEffect effect3 = new VertexEffectRotate(angle2, axisY, cent0);
425
    VertexEffect effect4 = new VertexEffectRotate(angle3, axisY, cent0);
426
    VertexEffect effect5 = new VertexEffectScale(flipY);
427

    
428
    effect2.setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
429
    effect3.setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
430
    effect4.setMeshAssociation (136,-1); // apply to meshes 3 & 7
431
    effect5.setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
432

    
433
    mesh.apply(effect0);
434
    mesh.apply(effect1);
435
    mesh.apply(effect2);
436
    mesh.apply(effect3);
437
    mesh.apply(effect4);
438
    mesh.apply(effect5);
439

    
440
    Static3D[] verticesRound = new Static3D[6];
441
    verticesRound[0] = new Static3D(    0, SQ2/2,    0 );
442
    verticesRound[1] = new Static3D( 0.5f,     0, 0.5f );
443
    verticesRound[2] = new Static3D(-0.5f,     0, 0.5f );
444
    verticesRound[3] = new Static3D(    0,-SQ2/2,    0 );
445
    verticesRound[4] = new Static3D(-0.5f,     0,-0.5f );
446
    verticesRound[5] = new Static3D( 0.5f,     0,-0.5f );
447

    
448
    roundCorners(mesh,cent0,verticesRound,0.06f,0.20f);
449

    
450
    mesh.mergeEffComponents();
451

    
452
    return mesh;
453
    }
454

    
455
///////////////////////////////////////////////////////////////////////////////////////////////////
456

    
457
  MeshBase createTetraMesh()
458
    {
459
    MeshBase[] meshes = new MeshBase[4];
460
    int association = 1;
461

    
462
    float C = 0.06f;
463
    float D = 0.035f;
464
    float E = SQ3/2;
465
    float F = 0.5f;
466

    
467
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
468

    
469
    float[] bands = new float[] { 1.0f    , 0,
470
                                  1.0f  -C, D*0.50f,
471
                                  1.0f-2*C, D*0.80f,
472
                                  1.0f-4*C, D*1.10f,
473
                                  0.5f    , D*1.30f,
474
                                  0.0f    , D*1.35f };
475

    
476
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
477
    meshes[0].setEffectAssociation(0,association,0);
478

    
479
    for(int i=1; i<4; i++)
480
      {
481
      association <<= 1;
482
      meshes[i] = meshes[0].copy(true);
483
      meshes[i].setEffectAssociation(0,association,0);
484
      }
485

    
486
    MeshBase mesh = new MeshJoined(meshes);
487

    
488
    Static3D flipZ = new Static3D( 1, 1,-1);
489

    
490
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
491
    Static1D angle1= new Static1D( 90);
492
    Static1D angle2= new Static1D(180);
493
    Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
494

    
495
    Static3D axisX = new Static3D(1,0,0);
496
    Static3D axisY = new Static3D(0,1,0);
497
    Static3D axisZ = new Static3D(0,0,1);
498

    
499
    Static3D cent0 = new Static3D(0,0,0);
500
    Static3D cent1 = new Static3D(0,SQ2/4,0);
501

    
502
    VertexEffect effect0 = new VertexEffectRotate(angle2, axisZ, cent0);
503
    VertexEffect effect1 = new VertexEffectMove(move1);
504
    VertexEffect effect2 = new VertexEffectRotate(alpha , axisX, cent1);
505
    VertexEffect effect3 = new VertexEffectScale(flipZ);
506
    VertexEffect effect4 = new VertexEffectRotate(angle1, axisY, cent0);
507
    VertexEffect effect5 = new VertexEffectRotate(angle2, axisZ, cent0);
508

    
509
    effect0.setMeshAssociation(15,-1); // meshes 0,1,2,3
510
    effect1.setMeshAssociation(15,-1); // meshes 0,1,2,3
511
    effect2.setMeshAssociation(15,-1); // meshes 0,1,2,3
512
    effect3.setMeshAssociation(10,-1); // meshes 1 & 3
513
    effect4.setMeshAssociation(12,-1); // meshes 2 & 3
514
    effect5.setMeshAssociation(12,-1); // meshes 2 & 3
515

    
516
    mesh.apply(effect0);
517
    mesh.apply(effect1);
518
    mesh.apply(effect2);
519
    mesh.apply(effect3);
520
    mesh.apply(effect4);
521
    mesh.apply(effect5);
522

    
523
    Static3D[] verticesRound = new Static3D[4];
524
    verticesRound[0] = new Static3D(-0.5f,+SQ2/4,   0 );
525
    verticesRound[1] = new Static3D(+0.5f,+SQ2/4,   0 );
526
    verticesRound[2] = new Static3D(    0,-SQ2/4,+0.5f);
527
    verticesRound[3] = new Static3D(    0,-SQ2/4,-0.5f);
528
    roundCorners(mesh,cent0,verticesRound,0.08f,0.15f);
529

    
530
    mesh.mergeEffComponents();
531
    mesh.addEmptyTexComponent();
532
    mesh.addEmptyTexComponent();
533
    mesh.addEmptyTexComponent();
534
    mesh.addEmptyTexComponent();
535

    
536
    return mesh;
537
    }
538

    
539
///////////////////////////////////////////////////////////////////////////////////////////////////
540
// DINO
541

    
542
  MeshBase createDinoMesh()
543
    {
544
    final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
545

    
546
    final int MESHES=4;
547

    
548
    float D = 0.02f;
549
    float E = 0.5f*SQ2;
550
    float F = 0.5f;
551

    
552
    float[] bands0 = { 1.0f    , 0,
553
                       1.0f-2*D, D*0.25f,
554
                       1.0f-4*D, D*0.35f,
555
                       1.0f-8*D, D*0.6f,
556
                       0.60f   , D*1.0f,
557
                       0.30f   , D*1.375f,
558
                       0.0f    , D*1.4f };
559

    
560
    float[] vertices0 = { -F,F/3, 0,-2*F/3, +F,F/3 };
561

    
562
    MeshBase[] meshes = new MeshPolygon[MESHES];
563
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 5);
564
    meshes[0].setEffectAssociation(0,1,0);
565
    meshes[1] = meshes[0].copy(true);
566
    meshes[1].setEffectAssociation(0,2,0);
567

    
568
    float[] bands1 = { 1.0f    , 0,
569
                       0.50f   , 0.10f,
570
                       0.0f    , 0.20f };
571

    
572
    float[] vertices1 = { -E/2,-E*(SQ3/6), E/2,-E*(SQ3/6), 0,E*(SQ3/3) };
573

    
574
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
575
    meshes[2].setEffectAssociation(0,4,0);
576
    meshes[3] = meshes[2].copy(true);
577
    meshes[3].setEffectAssociation(0,8,0);
578

    
579
    MeshBase mesh = new MeshJoined(meshes);
580

    
581
    Static1D angle1 = new Static1D(+ANGLE);
582
    Static1D angle2 = new Static1D(-ANGLE);
583

    
584
    Static3D axisX  = new Static3D(1,0,0);
585
    Static3D axisY  = new Static3D(0,1,0);
586
    Static3D axisZ  = new Static3D(0,-1,1);
587

    
588
    Static3D center0= new Static3D(0,0,0);
589
    Static3D center1= new Static3D(0,-3*F,0);
590

    
591
    VertexEffect effect0 = new VertexEffectScale ( new Static3D(3,3,3) );
592
    VertexEffect effect1 = new VertexEffectMove  ( new Static3D(0,-F,0) );
593
    VertexEffect effect2 = new VertexEffectRotate( new Static1D(90), axisX, center0 );
594
    VertexEffect effect3 = new VertexEffectScale ( new Static3D(1,-1,1) );
595
    VertexEffect effect4 = new VertexEffectMove  ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
596
    VertexEffect effect5 = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
597
    VertexEffect effect6 = new VertexEffectScale ( new Static3D(-1,1,1) );
598
    VertexEffect effect7 = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
599
    VertexEffect effect8 = new VertexEffectRotate( angle1           , axisZ, center1 );
600
    VertexEffect effect9 = new VertexEffectRotate( angle2           , axisZ, center1 );
601

    
602
    effect0.setMeshAssociation(15,-1);  // apply to meshes 0,1,2,3
603
    effect1.setMeshAssociation( 3,-1);  // apply to meshes 0,1
604
    effect2.setMeshAssociation( 2,-1);  // apply to mesh 1
605
    effect3.setMeshAssociation( 2,-1);  // apply to mesh 0
606
    effect4.setMeshAssociation(12,-1);  // apply to meshes 2,3
607
    effect5.setMeshAssociation(12,-1);  // apply to meshes 2,3
608
    effect6.setMeshAssociation( 8,-1);  // apply to mesh 3
609
    effect7.setMeshAssociation(12,-1);  // apply to meshes 2,3
610
    effect8.setMeshAssociation( 4,-1);  // apply to mesh 2
611
    effect9.setMeshAssociation( 8,-1);  // apply to mesh 3
612

    
613
    mesh.apply(effect0);
614
    mesh.apply(effect1);
615
    mesh.apply(effect2);
616
    mesh.apply(effect3);
617
    mesh.apply(effect4);
618
    mesh.apply(effect5);
619
    mesh.apply(effect6);
620
    mesh.apply(effect7);
621
    mesh.apply(effect8);
622
    mesh.apply(effect9);
623

    
624
    Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
625

    
626
    Static3D[] verticesRound = new Static3D[4];
627
    verticesRound[0] = new Static3D(     0,-3*F,    0 );
628
    verticesRound[1] = new Static3D(     0,   0, -3*F );
629
    verticesRound[2] = new Static3D(  -3*F,   0,    0 );
630
    verticesRound[3] = new Static3D(  +3*F,   0,    0 );
631
    roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
632

    
633
    mesh.mergeEffComponents();
634

    
635
    return mesh;
636
    }
637

    
638
///////////////////////////////////////////////////////////////////////////////////////////////////
639
// Helicopter
640

    
641
  MeshBase createHelicopterCornerMesh()
642
    {
643
    float D = 0.02f;
644
    float E = 0.5f;
645
    float F = SQ2/4;
646

    
647
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
648

    
649
    float[] bands0 = { 1.0f    , 0,
650
                       1.0f-2*D, D*0.25f,
651
                       1.0f-4*D, D*0.35f,
652
                       1.0f-8*D, D*0.6f,
653
                       0.60f   , D*1.0f,
654
                       0.30f   , D*1.375f,
655
                       0.0f    , D*1.4f };
656

    
657
    MeshBase[] meshes = new MeshBase[6];
658

    
659
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
660
    meshes[0].setEffectAssociation(0,1,0);
661
    meshes[1] = meshes[0].copy(true);
662
    meshes[1].setEffectAssociation(0,2,0);
663
    meshes[2] = meshes[0].copy(true);
664
    meshes[2].setEffectAssociation(0,4,0);
665

    
666
    float[] vertices1 = { -F,-1.0f/12, +F,-1.0f/12, 0,1.0f/6 };
667
    float[] bands1 = { 1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f };
668

    
669
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
670
    meshes[3].setEffectAssociation(0,8,0);
671
    meshes[4] = meshes[3].copy(true);
672
    meshes[4].setEffectAssociation(0,16,0);
673
    meshes[5] = meshes[3].copy(true);
674
    meshes[5].setEffectAssociation(0,32,0);
675

    
676
    MeshBase mesh = new MeshJoined(meshes);
677

    
678
    Static3D axisX  = new Static3D(1,0,0);
679
    Static3D axisY  = new Static3D(0,1,0);
680
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
681
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
682
    Static1D angle1 = new Static1D(+90);
683
    Static1D angle2 = new Static1D(-90);
684
    Static1D angle3 = new Static1D(-135);
685
    Static1D angle4 = new Static1D(90);
686
    Static1D angle5 = new Static1D(120);
687
    Static1D angle6 = new Static1D(240);
688
    Static3D center1= new Static3D(0,0,0);
689
    Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
690
    Static3D move1  = new Static3D(-E/4,-E/4,0);
691
    Static3D move2  = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
692

    
693
    VertexEffect effect0 = new VertexEffectMove(move1);
694
    VertexEffect effect1 = new VertexEffectScale(new Static3D(1,1,-1));
695
    VertexEffect effect2 = new VertexEffectRotate(angle1,axisX,center1);
696
    VertexEffect effect3 = new VertexEffectRotate(angle2,axisY,center1);
697
    VertexEffect effect4 = new VertexEffectMove(move2);
698
    VertexEffect effect5 = new VertexEffectRotate(angle1,axisX,center2);
699
    VertexEffect effect6 = new VertexEffectRotate(angle3,axisY,center2);
700
    VertexEffect effect7 = new VertexEffectRotate(angle4,axis0,center2);
701
    VertexEffect effect8 = new VertexEffectRotate(angle5,axis1,center2);
702
    VertexEffect effect9 = new VertexEffectRotate(angle6,axis1,center2);
703

    
704
    effect0.setMeshAssociation( 7,-1);  // meshes 0,1,2
705
    effect1.setMeshAssociation( 6,-1);  // meshes 1,2
706
    effect2.setMeshAssociation( 2,-1);  // mesh 1
707
    effect3.setMeshAssociation( 4,-1);  // mesh 2
708
    effect4.setMeshAssociation(56,-1);  // meshes 3,4,5
709
    effect5.setMeshAssociation(56,-1);  // meshes 3,4,5
710
    effect6.setMeshAssociation(56,-1);  // meshes 3,4,5
711
    effect7.setMeshAssociation(56,-1);  // meshes 3,4,5
712
    effect8.setMeshAssociation(16,-1);  // mesh 4
713
    effect9.setMeshAssociation(32,-1);  // mesh 5
714

    
715
    mesh.apply(effect0);
716
    mesh.apply(effect1);
717
    mesh.apply(effect2);
718
    mesh.apply(effect3);
719
    mesh.apply(effect4);
720
    mesh.apply(effect5);
721
    mesh.apply(effect6);
722
    mesh.apply(effect7);
723
    mesh.apply(effect8);
724
    mesh.apply(effect9);
725

    
726
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
727

    
728
    Static3D[] verticesType1 = new Static3D[1];
729
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
730
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
731

    
732
    Static3D[] verticesType2 = new Static3D[3];
733
    verticesType2[0] = new Static3D(-E, 0, 0);
734
    verticesType2[1] = new Static3D( 0,-E, 0);
735
    verticesType2[2] = new Static3D( 0, 0,-E);
736
    roundCorners(mesh,roundingCenter,verticesType2,0.10f,0.20f);
737

    
738
    mesh.mergeEffComponents();
739

    
740
    return mesh;
741
    }
742

    
743
///////////////////////////////////////////////////////////////////////////////////////////////////
744

    
745
  MeshBase createHelicopterFaceMesh()
746
    {
747
    MeshBase[] meshes = new MeshBase[4];
748

    
749
    float D = 0.02f;
750
    float E = 0.5f;
751
    float F = SQ2/4;
752
    float G = 1.0f/12;
753

    
754
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
755

    
756
    float[] bands0 = { 1.0f    , 0,
757
                       1.0f-2*D, D*0.25f,
758
                       1.0f-4*D, D*0.35f,
759
                       1.0f-8*D, D*0.6f,
760
                       0.60f   , D*1.0f,
761
                       0.30f   , D*1.375f,
762
                       0.0f    , D*1.4f };
763

    
764
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
765
    meshes[0].setEffectAssociation(0,1,0);
766

    
767
    float[] vertices1 = { -F,-G, +F,-G, 0,2*G};
768

    
769
    float[] bands1 = { 1.0f   , 0.0f,
770
                       0.5f   , 0.01f,
771
                       0.0f   , 0.01f };
772

    
773
    meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3);
774
    meshes[1].setEffectAssociation(0,2,0);
775

    
776
    float[] vertices2 = { -E/2,-F/3, +E/2,-F/3, 0,2*F/3};
777

    
778
    float[] bands2 = { 1.0f   , 0.0f,
779
                       0.5f   , 0.01f,
780
                       0.0f   , 0.01f };
781

    
782
    meshes[2] = new MeshPolygon(vertices2, bands2, 1, 3);
783
    meshes[2].setEffectAssociation(0,4,0);
784
    meshes[3] = meshes[2].copy(true);
785
    meshes[3].setEffectAssociation(0,8,0);
786

    
787
    MeshBase mesh = new MeshJoined(meshes);
788

    
789
    Static3D move0  = new Static3D(-E/4, -E/4, 0);
790
    Static3D move1  = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
791
    Static3D move2  = new Static3D(-E/2, F/3, 0);
792
    Static3D move3  = new Static3D(+E/2, F/3, 0);
793
    Static3D move4  = new Static3D(+E/3,+E/3, 0);
794
    Static1D angle1 = new Static1D(135);
795
    Static1D angle2 = new Static1D(90);
796
    Static1D angle3 = new Static1D(-90);
797
    Static1D angle4 = new Static1D(-135);
798
    Static3D axisX  = new Static3D(1,0,0);
799
    Static3D axisY  = new Static3D(0,1,0);
800
    Static3D axisZ  = new Static3D(0,0,1);
801
    Static3D axis1  = new Static3D(1,-1,0);
802
    Static3D center = new Static3D(0,0,0);
803
    Static3D center1= new Static3D(-E/2,-E/2,0);
804

    
805
    VertexEffect effect0 = new VertexEffectMove(move0);
806
    VertexEffect effect1 = new VertexEffectRotate(angle1, axisZ, center);
807
    VertexEffect effect2 = new VertexEffectMove(move1);
808
    VertexEffect effect3 = new VertexEffectRotate(angle2, axis1, center1);
809
    VertexEffect effect4 = new VertexEffectMove(move2);
810
    VertexEffect effect5 = new VertexEffectMove(move3);
811
    VertexEffect effect6 = new VertexEffectRotate(angle3, axisZ, center);
812
    VertexEffect effect7 = new VertexEffectRotate(angle4, axisX, center);
813
    VertexEffect effect8 = new VertexEffectRotate(angle1, axisY, center);
814
    VertexEffect effect9 = new VertexEffectMove(move4);
815

    
816
    effect0.setMeshAssociation( 1,-1);  // mesh 0
817
    effect1.setMeshAssociation( 2,-1);  // mesh 1
818
    effect2.setMeshAssociation( 2,-1);  // mesh 1
819
    effect3.setMeshAssociation( 2,-1);  // mesh 1
820
    effect4.setMeshAssociation( 4,-1);  // mesh 2
821
    effect5.setMeshAssociation( 8,-1);  // mesh 3
822
    effect6.setMeshAssociation( 8,-1);  // mesh 3
823
    effect7.setMeshAssociation( 4,-1);  // mesh 2
824
    effect8.setMeshAssociation( 8,-1);  // mesh 3
825
    effect9.setMeshAssociation(15,-1);  // meshes 0,1,2,3
826

    
827
    mesh.apply(effect0);
828
    mesh.apply(effect1);
829
    mesh.apply(effect2);
830
    mesh.apply(effect3);
831
    mesh.apply(effect4);
832
    mesh.apply(effect5);
833
    mesh.apply(effect6);
834
    mesh.apply(effect7);
835
    mesh.apply(effect8);
836
    mesh.apply(effect9);
837

    
838
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
839

    
840
    Static3D[] verticesType1 = new Static3D[1];
841
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
842
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
843

    
844
    Static3D[] verticesType2 = new Static3D[2];
845
    verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
846
    verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
847
    roundCorners(mesh,roundingCenter,verticesType2,0.10f,0.20f);
848

    
849
    mesh.mergeEffComponents();
850
    mesh.addEmptyTexComponent();
851
    mesh.addEmptyTexComponent();
852

    
853
    return mesh;
854
    }
855

    
856
///////////////////////////////////////////////////////////////////////////////////////////////////
857
// Redi cube
858

    
859
  MeshBase createRediEdgeMesh()
860
    {
861
    final int MESHES=6;
862

    
863
    float C = 0.02f;
864
    float D = 0.02f;
865
    float F = 0.25f;
866

    
867
    float[] bands0 = { 1.0f    , 0,
868
                       1.0f-2*C, D*0.25f,
869
                       1.0f-4*C, D*0.35f,
870
                       1.0f-8*C, D*0.6f,
871
                       0.60f   , D*1.0f,
872
                       0.30f   , D*1.375f,
873
                       0.0f    , D*1.4f };
874

    
875
    float[] vertices0 = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F };
876

    
877
    MeshBase[] meshes = new MeshPolygon[MESHES];
878
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 2);
879
    meshes[0].setEffectAssociation(0,1,0);
880
    meshes[1] = meshes[0].copy(true);
881
    meshes[1].setEffectAssociation(0,2,0);
882

    
883
    float[] bands1 = { 1.0f    , 0,
884
                       0.90f   , D,
885
                       0.0f    , D };
886

    
887
    float[] vertices1 = { -F/2, +F/2, -F/2, -1.5f*F, 1.5f*F, +F/2 };
888

    
889
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
890
    meshes[2].setEffectAssociation(0,4,0);
891
    meshes[3] = meshes[2].copy(true);
892
    meshes[3].setEffectAssociation(0,8,0);
893

    
894
    float[] bands2 = { 1.0f    , 0,
895
                       0.90f   , D,
896
                       0.0f    , D };
897

    
898
    float X = 0.25f*SQ2;
899
    float Y = SQ6/16;
900

    
901
    float[] vertices2 = { -X, Y, -1.5f*X, -Y, +1.5f*X, -Y, +X, Y };
902

    
903
    meshes[4] = new MeshPolygon(vertices2, bands2, 1, 1);
904
    meshes[4].setEffectAssociation(0,16,0);
905
    meshes[5] = meshes[4].copy(true);
906
    meshes[5].setEffectAssociation(0,32,0);
907

    
908
    MeshBase mesh = new MeshJoined(meshes);
909

    
910
    Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
911
    Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
912
    Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
913
    Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
914
    Static3D flipZ = new Static3D(1,1,-1);
915
    Static3D flipX = new Static3D(-1,1,1);
916
    Static3D scale = new Static3D(2,2,2);
917
    Static3D cent0 = new Static3D(0,0, 0);
918
    Static3D cent1 = new Static3D(0,0, -1.5f);
919
    Static3D axisX = new Static3D(1,0, 0);
920
    Static3D axisY = new Static3D(0,1, 0);
921
    Static3D axis  = new Static3D(0,SQ2/2,-SQ2/2);
922
    Static1D angle1= new Static1D(90);
923
    Static1D angle2= new Static1D(45);
924
    Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
925

    
926
    VertexEffect effect0 = new VertexEffectScale(scale);
927
    VertexEffect effect1 = new VertexEffectMove(move0);
928
    VertexEffect effect2 = new VertexEffectScale(flipZ);
929
    VertexEffect effect3 = new VertexEffectRotate(angle1,axisX,cent0);
930
    VertexEffect effect4 = new VertexEffectMove(move1);
931
    VertexEffect effect5 = new VertexEffectRotate(angle1,axisY,cent0);
932
    VertexEffect effect6 = new VertexEffectMove(move2);
933
    VertexEffect effect7 = new VertexEffectScale(flipX);
934
    VertexEffect effect8 = new VertexEffectRotate(angle2,axisX,cent0);
935
    VertexEffect effect9 = new VertexEffectMove(move3);
936
    VertexEffect effect10= new VertexEffectRotate(angle3,axis ,cent1);
937
    VertexEffect effect11= new VertexEffectScale(flipX);
938

    
939
    effect0.setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
940
    effect1.setMeshAssociation( 3,-1);  // meshes 0,1
941
    effect2.setMeshAssociation( 2,-1);  // mesh 1
942
    effect3.setMeshAssociation( 2,-1);  // mesh 1
943
    effect4.setMeshAssociation(12,-1);  // meshes 2,3
944
    effect5.setMeshAssociation(60,-1);  // meshes 2,3,4,5
945
    effect6.setMeshAssociation(12,-1);  // meshes 2,3
946
    effect7.setMeshAssociation( 8,-1);  // mesh 3
947
    effect8.setMeshAssociation(48,-1);  // meshes 4,5
948
    effect9.setMeshAssociation(48,-1);  // meshes 4,5
949
    effect10.setMeshAssociation(48,-1); // meshes 4,5
950
    effect11.setMeshAssociation(32,-1); // mesh 5
951

    
952
    mesh.apply(effect0);
953
    mesh.apply(effect1);
954
    mesh.apply(effect2);
955
    mesh.apply(effect3);
956
    mesh.apply(effect4);
957
    mesh.apply(effect5);
958
    mesh.apply(effect6);
959
    mesh.apply(effect7);
960
    mesh.apply(effect8);
961
    mesh.apply(effect9);
962
    mesh.apply(effect10);
963
    mesh.apply(effect11);
964

    
965
    Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
966
    Static3D[] vertices = new Static3D[4];
967
    vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
968
    vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
969
    vertices[2] = new Static3D(0.0f, 0.0f,-1.5f);
970
    vertices[3] = new Static3D(0.0f,-1.5f, 0.0f);
971

    
972
    roundCorners(mesh,center,vertices,0.06f,0.20f);
973

    
974
    mesh.mergeEffComponents();
975

    
976
    return mesh;
977
    }
978

    
979
///////////////////////////////////////////////////////////////////////////////////////////////////
980

    
981
  MeshBase createRediCornerMesh()
982
    {
983
    final int MESHES=6;
984
    MeshBase[] meshes = new MeshBase[MESHES];
985

    
986
    float C = 0.027f;
987
    float D = 0.027f;
988
    float E = 0.5f;
989
    float[] vertices1 = { -E,-E, +E,-E, +E,+E, -E,+E };
990

    
991
    float[] bands1 = new float[] { 1.0f   ,-D,
992
                                  1.0f-C/2,-D*0.55f,
993
                                  1.0f-C  ,-D*0.25f,
994
                                  1.0f-2*C, 0.0f,
995
                                  0.50f   , D*1.5f,
996
                                  0.0f    , D*1.75f };
997

    
998
    meshes[0] = new MeshPolygon(vertices1,bands1,2,2);
999
    meshes[0].setEffectAssociation(0,1,0);
1000
    meshes[1] = meshes[0].copy(true);
1001
    meshes[1].setEffectAssociation(0,2,0);
1002
    meshes[2] = meshes[0].copy(true);
1003
    meshes[2].setEffectAssociation(0,4,0);
1004

    
1005
    float F = SQ2/2;
1006
    float X = 0.5f;
1007

    
1008
    float[] vertices2 = { -E,+F, -E+X,0, -E,-F, +E,-F, +E-X,0, +E,+F };
1009

    
1010
    float[] bands2 = new float[] { 1.0f,0.0f,
1011
                                   0.0f,0.0f };
1012

    
1013
    meshes[3] = new MeshPolygon(vertices2,bands2,0,0);
1014
    meshes[3].setEffectAssociation(0,8,0);
1015
    meshes[4] = meshes[3].copy(true);
1016
    meshes[4].setEffectAssociation(0,16,0);
1017
    meshes[5] = meshes[3].copy(true);
1018
    meshes[5].setEffectAssociation(0,32,0);
1019

    
1020
    MeshBase mesh = new MeshJoined(meshes);
1021

    
1022
    Static3D axisY   = new Static3D(0,1,0);
1023
    Static3D axisX   = new Static3D(1,0,0);
1024
    Static3D axisZ   = new Static3D(0,0,1);
1025
    Static3D center  = new Static3D(0,0,0);
1026
    Static1D angle90 = new Static1D(90);
1027
    Static1D angle270= new Static1D(270);
1028
    Static1D angle45 = new Static1D(-45);
1029

    
1030
    VertexEffect effect0 = new VertexEffectMove(new Static3D(0,0,+0.5f));
1031
    VertexEffect effect1 = new VertexEffectRotate( angle270, axisX, center );
1032
    VertexEffect effect2 = new VertexEffectRotate( angle90 , axisY, center );
1033
    VertexEffect effect3 = new VertexEffectRotate( angle45 , axisX, center );
1034
    VertexEffect effect4 = new VertexEffectRotate( angle90 , axisY, center );
1035
    VertexEffect effect5 = new VertexEffectRotate( angle270, axisZ, center );
1036

    
1037
    effect0.setMeshAssociation( 7,-1);  // 0,1,2
1038
    effect1.setMeshAssociation( 2,-1);  // 1
1039
    effect2.setMeshAssociation( 4,-1);  // 2
1040
    effect3.setMeshAssociation(56,-1);  // 3
1041
    effect4.setMeshAssociation(16,-1);  // 4
1042
    effect5.setMeshAssociation(32,-1);  // 5
1043

    
1044
    mesh.apply(effect0);
1045
    mesh.apply(effect1);
1046
    mesh.apply(effect2);
1047
    mesh.apply(effect3);
1048
    mesh.apply(effect4);
1049
    mesh.apply(effect5);
1050

    
1051
    Static3D[] vertices = new Static3D[8];
1052
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1053
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1054
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1055
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1056
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1057
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1058
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1059
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1060

    
1061
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1062

    
1063
    mesh.mergeEffComponents();
1064

    
1065
    return mesh;
1066
    }
1067
  }
(2-2/21)