Project

General

Profile

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

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

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
///////////////////////////////////////////////////////////////////////////////////////////////////
679

    
680
  MeshBase createFacesMinxCorner()
681
    {
682
    MeshBase[] meshes = new MeshPolygon[6];
683

    
684
    float[] vertices0 = {  };   // TODO
685
    float[] bands0 = computeBands(0.03f,27,0.25f,0.5f,5);
686
    float[] vertices1 = {  };   // TODO
687
    float[] bands1 = computeBands(0.00f,27,0.25f,0.5f,2);
688

    
689
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
690
    meshes[0].setEffectAssociation(0, 1,0);
691
    meshes[1] = meshes[0].copy(true);
692
    meshes[1].setEffectAssociation(0, 2,0);
693
    meshes[2] = meshes[0].copy(true);
694
    meshes[2].setEffectAssociation(0, 4,0);
695
    meshes[3] = new MeshPolygon(vertices1, bands1, 0, 0);
696
    meshes[3].setEffectAssociation(0, 8,0);
697
    meshes[4] = meshes[3].copy(true);
698
    meshes[4].setEffectAssociation(0,16,0);
699
    meshes[5] = meshes[3].copy(true);
700
    meshes[5].setEffectAssociation(0,32,0);
701

    
702
    return new MeshJoined(meshes);
703
    }
704

    
705
///////////////////////////////////////////////////////////////////////////////////////////////////
706
// EFFECTS
707
///////////////////////////////////////////////////////////////////////////////////////////////////
708

    
709
  VertexEffect[] createVertexEffectsCube()
710
    {
711
    Static3D axisY   = new Static3D(0,1,0);
712
    Static3D axisX   = new Static3D(1,0,0);
713
    Static3D center  = new Static3D(0,0,0);
714
    Static1D angle90 = new Static1D(90);
715
    Static1D angle180= new Static1D(180);
716
    Static1D angle270= new Static1D(270);
717

    
718
    VertexEffect[] effect = new VertexEffect[6];
719

    
720
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
721
    effect[1] = new VertexEffectRotate( angle180, axisX, center );
722
    effect[2] = new VertexEffectRotate( angle90 , axisX, center );
723
    effect[3] = new VertexEffectRotate( angle270, axisX, center );
724
    effect[4] = new VertexEffectRotate( angle270, axisY, center );
725
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
726

    
727
    effect[0].setMeshAssociation(63,-1);  // all 6 sides
728
    effect[1].setMeshAssociation(32,-1);  // back
729
    effect[2].setMeshAssociation( 8,-1);  // bottom
730
    effect[3].setMeshAssociation( 4,-1);  // top
731
    effect[4].setMeshAssociation( 2,-1);  // left
732
    effect[5].setMeshAssociation( 1,-1);  // right
733

    
734
    return effect;
735
    }
736

    
737
///////////////////////////////////////////////////////////////////////////////////////////////////
738

    
739
  VertexEffect[] createVertexEffectsSkewbCorner()
740
    {
741
    float E = 0.5f;
742

    
743
    Static3D axisX  = new Static3D(1,0,0);
744
    Static3D axisY  = new Static3D(0,1,0);
745
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
746
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
747
    Static1D angle1 = new Static1D(+90);
748
    Static1D angle2 = new Static1D(-90);
749
    Static1D angle3 = new Static1D(-15);
750
    Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
751
    Static1D angle5 = new Static1D(120);
752
    Static1D angle6 = new Static1D(240);
753
    Static3D center1= new Static3D(0,0,0);
754
    Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
755
    Static3D move1  = new Static3D(-E/4,-E/4,0);
756
    Static3D move2  = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
757

    
758
    VertexEffect[] effect = new VertexEffect[10];
759

    
760
    effect[0] = new VertexEffectMove(move1);
761
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
762
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
763
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
764
    effect[4] = new VertexEffectMove(move2);
765
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
766
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
767
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
768
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
769
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
770

    
771
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
772
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
773
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
774
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
775
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
776
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
777
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
778
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
779
    effect[8].setMeshAssociation(16,-1);  // mesh 4
780
    effect[9].setMeshAssociation(32,-1);  // mesh 5
781

    
782
    return effect;
783
    }
784

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

    
787
  VertexEffect[] createVertexEffectsSkewbFace()
788
    {
789
    Static3D center = new Static3D(0,0,0);
790
    Static3D axisX  = new Static3D(1,0,0);
791
    Static3D axisZ  = new Static3D(0,0,1);
792
    float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
793

    
794
    VertexEffect[] effect = new VertexEffect[6];
795

    
796
    effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center);
797
    effect[1] = new VertexEffectRotate( new Static1D(  135), axisZ, center);
798
    effect[2] = new VertexEffectRotate( new Static1D(   45), axisZ, center);
799
    effect[3] = new VertexEffectRotate( new Static1D(  -45), axisZ, center);
800
    effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center);
801
    effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) );
802

    
803
    effect[0].setMeshAssociation(30,-1);  // meshes 1,2,3,4
804
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
805
    effect[2].setMeshAssociation( 5,-1);  // meshes 0,2
806
    effect[3].setMeshAssociation( 8,-1);  // mesh 3
807
    effect[4].setMeshAssociation(16,-1);  // mesh 4
808
    effect[5].setMeshAssociation(30,-1);  // meshes 1,2,3,4
809

    
810
    return effect;
811
    }
812

    
813
///////////////////////////////////////////////////////////////////////////////////////////////////
814

    
815
  VertexEffect[] createVertexEffectsOcta()
816
    {
817
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
818
    Static1D angle1= new Static1D( 90);
819
    Static1D angle2= new Static1D(180);
820
    Static1D angle3= new Static1D(270);
821
    Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
822
    Static3D axisX = new Static3D(1,0,0);
823
    Static3D axisY = new Static3D(0,1,0);
824
    Static3D cent0 = new Static3D(0,0,0);
825
    Static3D cent1 = new Static3D(0,SQ2/2,0);
826
    Static3D flipY = new Static3D( 1,-1, 1);
827
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
828

    
829
    VertexEffect[] effect = new VertexEffect[7];
830

    
831
    effect[0] = new VertexEffectScale(scale);
832
    effect[1] = new VertexEffectMove(move1);
833
    effect[2] = new VertexEffectRotate(alpha , axisX, cent1);
834
    effect[3] = new VertexEffectRotate(angle1, axisY, cent0);
835
    effect[4] = new VertexEffectRotate(angle2, axisY, cent0);
836
    effect[5] = new VertexEffectRotate(angle3, axisY, cent0);
837
    effect[6] = new VertexEffectScale(flipY);
838

    
839
    effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
840
    effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
841
    effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7
842
    effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
843

    
844
    return effect;
845
    }
846

    
847
///////////////////////////////////////////////////////////////////////////////////////////////////
848

    
849
  VertexEffect[] createVertexEffectsTetra()
850
    {
851
    Static3D flipZ = new Static3D( 1, 1,-1);
852
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
853
    Static1D angle1= new Static1D( 90);
854
    Static1D angle2= new Static1D(180);
855
    Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
856
    Static3D axisX = new Static3D(1,0,0);
857
    Static3D axisY = new Static3D(0,1,0);
858
    Static3D axisZ = new Static3D(0,0,1);
859
    Static3D cent0 = new Static3D(0,0,0);
860
    Static3D cent1 = new Static3D(0,SQ2/4,0);
861
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
862

    
863
    VertexEffect[] effect = new VertexEffect[7];
864

    
865
    effect[0] = new VertexEffectScale(scale);
866
    effect[1] = new VertexEffectRotate(angle2, axisZ, cent0);
867
    effect[2] = new VertexEffectMove(move1);
868
    effect[3] = new VertexEffectRotate(alpha , axisX, cent1);
869
    effect[4] = new VertexEffectScale(flipZ);
870
    effect[5] = new VertexEffectRotate(angle1, axisY, cent0);
871
    effect[6] = new VertexEffectRotate(angle2, axisZ, cent0);
872

    
873
    effect[4].setMeshAssociation(10,-1); // meshes 1 & 3
874
    effect[5].setMeshAssociation(12,-1); // meshes 2 & 3
875
    effect[6].setMeshAssociation(12,-1); // meshes 2 & 3
876

    
877
    return effect;
878
    }
879

    
880
///////////////////////////////////////////////////////////////////////////////////////////////////
881

    
882
  VertexEffect[] createVertexEffectsDino()
883
    {
884
    float E = 0.5f*SQ2;
885
    float F = 0.5f;
886
    final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
887

    
888
    Static1D angle1 = new Static1D(-ANGLE);
889
    Static1D angle2 = new Static1D(+ANGLE);
890
    Static3D axisX  = new Static3D(1,0,0);
891
    Static3D axisY  = new Static3D(0,1,0);
892
    Static3D axisZ  = new Static3D(0,-1,1);
893
    Static3D center0= new Static3D(0,0,0);
894
    Static3D center1= new Static3D(0,-3*F,0);
895

    
896
    VertexEffect[] effect = new VertexEffect[10];
897

    
898
    effect[0] = new VertexEffectScale ( new Static3D(3,3,3) );
899
    effect[1] = new VertexEffectMove  ( new Static3D(0,-F,0) );
900
    effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 );
901
    effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) );
902
    effect[4] = new VertexEffectMove  ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
903
    effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
904
    effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) );
905
    effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
906
    effect[8] = new VertexEffectRotate( angle1           , axisZ, center1 );
907
    effect[9] = new VertexEffectRotate( angle2           , axisZ, center1 );
908

    
909
    effect[0].setMeshAssociation(15,-1);  // apply to meshes 0,1,2,3
910
    effect[1].setMeshAssociation( 3,-1);  // apply to meshes 0,1
911
    effect[2].setMeshAssociation( 2,-1);  // apply to mesh 1
912
    effect[3].setMeshAssociation( 2,-1);  // apply to mesh 1
913
    effect[4].setMeshAssociation(12,-1);  // apply to meshes 2,3
914
    effect[5].setMeshAssociation(12,-1);  // apply to meshes 2,3
915
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
916
    effect[7].setMeshAssociation(12,-1);  // apply to meshes 2,3
917
    effect[8].setMeshAssociation( 4,-1);  // apply to mesh 2
918
    effect[9].setMeshAssociation( 8,-1);  // apply to mesh 3
919

    
920
    return effect;
921
    }
922

    
923
///////////////////////////////////////////////////////////////////////////////////////////////////
924

    
925
  VertexEffect[] createVertexEffectsHelicopterCorner()
926
    {
927
    float E = 0.5f;
928

    
929
    Static3D axisX  = new Static3D(1,0,0);
930
    Static3D axisY  = new Static3D(0,1,0);
931
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
932
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
933
    Static1D angle1 = new Static1D(+90);
934
    Static1D angle2 = new Static1D(-90);
935
    Static1D angle3 = new Static1D(-135);
936
    Static1D angle4 = new Static1D(90);
937
    Static1D angle5 = new Static1D(120);
938
    Static1D angle6 = new Static1D(240);
939
    Static3D center1= new Static3D(0,0,0);
940
    Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
941
    Static3D move1  = new Static3D(-E/4,-E/4,0);
942
    Static3D move2  = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
943

    
944
    VertexEffect[] effect = new VertexEffect[10];
945

    
946
    effect[0] = new VertexEffectMove(move1);
947
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
948
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
949
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
950
    effect[4] = new VertexEffectMove(move2);
951
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
952
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
953
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
954
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
955
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
956

    
957
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
958
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
959
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
960
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
961
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
962
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
963
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
964
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
965
    effect[8].setMeshAssociation(16,-1);  // mesh 4
966
    effect[9].setMeshAssociation(32,-1);  // mesh 5
967

    
968
    return effect;
969
    }
970

    
971
///////////////////////////////////////////////////////////////////////////////////////////////////
972

    
973
  VertexEffect[] createVertexEffectsHelicopterFace()
974
    {
975
    float E = 0.5f;
976
    float F = SQ2/4;
977

    
978
    Static3D move0  = new Static3D(-E/4, -E/4, 0);
979
    Static3D move1  = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
980
    Static3D move2  = new Static3D(-E/2, F/3, 0);
981
    Static3D move3  = new Static3D(+E/2, F/3, 0);
982
    Static3D move4  = new Static3D(+E/3,+E/3, 0);
983
    Static1D angle1 = new Static1D(135);
984
    Static1D angle2 = new Static1D(90);
985
    Static1D angle3 = new Static1D(-90);
986
    Static1D angle4 = new Static1D(-135);
987
    Static3D axisX  = new Static3D(1,0,0);
988
    Static3D axisY  = new Static3D(0,1,0);
989
    Static3D axisZ  = new Static3D(0,0,1);
990
    Static3D axis1  = new Static3D(1,-1,0);
991
    Static3D center = new Static3D(0,0,0);
992
    Static3D center1= new Static3D(-E/2,-E/2,0);
993

    
994
    VertexEffect[] effect = new VertexEffect[10];
995

    
996
    effect[0] = new VertexEffectMove(move0);
997
    effect[1] = new VertexEffectRotate(angle1, axisZ, center);
998
    effect[2] = new VertexEffectMove(move1);
999
    effect[3] = new VertexEffectRotate(angle2, axis1, center1);
1000
    effect[4] = new VertexEffectMove(move2);
1001
    effect[5] = new VertexEffectMove(move3);
1002
    effect[6] = new VertexEffectRotate(angle3, axisZ, center);
1003
    effect[7] = new VertexEffectRotate(angle4, axisX, center);
1004
    effect[8] = new VertexEffectRotate(angle1, axisY, center);
1005
    effect[9] = new VertexEffectMove(move4);
1006

    
1007
    effect[0].setMeshAssociation( 1,-1);  // mesh 0
1008
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
1009
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1010
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1011
    effect[4].setMeshAssociation( 4,-1);  // mesh 2
1012
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
1013
    effect[6].setMeshAssociation( 8,-1);  // mesh 3
1014
    effect[7].setMeshAssociation( 4,-1);  // mesh 2
1015
    effect[8].setMeshAssociation( 8,-1);  // mesh 3
1016
    effect[9].setMeshAssociation(15,-1);  // meshes 0,1,2,3
1017

    
1018
    return effect;
1019
    }
1020

    
1021
///////////////////////////////////////////////////////////////////////////////////////////////////
1022

    
1023
  VertexEffect[] createVertexEffectsRediEdge()
1024
    {
1025
    Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
1026
    Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
1027
    Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
1028
    Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
1029
    Static3D flipZ = new Static3D(1,1,-1);
1030
    Static3D flipX = new Static3D(-1,1,1);
1031
    Static3D scale = new Static3D(2,2,2);
1032
    Static3D cent0 = new Static3D(0,0, 0);
1033
    Static3D cent1 = new Static3D(0,0, -1.5f);
1034
    Static3D axisX = new Static3D(1,0, 0);
1035
    Static3D axisY = new Static3D(0,1, 0);
1036
    Static3D axis  = new Static3D(0,SQ2/2,-SQ2/2);
1037
    Static1D angle1= new Static1D(90);
1038
    Static1D angle2= new Static1D(45);
1039
    Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
1040

    
1041
    VertexEffect[] effect = new VertexEffect[12];
1042

    
1043
    effect[0] = new VertexEffectScale(scale);
1044
    effect[1] = new VertexEffectMove(move0);
1045
    effect[2] = new VertexEffectScale(flipZ);
1046
    effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
1047
    effect[4] = new VertexEffectMove(move1);
1048
    effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
1049
    effect[6] = new VertexEffectMove(move2);
1050
    effect[7] = new VertexEffectScale(flipX);
1051
    effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
1052
    effect[9] = new VertexEffectMove(move3);
1053
    effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
1054
    effect[11]= new VertexEffectScale(flipX);
1055

    
1056
    effect[0].setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
1057
    effect[1].setMeshAssociation( 3,-1);  // meshes 0,1
1058
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1059
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1060
    effect[4].setMeshAssociation(12,-1);  // meshes 2,3
1061
    effect[5].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1062
    effect[6].setMeshAssociation(12,-1);  // meshes 2,3
1063
    effect[7].setMeshAssociation( 8,-1);  // mesh 3
1064
    effect[8].setMeshAssociation(48,-1);  // meshes 4,5
1065
    effect[9].setMeshAssociation(48,-1);  // meshes 4,5
1066
    effect[10].setMeshAssociation(48,-1); // meshes 4,5
1067
    effect[11].setMeshAssociation(32,-1); // mesh 5
1068

    
1069
    return effect;
1070
    }
1071

    
1072
///////////////////////////////////////////////////////////////////////////////////////////////////
1073

    
1074
  VertexEffect[] createVertexEffectsRediCorner()
1075
    {
1076
    Static3D axisY   = new Static3D(0,1,0);
1077
    Static3D axisX   = new Static3D(1,0,0);
1078
    Static3D axisZ   = new Static3D(0,0,1);
1079
    Static3D center  = new Static3D(0,0,0);
1080
    Static1D angle90 = new Static1D(90);
1081
    Static1D angle270= new Static1D(270);
1082
    Static1D angle45 = new Static1D(-45);
1083
    Static3D scale   = new Static3D(1.0f, SQ2, 1.0f);
1084

    
1085
    VertexEffect[] effect = new VertexEffect[7];
1086

    
1087
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
1088
    effect[1] = new VertexEffectRotate( angle270, axisX, center );
1089
    effect[2] = new VertexEffectRotate( angle90 , axisY, center );
1090
    effect[3] = new VertexEffectScale(scale);
1091
    effect[4] = new VertexEffectRotate( angle45 , axisX, center );
1092
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
1093
    effect[6] = new VertexEffectRotate( angle270, axisZ, center );
1094

    
1095
    effect[0].setMeshAssociation( 7,-1);  // 0,1,2
1096
    effect[1].setMeshAssociation( 2,-1);  // 1
1097
    effect[2].setMeshAssociation( 4,-1);  // 2
1098
    effect[3].setMeshAssociation(56,-1);  // 3,4,5
1099
    effect[4].setMeshAssociation(56,-1);  // 3,4,5
1100
    effect[5].setMeshAssociation(16,-1);  // 4
1101
    effect[6].setMeshAssociation(32,-1);  // 5
1102

    
1103
    return effect;
1104
    }
1105

    
1106
///////////////////////////////////////////////////////////////////////////////////////////////////
1107

    
1108
  VertexEffect[] createVertexEffectsIvyCorner()
1109
    {
1110
    Static3D axisX  = new Static3D(1,0,0);
1111
    Static3D axisY  = new Static3D(0,1,0);
1112
    Static1D angle1 = new Static1D(+90);
1113
    Static1D angle2 = new Static1D(-90);
1114
    Static3D center = new Static3D(0,0,0);
1115
    Static3D move1  = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
1116

    
1117
    VertexEffect[] effect = new VertexEffect[5];
1118

    
1119
    effect[0] = new VertexEffectScale(1/IVY_C);
1120
    effect[1] = new VertexEffectMove(move1);
1121
    effect[2] = new VertexEffectScale(new Static3D(1,1,-1));
1122
    effect[3] = new VertexEffectRotate(angle1,axisX,center);
1123
    effect[4] = new VertexEffectRotate(angle2,axisY,center);
1124

    
1125
    effect[2].setMeshAssociation(54,-1);  // meshes 1,2,4,5
1126
    effect[3].setMeshAssociation(18,-1);  // meshes 1,4
1127
    effect[4].setMeshAssociation(36,-1);  // meshes 2,5
1128

    
1129
    return effect;
1130
    }
1131

    
1132
///////////////////////////////////////////////////////////////////////////////////////////////////
1133

    
1134
  VertexEffect[] createVertexEffectsRexEdge()
1135
    {
1136
    float E = 0.5f - REX_D;
1137
    float F = 0.5f;
1138
    float G = (float)Math.sqrt(E*E+F*F);
1139
    float A = (float)((180/Math.PI)*Math.asin(E/G));
1140

    
1141
    Static3D move1 = new Static3D(    0.0f, -E/3, 0.0f);
1142
    Static3D move2 = new Static3D(2*G/3 -F, +E/3, 0.0f);
1143

    
1144
    Static3D center0= new Static3D(0.0f, 0.0f, 0.0f);
1145
    Static3D center1= new Static3D(  -F, 0.0f, 0.0f);
1146
    Static3D center2= new Static3D(  +F, 0.0f, 0.0f);
1147
    Static3D axisX  = new Static3D(1.0f, 0.0f, 0.0f);
1148
    Static3D axisY  = new Static3D(0.0f, 1.0f, 0.0f);
1149
    Static3D axisZ  = new Static3D(0.0f, 0.0f, 1.0f);
1150

    
1151
    Static1D angle180 = new Static1D(180);
1152
    Static1D angle90  = new Static1D( 90);
1153
    Static1D angle270 = new Static1D(270);
1154
    Static1D angle1   = new Static1D(+A);
1155
    Static1D angle2   = new Static1D(-A);
1156

    
1157
    VertexEffect[] effect = new VertexEffect[12];
1158

    
1159
    effect[0] = new VertexEffectMove(move1);
1160
    effect[1] = new VertexEffectMove(move2);
1161
    effect[2] = new VertexEffectRotate(  angle90, axisX, center0 );
1162
    effect[3] = new VertexEffectRotate( angle270, axisX, center0 );
1163
    effect[4] = new VertexEffectRotate( angle180, axisX, center0 );
1164
    effect[5] = new VertexEffectRotate( angle180, axisY, center0 );
1165
    effect[6] = new VertexEffectScale ( new Static3D(-1, 1, 1) );
1166
    effect[7] = new VertexEffectScale ( new Static3D( 1,-1, 1) );
1167
    effect[8] = new VertexEffectRotate(   angle1, axisY, center1);
1168
    effect[9] = new VertexEffectRotate(   angle2, axisY, center2);
1169
    effect[10]= new VertexEffectRotate(   angle2, axisZ, center1);
1170
    effect[11]= new VertexEffectRotate(   angle1, axisZ, center2);
1171

    
1172
    effect[0].setMeshAssociation( 3,-1);  // meshes 0 & 1
1173
    effect[1].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1174
    effect[2].setMeshAssociation( 2,-1);  // meshes 1
1175
    effect[3].setMeshAssociation(12,-1);  // meshes 2,3
1176
    effect[4].setMeshAssociation(48,-1);  // meshes 4,5
1177
    effect[5].setMeshAssociation(32,-1);  // mesh 5
1178
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
1179
    effect[7].setMeshAssociation( 2,-1);  // apply to mesh 1
1180
    effect[8].setMeshAssociation(16,-1);  // apply to mesh 4
1181
    effect[9].setMeshAssociation(32,-1);  // apply to mesh 5
1182
    effect[10].setMeshAssociation(4,-1);  // apply to mesh 2
1183
    effect[11].setMeshAssociation(8,-1);  // apply to mesh 3
1184

    
1185
    return effect;
1186
    }
1187

    
1188
///////////////////////////////////////////////////////////////////////////////////////////////////
1189

    
1190
  VertexEffect[] createVertexEffectsRexCorner()
1191
    {
1192
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1193
    Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f);
1194
    Static1D angle = new Static1D(225);
1195

    
1196
    VertexEffect[] effect = new VertexEffect[1];
1197
    effect[0] = new VertexEffectRotate(angle, axisZ, center);
1198

    
1199
    return effect;
1200
    }
1201

    
1202
///////////////////////////////////////////////////////////////////////////////////////////////////
1203

    
1204
  VertexEffect[] createVertexEffectsMinxCorner()
1205
    {
1206
    // TODO
1207

    
1208
    return null;
1209
    }
1210

    
1211
///////////////////////////////////////////////////////////////////////////////////////////////////
1212
// OBJECTS
1213
///////////////////////////////////////////////////////////////////////////////////////////////////
1214
// CUBE
1215

    
1216
  MeshBase createCubeMesh(int index)
1217
    {
1218
    MeshBase mesh = createFacesCube(index);
1219
    VertexEffect[] effects = createVertexEffectsCube();
1220
    for( VertexEffect effect : effects ) mesh.apply(effect);
1221

    
1222
    Static3D roundingCenter  = new Static3D(0,0,0);
1223
    Static3D[] vertices = new Static3D[8];
1224
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1225
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1226
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1227
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1228
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1229
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1230
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1231
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1232

    
1233
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
1234

    
1235
    mesh.mergeEffComponents();
1236

    
1237
    return mesh;
1238
    }
1239

    
1240
///////////////////////////////////////////////////////////////////////////////////////////////////
1241
// SKEWB
1242

    
1243
  MeshBase createSkewbCornerMesh()
1244
    {
1245
    MeshBase mesh = createFacesSkewbCorner();
1246
    VertexEffect[] effects = createVertexEffectsSkewbCorner();
1247
    for( VertexEffect effect : effects ) mesh.apply(effect);
1248

    
1249
    float E = 0.5f;
1250
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1251

    
1252
    Static3D[] verticesType1 = new Static3D[1];
1253
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1254
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1255

    
1256
    Static3D[] verticesType2 = new Static3D[3];
1257
    verticesType2[0] = new Static3D(-E, 0, 0);
1258
    verticesType2[1] = new Static3D( 0,-E, 0);
1259
    verticesType2[2] = new Static3D( 0, 0,-E);
1260
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1261

    
1262
    mesh.mergeEffComponents();
1263

    
1264
    return mesh;
1265
    }
1266

    
1267
///////////////////////////////////////////////////////////////////////////////////////////////////
1268

    
1269
  MeshBase createSkewbFaceMesh()
1270
    {
1271
    MeshBase mesh = createFacesSkewbFace();
1272
    VertexEffect[] effects = createVertexEffectsSkewbFace();
1273
    for( VertexEffect effect : effects ) mesh.apply(effect);
1274

    
1275
    Static3D roundingCenter = new Static3D(0,0,-0.2f);
1276
    float E = SQ2/4;
1277
    Static3D[] vertices = new Static3D[4];
1278
    vertices[0] = new Static3D(-E*SQ2,      0, 0);
1279
    vertices[1] = new Static3D(+E*SQ2,      0, 0);
1280
    vertices[2] = new Static3D(     0, -E*SQ2, 0);
1281
    vertices[3] = new Static3D(     0, +E*SQ2, 0);
1282
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
1283

    
1284
    mesh.mergeEffComponents();
1285
    mesh.addEmptyTexComponent();
1286

    
1287
    return mesh;
1288
    }
1289

    
1290
///////////////////////////////////////////////////////////////////////////////////////////////////
1291
// SKEWB DIAMOND / PYRAMINX
1292

    
1293
  MeshBase createOctaMesh()
1294
    {
1295
    MeshBase mesh = createFacesOcta();
1296
    VertexEffect[] effects = createVertexEffectsOcta();
1297
    for( VertexEffect effect : effects ) mesh.apply(effect);
1298

    
1299
    Static3D roundingCenter = new Static3D(0,0,0);
1300
    Static3D[] vertices = new Static3D[6];
1301
    vertices[0] = new Static3D(    0, SQ2/2,    0 );
1302
    vertices[1] = new Static3D( 0.5f,     0, 0.5f );
1303
    vertices[2] = new Static3D(-0.5f,     0, 0.5f );
1304
    vertices[3] = new Static3D(    0,-SQ2/2,    0 );
1305
    vertices[4] = new Static3D(-0.5f,     0,-0.5f );
1306
    vertices[5] = new Static3D( 0.5f,     0,-0.5f );
1307

    
1308
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
1309

    
1310
    mesh.mergeEffComponents();
1311

    
1312
    return mesh;
1313
    }
1314

    
1315
///////////////////////////////////////////////////////////////////////////////////////////////////
1316

    
1317
  MeshBase createTetraMesh()
1318
    {
1319
    MeshBase mesh = createFacesTetra();
1320
    VertexEffect[] effects = createVertexEffectsTetra();
1321
    for( VertexEffect effect : effects ) mesh.apply(effect);
1322

    
1323
    Static3D roundingCenter = new Static3D(0,0,0);
1324
    Static3D[] verticesRound = new Static3D[4];
1325
    verticesRound[0] = new Static3D(-0.5f,+SQ2/4,   0 );
1326
    verticesRound[1] = new Static3D(+0.5f,+SQ2/4,   0 );
1327
    verticesRound[2] = new Static3D(    0,-SQ2/4,+0.5f);
1328
    verticesRound[3] = new Static3D(    0,-SQ2/4,-0.5f);
1329
    roundCorners(mesh,roundingCenter,verticesRound,0.08f,0.15f);
1330

    
1331
    mesh.mergeEffComponents();
1332
    mesh.addEmptyTexComponent();
1333
    mesh.addEmptyTexComponent();
1334
    mesh.addEmptyTexComponent();
1335
    mesh.addEmptyTexComponent();
1336

    
1337
    return mesh;
1338
    }
1339

    
1340
///////////////////////////////////////////////////////////////////////////////////////////////////
1341
// DINO
1342

    
1343
  MeshBase createDinoMesh()
1344
    {
1345
    MeshBase mesh = createFacesDino();
1346
    VertexEffect[] effects = createVertexEffectsDino();
1347
    for( VertexEffect effect : effects ) mesh.apply(effect);
1348

    
1349
    float F = 0.5f;
1350
    Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
1351
    Static3D[] verticesRound = new Static3D[4];
1352
    verticesRound[0] = new Static3D(     0,-3*F,    0 );
1353
    verticesRound[1] = new Static3D(     0,   0, -3*F );
1354
    verticesRound[2] = new Static3D(  -3*F,   0,    0 );
1355
    verticesRound[3] = new Static3D(  +3*F,   0,    0 );
1356
    roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
1357

    
1358
    mesh.mergeEffComponents();
1359

    
1360
    return mesh;
1361
    }
1362

    
1363
///////////////////////////////////////////////////////////////////////////////////////////////////
1364
// Helicopter
1365

    
1366
  MeshBase createHelicopterCornerMesh()
1367
    {
1368
    MeshBase mesh = createFacesHelicopterCorner();
1369
    VertexEffect[] effects = createVertexEffectsHelicopterCorner();
1370
    for( VertexEffect effect : effects ) mesh.apply(effect);
1371

    
1372
    float E = 0.5f;
1373
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1374

    
1375
    Static3D[] verticesType1 = new Static3D[1];
1376
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1377
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1378

    
1379
    Static3D[] verticesType2 = new Static3D[3];
1380
    verticesType2[0] = new Static3D(-E, 0, 0);
1381
    verticesType2[1] = new Static3D( 0,-E, 0);
1382
    verticesType2[2] = new Static3D( 0, 0,-E);
1383
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1384

    
1385
    mesh.mergeEffComponents();
1386

    
1387
    return mesh;
1388
    }
1389

    
1390
///////////////////////////////////////////////////////////////////////////////////////////////////
1391

    
1392
  MeshBase createHelicopterFaceMesh()
1393
    {
1394
    MeshBase mesh = createFacesHelicopterFace();
1395
    VertexEffect[] effects = createVertexEffectsHelicopterFace();
1396
    for( VertexEffect effect : effects ) mesh.apply(effect);
1397

    
1398
    float E = 0.5f;
1399
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
1400

    
1401
    Static3D[] verticesType1 = new Static3D[1];
1402
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
1403
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
1404

    
1405
    Static3D[] verticesType2 = new Static3D[2];
1406
    verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
1407
    verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
1408
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1409

    
1410
    mesh.mergeEffComponents();
1411
    mesh.addEmptyTexComponent();
1412
    mesh.addEmptyTexComponent();
1413

    
1414
    return mesh;
1415
    }
1416

    
1417
///////////////////////////////////////////////////////////////////////////////////////////////////
1418
// Redi cube
1419

    
1420
  MeshBase createRediEdgeMesh()
1421
    {
1422
    MeshBase mesh = createFacesRediEdge();
1423
    VertexEffect[] effects = createVertexEffectsRediEdge();
1424
    for( VertexEffect effect : effects ) mesh.apply(effect);
1425

    
1426
    Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
1427
    Static3D[] vertices = new Static3D[2];
1428
    vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
1429
    vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
1430
    roundCorners(mesh,center,vertices,0.06f,0.20f);
1431

    
1432
    mesh.mergeEffComponents();
1433

    
1434
    return mesh;
1435
    }
1436

    
1437
///////////////////////////////////////////////////////////////////////////////////////////////////
1438

    
1439
  MeshBase createRediCornerMesh()
1440
    {
1441
    MeshBase mesh = createFacesRediCorner();
1442
    VertexEffect[] effects = createVertexEffectsRediCorner();
1443
    for( VertexEffect effect : effects ) mesh.apply(effect);
1444

    
1445
    Static3D center = new Static3D(0,0,0);
1446
    Static3D[] vertices = new Static3D[8];
1447
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1448
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1449
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1450
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1451
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1452
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1453
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1454
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1455

    
1456
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1457

    
1458
    mesh.mergeEffComponents();
1459

    
1460
    return mesh;
1461
    }
1462

    
1463
///////////////////////////////////////////////////////////////////////////////////////////////////
1464

    
1465
  MeshBase createIvyCornerMesh()
1466
    {
1467
    MeshBase mesh = createFacesIvyCorner();
1468
    VertexEffect[] effects = createVertexEffectsIvyCorner();
1469
    for( VertexEffect effect : effects ) mesh.apply(effect);
1470

    
1471
    Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
1472
    Static3D[] vertices = new Static3D[4];
1473
    vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f);
1474
    vertices[1] = new Static3D(-1.0f,+0.0f,+0.0f);
1475
    vertices[2] = new Static3D(+0.0f,-1.0f,+0.0f);
1476
    vertices[3] = new Static3D(+0.0f,+0.0f,-1.0f);
1477

    
1478
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1479

    
1480
    mesh.mergeEffComponents();
1481

    
1482
    return mesh;
1483
    }
1484

    
1485
///////////////////////////////////////////////////////////////////////////////////////////////////
1486

    
1487
  MeshBase createIvyFaceMesh()
1488
    {
1489
    MeshBase mesh = createFacesIvyFace();
1490

    
1491
    Static3D center = new Static3D(-0.0f,-0.0f,-0.5f);
1492
    Static3D[] vertices = new Static3D[2];
1493
    vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f);
1494
    vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f);
1495

    
1496
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1497

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

    
1504
    return mesh;
1505
    }
1506

    
1507
///////////////////////////////////////////////////////////////////////////////////////////////////
1508

    
1509
  MeshBase createRexCornerMesh()
1510
    {
1511
    MeshBase mesh = createFacesRexCorner();
1512
    VertexEffect[] effects = createVertexEffectsRexCorner();
1513
    for( VertexEffect effect : effects ) mesh.apply(effect);
1514

    
1515
    final float G = (1-REX_D)/3;
1516
    Static3D center = new Static3D(0.0f,0.0f,-G*SQ2/2);
1517
    Static3D[] vertices = new Static3D[1];
1518
    vertices[0] = new Static3D(+G,-G,+0.0f);
1519
    roundCorners(mesh,center,vertices,0.10f,0.10f);
1520

    
1521
    mesh.mergeEffComponents();
1522
    mesh.addEmptyTexComponent();
1523
    mesh.addEmptyTexComponent();
1524
    mesh.addEmptyTexComponent();
1525
    mesh.addEmptyTexComponent();
1526

    
1527
    return mesh;
1528
    }
1529

    
1530
///////////////////////////////////////////////////////////////////////////////////////////////////
1531

    
1532
  MeshBase createRexFaceMesh()
1533
    {
1534
    MeshBase mesh = createFacesRexFace();
1535

    
1536
    mesh.mergeEffComponents();
1537
    mesh.addEmptyTexComponent();
1538
    mesh.addEmptyTexComponent();
1539
    mesh.addEmptyTexComponent();
1540
    mesh.addEmptyTexComponent();
1541

    
1542
    return mesh;
1543
    }
1544

    
1545
///////////////////////////////////////////////////////////////////////////////////////////////////
1546

    
1547
  MeshBase createRexEdgeMesh()
1548
    {
1549
    MeshBase mesh = createFacesRexEdge();
1550
    VertexEffect[] effects = createVertexEffectsRexEdge();
1551
    for( VertexEffect effect : effects ) mesh.apply(effect);
1552

    
1553
    Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
1554
    Static3D[] vertices = new Static3D[2];
1555
    vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
1556
    vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
1557
    roundCorners(mesh,center,vertices,0.06f,0.10f);
1558

    
1559
    mesh.mergeEffComponents();
1560

    
1561
    return mesh;
1562
    }
1563

    
1564
///////////////////////////////////////////////////////////////////////////////////////////////////
1565

    
1566
  MeshBase createMinxCornerMesh()
1567
    {
1568
    MeshBase mesh = createFacesMinxCorner();
1569
    VertexEffect[] effects = createVertexEffectsMinxCorner();
1570
    for( VertexEffect effect : effects ) mesh.apply(effect);
1571
/*
1572
    Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
1573
    Static3D[] vertices = new Static3D[2];
1574
    vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
1575
    vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
1576
    roundCorners(mesh,center,vertices,0.06f,0.10f);
1577
*/
1578
    mesh.mergeEffComponents();
1579

    
1580
    return mesh;
1581
    }
1582
  }
(2-2/28)