Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / FactoryCubit.java @ 59b87d56

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.03f;
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 int REX_N = 5;
49
  private static final Static1D RADIUS = new Static1D(1);
50
  private static FactoryCubit mThis;
51

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

    
54
  private FactoryCubit()
55
    {
56

    
57
    }
58

    
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60

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

    
65
    return mThis;
66
    }
67

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

    
103
///////////////////////////////////////////////////////////////////////////////////////////////////
104

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

    
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111

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

    
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119

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

    
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

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

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

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

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

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

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

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

    
173
    return bands;
174
    }
175

    
176
///////////////////////////////////////////////////////////////////////////////////////////////////
177

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

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

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

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

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

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

    
207
    double radAngle = Math.PI*angle/180;
208
    float sinA = (float)Math.sin(radAngle);
209
    float cosA = (float)Math.cos(radAngle);
210

    
211
    float rvx = vx*cosA +vy*sinA;
212
    float rvy =-vx*sinA +vy*cosA;
213

    
214
    array[index  ] = rvx + cx;
215
    array[index+1] = rvy + cy;
216
    }
217

    
218
///////////////////////////////////////////////////////////////////////////////////////////////////
219

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

    
224
    float E = 0.5f;
225
    int extraI, extraV, num;
226

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

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

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

    
251
    return new MeshJoined(meshes);
252
    }
253

    
254
///////////////////////////////////////////////////////////////////////////////////////////////////
255

    
256
  MeshBase createFacesSkewbCorner()
257
    {
258
    MeshBase[] meshes = new MeshBase[6];
259

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

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

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

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

    
283
    return new MeshJoined(meshes);
284
    }
285

    
286
///////////////////////////////////////////////////////////////////////////////////////////////////
287

    
288
  MeshBase createFacesSkewbFace()
289
    {
290
    MeshBase[] meshes = new MeshBase[5];
291

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

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

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

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

    
311
    return new MeshJoined(meshes);
312
    }
313

    
314
///////////////////////////////////////////////////////////////////////////////////////////////////
315

    
316
  MeshBase createFacesOcta()
317
    {
318
    MeshBase[] meshes = new MeshPolygon[8];
319

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

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

    
342
    return new MeshJoined(meshes);
343
    }
344

    
345
///////////////////////////////////////////////////////////////////////////////////////////////////
346

    
347
  MeshBase createFacesTetra()
348
    {
349
    MeshBase[] meshes = new MeshBase[4];
350

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

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

    
365
    return new MeshJoined(meshes);
366
    }
367

    
368
///////////////////////////////////////////////////////////////////////////////////////////////////
369

    
370
  MeshBase createFacesDino()
371
    {
372
    MeshBase[] meshes = new MeshPolygon[4];
373

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

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

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

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

    
392
    return new MeshJoined(meshes);
393
    }
394

    
395
///////////////////////////////////////////////////////////////////////////////////////////////////
396

    
397
  MeshBase createFacesHelicopterCorner()
398
    {
399
    MeshBase[] meshes = new MeshBase[6];
400

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

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

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

    
423
    return new MeshJoined(meshes);
424
    }
425

    
426
///////////////////////////////////////////////////////////////////////////////////////////////////
427

    
428
  MeshBase createFacesHelicopterFace()
429
    {
430
    MeshBase[] meshes = new MeshBase[4];
431

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

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

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

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

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

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

    
454
    return new MeshJoined(meshes);
455
    }
456

    
457
///////////////////////////////////////////////////////////////////////////////////////////////////
458

    
459
  MeshBase createFacesRediEdge()
460
    {
461
    MeshBase[] meshes = new MeshPolygon[6];
462

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

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

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

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

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

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

    
489
    return new MeshJoined(meshes);
490
    }
491

    
492
///////////////////////////////////////////////////////////////////////////////////////////////////
493

    
494
  MeshBase createFacesRediCorner()
495
    {
496
    MeshBase[] meshes = new MeshBase[6];
497

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

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

    
509
    float F = 0.5f;
510
    float X = 0.5f;
511
    float G = 0.72f;
512
    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 };
513
    float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2);
514

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

    
522
    return new MeshJoined(meshes);
523
    }
524

    
525
///////////////////////////////////////////////////////////////////////////////////////////////////
526

    
527
  MeshBase createFacesIvyCorner()
528
    {
529
    MeshBase[] meshes = new MeshBase[6];
530

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

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

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

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

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

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

    
569
    return new MeshJoined(meshes);
570
    }
571

    
572
///////////////////////////////////////////////////////////////////////////////////////////////////
573

    
574
  MeshBase createFacesIvyFace()
575
    {
576
    MeshBase[] meshes = new MeshBase[2];
577

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

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

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

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

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

    
601
    return new MeshJoined(meshes);
602
    }
603

    
604
///////////////////////////////////////////////////////////////////////////////////////////////////
605

    
606
  MeshBase createFacesRexCorner()
607
    {
608
    MeshBase[] meshes = new MeshBase[2];
609

    
610
    final float angle = (float)Math.PI/(6*REX_N);
611
    float[] vertices = new float[6*REX_N];
612
    final float H = SQ2*(SQ3/3 - 0.5f);
613
    final float D = 0.5f - REX_D;
614
    final float F = H*D;
615
    final float B = (float)Math.sqrt(12/(H*H) - 0.75f) - 0.5f;
616

    
617
    final float V1x = -F*0.5f;
618
    final float V1y = -F*SQ3/6;
619
    final float V2x = -V1x;
620
    final float V2y = V1y;
621
    final float V3x = 0.0f;
622
    final float V3y = -2*V1y;
623

    
624
    final float C1x = 0.0f;
625
    final float C1y = -D*( (SQ3/6)*H - (float)Math.sqrt(4.0f-0.25f*H*H) );
626
    final float C2x = B*V2x;
627
    final float C2y = B*V2y;
628
    final float C3x = B*V3x;
629
    final float C3y = B*V3y;
630

    
631
    for(int i=0; i<REX_N; i++)
632
      {
633
      writeVertex(C1x,C1y,V1x,V1y, i*angle, vertices, 2*i          );
634
      writeVertex(C2x,C2y,V2x,V2y, i*angle, vertices, 2*i + 2*REX_N);
635
      writeVertex(C3x,C3y,V3x,V3y, i*angle, vertices, 2*i + 4*REX_N);
636
      }
637

    
638
    float[] bands0 = computeBands(+0.03f,35,0.5f,0.5f,5);
639
    float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2);
640

    
641
    meshes[0] = new MeshPolygon(vertices,bands0,1,1);
642
    meshes[0].setEffectAssociation(0,1,0);
643
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
644
    meshes[1].setEffectAssociation(0,2,0);
645

    
646
    return new MeshJoined(meshes);
647
    }
648

    
649
///////////////////////////////////////////////////////////////////////////////////////////////////
650

    
651
  MeshBase createFacesRexFace()
652
    {
653
    MeshBase[] meshes = new MeshBase[2];
654

    
655
    final float angle = (float)Math.PI/(6*REX_N);
656
    float[] vertices = new float[8*REX_N];
657
    final float H = SQ3/2 - 0.5f;
658
    final float D = 0.5f - REX_D;
659
    final float F = H*D;
660

    
661
    final float V1x = 0.0f;
662
    final float V1y = +F;
663
    final float V2x = +F;
664
    final float V2y = 0.0f;
665
    final float V3x = 0.0f;
666
    final float V3y = -F;
667
    final float V4x = -F;
668
    final float V4y = 0.0f;
669

    
670
    final float C1x = -D;
671
    final float C1y = -D;
672
    final float C2x = -D;
673
    final float C2y = +D;
674
    final float C3x = +D;
675
    final float C3y = +D;
676
    final float C4x = +D;
677
    final float C4y = -D;
678

    
679
    for(int i=0; i<REX_N; i++)
680
      {
681
      writeVertex(C1x,C1y,V1x,V1y, i*angle, vertices, 2*i          );
682
      writeVertex(C2x,C2y,V2x,V2y, i*angle, vertices, 2*i + 2*REX_N);
683
      writeVertex(C3x,C3y,V3x,V3y, i*angle, vertices, 2*i + 4*REX_N);
684
      writeVertex(C4x,C4y,V4x,V4y, i*angle, vertices, 2*i + 6*REX_N);
685
      }
686

    
687
    float[] bands0 = computeBands(+0.03f,35,0.5f,0.5f,5);
688
    float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2);
689

    
690
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
691
    meshes[0].setEffectAssociation(0,1,0);
692
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
693
    meshes[1].setEffectAssociation(0,2,0);
694

    
695
    return new MeshJoined(meshes);
696
    }
697

    
698
///////////////////////////////////////////////////////////////////////////////////////////////////
699

    
700
  MeshBase createFacesRexEdge()
701
    {
702
    MeshBase[] meshes = new MeshBase[4];
703

    
704
    final float angle = (float)Math.PI/(6*REX_N);
705
    float[] vertices = new float[4*REX_N + 4];
706
    final float H = 1.0f - SQ3/2;
707
    final float D = 0.5f - REX_D;
708
    final float F = H*D;
709

    
710
    final float V1x = -D;
711
    final float V1y = +D - D*SQ3/2;
712
    final float V2x = 0.0f;
713
    final float V2y = D*(SQ3-1) - D*SQ3/2;
714

    
715
    final float C1x = -D;
716
    final float C1y = -D - D*SQ3/2;
717
    final float C2x = +D;
718
    final float C2y = C1y;
719

    
720
    for(int i=0; i<REX_N; i++)
721
      {
722
      writeVertex(C1x,C1y,V1x,V1y, i*angle, vertices, 2*i          );
723
      writeVertex(C2x,C2y,V2x,V2y, i*angle, vertices, 2*i + 2*REX_N);
724
      }
725

    
726
    vertices[4*REX_N  ] = +D;
727
    vertices[4*REX_N+1] = +F + REX_D;
728
    vertices[4*REX_N+2] = -D;
729
    vertices[4*REX_N+3] = +F + REX_D;
730

    
731
    float[] bands0 = computeBands(+0.03f,35,0.5f,0.5f,5);
732
    float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2);
733

    
734
    meshes[0] = new MeshPolygon(vertices,bands0,1,2);
735
    meshes[0].setEffectAssociation(0,1,0);
736
    meshes[1] = meshes[0].copy(true);
737
    meshes[1].setEffectAssociation(0,2,0);
738
    meshes[2] = new MeshPolygon(vertices,bands1,0,0);
739
    meshes[2].setEffectAssociation(0,4,0);
740
    meshes[3] = meshes[2].copy(true);
741
    meshes[3].setEffectAssociation(0,8,0);
742

    
743
    return new MeshJoined(meshes);
744
    }
745

    
746
///////////////////////////////////////////////////////////////////////////////////////////////////
747
// EFFECTS
748
///////////////////////////////////////////////////////////////////////////////////////////////////
749

    
750
  VertexEffect[] createVertexEffectsCube()
751
    {
752
    Static3D axisY   = new Static3D(0,1,0);
753
    Static3D axisX   = new Static3D(1,0,0);
754
    Static3D center  = new Static3D(0,0,0);
755
    Static1D angle90 = new Static1D(90);
756
    Static1D angle180= new Static1D(180);
757
    Static1D angle270= new Static1D(270);
758

    
759
    VertexEffect[] effect = new VertexEffect[6];
760

    
761
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
762
    effect[1] = new VertexEffectRotate( angle180, axisX, center );
763
    effect[2] = new VertexEffectRotate( angle90 , axisX, center );
764
    effect[3] = new VertexEffectRotate( angle270, axisX, center );
765
    effect[4] = new VertexEffectRotate( angle270, axisY, center );
766
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
767

    
768
    effect[0].setMeshAssociation(63,-1);  // all 6 sides
769
    effect[1].setMeshAssociation(32,-1);  // back
770
    effect[2].setMeshAssociation( 8,-1);  // bottom
771
    effect[3].setMeshAssociation( 4,-1);  // top
772
    effect[4].setMeshAssociation( 2,-1);  // left
773
    effect[5].setMeshAssociation( 1,-1);  // right
774

    
775
    return effect;
776
    }
777

    
778
///////////////////////////////////////////////////////////////////////////////////////////////////
779

    
780
  VertexEffect[] createVertexEffectsSkewbCorner()
781
    {
782
    float E = 0.5f;
783

    
784
    Static3D axisX  = new Static3D(1,0,0);
785
    Static3D axisY  = new Static3D(0,1,0);
786
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
787
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
788
    Static1D angle1 = new Static1D(+90);
789
    Static1D angle2 = new Static1D(-90);
790
    Static1D angle3 = new Static1D(-15);
791
    Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
792
    Static1D angle5 = new Static1D(120);
793
    Static1D angle6 = new Static1D(240);
794
    Static3D center1= new Static3D(0,0,0);
795
    Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
796
    Static3D move1  = new Static3D(-E/4,-E/4,0);
797
    Static3D move2  = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
798

    
799
    VertexEffect[] effect = new VertexEffect[10];
800

    
801
    effect[0] = new VertexEffectMove(move1);
802
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
803
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
804
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
805
    effect[4] = new VertexEffectMove(move2);
806
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
807
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
808
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
809
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
810
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
811

    
812
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
813
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
814
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
815
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
816
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
817
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
818
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
819
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
820
    effect[8].setMeshAssociation(16,-1);  // mesh 4
821
    effect[9].setMeshAssociation(32,-1);  // mesh 5
822

    
823
    return effect;
824
    }
825

    
826
///////////////////////////////////////////////////////////////////////////////////////////////////
827

    
828
  VertexEffect[] createVertexEffectsSkewbFace()
829
    {
830
    Static3D center = new Static3D(0,0,0);
831
    Static3D axisX  = new Static3D(1,0,0);
832
    Static3D axisZ  = new Static3D(0,0,1);
833
    float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
834

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

    
837
    effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center);
838
    effect[1] = new VertexEffectRotate( new Static1D(  135), axisZ, center);
839
    effect[2] = new VertexEffectRotate( new Static1D(   45), axisZ, center);
840
    effect[3] = new VertexEffectRotate( new Static1D(  -45), axisZ, center);
841
    effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center);
842
    effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) );
843

    
844
    effect[0].setMeshAssociation(30,-1);  // meshes 1,2,3,4
845
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
846
    effect[2].setMeshAssociation( 5,-1);  // meshes 0,2
847
    effect[3].setMeshAssociation( 8,-1);  // mesh 3
848
    effect[4].setMeshAssociation(16,-1);  // mesh 4
849
    effect[5].setMeshAssociation(30,-1);  // meshes 1,2,3,4
850

    
851
    return effect;
852
    }
853

    
854
///////////////////////////////////////////////////////////////////////////////////////////////////
855

    
856
  VertexEffect[] createVertexEffectsOcta()
857
    {
858
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
859
    Static1D angle1= new Static1D( 90);
860
    Static1D angle2= new Static1D(180);
861
    Static1D angle3= new Static1D(270);
862
    Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
863
    Static3D axisX = new Static3D(1,0,0);
864
    Static3D axisY = new Static3D(0,1,0);
865
    Static3D cent0 = new Static3D(0,0,0);
866
    Static3D cent1 = new Static3D(0,SQ2/2,0);
867
    Static3D flipY = new Static3D( 1,-1, 1);
868
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
869

    
870
    VertexEffect[] effect = new VertexEffect[7];
871

    
872
    effect[0] = new VertexEffectScale(scale);
873
    effect[1] = new VertexEffectMove(move1);
874
    effect[2] = new VertexEffectRotate(alpha , axisX, cent1);
875
    effect[3] = new VertexEffectRotate(angle1, axisY, cent0);
876
    effect[4] = new VertexEffectRotate(angle2, axisY, cent0);
877
    effect[5] = new VertexEffectRotate(angle3, axisY, cent0);
878
    effect[6] = new VertexEffectScale(flipY);
879

    
880
    effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
881
    effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
882
    effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7
883
    effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
884

    
885
    return effect;
886
    }
887

    
888
///////////////////////////////////////////////////////////////////////////////////////////////////
889

    
890
  VertexEffect[] createVertexEffectsTetra()
891
    {
892
    Static3D flipZ = new Static3D( 1, 1,-1);
893
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
894
    Static1D angle1= new Static1D( 90);
895
    Static1D angle2= new Static1D(180);
896
    Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
897
    Static3D axisX = new Static3D(1,0,0);
898
    Static3D axisY = new Static3D(0,1,0);
899
    Static3D axisZ = new Static3D(0,0,1);
900
    Static3D cent0 = new Static3D(0,0,0);
901
    Static3D cent1 = new Static3D(0,SQ2/4,0);
902
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
903

    
904
    VertexEffect[] effect = new VertexEffect[7];
905

    
906
    effect[0] = new VertexEffectScale(scale);
907
    effect[1] = new VertexEffectRotate(angle2, axisZ, cent0);
908
    effect[2] = new VertexEffectMove(move1);
909
    effect[3] = new VertexEffectRotate(alpha , axisX, cent1);
910
    effect[4] = new VertexEffectScale(flipZ);
911
    effect[5] = new VertexEffectRotate(angle1, axisY, cent0);
912
    effect[6] = new VertexEffectRotate(angle2, axisZ, cent0);
913

    
914
    effect[4].setMeshAssociation(10,-1); // meshes 1 & 3
915
    effect[5].setMeshAssociation(12,-1); // meshes 2 & 3
916
    effect[6].setMeshAssociation(12,-1); // meshes 2 & 3
917

    
918
    return effect;
919
    }
920

    
921
///////////////////////////////////////////////////////////////////////////////////////////////////
922

    
923
  VertexEffect[] createVertexEffectsDino()
924
    {
925
    float E = 0.5f*SQ2;
926
    float F = 0.5f;
927
    final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
928

    
929
    Static1D angle1 = new Static1D(-ANGLE);
930
    Static1D angle2 = new Static1D(+ANGLE);
931
    Static3D axisX  = new Static3D(1,0,0);
932
    Static3D axisY  = new Static3D(0,1,0);
933
    Static3D axisZ  = new Static3D(0,-1,1);
934
    Static3D center0= new Static3D(0,0,0);
935
    Static3D center1= new Static3D(0,-3*F,0);
936

    
937
    VertexEffect[] effect = new VertexEffect[10];
938

    
939
    effect[0] = new VertexEffectScale ( new Static3D(3,3,3) );
940
    effect[1] = new VertexEffectMove  ( new Static3D(0,-F,0) );
941
    effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 );
942
    effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) );
943
    effect[4] = new VertexEffectMove  ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
944
    effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
945
    effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) );
946
    effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
947
    effect[8] = new VertexEffectRotate( angle1           , axisZ, center1 );
948
    effect[9] = new VertexEffectRotate( angle2           , axisZ, center1 );
949

    
950
    effect[0].setMeshAssociation(15,-1);  // apply to meshes 0,1,2,3
951
    effect[1].setMeshAssociation( 3,-1);  // apply to meshes 0,1
952
    effect[2].setMeshAssociation( 2,-1);  // apply to mesh 1
953
    effect[3].setMeshAssociation( 2,-1);  // apply to mesh 0
954
    effect[4].setMeshAssociation(12,-1);  // apply to meshes 2,3
955
    effect[5].setMeshAssociation(12,-1);  // apply to meshes 2,3
956
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
957
    effect[7].setMeshAssociation(12,-1);  // apply to meshes 2,3
958
    effect[8].setMeshAssociation( 4,-1);  // apply to mesh 2
959
    effect[9].setMeshAssociation( 8,-1);  // apply to mesh 3
960

    
961
    return effect;
962
    }
963

    
964
///////////////////////////////////////////////////////////////////////////////////////////////////
965

    
966
  VertexEffect[] createVertexEffectsHelicopterCorner()
967
    {
968
    float E = 0.5f;
969

    
970
    Static3D axisX  = new Static3D(1,0,0);
971
    Static3D axisY  = new Static3D(0,1,0);
972
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
973
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
974
    Static1D angle1 = new Static1D(+90);
975
    Static1D angle2 = new Static1D(-90);
976
    Static1D angle3 = new Static1D(-135);
977
    Static1D angle4 = new Static1D(90);
978
    Static1D angle5 = new Static1D(120);
979
    Static1D angle6 = new Static1D(240);
980
    Static3D center1= new Static3D(0,0,0);
981
    Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
982
    Static3D move1  = new Static3D(-E/4,-E/4,0);
983
    Static3D move2  = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
984

    
985
    VertexEffect[] effect = new VertexEffect[10];
986

    
987
    effect[0] = new VertexEffectMove(move1);
988
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
989
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
990
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
991
    effect[4] = new VertexEffectMove(move2);
992
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
993
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
994
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
995
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
996
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
997

    
998
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
999
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
1000
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1001
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
1002
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1003
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1004
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
1005
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
1006
    effect[8].setMeshAssociation(16,-1);  // mesh 4
1007
    effect[9].setMeshAssociation(32,-1);  // mesh 5
1008

    
1009
    return effect;
1010
    }
1011

    
1012
///////////////////////////////////////////////////////////////////////////////////////////////////
1013

    
1014
  VertexEffect[] createVertexEffectsHelicopterFace()
1015
    {
1016
    float E = 0.5f;
1017
    float F = SQ2/4;
1018

    
1019
    Static3D move0  = new Static3D(-E/4, -E/4, 0);
1020
    Static3D move1  = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
1021
    Static3D move2  = new Static3D(-E/2, F/3, 0);
1022
    Static3D move3  = new Static3D(+E/2, F/3, 0);
1023
    Static3D move4  = new Static3D(+E/3,+E/3, 0);
1024
    Static1D angle1 = new Static1D(135);
1025
    Static1D angle2 = new Static1D(90);
1026
    Static1D angle3 = new Static1D(-90);
1027
    Static1D angle4 = new Static1D(-135);
1028
    Static3D axisX  = new Static3D(1,0,0);
1029
    Static3D axisY  = new Static3D(0,1,0);
1030
    Static3D axisZ  = new Static3D(0,0,1);
1031
    Static3D axis1  = new Static3D(1,-1,0);
1032
    Static3D center = new Static3D(0,0,0);
1033
    Static3D center1= new Static3D(-E/2,-E/2,0);
1034

    
1035
    VertexEffect[] effect = new VertexEffect[10];
1036

    
1037
    effect[0] = new VertexEffectMove(move0);
1038
    effect[1] = new VertexEffectRotate(angle1, axisZ, center);
1039
    effect[2] = new VertexEffectMove(move1);
1040
    effect[3] = new VertexEffectRotate(angle2, axis1, center1);
1041
    effect[4] = new VertexEffectMove(move2);
1042
    effect[5] = new VertexEffectMove(move3);
1043
    effect[6] = new VertexEffectRotate(angle3, axisZ, center);
1044
    effect[7] = new VertexEffectRotate(angle4, axisX, center);
1045
    effect[8] = new VertexEffectRotate(angle1, axisY, center);
1046
    effect[9] = new VertexEffectMove(move4);
1047

    
1048
    effect[0].setMeshAssociation( 1,-1);  // mesh 0
1049
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
1050
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1051
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1052
    effect[4].setMeshAssociation( 4,-1);  // mesh 2
1053
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
1054
    effect[6].setMeshAssociation( 8,-1);  // mesh 3
1055
    effect[7].setMeshAssociation( 4,-1);  // mesh 2
1056
    effect[8].setMeshAssociation( 8,-1);  // mesh 3
1057
    effect[9].setMeshAssociation(15,-1);  // meshes 0,1,2,3
1058

    
1059
    return effect;
1060
    }
1061

    
1062
///////////////////////////////////////////////////////////////////////////////////////////////////
1063

    
1064
  VertexEffect[] createVertexEffectsRediEdge()
1065
    {
1066
    Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
1067
    Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
1068
    Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
1069
    Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
1070
    Static3D flipZ = new Static3D(1,1,-1);
1071
    Static3D flipX = new Static3D(-1,1,1);
1072
    Static3D scale = new Static3D(2,2,2);
1073
    Static3D cent0 = new Static3D(0,0, 0);
1074
    Static3D cent1 = new Static3D(0,0, -1.5f);
1075
    Static3D axisX = new Static3D(1,0, 0);
1076
    Static3D axisY = new Static3D(0,1, 0);
1077
    Static3D axis  = new Static3D(0,SQ2/2,-SQ2/2);
1078
    Static1D angle1= new Static1D(90);
1079
    Static1D angle2= new Static1D(45);
1080
    Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
1081

    
1082
    VertexEffect[] effect = new VertexEffect[12];
1083

    
1084
    effect[0] = new VertexEffectScale(scale);
1085
    effect[1] = new VertexEffectMove(move0);
1086
    effect[2] = new VertexEffectScale(flipZ);
1087
    effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
1088
    effect[4] = new VertexEffectMove(move1);
1089
    effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
1090
    effect[6] = new VertexEffectMove(move2);
1091
    effect[7] = new VertexEffectScale(flipX);
1092
    effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
1093
    effect[9] = new VertexEffectMove(move3);
1094
    effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
1095
    effect[11]= new VertexEffectScale(flipX);
1096

    
1097
    effect[0].setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
1098
    effect[1].setMeshAssociation( 3,-1);  // meshes 0,1
1099
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1100
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1101
    effect[4].setMeshAssociation(12,-1);  // meshes 2,3
1102
    effect[5].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1103
    effect[6].setMeshAssociation(12,-1);  // meshes 2,3
1104
    effect[7].setMeshAssociation( 8,-1);  // mesh 3
1105
    effect[8].setMeshAssociation(48,-1);  // meshes 4,5
1106
    effect[9].setMeshAssociation(48,-1);  // meshes 4,5
1107
    effect[10].setMeshAssociation(48,-1); // meshes 4,5
1108
    effect[11].setMeshAssociation(32,-1); // mesh 5
1109

    
1110
    return effect;
1111
    }
1112

    
1113
///////////////////////////////////////////////////////////////////////////////////////////////////
1114

    
1115
  VertexEffect[] createVertexEffectsRediCorner()
1116
    {
1117
    Static3D axisY   = new Static3D(0,1,0);
1118
    Static3D axisX   = new Static3D(1,0,0);
1119
    Static3D axisZ   = new Static3D(0,0,1);
1120
    Static3D center  = new Static3D(0,0,0);
1121
    Static1D angle90 = new Static1D(90);
1122
    Static1D angle270= new Static1D(270);
1123
    Static1D angle45 = new Static1D(-45);
1124
    Static3D scale   = new Static3D(1.0f, SQ2, 1.0f);
1125

    
1126
    VertexEffect[] effect = new VertexEffect[7];
1127

    
1128
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
1129
    effect[1] = new VertexEffectRotate( angle270, axisX, center );
1130
    effect[2] = new VertexEffectRotate( angle90 , axisY, center );
1131
    effect[3] = new VertexEffectScale(scale);
1132
    effect[4] = new VertexEffectRotate( angle45 , axisX, center );
1133
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
1134
    effect[6] = new VertexEffectRotate( angle270, axisZ, center );
1135

    
1136
    effect[0].setMeshAssociation( 7,-1);  // 0,1,2
1137
    effect[1].setMeshAssociation( 2,-1);  // 1
1138
    effect[2].setMeshAssociation( 4,-1);  // 2
1139
    effect[3].setMeshAssociation(56,-1);  // 3,4,5
1140
    effect[4].setMeshAssociation(56,-1);  // 3,4,5
1141
    effect[5].setMeshAssociation(16,-1);  // 4
1142
    effect[6].setMeshAssociation(32,-1);  // 5
1143

    
1144
    return effect;
1145
    }
1146

    
1147
///////////////////////////////////////////////////////////////////////////////////////////////////
1148

    
1149
  VertexEffect[] createVertexEffectsIvyCorner()
1150
    {
1151
    Static3D axisX  = new Static3D(1,0,0);
1152
    Static3D axisY  = new Static3D(0,1,0);
1153
    Static1D angle1 = new Static1D(+90);
1154
    Static1D angle2 = new Static1D(-90);
1155
    Static3D center = new Static3D(0,0,0);
1156
    Static3D move1  = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
1157

    
1158
    VertexEffect[] effect = new VertexEffect[5];
1159

    
1160
    effect[0] = new VertexEffectScale(1/IVY_C);
1161
    effect[1] = new VertexEffectMove(move1);
1162
    effect[2] = new VertexEffectScale(new Static3D(1,1,-1));
1163
    effect[3] = new VertexEffectRotate(angle1,axisX,center);
1164
    effect[4] = new VertexEffectRotate(angle2,axisY,center);
1165

    
1166
    effect[2].setMeshAssociation(54,-1);  // meshes 1,2,4,5
1167
    effect[3].setMeshAssociation(18,-1);  // meshes 1,4
1168
    effect[4].setMeshAssociation(36,-1);  // meshes 2,5
1169

    
1170
    return effect;
1171
    }
1172

    
1173
///////////////////////////////////////////////////////////////////////////////////////////////////
1174

    
1175
  VertexEffect[] createVertexEffectsRexEdge()
1176
    {
1177
    final float H = 1.0f - SQ3/2;
1178
    final float D = 0.5f - REX_D;
1179
    final float F = H*D;
1180

    
1181
    Static3D move  = new Static3D(0.0f, 0.5f - F, 0.0f);
1182
    Static3D center= new Static3D(0.0f, F, 0.0f);
1183
    Static3D axisX = new Static3D(1.0f, 0.0f, 0.0f);
1184
    Static3D axisY = new Static3D(0.0f, 1.0f, 0.0f);
1185

    
1186
    Static1D angle180 = new Static1D(180);
1187
    Static1D angle90  = new Static1D( 90);
1188

    
1189
    VertexEffect[] effect = new VertexEffect[3];
1190

    
1191
    effect[0] = new VertexEffectRotate(angle180, axisY, center);
1192
    effect[1] = new VertexEffectRotate(angle90 , axisX, center);
1193
    effect[2] = new VertexEffectMove(move);
1194

    
1195
    effect[0].setMeshAssociation(10,-1);  // meshes 1 & 3
1196
    effect[1].setMeshAssociation(10,-1);  // meshes 1 & 3
1197

    
1198
    return effect;
1199
    }
1200

    
1201
///////////////////////////////////////////////////////////////////////////////////////////////////
1202

    
1203
  VertexEffect[] createVertexEffectsRexCorner()
1204
    {
1205
    float F = SQ3/6*(1.0f-2*REX_D);
1206
    Static3D move  = new Static3D(F,F,0.0f);
1207
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1208
    Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f);
1209
    Static1D angle = new Static1D(45);
1210

    
1211
    VertexEffect[] effect = new VertexEffect[2];
1212

    
1213
    effect[0] = new VertexEffectRotate(angle, axisZ, center);
1214
    effect[1] = new VertexEffectMove(move);
1215

    
1216
    return effect;
1217
    }
1218

    
1219
///////////////////////////////////////////////////////////////////////////////////////////////////
1220
// OBJECTS
1221
///////////////////////////////////////////////////////////////////////////////////////////////////
1222
// CUBE
1223

    
1224
  MeshBase createCubeMesh(int index)
1225
    {
1226
    MeshBase mesh = createFacesCube(index);
1227
    VertexEffect[] effects = createVertexEffectsCube();
1228
    for( VertexEffect effect : effects ) mesh.apply(effect);
1229

    
1230
    Static3D roundingCenter  = new Static3D(0,0,0);
1231
    Static3D[] vertices = new Static3D[8];
1232
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1233
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1234
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1235
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1236
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1237
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1238
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1239
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1240

    
1241
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
1242

    
1243
    mesh.mergeEffComponents();
1244

    
1245
    return mesh;
1246
    }
1247

    
1248
///////////////////////////////////////////////////////////////////////////////////////////////////
1249
// SKEWB
1250

    
1251
  MeshBase createSkewbCornerMesh()
1252
    {
1253
    MeshBase mesh = createFacesSkewbCorner();
1254
    VertexEffect[] effects = createVertexEffectsSkewbCorner();
1255
    for( VertexEffect effect : effects ) mesh.apply(effect);
1256

    
1257
    float E = 0.5f;
1258
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1259

    
1260
    Static3D[] verticesType1 = new Static3D[1];
1261
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1262
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1263

    
1264
    Static3D[] verticesType2 = new Static3D[3];
1265
    verticesType2[0] = new Static3D(-E, 0, 0);
1266
    verticesType2[1] = new Static3D( 0,-E, 0);
1267
    verticesType2[2] = new Static3D( 0, 0,-E);
1268
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1269

    
1270
    mesh.mergeEffComponents();
1271

    
1272
    return mesh;
1273
    }
1274

    
1275
///////////////////////////////////////////////////////////////////////////////////////////////////
1276

    
1277
  MeshBase createSkewbFaceMesh()
1278
    {
1279
    MeshBase mesh = createFacesSkewbFace();
1280
    VertexEffect[] effects = createVertexEffectsSkewbFace();
1281
    for( VertexEffect effect : effects ) mesh.apply(effect);
1282

    
1283
    Static3D roundingCenter = new Static3D(0,0,-0.2f);
1284
    float E = SQ2/4;
1285
    Static3D[] vertices = new Static3D[4];
1286
    vertices[0] = new Static3D(-E*SQ2,      0, 0);
1287
    vertices[1] = new Static3D(+E*SQ2,      0, 0);
1288
    vertices[2] = new Static3D(     0, -E*SQ2, 0);
1289
    vertices[3] = new Static3D(     0, +E*SQ2, 0);
1290
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
1291

    
1292
    mesh.mergeEffComponents();
1293
    mesh.addEmptyTexComponent();
1294

    
1295
    return mesh;
1296
    }
1297

    
1298
///////////////////////////////////////////////////////////////////////////////////////////////////
1299
// SKEWB DIAMOND / PYRAMINX
1300

    
1301
  MeshBase createOctaMesh()
1302
    {
1303
    MeshBase mesh = createFacesOcta();
1304
    VertexEffect[] effects = createVertexEffectsOcta();
1305
    for( VertexEffect effect : effects ) mesh.apply(effect);
1306

    
1307
    Static3D roundingCenter = new Static3D(0,0,0);
1308
    Static3D[] vertices = new Static3D[6];
1309
    vertices[0] = new Static3D(    0, SQ2/2,    0 );
1310
    vertices[1] = new Static3D( 0.5f,     0, 0.5f );
1311
    vertices[2] = new Static3D(-0.5f,     0, 0.5f );
1312
    vertices[3] = new Static3D(    0,-SQ2/2,    0 );
1313
    vertices[4] = new Static3D(-0.5f,     0,-0.5f );
1314
    vertices[5] = new Static3D( 0.5f,     0,-0.5f );
1315

    
1316
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
1317

    
1318
    mesh.mergeEffComponents();
1319

    
1320
    return mesh;
1321
    }
1322

    
1323
///////////////////////////////////////////////////////////////////////////////////////////////////
1324

    
1325
  MeshBase createTetraMesh()
1326
    {
1327
    MeshBase mesh = createFacesTetra();
1328
    VertexEffect[] effects = createVertexEffectsTetra();
1329
    for( VertexEffect effect : effects ) mesh.apply(effect);
1330

    
1331
    Static3D roundingCenter = new Static3D(0,0,0);
1332
    Static3D[] verticesRound = new Static3D[4];
1333
    verticesRound[0] = new Static3D(-0.5f,+SQ2/4,   0 );
1334
    verticesRound[1] = new Static3D(+0.5f,+SQ2/4,   0 );
1335
    verticesRound[2] = new Static3D(    0,-SQ2/4,+0.5f);
1336
    verticesRound[3] = new Static3D(    0,-SQ2/4,-0.5f);
1337
    roundCorners(mesh,roundingCenter,verticesRound,0.08f,0.15f);
1338

    
1339
    mesh.mergeEffComponents();
1340
    mesh.addEmptyTexComponent();
1341
    mesh.addEmptyTexComponent();
1342
    mesh.addEmptyTexComponent();
1343
    mesh.addEmptyTexComponent();
1344

    
1345
    return mesh;
1346
    }
1347

    
1348
///////////////////////////////////////////////////////////////////////////////////////////////////
1349
// DINO
1350

    
1351
  MeshBase createDinoMesh()
1352
    {
1353
    MeshBase mesh = createFacesDino();
1354
    VertexEffect[] effects = createVertexEffectsDino();
1355
    for( VertexEffect effect : effects ) mesh.apply(effect);
1356

    
1357
    float F = 0.5f;
1358
    Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
1359
    Static3D[] verticesRound = new Static3D[4];
1360
    verticesRound[0] = new Static3D(     0,-3*F,    0 );
1361
    verticesRound[1] = new Static3D(     0,   0, -3*F );
1362
    verticesRound[2] = new Static3D(  -3*F,   0,    0 );
1363
    verticesRound[3] = new Static3D(  +3*F,   0,    0 );
1364
    roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
1365

    
1366
    mesh.mergeEffComponents();
1367

    
1368
    return mesh;
1369
    }
1370

    
1371
///////////////////////////////////////////////////////////////////////////////////////////////////
1372
// Helicopter
1373

    
1374
  MeshBase createHelicopterCornerMesh()
1375
    {
1376
    MeshBase mesh = createFacesHelicopterCorner();
1377
    VertexEffect[] effects = createVertexEffectsHelicopterCorner();
1378
    for( VertexEffect effect : effects ) mesh.apply(effect);
1379

    
1380
    float E = 0.5f;
1381
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1382

    
1383
    Static3D[] verticesType1 = new Static3D[1];
1384
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1385
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1386

    
1387
    Static3D[] verticesType2 = new Static3D[3];
1388
    verticesType2[0] = new Static3D(-E, 0, 0);
1389
    verticesType2[1] = new Static3D( 0,-E, 0);
1390
    verticesType2[2] = new Static3D( 0, 0,-E);
1391
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1392

    
1393
    mesh.mergeEffComponents();
1394

    
1395
    return mesh;
1396
    }
1397

    
1398
///////////////////////////////////////////////////////////////////////////////////////////////////
1399

    
1400
  MeshBase createHelicopterFaceMesh()
1401
    {
1402
    MeshBase mesh = createFacesHelicopterFace();
1403
    VertexEffect[] effects = createVertexEffectsHelicopterFace();
1404
    for( VertexEffect effect : effects ) mesh.apply(effect);
1405

    
1406
    float E = 0.5f;
1407
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
1408

    
1409
    Static3D[] verticesType1 = new Static3D[1];
1410
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
1411
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
1412

    
1413
    Static3D[] verticesType2 = new Static3D[2];
1414
    verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
1415
    verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
1416
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1417

    
1418
    mesh.mergeEffComponents();
1419
    mesh.addEmptyTexComponent();
1420
    mesh.addEmptyTexComponent();
1421

    
1422
    return mesh;
1423
    }
1424

    
1425
///////////////////////////////////////////////////////////////////////////////////////////////////
1426
// Redi cube
1427

    
1428
  MeshBase createRediEdgeMesh()
1429
    {
1430
    MeshBase mesh = createFacesRediEdge();
1431
    VertexEffect[] effects = createVertexEffectsRediEdge();
1432
    for( VertexEffect effect : effects ) mesh.apply(effect);
1433

    
1434
    Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
1435
    Static3D[] vertices = new Static3D[2];
1436
    vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
1437
    vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
1438
    roundCorners(mesh,center,vertices,0.06f,0.20f);
1439

    
1440
    mesh.mergeEffComponents();
1441

    
1442
    return mesh;
1443
    }
1444

    
1445
///////////////////////////////////////////////////////////////////////////////////////////////////
1446

    
1447
  MeshBase createRediCornerMesh()
1448
    {
1449
    MeshBase mesh = createFacesRediCorner();
1450
    VertexEffect[] effects = createVertexEffectsRediCorner();
1451
    for( VertexEffect effect : effects ) mesh.apply(effect);
1452

    
1453
    Static3D center = new Static3D(0,0,0);
1454
    Static3D[] vertices = new Static3D[8];
1455
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1456
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1457
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1458
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1459
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1460
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1461
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1462
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1463

    
1464
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1465

    
1466
    mesh.mergeEffComponents();
1467

    
1468
    return mesh;
1469
    }
1470

    
1471
///////////////////////////////////////////////////////////////////////////////////////////////////
1472

    
1473
  MeshBase createIvyCornerMesh()
1474
    {
1475
    MeshBase mesh = createFacesIvyCorner();
1476
    VertexEffect[] effects = createVertexEffectsIvyCorner();
1477
    for( VertexEffect effect : effects ) mesh.apply(effect);
1478

    
1479
    Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
1480
    Static3D[] vertices = new Static3D[4];
1481
    vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f);
1482
    vertices[1] = new Static3D(-1.0f,+0.0f,+0.0f);
1483
    vertices[2] = new Static3D(+0.0f,-1.0f,+0.0f);
1484
    vertices[3] = new Static3D(+0.0f,+0.0f,-1.0f);
1485

    
1486
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1487

    
1488
    mesh.mergeEffComponents();
1489

    
1490
    return mesh;
1491
    }
1492

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

    
1495
  MeshBase createIvyFaceMesh()
1496
    {
1497
    MeshBase mesh = createFacesIvyFace();
1498

    
1499
    Static3D center = new Static3D(-0.0f,-0.0f,-0.5f);
1500
    Static3D[] vertices = new Static3D[2];
1501
    vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f);
1502
    vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f);
1503

    
1504
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1505

    
1506
    mesh.mergeEffComponents();
1507
    mesh.addEmptyTexComponent();
1508
    mesh.addEmptyTexComponent();
1509
    mesh.addEmptyTexComponent();
1510
    mesh.addEmptyTexComponent();
1511

    
1512
    return mesh;
1513
    }
1514

    
1515
///////////////////////////////////////////////////////////////////////////////////////////////////
1516

    
1517
  MeshBase createRexCornerMesh()
1518
    {
1519
    MeshBase mesh = createFacesRexCorner();
1520
    VertexEffect[] effects = createVertexEffectsRexCorner();
1521
    for( VertexEffect effect : effects ) mesh.apply(effect);
1522

    
1523
    Static3D center = new Static3D(0.0f,0.0f,-0.25f);
1524
    Static3D[] vertices = new Static3D[1];
1525
    vertices[0] = new Static3D(+0.25f,+0.25f,+0.0f);
1526
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1527

    
1528
    mesh.mergeEffComponents();
1529
    mesh.addEmptyTexComponent();
1530
    mesh.addEmptyTexComponent();
1531

    
1532
    return mesh;
1533
    }
1534

    
1535
///////////////////////////////////////////////////////////////////////////////////////////////////
1536

    
1537
  MeshBase createRexFaceMesh()
1538
    {
1539
    MeshBase mesh = createFacesRexFace();
1540

    
1541
    mesh.mergeEffComponents();
1542
    mesh.addEmptyTexComponent();
1543
    mesh.addEmptyTexComponent();
1544

    
1545
    return mesh;
1546
    }
1547

    
1548
///////////////////////////////////////////////////////////////////////////////////////////////////
1549

    
1550
  MeshBase createRexEdgeMesh()
1551
    {
1552
    MeshBase mesh = createFacesRexEdge();
1553
    VertexEffect[] effects = createVertexEffectsRexEdge();
1554
    for( VertexEffect effect : effects ) mesh.apply(effect);
1555

    
1556
    Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
1557
    Static3D[] vertices = new Static3D[2];
1558
    vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
1559
    vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
1560
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1561

    
1562
    mesh.mergeEffComponents();
1563

    
1564
    return mesh;
1565
    }
1566
  }
(2-2/26)