Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / FactoryCubit.java @ da36b97e

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.type.Static1D;
31
import org.distorted.library.type.Static3D;
32
import org.distorted.library.type.Static4D;
33

    
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

    
36
class FactoryCubit
37
  {
38
  static final float IVY_D = 0.003f;
39
  static final float IVY_C = 0.59f;
40
  static final float IVY_M = 0.35f;
41
  static final float REX_D = 0.2f;
42

    
43
  private static final float SQ2 = (float)Math.sqrt(2);
44
  private static final float SQ3 = (float)Math.sqrt(3);
45
  private static final float SQ6 = (float)Math.sqrt(6);
46

    
47
  private static final int IVY_N = 8;
48
  private static final Static1D RADIUS = new Static1D(1);
49
  private static FactoryCubit mThis;
50

    
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

    
53
  private FactoryCubit()
54
    {
55

    
56
    }
57

    
58
///////////////////////////////////////////////////////////////////////////////////////////////////
59

    
60
  public static FactoryCubit getInstance()
61
    {
62
    if( mThis==null ) mThis = new FactoryCubit();
63

    
64
    return mThis;
65
    }
66

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68
// H - height of the band in the middle
69
// alpha - angle of the edge  [0,90]
70
// dist - often in a polygon the distance from edge to center is not 1, but something else.
71
// This is the distance.
72
// K - where to begin the second, much more flat part of the band. [0,1]
73
// N - number of bands. N>=3
74
//
75
// theory: two distinct parts to the band:
76
// 1) (0,B) - steep
77
// 2) (B,1) - flat
78
//
79
// In first part, we have y = g(x) ; in second - y = g(f(x)) where
80
//
81
// g(x) = sqrt( R^2 - (x-D)^2 ) - R*cos(alpha)
82
// f(x) = ((D-B)/(1-B)*x + B*(1-D)/(1-B)
83
// h(x) = R*(sin(alpha) - sin(x))
84
// R = H/(1-cos(alpha))
85
// D = H*sin(alpha)
86
// B = h(K*alpha)
87
//
88
// The N points are taken at:
89
//
90
// 1) in the second part, there are K2 = (N-3)/3 such points
91
// 2) in the first - K1 = (N-3) - K2
92
// 3) also, the 3 points 0,B,1
93
//
94
// so we have the sequence A[i] of N points
95
//
96
// 0
97
// h((i+1)*(1-K)*alpha/(K1+1)) (i=0,1,...,K1-1)
98
// B
99
// (1-B)*(i+1)/(K2+1) + B   (i=0,i,...,K2-1)
100
// 1
101

    
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103

    
104
  private float f(float D, float B, float x)
105
    {
106
    return ((D-B)*x + B*(1-D))/(1-B);
107
    }
108

    
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110

    
111
  private float g(float R, float D, float x, float cosAlpha)
112
    {
113
    float d = x-D;
114
    return (float)(Math.sqrt(R*R-d*d)-R*cosAlpha);
115
    }
116

    
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118

    
119
  private float h(float R, float sinAlpha, float x)
120
    {
121
    return R*(sinAlpha-(float)Math.sin(x));
122
    }
123

    
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125

    
126
  private float[] computeBands(float H, int alpha, float dist, float K, int N)
127
    {
128
    float[] bands = new float[2*N];
129

    
130
    bands[0] = 1.0f;
131
    bands[1] = 0.0f;
132

    
133
    float beta = (float)Math.atan(dist*Math.tan(Math.PI*alpha/180));
134
    float sinBeta = (float)Math.sin(beta);
135
    float cosBeta = (float)Math.cos(beta);
136
    float R = cosBeta<1.0f ? H/(1.0f-cosBeta) : 0.0f;
137
    float D = R*sinBeta;
138
    float B = h(R,sinBeta,K*beta);
139

    
140
    if( D>1.0f )
141
      {
142
      for(int i=1; i<N; i++)
143
        {
144
        bands[2*i  ] = (float)(N-1-i)/(N-1);
145
        bands[2*i+1] = H*(1-bands[2*i]);
146
        }
147
      }
148
    else
149
      {
150
      int K2 = (int)((N-3)*K);
151
      int K1 = (N-3)-K2;
152

    
153
      for(int i=0; i<=K1; i++)
154
        {
155
        float angle = K*beta + (1-K)*beta*(K1-i)/(K1+1);
156
        float x = h(R,sinBeta,angle);
157
        bands[2*i+2] = 1.0f - x;
158
        bands[2*i+3] = g(R,D,x,cosBeta);
159
        }
160

    
161
      for(int i=0; i<=K2; i++)
162
        {
163
        float x = (1-B)*(i+1)/(K2+1) + B;
164
        bands[2*K1+2 + 2*i+2] = 1.0f - x;
165
        bands[2*K1+2 + 2*i+3] = g(R,D,f(D,B,x),cosBeta);
166
        }
167
      }
168

    
169
    bands[2*N-2] = 0.0f;
170
    bands[2*N-1] =    H;
171

    
172
    return bands;
173
    }
174

    
175
///////////////////////////////////////////////////////////////////////////////////////////////////
176

    
177
  private void roundCorners(MeshBase mesh, Static3D center, Static3D[] vertices, float strength, float regionRadius)
178
    {
179
    Static4D reg= new Static4D(0,0,0,regionRadius);
180

    
181
    float centX = center.get0();
182
    float centY = center.get1();
183
    float centZ = center.get2();
184

    
185
    for (Static3D vertex : vertices)
186
      {
187
      float x = strength*(centX - vertex.get0());
188
      float y = strength*(centY - vertex.get1());
189
      float z = strength*(centZ - vertex.get2());
190

    
191
      VertexEffect effect = new VertexEffectDeform(new Static3D(x,y,z), RADIUS, vertex, reg);
192
      mesh.apply(effect);
193
      }
194
    }
195

    
196
///////////////////////////////////////////////////////////////////////////////////////////////////
197
// Compute (rx,ry) - coords of a point which is the result of rotation by angle 'radians' of the
198
// point (px,py) along axis Z. Center of rotation: (cx,cy). Rotation is counterclockwise!
199
// Write (rx,ry) to array[index] and array[index+1].
200

    
201
  private void writeVertex( float cx, float cy, float px, float py, float radians, float[] array, int index)
202
    {
203
    float vx = px-cx;
204
    float vy = py-cy;
205

    
206
    float sinA = (float)Math.sin(radians);
207
    float cosA = (float)Math.cos(radians);
208

    
209
    float rvx = vx*cosA - vy*sinA;
210
    float rvy = vx*sinA + vy*cosA;
211

    
212
    array[index  ] = rvx + cx;
213
    array[index+1] = rvy + cy;
214
    }
215

    
216
///////////////////////////////////////////////////////////////////////////////////////////////////
217

    
218
  MeshBase createFacesCube(int sizeIndex)
219
    {
220
    MeshBase[] meshes = new MeshPolygon[6];
221

    
222
    float E = 0.5f;
223
    int extraI, extraV, num;
224

    
225
    switch(sizeIndex)
226
      {
227
      case 0 : num = 6; extraI = 2; extraV = 2; break;
228
      case 1 : num = 5; extraI = 2; extraV = 2; break;
229
      case 2 : num = 5; extraI = 1; extraV = 2; break;
230
      default: num = 4; extraI = 1; extraV = 1; break;
231
      }
232

    
233
    float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E };
234
    float[] bands = computeBands(0.048f,35,E,0.7f,num);
235

    
236
    meshes[0] = new MeshPolygon(vertices,bands,extraI,extraV);
237
    meshes[0].setEffectAssociation(0,1,0);
238
    meshes[1] = meshes[0].copy(true);
239
    meshes[1].setEffectAssociation(0,2,0);
240
    meshes[2] = meshes[0].copy(true);
241
    meshes[2].setEffectAssociation(0,4,0);
242
    meshes[3] = meshes[0].copy(true);
243
    meshes[3].setEffectAssociation(0,8,0);
244
    meshes[4] = meshes[0].copy(true);
245
    meshes[4].setEffectAssociation(0,16,0);
246
    meshes[5] = meshes[0].copy(true);
247
    meshes[5].setEffectAssociation(0,32,0);
248

    
249
    return new MeshJoined(meshes);
250
    }
251

    
252
///////////////////////////////////////////////////////////////////////////////////////////////////
253

    
254
  MeshBase createFacesSkewbCorner()
255
    {
256
    MeshBase[] meshes = new MeshBase[6];
257

    
258
    float E = 0.5f;
259
    float F = SQ2/2;
260
    float G = SQ6/16;
261
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
262
    float[] bands0 = computeBands(0.028f,35,E/3,0.7f,7);
263

    
264
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
265
    meshes[0].setEffectAssociation(0,1,0);
266
    meshes[1] = meshes[0].copy(true);
267
    meshes[1].setEffectAssociation(0,2,0);
268
    meshes[2] = meshes[0].copy(true);
269
    meshes[2].setEffectAssociation(0,4,0);
270

    
271
    float[] vertices1 = { -F/2,-2*G, F/2,-2*G, 3*F/8,-G, 1*F/8,G, 0,2*G };
272
    float[] bands1 = computeBands(0,0,1,0,3);
273

    
274
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
275
    meshes[3].setEffectAssociation(0,8,0);
276
    meshes[4] = meshes[3].copy(true);
277
    meshes[4].setEffectAssociation(0,16,0);
278
    meshes[5] = meshes[3].copy(true);
279
    meshes[5].setEffectAssociation(0,32,0);
280

    
281
    return new MeshJoined(meshes);
282
    }
283

    
284
///////////////////////////////////////////////////////////////////////////////////////////////////
285

    
286
  MeshBase createFacesSkewbFace()
287
    {
288
    MeshBase[] meshes = new MeshBase[5];
289

    
290
    float E = SQ2/4;
291
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
292
    float[] bands0 = computeBands(0.051f,35,E/2,0.9f,7);
293

    
294
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
295
    meshes[0].setEffectAssociation(0,1,0);
296

    
297
    float[] vertices1 = { -E,-SQ3*E, -E*0.7f,-SQ3*E, +E*0.7f,-SQ3*E, +E,-SQ3*E, 0,0 };
298
    float[] bands1 = computeBands(0,0,1,0,3);
299

    
300
    meshes[1] = new MeshPolygon(vertices1,bands1,0,0);
301
    meshes[1].setEffectAssociation(0,2,0);
302
    meshes[2] = meshes[1].copy(true);
303
    meshes[2].setEffectAssociation(0,4,0);
304
    meshes[3] = meshes[1].copy(true);
305
    meshes[3].setEffectAssociation(0,8,0);
306
    meshes[4] = meshes[1].copy(true);
307
    meshes[4].setEffectAssociation(0,16,0);
308

    
309
    return new MeshJoined(meshes);
310
    }
311

    
312
///////////////////////////////////////////////////////////////////////////////////////////////////
313

    
314
  MeshBase createFacesOcta()
315
    {
316
    MeshBase[] meshes = new MeshPolygon[8];
317

    
318
    float E = 0.75f;
319
    float F = 0.5f;
320
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
321
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
322

    
323
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
324
    meshes[0].setEffectAssociation(0,1,0);
325
    meshes[1] = meshes[0].copy(true);
326
    meshes[1].setEffectAssociation(0,2,0);
327
    meshes[2] = meshes[0].copy(true);
328
    meshes[2].setEffectAssociation(0,4,0);
329
    meshes[3] = meshes[0].copy(true);
330
    meshes[3].setEffectAssociation(0,8,0);
331
    meshes[4] = meshes[0].copy(true);
332
    meshes[4].setEffectAssociation(0,16,0);
333
    meshes[5] = meshes[0].copy(true);
334
    meshes[5].setEffectAssociation(0,32,0);
335
    meshes[6] = meshes[0].copy(true);
336
    meshes[6].setEffectAssociation(0,64,0);
337
    meshes[7] = meshes[0].copy(true);
338
    meshes[7].setEffectAssociation(0,128,0);
339

    
340
    return new MeshJoined(meshes);
341
    }
342

    
343
///////////////////////////////////////////////////////////////////////////////////////////////////
344

    
345
  MeshBase createFacesTetra()
346
    {
347
    MeshBase[] meshes = new MeshBase[4];
348

    
349
    float E = 0.75f;
350
    float F = 0.5f;
351
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
352
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
353

    
354
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
355
    meshes[0].setEffectAssociation(0,1,0);
356
    meshes[1] = meshes[0].copy(true);
357
    meshes[1].setEffectAssociation(0,2,0);
358
    meshes[2] = meshes[0].copy(true);
359
    meshes[2].setEffectAssociation(0,4,0);
360
    meshes[3] = meshes[0].copy(true);
361
    meshes[3].setEffectAssociation(0,8,0);
362

    
363
    return new MeshJoined(meshes);
364
    }
365

    
366
///////////////////////////////////////////////////////////////////////////////////////////////////
367

    
368
  MeshBase createFacesDino()
369
    {
370
    MeshBase[] meshes = new MeshPolygon[4];
371

    
372
    float E = 0.5f*SQ2;
373
    float F = 0.5f;
374
    float[] vertices0 = { -F,F/3, 0,-2*F/3, +F,F/3 };
375
    float[] bands0 = computeBands(0.028f,30,F/3,0.8f,7);
376

    
377
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 5);
378
    meshes[0].setEffectAssociation(0,1,0);
379
    meshes[1] = meshes[0].copy(true);
380
    meshes[1].setEffectAssociation(0,2,0);
381

    
382
    float[] vertices1 = { -E/2,-E*(SQ3/6), E/2,-E*(SQ3/6), 0,E*(SQ3/3) };
383
    float[] bands1 = computeBands(0.02f,45,F/3,0.2f,3);
384

    
385
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
386
    meshes[2].setEffectAssociation(0,4,0);
387
    meshes[3] = meshes[2].copy(true);
388
    meshes[3].setEffectAssociation(0,8,0);
389

    
390
    return new MeshJoined(meshes);
391
    }
392

    
393
///////////////////////////////////////////////////////////////////////////////////////////////////
394

    
395
  MeshBase createFacesHelicopterCorner()
396
    {
397
    MeshBase[] meshes = new MeshBase[6];
398

    
399
    float E = 0.5f;
400
    float F = SQ2/4;
401
    float G = 1.0f/12;
402
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
403
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
404

    
405
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
406
    meshes[0].setEffectAssociation(0,1,0);
407
    meshes[1] = meshes[0].copy(true);
408
    meshes[1].setEffectAssociation(0,2,0);
409
    meshes[2] = meshes[0].copy(true);
410
    meshes[2].setEffectAssociation(0,4,0);
411

    
412
    float[] vertices1 = { -F,-G, 0,-G, +F,-G, 0,2*G };
413
    float[] bands1 = computeBands(0.00f,0,0,0.0f,3);
414
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
415
    meshes[3].setEffectAssociation(0,8,0);
416
    meshes[4] = meshes[3].copy(true);
417
    meshes[4].setEffectAssociation(0,16,0);
418
    meshes[5] = meshes[3].copy(true);
419
    meshes[5].setEffectAssociation(0,32,0);
420

    
421
    return new MeshJoined(meshes);
422
    }
423

    
424
///////////////////////////////////////////////////////////////////////////////////////////////////
425

    
426
  MeshBase createFacesHelicopterFace()
427
    {
428
    MeshBase[] meshes = new MeshBase[4];
429

    
430
    float E = 0.5f;
431
    float F = SQ2/4;
432
    float G = 1.0f/12;
433
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
434
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
435

    
436
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
437
    meshes[0].setEffectAssociation(0,1,0);
438

    
439
    float[] vertices1 = { -F,-G, +F,-G, 0,2*G};
440
    float[] bands1 = computeBands(0.01f,45,F,0.0f,3);
441

    
442
    meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3);
443
    meshes[1].setEffectAssociation(0,2,0);
444

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

    
447
    meshes[2] = new MeshPolygon(vertices2, bands1, 1, 3);
448
    meshes[2].setEffectAssociation(0,4,0);
449
    meshes[3] = meshes[2].copy(true);
450
    meshes[3].setEffectAssociation(0,8,0);
451

    
452
    return new MeshJoined(meshes);
453
    }
454

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

    
457
  MeshBase createFacesRediEdge()
458
    {
459
    MeshBase[] meshes = new MeshPolygon[6];
460

    
461
    float F = 0.25f;
462
    float[] vertices0 = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F };
463
    float[] bands0 = computeBands(0.038f,35,F,0.7f,7);
464

    
465
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 2);
466
    meshes[0].setEffectAssociation(0,1,0);
467
    meshes[1] = meshes[0].copy(true);
468
    meshes[1].setEffectAssociation(0,2,0);
469

    
470
    float[] bands1 = computeBands(0.02f,35,F/2,0.2f,3);
471
    float[] vertices1 = { -F/2, +F/2, -F/2, -1.5f*F, 1.5f*F, +F/2 };
472

    
473
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
474
    meshes[2].setEffectAssociation(0,4,0);
475
    meshes[3] = meshes[2].copy(true);
476
    meshes[3].setEffectAssociation(0,8,0);
477

    
478
    float X = 0.25f*SQ2;
479
    float Y = SQ6/16;
480
    float[] vertices2 = { -X, Y, -1.5f*X, -Y, +1.5f*X, -Y, +X, Y };
481

    
482
    meshes[4] = new MeshPolygon(vertices2, bands1, 1, 1);
483
    meshes[4].setEffectAssociation(0,16,0);
484
    meshes[5] = meshes[4].copy(true);
485
    meshes[5].setEffectAssociation(0,32,0);
486

    
487
    return new MeshJoined(meshes);
488
    }
489

    
490
///////////////////////////////////////////////////////////////////////////////////////////////////
491

    
492
  MeshBase createFacesRediCorner()
493
    {
494
    MeshBase[] meshes = new MeshBase[6];
495

    
496
    float E = 0.5f;
497
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
498
    float[] bands0 = computeBands(0.06f,35,E,0.7f,6);
499

    
500
    meshes[0] = new MeshPolygon(vertices0,bands0,2,2);
501
    meshes[0].setEffectAssociation(0,1,0);
502
    meshes[1] = meshes[0].copy(true);
503
    meshes[1].setEffectAssociation(0,2,0);
504
    meshes[2] = meshes[0].copy(true);
505
    meshes[2].setEffectAssociation(0,4,0);
506

    
507
    float F = 0.5f;
508
    float X = 0.5f;
509
    float G = 0.72f;
510
    float[] vertices1 = { -E,+F, -E+X,0, -E,-F, -E*G,-F, +E*G,-F, +E,-F, +E-X,0, +E,+F, +E*G,+F, -E*G,+F };
511
    float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2);
512

    
513
    meshes[3] = new MeshPolygon(vertices1,bands1,0,0);
514
    meshes[3].setEffectAssociation(0,8,0);
515
    meshes[4] = meshes[3].copy(true);
516
    meshes[4].setEffectAssociation(0,16,0);
517
    meshes[5] = meshes[3].copy(true);
518
    meshes[5].setEffectAssociation(0,32,0);
519

    
520
    return new MeshJoined(meshes);
521
    }
522

    
523
///////////////////////////////////////////////////////////////////////////////////////////////////
524

    
525
  MeshBase createFacesIvyCorner()
526
    {
527
    MeshBase[] meshes = new MeshBase[6];
528

    
529
    final float angle = (float)Math.PI/(2*IVY_N);
530
    final float CORR  = 1.0f - 2*IVY_D;
531
    final float DIST  = -0.5f*CORR + IVY_D;
532
    float[] vertices  = new float[2*(IVY_N+1)+6];
533

    
534
    vertices[0] = (0.5f-IVY_M) * IVY_C;
535
    vertices[1] = (DIST-IVY_M) * IVY_C;
536
    vertices[2] = (0.5f-IVY_M) * IVY_C;
537
    vertices[3] = (0.5f-IVY_M) * IVY_C;
538
    vertices[4] = (DIST-IVY_M) * IVY_C;
539
    vertices[5] = (0.5f-IVY_M) * IVY_C;
540

    
541
    for(int i=0; i<=IVY_N; i++)
542
      {
543
      float ang = (IVY_N-i)*angle;
544
      float sin = (float)Math.sin(ang);
545
      float cos = (float)Math.cos(ang);
546

    
547
      vertices[2*i+6] = (CORR*(cos-0.5f)-IVY_M)*IVY_C;
548
      vertices[2*i+7] = (CORR*(sin-0.5f)-IVY_M)*IVY_C;
549
      }
550

    
551
    float[] bands0 = computeBands(+0.012f,20,0.2f,0.5f,7);
552
    float[] bands1 = computeBands(-0.100f,20,0.2f,0.0f,2);
553

    
554
    meshes[0] = new MeshPolygon(vertices,bands0,1,2);
555
    meshes[0].setEffectAssociation(0,1,0);
556
    meshes[1] = meshes[0].copy(true);
557
    meshes[1].setEffectAssociation(0,2,0);
558
    meshes[2] = meshes[0].copy(true);
559
    meshes[2].setEffectAssociation(0,4,0);
560
    meshes[3] = new MeshPolygon(vertices,bands1,1,2);
561
    meshes[3].setEffectAssociation(0,8,0);
562
    meshes[4] = meshes[3].copy(true);
563
    meshes[4].setEffectAssociation(0,16,0);
564
    meshes[5] = meshes[3].copy(true);
565
    meshes[5].setEffectAssociation(0,32,0);
566

    
567
    return new MeshJoined(meshes);
568
    }
569

    
570
///////////////////////////////////////////////////////////////////////////////////////////////////
571

    
572
  MeshBase createFacesIvyFace()
573
    {
574
    MeshBase[] meshes = new MeshBase[2];
575

    
576
    final float angle = (float)Math.PI/(2*IVY_N);
577
    final float CORR  = 1.0f - 2*IVY_D;
578
    float[] vertices = new float[4*IVY_N];
579

    
580
    for(int i=0; i<IVY_N; i++)
581
      {
582
      float sin = (float)Math.sin(i*angle);
583
      float cos = (float)Math.cos(i*angle);
584

    
585
      vertices[2*i          ] = CORR*(0.5f-cos);
586
      vertices[2*i+1        ] = CORR*(0.5f-sin);
587
      vertices[2*i  +2*IVY_N] = CORR*(cos-0.5f);
588
      vertices[2*i+1+2*IVY_N] = CORR*(sin-0.5f);
589
      }
590

    
591
    float[] bands0 = computeBands(+0.03f,35,0.5f,0.5f,5);
592
    float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2);
593

    
594
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
595
    meshes[0].setEffectAssociation(0,1,0);
596
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
597
    meshes[1].setEffectAssociation(0,2,0);
598

    
599
    return new MeshJoined(meshes);
600
    }
601

    
602
///////////////////////////////////////////////////////////////////////////////////////////////////
603

    
604
  MeshBase createFacesRexCorner()
605
    {
606
    MeshBase[] meshes = new MeshBase[2];
607

    
608
    float F = REX_D*SQ2;
609
    float G = (1-REX_D)*SQ2/2;
610
    float H = 0.1f;
611
    float J = +2*G/3 - H*G;
612

    
613
    float[] vertices = { -F/2, -G/3, +F/2, -G/3, H*F/2, J, -H*F/2, J};
614

    
615
    float[] bands0 = computeBands(+0.016f,10,G/3,0.5f,5);
616
    float[] bands1 = computeBands(-0.230f,45,G/3,0.0f,2);
617

    
618
    meshes[0] = new MeshPolygon(vertices,bands0,1,1);
619
    meshes[0].setEffectAssociation(0,1,0);
620
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
621
    meshes[1].setEffectAssociation(0,2,0);
622

    
623
    return new MeshJoined(meshes);
624
    }
625

    
626
///////////////////////////////////////////////////////////////////////////////////////////////////
627

    
628
  MeshBase createFacesRexFace()
629
    {
630
    MeshBase[] meshes = new MeshBase[2];
631

    
632
    float[] vertices = { -REX_D,0.0f, 0.0f, -REX_D, +REX_D, 0.0f, 0.0f, +REX_D};
633

    
634
    float[] bands0 = computeBands(0.016f,10,REX_D/2,0.5f,5);
635
    float[] bands1 = computeBands(0.000f,45,REX_D/2,0.0f,2);
636

    
637
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
638
    meshes[0].setEffectAssociation(0,1,0);
639
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
640
    meshes[1].setEffectAssociation(0,2,0);
641

    
642
    return new MeshJoined(meshes);
643
    }
644

    
645
///////////////////////////////////////////////////////////////////////////////////////////////////
646

    
647
  MeshBase createFacesRexEdge()
648
    {
649
    MeshBase[] meshes = new MeshPolygon[6];
650

    
651
    float E = 0.5f - REX_D;
652
    float F = 0.5f;
653
    float[] vertices0 = { -F,E/3, 0,-2*E/3, +F,E/3 };
654
    float[] bands0 = computeBands(0.03f,27,F/3,0.8f,5);
655

    
656
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 3);
657
    meshes[0].setEffectAssociation(0,1,0);
658
    meshes[1] = meshes[0].copy(true);
659
    meshes[1].setEffectAssociation(0,2,0);
660

    
661
    float G = (float)Math.sqrt(E*E+F*F);
662
    float[] vertices1 = { -2*G/3, -E/3, G/3, -E/3, G/3, 2*E/3 };
663
    float[] bands1 = computeBands(0.00f,45,G/3,0.2f,3);
664

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

    
674
    return new MeshJoined(meshes);
675
    }
676

    
677
///////////////////////////////////////////////////////////////////////////////////////////////////
678
// EFFECTS
679
///////////////////////////////////////////////////////////////////////////////////////////////////
680

    
681
  VertexEffect[] createVertexEffectsCube()
682
    {
683
    Static3D axisY   = new Static3D(0,1,0);
684
    Static3D axisX   = new Static3D(1,0,0);
685
    Static3D center  = new Static3D(0,0,0);
686
    Static1D angle90 = new Static1D(90);
687
    Static1D angle180= new Static1D(180);
688
    Static1D angle270= new Static1D(270);
689

    
690
    VertexEffect[] effect = new VertexEffect[6];
691

    
692
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
693
    effect[1] = new VertexEffectRotate( angle180, axisX, center );
694
    effect[2] = new VertexEffectRotate( angle90 , axisX, center );
695
    effect[3] = new VertexEffectRotate( angle270, axisX, center );
696
    effect[4] = new VertexEffectRotate( angle270, axisY, center );
697
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
698

    
699
    effect[0].setMeshAssociation(63,-1);  // all 6 sides
700
    effect[1].setMeshAssociation(32,-1);  // back
701
    effect[2].setMeshAssociation( 8,-1);  // bottom
702
    effect[3].setMeshAssociation( 4,-1);  // top
703
    effect[4].setMeshAssociation( 2,-1);  // left
704
    effect[5].setMeshAssociation( 1,-1);  // right
705

    
706
    return effect;
707
    }
708

    
709
///////////////////////////////////////////////////////////////////////////////////////////////////
710

    
711
  VertexEffect[] createVertexEffectsSkewbCorner()
712
    {
713
    float E = 0.5f;
714

    
715
    Static3D axisX  = new Static3D(1,0,0);
716
    Static3D axisY  = new Static3D(0,1,0);
717
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
718
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
719
    Static1D angle1 = new Static1D(+90);
720
    Static1D angle2 = new Static1D(-90);
721
    Static1D angle3 = new Static1D(-15);
722
    Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
723
    Static1D angle5 = new Static1D(120);
724
    Static1D angle6 = new Static1D(240);
725
    Static3D center1= new Static3D(0,0,0);
726
    Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
727
    Static3D move1  = new Static3D(-E/4,-E/4,0);
728
    Static3D move2  = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
729

    
730
    VertexEffect[] effect = new VertexEffect[10];
731

    
732
    effect[0] = new VertexEffectMove(move1);
733
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
734
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
735
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
736
    effect[4] = new VertexEffectMove(move2);
737
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
738
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
739
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
740
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
741
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
742

    
743
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
744
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
745
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
746
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
747
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
748
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
749
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
750
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
751
    effect[8].setMeshAssociation(16,-1);  // mesh 4
752
    effect[9].setMeshAssociation(32,-1);  // mesh 5
753

    
754
    return effect;
755
    }
756

    
757
///////////////////////////////////////////////////////////////////////////////////////////////////
758

    
759
  VertexEffect[] createVertexEffectsSkewbFace()
760
    {
761
    Static3D center = new Static3D(0,0,0);
762
    Static3D axisX  = new Static3D(1,0,0);
763
    Static3D axisZ  = new Static3D(0,0,1);
764
    float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
765

    
766
    VertexEffect[] effect = new VertexEffect[6];
767

    
768
    effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center);
769
    effect[1] = new VertexEffectRotate( new Static1D(  135), axisZ, center);
770
    effect[2] = new VertexEffectRotate( new Static1D(   45), axisZ, center);
771
    effect[3] = new VertexEffectRotate( new Static1D(  -45), axisZ, center);
772
    effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center);
773
    effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) );
774

    
775
    effect[0].setMeshAssociation(30,-1);  // meshes 1,2,3,4
776
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
777
    effect[2].setMeshAssociation( 5,-1);  // meshes 0,2
778
    effect[3].setMeshAssociation( 8,-1);  // mesh 3
779
    effect[4].setMeshAssociation(16,-1);  // mesh 4
780
    effect[5].setMeshAssociation(30,-1);  // meshes 1,2,3,4
781

    
782
    return effect;
783
    }
784

    
785
///////////////////////////////////////////////////////////////////////////////////////////////////
786

    
787
  VertexEffect[] createVertexEffectsOcta()
788
    {
789
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
790
    Static1D angle1= new Static1D( 90);
791
    Static1D angle2= new Static1D(180);
792
    Static1D angle3= new Static1D(270);
793
    Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
794
    Static3D axisX = new Static3D(1,0,0);
795
    Static3D axisY = new Static3D(0,1,0);
796
    Static3D cent0 = new Static3D(0,0,0);
797
    Static3D cent1 = new Static3D(0,SQ2/2,0);
798
    Static3D flipY = new Static3D( 1,-1, 1);
799
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
800

    
801
    VertexEffect[] effect = new VertexEffect[7];
802

    
803
    effect[0] = new VertexEffectScale(scale);
804
    effect[1] = new VertexEffectMove(move1);
805
    effect[2] = new VertexEffectRotate(alpha , axisX, cent1);
806
    effect[3] = new VertexEffectRotate(angle1, axisY, cent0);
807
    effect[4] = new VertexEffectRotate(angle2, axisY, cent0);
808
    effect[5] = new VertexEffectRotate(angle3, axisY, cent0);
809
    effect[6] = new VertexEffectScale(flipY);
810

    
811
    effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
812
    effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
813
    effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7
814
    effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
815

    
816
    return effect;
817
    }
818

    
819
///////////////////////////////////////////////////////////////////////////////////////////////////
820

    
821
  VertexEffect[] createVertexEffectsTetra()
822
    {
823
    Static3D flipZ = new Static3D( 1, 1,-1);
824
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
825
    Static1D angle1= new Static1D( 90);
826
    Static1D angle2= new Static1D(180);
827
    Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
828
    Static3D axisX = new Static3D(1,0,0);
829
    Static3D axisY = new Static3D(0,1,0);
830
    Static3D axisZ = new Static3D(0,0,1);
831
    Static3D cent0 = new Static3D(0,0,0);
832
    Static3D cent1 = new Static3D(0,SQ2/4,0);
833
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
834

    
835
    VertexEffect[] effect = new VertexEffect[7];
836

    
837
    effect[0] = new VertexEffectScale(scale);
838
    effect[1] = new VertexEffectRotate(angle2, axisZ, cent0);
839
    effect[2] = new VertexEffectMove(move1);
840
    effect[3] = new VertexEffectRotate(alpha , axisX, cent1);
841
    effect[4] = new VertexEffectScale(flipZ);
842
    effect[5] = new VertexEffectRotate(angle1, axisY, cent0);
843
    effect[6] = new VertexEffectRotate(angle2, axisZ, cent0);
844

    
845
    effect[4].setMeshAssociation(10,-1); // meshes 1 & 3
846
    effect[5].setMeshAssociation(12,-1); // meshes 2 & 3
847
    effect[6].setMeshAssociation(12,-1); // meshes 2 & 3
848

    
849
    return effect;
850
    }
851

    
852
///////////////////////////////////////////////////////////////////////////////////////////////////
853

    
854
  VertexEffect[] createVertexEffectsDino()
855
    {
856
    float E = 0.5f*SQ2;
857
    float F = 0.5f;
858
    final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
859

    
860
    Static1D angle1 = new Static1D(-ANGLE);
861
    Static1D angle2 = new Static1D(+ANGLE);
862
    Static3D axisX  = new Static3D(1,0,0);
863
    Static3D axisY  = new Static3D(0,1,0);
864
    Static3D axisZ  = new Static3D(0,-1,1);
865
    Static3D center0= new Static3D(0,0,0);
866
    Static3D center1= new Static3D(0,-3*F,0);
867

    
868
    VertexEffect[] effect = new VertexEffect[10];
869

    
870
    effect[0] = new VertexEffectScale ( new Static3D(3,3,3) );
871
    effect[1] = new VertexEffectMove  ( new Static3D(0,-F,0) );
872
    effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 );
873
    effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) );
874
    effect[4] = new VertexEffectMove  ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
875
    effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
876
    effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) );
877
    effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
878
    effect[8] = new VertexEffectRotate( angle1           , axisZ, center1 );
879
    effect[9] = new VertexEffectRotate( angle2           , axisZ, center1 );
880

    
881
    effect[0].setMeshAssociation(15,-1);  // apply to meshes 0,1,2,3
882
    effect[1].setMeshAssociation( 3,-1);  // apply to meshes 0,1
883
    effect[2].setMeshAssociation( 2,-1);  // apply to mesh 1
884
    effect[3].setMeshAssociation( 2,-1);  // apply to mesh 1
885
    effect[4].setMeshAssociation(12,-1);  // apply to meshes 2,3
886
    effect[5].setMeshAssociation(12,-1);  // apply to meshes 2,3
887
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
888
    effect[7].setMeshAssociation(12,-1);  // apply to meshes 2,3
889
    effect[8].setMeshAssociation( 4,-1);  // apply to mesh 2
890
    effect[9].setMeshAssociation( 8,-1);  // apply to mesh 3
891

    
892
    return effect;
893
    }
894

    
895
///////////////////////////////////////////////////////////////////////////////////////////////////
896

    
897
  VertexEffect[] createVertexEffectsHelicopterCorner()
898
    {
899
    float E = 0.5f;
900

    
901
    Static3D axisX  = new Static3D(1,0,0);
902
    Static3D axisY  = new Static3D(0,1,0);
903
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
904
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
905
    Static1D angle1 = new Static1D(+90);
906
    Static1D angle2 = new Static1D(-90);
907
    Static1D angle3 = new Static1D(-135);
908
    Static1D angle4 = new Static1D(90);
909
    Static1D angle5 = new Static1D(120);
910
    Static1D angle6 = new Static1D(240);
911
    Static3D center1= new Static3D(0,0,0);
912
    Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
913
    Static3D move1  = new Static3D(-E/4,-E/4,0);
914
    Static3D move2  = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
915

    
916
    VertexEffect[] effect = new VertexEffect[10];
917

    
918
    effect[0] = new VertexEffectMove(move1);
919
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
920
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
921
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
922
    effect[4] = new VertexEffectMove(move2);
923
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
924
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
925
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
926
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
927
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
928

    
929
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
930
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
931
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
932
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
933
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
934
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
935
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
936
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
937
    effect[8].setMeshAssociation(16,-1);  // mesh 4
938
    effect[9].setMeshAssociation(32,-1);  // mesh 5
939

    
940
    return effect;
941
    }
942

    
943
///////////////////////////////////////////////////////////////////////////////////////////////////
944

    
945
  VertexEffect[] createVertexEffectsHelicopterFace()
946
    {
947
    float E = 0.5f;
948
    float F = SQ2/4;
949

    
950
    Static3D move0  = new Static3D(-E/4, -E/4, 0);
951
    Static3D move1  = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
952
    Static3D move2  = new Static3D(-E/2, F/3, 0);
953
    Static3D move3  = new Static3D(+E/2, F/3, 0);
954
    Static3D move4  = new Static3D(+E/3,+E/3, 0);
955
    Static1D angle1 = new Static1D(135);
956
    Static1D angle2 = new Static1D(90);
957
    Static1D angle3 = new Static1D(-90);
958
    Static1D angle4 = new Static1D(-135);
959
    Static3D axisX  = new Static3D(1,0,0);
960
    Static3D axisY  = new Static3D(0,1,0);
961
    Static3D axisZ  = new Static3D(0,0,1);
962
    Static3D axis1  = new Static3D(1,-1,0);
963
    Static3D center = new Static3D(0,0,0);
964
    Static3D center1= new Static3D(-E/2,-E/2,0);
965

    
966
    VertexEffect[] effect = new VertexEffect[10];
967

    
968
    effect[0] = new VertexEffectMove(move0);
969
    effect[1] = new VertexEffectRotate(angle1, axisZ, center);
970
    effect[2] = new VertexEffectMove(move1);
971
    effect[3] = new VertexEffectRotate(angle2, axis1, center1);
972
    effect[4] = new VertexEffectMove(move2);
973
    effect[5] = new VertexEffectMove(move3);
974
    effect[6] = new VertexEffectRotate(angle3, axisZ, center);
975
    effect[7] = new VertexEffectRotate(angle4, axisX, center);
976
    effect[8] = new VertexEffectRotate(angle1, axisY, center);
977
    effect[9] = new VertexEffectMove(move4);
978

    
979
    effect[0].setMeshAssociation( 1,-1);  // mesh 0
980
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
981
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
982
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
983
    effect[4].setMeshAssociation( 4,-1);  // mesh 2
984
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
985
    effect[6].setMeshAssociation( 8,-1);  // mesh 3
986
    effect[7].setMeshAssociation( 4,-1);  // mesh 2
987
    effect[8].setMeshAssociation( 8,-1);  // mesh 3
988
    effect[9].setMeshAssociation(15,-1);  // meshes 0,1,2,3
989

    
990
    return effect;
991
    }
992

    
993
///////////////////////////////////////////////////////////////////////////////////////////////////
994

    
995
  VertexEffect[] createVertexEffectsRediEdge()
996
    {
997
    Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
998
    Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
999
    Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
1000
    Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
1001
    Static3D flipZ = new Static3D(1,1,-1);
1002
    Static3D flipX = new Static3D(-1,1,1);
1003
    Static3D scale = new Static3D(2,2,2);
1004
    Static3D cent0 = new Static3D(0,0, 0);
1005
    Static3D cent1 = new Static3D(0,0, -1.5f);
1006
    Static3D axisX = new Static3D(1,0, 0);
1007
    Static3D axisY = new Static3D(0,1, 0);
1008
    Static3D axis  = new Static3D(0,SQ2/2,-SQ2/2);
1009
    Static1D angle1= new Static1D(90);
1010
    Static1D angle2= new Static1D(45);
1011
    Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
1012

    
1013
    VertexEffect[] effect = new VertexEffect[12];
1014

    
1015
    effect[0] = new VertexEffectScale(scale);
1016
    effect[1] = new VertexEffectMove(move0);
1017
    effect[2] = new VertexEffectScale(flipZ);
1018
    effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
1019
    effect[4] = new VertexEffectMove(move1);
1020
    effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
1021
    effect[6] = new VertexEffectMove(move2);
1022
    effect[7] = new VertexEffectScale(flipX);
1023
    effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
1024
    effect[9] = new VertexEffectMove(move3);
1025
    effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
1026
    effect[11]= new VertexEffectScale(flipX);
1027

    
1028
    effect[0].setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
1029
    effect[1].setMeshAssociation( 3,-1);  // meshes 0,1
1030
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1031
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1032
    effect[4].setMeshAssociation(12,-1);  // meshes 2,3
1033
    effect[5].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1034
    effect[6].setMeshAssociation(12,-1);  // meshes 2,3
1035
    effect[7].setMeshAssociation( 8,-1);  // mesh 3
1036
    effect[8].setMeshAssociation(48,-1);  // meshes 4,5
1037
    effect[9].setMeshAssociation(48,-1);  // meshes 4,5
1038
    effect[10].setMeshAssociation(48,-1); // meshes 4,5
1039
    effect[11].setMeshAssociation(32,-1); // mesh 5
1040

    
1041
    return effect;
1042
    }
1043

    
1044
///////////////////////////////////////////////////////////////////////////////////////////////////
1045

    
1046
  VertexEffect[] createVertexEffectsRediCorner()
1047
    {
1048
    Static3D axisY   = new Static3D(0,1,0);
1049
    Static3D axisX   = new Static3D(1,0,0);
1050
    Static3D axisZ   = new Static3D(0,0,1);
1051
    Static3D center  = new Static3D(0,0,0);
1052
    Static1D angle90 = new Static1D(90);
1053
    Static1D angle270= new Static1D(270);
1054
    Static1D angle45 = new Static1D(-45);
1055
    Static3D scale   = new Static3D(1.0f, SQ2, 1.0f);
1056

    
1057
    VertexEffect[] effect = new VertexEffect[7];
1058

    
1059
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
1060
    effect[1] = new VertexEffectRotate( angle270, axisX, center );
1061
    effect[2] = new VertexEffectRotate( angle90 , axisY, center );
1062
    effect[3] = new VertexEffectScale(scale);
1063
    effect[4] = new VertexEffectRotate( angle45 , axisX, center );
1064
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
1065
    effect[6] = new VertexEffectRotate( angle270, axisZ, center );
1066

    
1067
    effect[0].setMeshAssociation( 7,-1);  // 0,1,2
1068
    effect[1].setMeshAssociation( 2,-1);  // 1
1069
    effect[2].setMeshAssociation( 4,-1);  // 2
1070
    effect[3].setMeshAssociation(56,-1);  // 3,4,5
1071
    effect[4].setMeshAssociation(56,-1);  // 3,4,5
1072
    effect[5].setMeshAssociation(16,-1);  // 4
1073
    effect[6].setMeshAssociation(32,-1);  // 5
1074

    
1075
    return effect;
1076
    }
1077

    
1078
///////////////////////////////////////////////////////////////////////////////////////////////////
1079

    
1080
  VertexEffect[] createVertexEffectsIvyCorner()
1081
    {
1082
    Static3D axisX  = new Static3D(1,0,0);
1083
    Static3D axisY  = new Static3D(0,1,0);
1084
    Static1D angle1 = new Static1D(+90);
1085
    Static1D angle2 = new Static1D(-90);
1086
    Static3D center = new Static3D(0,0,0);
1087
    Static3D move1  = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
1088

    
1089
    VertexEffect[] effect = new VertexEffect[5];
1090

    
1091
    effect[0] = new VertexEffectScale(1/IVY_C);
1092
    effect[1] = new VertexEffectMove(move1);
1093
    effect[2] = new VertexEffectScale(new Static3D(1,1,-1));
1094
    effect[3] = new VertexEffectRotate(angle1,axisX,center);
1095
    effect[4] = new VertexEffectRotate(angle2,axisY,center);
1096

    
1097
    effect[2].setMeshAssociation(54,-1);  // meshes 1,2,4,5
1098
    effect[3].setMeshAssociation(18,-1);  // meshes 1,4
1099
    effect[4].setMeshAssociation(36,-1);  // meshes 2,5
1100

    
1101
    return effect;
1102
    }
1103

    
1104
///////////////////////////////////////////////////////////////////////////////////////////////////
1105

    
1106
  VertexEffect[] createVertexEffectsRexEdge()
1107
    {
1108
    float E = 0.5f - REX_D;
1109
    float F = 0.5f;
1110
    float G = (float)Math.sqrt(E*E+F*F);
1111
    float A = (float)((180/Math.PI)*Math.asin(E/G));
1112

    
1113
    Static3D move1 = new Static3D(    0.0f, -E/3, 0.0f);
1114
    Static3D move2 = new Static3D(2*G/3 -F, +E/3, 0.0f);
1115

    
1116
    Static3D center0= new Static3D(0.0f, 0.0f, 0.0f);
1117
    Static3D center1= new Static3D(  -F, 0.0f, 0.0f);
1118
    Static3D center2= new Static3D(  +F, 0.0f, 0.0f);
1119
    Static3D axisX  = new Static3D(1.0f, 0.0f, 0.0f);
1120
    Static3D axisY  = new Static3D(0.0f, 1.0f, 0.0f);
1121
    Static3D axisZ  = new Static3D(0.0f, 0.0f, 1.0f);
1122

    
1123
    Static1D angle180 = new Static1D(180);
1124
    Static1D angle90  = new Static1D( 90);
1125
    Static1D angle270 = new Static1D(270);
1126
    Static1D angle1   = new Static1D(+A);
1127
    Static1D angle2   = new Static1D(-A);
1128

    
1129
    VertexEffect[] effect = new VertexEffect[12];
1130

    
1131
    effect[0] = new VertexEffectMove(move1);
1132
    effect[1] = new VertexEffectMove(move2);
1133
    effect[2] = new VertexEffectRotate(  angle90, axisX, center0 );
1134
    effect[3] = new VertexEffectRotate( angle270, axisX, center0 );
1135
    effect[4] = new VertexEffectRotate( angle180, axisX, center0 );
1136
    effect[5] = new VertexEffectRotate( angle180, axisY, center0 );
1137
    effect[6] = new VertexEffectScale ( new Static3D(-1, 1, 1) );
1138
    effect[7] = new VertexEffectScale ( new Static3D( 1,-1, 1) );
1139
    effect[8] = new VertexEffectRotate(   angle1, axisY, center1);
1140
    effect[9] = new VertexEffectRotate(   angle2, axisY, center2);
1141
    effect[10]= new VertexEffectRotate(   angle2, axisZ, center1);
1142
    effect[11]= new VertexEffectRotate(   angle1, axisZ, center2);
1143

    
1144
    effect[0].setMeshAssociation( 3,-1);  // meshes 0 & 1
1145
    effect[1].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1146
    effect[2].setMeshAssociation( 2,-1);  // meshes 1
1147
    effect[3].setMeshAssociation(12,-1);  // meshes 2,3
1148
    effect[4].setMeshAssociation(48,-1);  // meshes 4,5
1149
    effect[5].setMeshAssociation(32,-1);  // mesh 5
1150
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
1151
    effect[7].setMeshAssociation( 2,-1);  // apply to mesh 1
1152
    effect[8].setMeshAssociation(16,-1);  // apply to mesh 4
1153
    effect[9].setMeshAssociation(32,-1);  // apply to mesh 5
1154
    effect[10].setMeshAssociation(4,-1);  // apply to mesh 2
1155
    effect[11].setMeshAssociation(8,-1);  // apply to mesh 3
1156

    
1157
    return effect;
1158
    }
1159

    
1160
///////////////////////////////////////////////////////////////////////////////////////////////////
1161

    
1162
  VertexEffect[] createVertexEffectsRexCorner()
1163
    {
1164
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1165
    Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f);
1166
    Static1D angle = new Static1D(225);
1167

    
1168
    VertexEffect[] effect = new VertexEffect[1];
1169
    effect[0] = new VertexEffectRotate(angle, axisZ, center);
1170

    
1171
    return effect;
1172
    }
1173

    
1174
///////////////////////////////////////////////////////////////////////////////////////////////////
1175
// OBJECTS
1176
///////////////////////////////////////////////////////////////////////////////////////////////////
1177
// CUBE
1178

    
1179
  MeshBase createCubeMesh(int index)
1180
    {
1181
    MeshBase mesh = createFacesCube(index);
1182
    VertexEffect[] effects = createVertexEffectsCube();
1183
    for( VertexEffect effect : effects ) mesh.apply(effect);
1184

    
1185
    Static3D roundingCenter  = new Static3D(0,0,0);
1186
    Static3D[] vertices = new Static3D[8];
1187
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1188
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1189
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1190
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1191
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1192
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1193
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1194
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1195

    
1196
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
1197

    
1198
    mesh.mergeEffComponents();
1199

    
1200
    return mesh;
1201
    }
1202

    
1203
///////////////////////////////////////////////////////////////////////////////////////////////////
1204
// SKEWB
1205

    
1206
  MeshBase createSkewbCornerMesh()
1207
    {
1208
    MeshBase mesh = createFacesSkewbCorner();
1209
    VertexEffect[] effects = createVertexEffectsSkewbCorner();
1210
    for( VertexEffect effect : effects ) mesh.apply(effect);
1211

    
1212
    float E = 0.5f;
1213
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1214

    
1215
    Static3D[] verticesType1 = new Static3D[1];
1216
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1217
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1218

    
1219
    Static3D[] verticesType2 = new Static3D[3];
1220
    verticesType2[0] = new Static3D(-E, 0, 0);
1221
    verticesType2[1] = new Static3D( 0,-E, 0);
1222
    verticesType2[2] = new Static3D( 0, 0,-E);
1223
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1224

    
1225
    mesh.mergeEffComponents();
1226

    
1227
    return mesh;
1228
    }
1229

    
1230
///////////////////////////////////////////////////////////////////////////////////////////////////
1231

    
1232
  MeshBase createSkewbFaceMesh()
1233
    {
1234
    MeshBase mesh = createFacesSkewbFace();
1235
    VertexEffect[] effects = createVertexEffectsSkewbFace();
1236
    for( VertexEffect effect : effects ) mesh.apply(effect);
1237

    
1238
    Static3D roundingCenter = new Static3D(0,0,-0.2f);
1239
    float E = SQ2/4;
1240
    Static3D[] vertices = new Static3D[4];
1241
    vertices[0] = new Static3D(-E*SQ2,      0, 0);
1242
    vertices[1] = new Static3D(+E*SQ2,      0, 0);
1243
    vertices[2] = new Static3D(     0, -E*SQ2, 0);
1244
    vertices[3] = new Static3D(     0, +E*SQ2, 0);
1245
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
1246

    
1247
    mesh.mergeEffComponents();
1248
    mesh.addEmptyTexComponent();
1249

    
1250
    return mesh;
1251
    }
1252

    
1253
///////////////////////////////////////////////////////////////////////////////////////////////////
1254
// SKEWB DIAMOND / PYRAMINX
1255

    
1256
  MeshBase createOctaMesh()
1257
    {
1258
    MeshBase mesh = createFacesOcta();
1259
    VertexEffect[] effects = createVertexEffectsOcta();
1260
    for( VertexEffect effect : effects ) mesh.apply(effect);
1261

    
1262
    Static3D roundingCenter = new Static3D(0,0,0);
1263
    Static3D[] vertices = new Static3D[6];
1264
    vertices[0] = new Static3D(    0, SQ2/2,    0 );
1265
    vertices[1] = new Static3D( 0.5f,     0, 0.5f );
1266
    vertices[2] = new Static3D(-0.5f,     0, 0.5f );
1267
    vertices[3] = new Static3D(    0,-SQ2/2,    0 );
1268
    vertices[4] = new Static3D(-0.5f,     0,-0.5f );
1269
    vertices[5] = new Static3D( 0.5f,     0,-0.5f );
1270

    
1271
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
1272

    
1273
    mesh.mergeEffComponents();
1274

    
1275
    return mesh;
1276
    }
1277

    
1278
///////////////////////////////////////////////////////////////////////////////////////////////////
1279

    
1280
  MeshBase createTetraMesh()
1281
    {
1282
    MeshBase mesh = createFacesTetra();
1283
    VertexEffect[] effects = createVertexEffectsTetra();
1284
    for( VertexEffect effect : effects ) mesh.apply(effect);
1285

    
1286
    Static3D roundingCenter = new Static3D(0,0,0);
1287
    Static3D[] verticesRound = new Static3D[4];
1288
    verticesRound[0] = new Static3D(-0.5f,+SQ2/4,   0 );
1289
    verticesRound[1] = new Static3D(+0.5f,+SQ2/4,   0 );
1290
    verticesRound[2] = new Static3D(    0,-SQ2/4,+0.5f);
1291
    verticesRound[3] = new Static3D(    0,-SQ2/4,-0.5f);
1292
    roundCorners(mesh,roundingCenter,verticesRound,0.08f,0.15f);
1293

    
1294
    mesh.mergeEffComponents();
1295
    mesh.addEmptyTexComponent();
1296
    mesh.addEmptyTexComponent();
1297
    mesh.addEmptyTexComponent();
1298
    mesh.addEmptyTexComponent();
1299

    
1300
    return mesh;
1301
    }
1302

    
1303
///////////////////////////////////////////////////////////////////////////////////////////////////
1304
// DINO
1305

    
1306
  MeshBase createDinoMesh()
1307
    {
1308
    MeshBase mesh = createFacesDino();
1309
    VertexEffect[] effects = createVertexEffectsDino();
1310
    for( VertexEffect effect : effects ) mesh.apply(effect);
1311

    
1312
    float F = 0.5f;
1313
    Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
1314
    Static3D[] verticesRound = new Static3D[4];
1315
    verticesRound[0] = new Static3D(     0,-3*F,    0 );
1316
    verticesRound[1] = new Static3D(     0,   0, -3*F );
1317
    verticesRound[2] = new Static3D(  -3*F,   0,    0 );
1318
    verticesRound[3] = new Static3D(  +3*F,   0,    0 );
1319
    roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
1320

    
1321
    mesh.mergeEffComponents();
1322

    
1323
    return mesh;
1324
    }
1325

    
1326
///////////////////////////////////////////////////////////////////////////////////////////////////
1327
// Helicopter
1328

    
1329
  MeshBase createHelicopterCornerMesh()
1330
    {
1331
    MeshBase mesh = createFacesHelicopterCorner();
1332
    VertexEffect[] effects = createVertexEffectsHelicopterCorner();
1333
    for( VertexEffect effect : effects ) mesh.apply(effect);
1334

    
1335
    float E = 0.5f;
1336
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1337

    
1338
    Static3D[] verticesType1 = new Static3D[1];
1339
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1340
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1341

    
1342
    Static3D[] verticesType2 = new Static3D[3];
1343
    verticesType2[0] = new Static3D(-E, 0, 0);
1344
    verticesType2[1] = new Static3D( 0,-E, 0);
1345
    verticesType2[2] = new Static3D( 0, 0,-E);
1346
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1347

    
1348
    mesh.mergeEffComponents();
1349

    
1350
    return mesh;
1351
    }
1352

    
1353
///////////////////////////////////////////////////////////////////////////////////////////////////
1354

    
1355
  MeshBase createHelicopterFaceMesh()
1356
    {
1357
    MeshBase mesh = createFacesHelicopterFace();
1358
    VertexEffect[] effects = createVertexEffectsHelicopterFace();
1359
    for( VertexEffect effect : effects ) mesh.apply(effect);
1360

    
1361
    float E = 0.5f;
1362
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
1363

    
1364
    Static3D[] verticesType1 = new Static3D[1];
1365
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
1366
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
1367

    
1368
    Static3D[] verticesType2 = new Static3D[2];
1369
    verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
1370
    verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
1371
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1372

    
1373
    mesh.mergeEffComponents();
1374
    mesh.addEmptyTexComponent();
1375
    mesh.addEmptyTexComponent();
1376

    
1377
    return mesh;
1378
    }
1379

    
1380
///////////////////////////////////////////////////////////////////////////////////////////////////
1381
// Redi cube
1382

    
1383
  MeshBase createRediEdgeMesh()
1384
    {
1385
    MeshBase mesh = createFacesRediEdge();
1386
    VertexEffect[] effects = createVertexEffectsRediEdge();
1387
    for( VertexEffect effect : effects ) mesh.apply(effect);
1388

    
1389
    Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
1390
    Static3D[] vertices = new Static3D[2];
1391
    vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
1392
    vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
1393
    roundCorners(mesh,center,vertices,0.06f,0.20f);
1394

    
1395
    mesh.mergeEffComponents();
1396

    
1397
    return mesh;
1398
    }
1399

    
1400
///////////////////////////////////////////////////////////////////////////////////////////////////
1401

    
1402
  MeshBase createRediCornerMesh()
1403
    {
1404
    MeshBase mesh = createFacesRediCorner();
1405
    VertexEffect[] effects = createVertexEffectsRediCorner();
1406
    for( VertexEffect effect : effects ) mesh.apply(effect);
1407

    
1408
    Static3D center = new Static3D(0,0,0);
1409
    Static3D[] vertices = new Static3D[8];
1410
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1411
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1412
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1413
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1414
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1415
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1416
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1417
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1418

    
1419
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1420

    
1421
    mesh.mergeEffComponents();
1422

    
1423
    return mesh;
1424
    }
1425

    
1426
///////////////////////////////////////////////////////////////////////////////////////////////////
1427

    
1428
  MeshBase createIvyCornerMesh()
1429
    {
1430
    MeshBase mesh = createFacesIvyCorner();
1431
    VertexEffect[] effects = createVertexEffectsIvyCorner();
1432
    for( VertexEffect effect : effects ) mesh.apply(effect);
1433

    
1434
    Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
1435
    Static3D[] vertices = new Static3D[4];
1436
    vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f);
1437
    vertices[1] = new Static3D(-1.0f,+0.0f,+0.0f);
1438
    vertices[2] = new Static3D(+0.0f,-1.0f,+0.0f);
1439
    vertices[3] = new Static3D(+0.0f,+0.0f,-1.0f);
1440

    
1441
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1442

    
1443
    mesh.mergeEffComponents();
1444

    
1445
    return mesh;
1446
    }
1447

    
1448
///////////////////////////////////////////////////////////////////////////////////////////////////
1449

    
1450
  MeshBase createIvyFaceMesh()
1451
    {
1452
    MeshBase mesh = createFacesIvyFace();
1453

    
1454
    Static3D center = new Static3D(-0.0f,-0.0f,-0.5f);
1455
    Static3D[] vertices = new Static3D[2];
1456
    vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f);
1457
    vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f);
1458

    
1459
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1460

    
1461
    mesh.mergeEffComponents();
1462
    mesh.addEmptyTexComponent();
1463
    mesh.addEmptyTexComponent();
1464
    mesh.addEmptyTexComponent();
1465
    mesh.addEmptyTexComponent();
1466

    
1467
    return mesh;
1468
    }
1469

    
1470
///////////////////////////////////////////////////////////////////////////////////////////////////
1471

    
1472
  MeshBase createRexCornerMesh()
1473
    {
1474
    MeshBase mesh = createFacesRexCorner();
1475
    VertexEffect[] effects = createVertexEffectsRexCorner();
1476
    for( VertexEffect effect : effects ) mesh.apply(effect);
1477

    
1478
    final float G = (1-REX_D)/3;
1479
    Static3D center = new Static3D(0.0f,0.0f,-G*SQ2/2);
1480
    Static3D[] vertices = new Static3D[1];
1481
    vertices[0] = new Static3D(+G,-G,+0.0f);
1482
    roundCorners(mesh,center,vertices,0.10f,0.10f);
1483

    
1484
    mesh.mergeEffComponents();
1485
    mesh.addEmptyTexComponent();
1486
    mesh.addEmptyTexComponent();
1487
    mesh.addEmptyTexComponent();
1488
    mesh.addEmptyTexComponent();
1489

    
1490
    return mesh;
1491
    }
1492

    
1493
///////////////////////////////////////////////////////////////////////////////////////////////////
1494

    
1495
  MeshBase createRexFaceMesh()
1496
    {
1497
    MeshBase mesh = createFacesRexFace();
1498

    
1499
    mesh.mergeEffComponents();
1500
    mesh.addEmptyTexComponent();
1501
    mesh.addEmptyTexComponent();
1502
    mesh.addEmptyTexComponent();
1503
    mesh.addEmptyTexComponent();
1504

    
1505
    return mesh;
1506
    }
1507

    
1508
///////////////////////////////////////////////////////////////////////////////////////////////////
1509

    
1510
  MeshBase createRexEdgeMesh()
1511
    {
1512
    MeshBase mesh = createFacesRexEdge();
1513
    VertexEffect[] effects = createVertexEffectsRexEdge();
1514
    for( VertexEffect effect : effects ) mesh.apply(effect);
1515

    
1516
    Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
1517
    Static3D[] vertices = new Static3D[2];
1518
    vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
1519
    vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
1520
    roundCorners(mesh,center,vertices,0.06f,0.10f);
1521

    
1522
    mesh.mergeEffComponents();
1523

    
1524
    return mesh;
1525
    }
1526
  }
(2-2/26)