Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / FactoryCubit.java @ 49cd8581

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
  private static final float SQ2 = (float)Math.sqrt(2);
39
  private static final float SQ3 = (float)Math.sqrt(3);
40
  private static final float SQ6 = (float)Math.sqrt(6);
41

    
42
  private static final float IVY_D = 0.05f;
43
  private static final int   IVY_N = 8;
44

    
45
  private static final Static1D RADIUS = new Static1D(1);
46

    
47
  private static FactoryCubit mThis;
48

    
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50

    
51
  private FactoryCubit()
52
    {
53

    
54
    }
55

    
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57

    
58
  public static FactoryCubit getInstance()
59
    {
60
    if( mThis==null ) mThis = new FactoryCubit();
61

    
62
    return mThis;
63
    }
64

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

    
100
///////////////////////////////////////////////////////////////////////////////////////////////////
101

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

    
107
///////////////////////////////////////////////////////////////////////////////////////////////////
108

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

    
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116

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

    
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123

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

    
128
    bands[0] = 1.0f;
129
    bands[1] = 0.0f;
130

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

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

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

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

    
167
    bands[2*N-2] = 0.0f;
168
    bands[2*N-1] =    H;
169

    
170
    return bands;
171
    }
172

    
173
///////////////////////////////////////////////////////////////////////////////////////////////////
174

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

    
179
    float centX = center.get0();
180
    float centY = center.get1();
181
    float centZ = center.get2();
182

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

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

    
194
///////////////////////////////////////////////////////////////////////////////////////////////////
195

    
196
  MeshBase createFacesCube(int sizeIndex)
197
    {
198
    MeshBase[] meshes = new MeshPolygon[6];
199

    
200
    float E = 0.5f;
201
    int extraI, extraV, num;
202

    
203
    switch(sizeIndex)
204
      {
205
      case 0 : num = 6; extraI = 2; extraV = 2; break;
206
      case 1 : num = 5; extraI = 2; extraV = 2; break;
207
      case 2 : num = 5; extraI = 1; extraV = 2; break;
208
      default: num = 4; extraI = 1; extraV = 1; break;
209
      }
210

    
211
    float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E };
212
    float[] bands = computeBands(0.048f,35,E,0.7f,num);
213

    
214
    meshes[0] = new MeshPolygon(vertices,bands,extraI,extraV);
215
    meshes[0].setEffectAssociation(0,1,0);
216
    meshes[1] = meshes[0].copy(true);
217
    meshes[1].setEffectAssociation(0,2,0);
218
    meshes[2] = meshes[0].copy(true);
219
    meshes[2].setEffectAssociation(0,4,0);
220
    meshes[3] = meshes[0].copy(true);
221
    meshes[3].setEffectAssociation(0,8,0);
222
    meshes[4] = meshes[0].copy(true);
223
    meshes[4].setEffectAssociation(0,16,0);
224
    meshes[5] = meshes[0].copy(true);
225
    meshes[5].setEffectAssociation(0,32,0);
226

    
227
    return new MeshJoined(meshes);
228
    }
229

    
230
///////////////////////////////////////////////////////////////////////////////////////////////////
231

    
232
  MeshBase createFacesSkewbCorner()
233
    {
234
    MeshBase[] meshes = new MeshBase[6];
235

    
236
    float E = 0.5f;
237
    float F = SQ2/2;
238
    float G = SQ6/16;
239
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
240
    float[] bands0 = computeBands(0.028f,35,E/3,0.7f,7);
241

    
242
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
243
    meshes[0].setEffectAssociation(0,1,0);
244
    meshes[1] = meshes[0].copy(true);
245
    meshes[1].setEffectAssociation(0,2,0);
246
    meshes[2] = meshes[0].copy(true);
247
    meshes[2].setEffectAssociation(0,4,0);
248

    
249
    float[] vertices1 = { -F/2,-2*G, F/2,-2*G, 3*F/8,-G, 1*F/8,G, 0,2*G };
250
    float[] bands1 = computeBands(0,0,1,0,3);
251

    
252
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
253
    meshes[3].setEffectAssociation(0,8,0);
254
    meshes[4] = meshes[3].copy(true);
255
    meshes[4].setEffectAssociation(0,16,0);
256
    meshes[5] = meshes[3].copy(true);
257
    meshes[5].setEffectAssociation(0,32,0);
258

    
259
    return new MeshJoined(meshes);
260
    }
261

    
262
///////////////////////////////////////////////////////////////////////////////////////////////////
263

    
264
  MeshBase createFacesSkewbFace()
265
    {
266
    MeshBase[] meshes = new MeshBase[5];
267

    
268
    float E = SQ2/4;
269
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
270
    float[] bands0 = computeBands(0.051f,35,E/2,0.9f,7);
271

    
272
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
273
    meshes[0].setEffectAssociation(0,1,0);
274

    
275
    float[] vertices1 = { -E,-SQ3*E, -E*0.7f,-SQ3*E, +E*0.7f,-SQ3*E, +E,-SQ3*E, 0,0 };
276
    float[] bands1 = computeBands(0,0,1,0,3);
277

    
278
    meshes[1] = new MeshPolygon(vertices1,bands1,0,0);
279
    meshes[1].setEffectAssociation(0,2,0);
280
    meshes[2] = meshes[1].copy(true);
281
    meshes[2].setEffectAssociation(0,4,0);
282
    meshes[3] = meshes[1].copy(true);
283
    meshes[3].setEffectAssociation(0,8,0);
284
    meshes[4] = meshes[1].copy(true);
285
    meshes[4].setEffectAssociation(0,16,0);
286

    
287
    return new MeshJoined(meshes);
288
    }
289

    
290
///////////////////////////////////////////////////////////////////////////////////////////////////
291

    
292
  MeshBase createFacesOcta()
293
    {
294
    MeshBase[] meshes = new MeshPolygon[8];
295

    
296
    float E = 0.75f;
297
    float F = 0.5f;
298
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
299
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
300

    
301
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
302
    meshes[0].setEffectAssociation(0,1,0);
303
    meshes[1] = meshes[0].copy(true);
304
    meshes[1].setEffectAssociation(0,2,0);
305
    meshes[2] = meshes[0].copy(true);
306
    meshes[2].setEffectAssociation(0,4,0);
307
    meshes[3] = meshes[0].copy(true);
308
    meshes[3].setEffectAssociation(0,8,0);
309
    meshes[4] = meshes[0].copy(true);
310
    meshes[4].setEffectAssociation(0,16,0);
311
    meshes[5] = meshes[0].copy(true);
312
    meshes[5].setEffectAssociation(0,32,0);
313
    meshes[6] = meshes[0].copy(true);
314
    meshes[6].setEffectAssociation(0,64,0);
315
    meshes[7] = meshes[0].copy(true);
316
    meshes[7].setEffectAssociation(0,128,0);
317

    
318
    return new MeshJoined(meshes);
319
    }
320

    
321
///////////////////////////////////////////////////////////////////////////////////////////////////
322

    
323
  MeshBase createFacesTetra()
324
    {
325
    MeshBase[] meshes = new MeshBase[4];
326

    
327
    float E = 0.75f;
328
    float F = 0.5f;
329
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
330
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
331

    
332
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
333
    meshes[0].setEffectAssociation(0,1,0);
334
    meshes[1] = meshes[0].copy(true);
335
    meshes[1].setEffectAssociation(0,2,0);
336
    meshes[2] = meshes[0].copy(true);
337
    meshes[2].setEffectAssociation(0,4,0);
338
    meshes[3] = meshes[0].copy(true);
339
    meshes[3].setEffectAssociation(0,8,0);
340

    
341
    return new MeshJoined(meshes);
342
    }
343

    
344
///////////////////////////////////////////////////////////////////////////////////////////////////
345

    
346
  MeshBase createFacesDino()
347
    {
348
    MeshBase[] meshes = new MeshPolygon[4];
349

    
350
    float E = 0.5f*SQ2;
351
    float F = 0.5f;
352
    float[] vertices0 = { -F,F/3, 0,-2*F/3, +F,F/3 };
353
    float[] bands0 = computeBands(0.028f,30,F/3,0.8f,7);
354

    
355
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 5);
356
    meshes[0].setEffectAssociation(0,1,0);
357
    meshes[1] = meshes[0].copy(true);
358
    meshes[1].setEffectAssociation(0,2,0);
359

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

    
363
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
364
    meshes[2].setEffectAssociation(0,4,0);
365
    meshes[3] = meshes[2].copy(true);
366
    meshes[3].setEffectAssociation(0,8,0);
367

    
368
    return new MeshJoined(meshes);
369
    }
370

    
371
///////////////////////////////////////////////////////////////////////////////////////////////////
372

    
373
  MeshBase createFacesHelicopterCorner()
374
    {
375
    MeshBase[] meshes = new MeshBase[6];
376

    
377
    float E = 0.5f;
378
    float F = SQ2/4;
379
    float G = 1.0f/12;
380
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
381
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
382

    
383
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
384
    meshes[0].setEffectAssociation(0,1,0);
385
    meshes[1] = meshes[0].copy(true);
386
    meshes[1].setEffectAssociation(0,2,0);
387
    meshes[2] = meshes[0].copy(true);
388
    meshes[2].setEffectAssociation(0,4,0);
389

    
390
    float[] vertices1 = { -F,-G, 0,-G, +F,-G, 0,2*G };
391
    float[] bands1 = computeBands(0.00f,0,0,0.0f,3);
392
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
393
    meshes[3].setEffectAssociation(0,8,0);
394
    meshes[4] = meshes[3].copy(true);
395
    meshes[4].setEffectAssociation(0,16,0);
396
    meshes[5] = meshes[3].copy(true);
397
    meshes[5].setEffectAssociation(0,32,0);
398

    
399
    return new MeshJoined(meshes);
400
    }
401

    
402
///////////////////////////////////////////////////////////////////////////////////////////////////
403

    
404
  MeshBase createFacesHelicopterFace()
405
    {
406
    MeshBase[] meshes = new MeshBase[4];
407

    
408
    float E = 0.5f;
409
    float F = SQ2/4;
410
    float G = 1.0f/12;
411
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
412
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
413

    
414
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
415
    meshes[0].setEffectAssociation(0,1,0);
416

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

    
420
    meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3);
421
    meshes[1].setEffectAssociation(0,2,0);
422

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

    
425
    meshes[2] = new MeshPolygon(vertices2, bands1, 1, 3);
426
    meshes[2].setEffectAssociation(0,4,0);
427
    meshes[3] = meshes[2].copy(true);
428
    meshes[3].setEffectAssociation(0,8,0);
429

    
430
    return new MeshJoined(meshes);
431
    }
432

    
433
///////////////////////////////////////////////////////////////////////////////////////////////////
434

    
435
  MeshBase createFacesRediEdge()
436
    {
437
    MeshBase[] meshes = new MeshPolygon[6];
438

    
439
    float F = 0.25f;
440
    float[] vertices0 = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F };
441
    float[] bands0 = computeBands(0.038f,35,F,0.7f,7);
442

    
443
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 2);
444
    meshes[0].setEffectAssociation(0,1,0);
445
    meshes[1] = meshes[0].copy(true);
446
    meshes[1].setEffectAssociation(0,2,0);
447

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

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

    
456
    float X = 0.25f*SQ2;
457
    float Y = SQ6/16;
458
    float[] vertices2 = { -X, Y, -1.5f*X, -Y, +1.5f*X, -Y, +X, Y };
459

    
460
    meshes[4] = new MeshPolygon(vertices2, bands1, 1, 1);
461
    meshes[4].setEffectAssociation(0,16,0);
462
    meshes[5] = meshes[4].copy(true);
463
    meshes[5].setEffectAssociation(0,32,0);
464

    
465
    return new MeshJoined(meshes);
466
    }
467

    
468
///////////////////////////////////////////////////////////////////////////////////////////////////
469

    
470
  MeshBase createFacesRediCorner()
471
    {
472
    MeshBase[] meshes = new MeshBase[6];
473

    
474
    float E = 0.5f;
475
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
476
    float[] bands0 = computeBands(0.06f,35,E,0.7f,6);
477

    
478
    meshes[0] = new MeshPolygon(vertices0,bands0,2,2);
479
    meshes[0].setEffectAssociation(0,1,0);
480
    meshes[1] = meshes[0].copy(true);
481
    meshes[1].setEffectAssociation(0,2,0);
482
    meshes[2] = meshes[0].copy(true);
483
    meshes[2].setEffectAssociation(0,4,0);
484

    
485
    float F = 0.5f;
486
    float X = 0.5f;
487
    float G = 0.72f;
488
    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 };
489
    float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2);
490

    
491
    meshes[3] = new MeshPolygon(vertices1,bands1,0,0);
492
    meshes[3].setEffectAssociation(0,8,0);
493
    meshes[4] = meshes[3].copy(true);
494
    meshes[4].setEffectAssociation(0,16,0);
495
    meshes[5] = meshes[3].copy(true);
496
    meshes[5].setEffectAssociation(0,32,0);
497

    
498
    return new MeshJoined(meshes);
499
    }
500

    
501
///////////////////////////////////////////////////////////////////////////////////////////////////
502

    
503
  MeshBase createFacesIvyCorner()
504
    {
505
    MeshBase mesh = createFacesSkewbCorner();
506
    mesh.addEmptyTexComponent();
507
    return mesh;
508
    }
509

    
510
///////////////////////////////////////////////////////////////////////////////////////////////////
511

    
512
  MeshBase createFacesIvyFace()
513
    {
514
    MeshBase[] meshes = new MeshBase[2];
515

    
516
    final float angle = (float)Math.PI/(2*IVY_N);
517
    float[] vertices = new float[4*IVY_N];
518

    
519
    for(int i=0; i<IVY_N; i++)
520
      {
521
      float sin = (float)Math.sin(i*angle);
522
      float cos = (float)Math.cos(i*angle);
523

    
524
      vertices[2*i          ] = 0.5f-cos;
525
      vertices[2*i+1        ] = 0.5f-sin;
526
      vertices[2*i  +2*IVY_N] = cos-0.5f;
527
      vertices[2*i+1+2*IVY_N] = sin-0.5f;
528
      }
529

    
530
    float[] bands0 = computeBands(+0.08f,35,0.5f,0.7f,6);
531
    float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2);
532

    
533
    meshes[0] = new MeshPolygon(vertices,bands0,1,1);
534
    meshes[0].setEffectAssociation(0,1,0);
535
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
536
    meshes[1].setEffectAssociation(0,2,0);
537

    
538
    return new MeshJoined(meshes);
539
    }
540

    
541
///////////////////////////////////////////////////////////////////////////////////////////////////
542
// EFFECTS
543
///////////////////////////////////////////////////////////////////////////////////////////////////
544

    
545
  VertexEffect[] createVertexEffectsCube()
546
    {
547
    Static3D axisY   = new Static3D(0,1,0);
548
    Static3D axisX   = new Static3D(1,0,0);
549
    Static3D center  = new Static3D(0,0,0);
550
    Static1D angle90 = new Static1D(90);
551
    Static1D angle180= new Static1D(180);
552
    Static1D angle270= new Static1D(270);
553

    
554
    VertexEffect[] effect = new VertexEffect[6];
555

    
556
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
557
    effect[1] = new VertexEffectRotate( angle180, axisX, center );
558
    effect[2] = new VertexEffectRotate( angle90 , axisX, center );
559
    effect[3] = new VertexEffectRotate( angle270, axisX, center );
560
    effect[4] = new VertexEffectRotate( angle270, axisY, center );
561
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
562

    
563
    effect[0].setMeshAssociation(63,-1);  // all 6 sides
564
    effect[1].setMeshAssociation(32,-1);  // back
565
    effect[2].setMeshAssociation( 8,-1);  // bottom
566
    effect[3].setMeshAssociation( 4,-1);  // top
567
    effect[4].setMeshAssociation( 2,-1);  // left
568
    effect[5].setMeshAssociation( 1,-1);  // right
569

    
570
    return effect;
571
    }
572

    
573
///////////////////////////////////////////////////////////////////////////////////////////////////
574

    
575
  VertexEffect[] createVertexEffectsSkewbCorner()
576
    {
577
    float E = 0.5f;
578

    
579
    Static3D axisX  = new Static3D(1,0,0);
580
    Static3D axisY  = new Static3D(0,1,0);
581
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
582
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
583
    Static1D angle1 = new Static1D(+90);
584
    Static1D angle2 = new Static1D(-90);
585
    Static1D angle3 = new Static1D(-15);
586
    Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
587
    Static1D angle5 = new Static1D(120);
588
    Static1D angle6 = new Static1D(240);
589
    Static3D center1= new Static3D(0,0,0);
590
    Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
591
    Static3D move1  = new Static3D(-E/4,-E/4,0);
592
    Static3D move2  = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
593

    
594
    VertexEffect[] effect = new VertexEffect[10];
595

    
596
    effect[0] = new VertexEffectMove(move1);
597
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
598
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
599
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
600
    effect[4] = new VertexEffectMove(move2);
601
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
602
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
603
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
604
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
605
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
606

    
607
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
608
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
609
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
610
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
611
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
612
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
613
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
614
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
615
    effect[8].setMeshAssociation(16,-1);  // mesh 4
616
    effect[9].setMeshAssociation(32,-1);  // mesh 5
617

    
618
    return effect;
619
    }
620

    
621
///////////////////////////////////////////////////////////////////////////////////////////////////
622

    
623
  VertexEffect[] createVertexEffectsSkewbFace()
624
    {
625
    Static3D center = new Static3D(0,0,0);
626
    Static3D axisX  = new Static3D(1,0,0);
627
    Static3D axisZ  = new Static3D(0,0,1);
628
    float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
629

    
630
    VertexEffect[] effect = new VertexEffect[6];
631

    
632
    effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center);
633
    effect[1] = new VertexEffectRotate( new Static1D(  135), axisZ, center);
634
    effect[2] = new VertexEffectRotate( new Static1D(   45), axisZ, center);
635
    effect[3] = new VertexEffectRotate( new Static1D(  -45), axisZ, center);
636
    effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center);
637
    effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) );
638

    
639
    effect[0].setMeshAssociation(30,-1);  // meshes 1,2,3,4
640
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
641
    effect[2].setMeshAssociation( 5,-1);  // meshes 0,2
642
    effect[3].setMeshAssociation( 8,-1);  // mesh 3
643
    effect[4].setMeshAssociation(16,-1);  // mesh 4
644
    effect[5].setMeshAssociation(30,-1);  // meshes 1,2,3,4
645

    
646
    return effect;
647
    }
648

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

    
651
  VertexEffect[] createVertexEffectsOcta()
652
    {
653
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
654
    Static1D angle1= new Static1D( 90);
655
    Static1D angle2= new Static1D(180);
656
    Static1D angle3= new Static1D(270);
657
    Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
658
    Static3D axisX = new Static3D(1,0,0);
659
    Static3D axisY = new Static3D(0,1,0);
660
    Static3D cent0 = new Static3D(0,0,0);
661
    Static3D cent1 = new Static3D(0,SQ2/2,0);
662
    Static3D flipY = new Static3D( 1,-1, 1);
663
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
664

    
665
    VertexEffect[] effect = new VertexEffect[7];
666

    
667
    effect[0] = new VertexEffectScale(scale);
668
    effect[1] = new VertexEffectMove(move1);
669
    effect[2] = new VertexEffectRotate(alpha , axisX, cent1);
670
    effect[3] = new VertexEffectRotate(angle1, axisY, cent0);
671
    effect[4] = new VertexEffectRotate(angle2, axisY, cent0);
672
    effect[5] = new VertexEffectRotate(angle3, axisY, cent0);
673
    effect[6] = new VertexEffectScale(flipY);
674

    
675
    effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
676
    effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
677
    effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7
678
    effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
679

    
680
    return effect;
681
    }
682

    
683
///////////////////////////////////////////////////////////////////////////////////////////////////
684

    
685
  VertexEffect[] createVertexEffectsTetra()
686
    {
687
    Static3D flipZ = new Static3D( 1, 1,-1);
688
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
689
    Static1D angle1= new Static1D( 90);
690
    Static1D angle2= new Static1D(180);
691
    Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
692
    Static3D axisX = new Static3D(1,0,0);
693
    Static3D axisY = new Static3D(0,1,0);
694
    Static3D axisZ = new Static3D(0,0,1);
695
    Static3D cent0 = new Static3D(0,0,0);
696
    Static3D cent1 = new Static3D(0,SQ2/4,0);
697
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
698

    
699
    VertexEffect[] effect = new VertexEffect[7];
700

    
701
    effect[0] = new VertexEffectScale(scale);
702
    effect[1] = new VertexEffectRotate(angle2, axisZ, cent0);
703
    effect[2] = new VertexEffectMove(move1);
704
    effect[3] = new VertexEffectRotate(alpha , axisX, cent1);
705
    effect[4] = new VertexEffectScale(flipZ);
706
    effect[5] = new VertexEffectRotate(angle1, axisY, cent0);
707
    effect[6] = new VertexEffectRotate(angle2, axisZ, cent0);
708

    
709
    effect[4].setMeshAssociation(10,-1); // meshes 1 & 3
710
    effect[5].setMeshAssociation(12,-1); // meshes 2 & 3
711
    effect[6].setMeshAssociation(12,-1); // meshes 2 & 3
712

    
713
    return effect;
714
    }
715

    
716
///////////////////////////////////////////////////////////////////////////////////////////////////
717

    
718
  VertexEffect[] createVertexEffectsDino()
719
    {
720
    float E = 0.5f*SQ2;
721
    float F = 0.5f;
722
    final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
723

    
724
    Static1D angle1 = new Static1D(-ANGLE);
725
    Static1D angle2 = new Static1D(+ANGLE);
726
    Static3D axisX  = new Static3D(1,0,0);
727
    Static3D axisY  = new Static3D(0,1,0);
728
    Static3D axisZ  = new Static3D(0,-1,1);
729
    Static3D center0= new Static3D(0,0,0);
730
    Static3D center1= new Static3D(0,-3*F,0);
731

    
732
    VertexEffect[] effect = new VertexEffect[10];
733

    
734
    effect[0] = new VertexEffectScale ( new Static3D(3,3,3) );
735
    effect[1] = new VertexEffectMove  ( new Static3D(0,-F,0) );
736
    effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 );
737
    effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) );
738
    effect[4] = new VertexEffectMove  ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
739
    effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
740
    effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) );
741
    effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
742
    effect[8] = new VertexEffectRotate( angle1           , axisZ, center1 );
743
    effect[9] = new VertexEffectRotate( angle2           , axisZ, center1 );
744

    
745
    effect[0].setMeshAssociation(15,-1);  // apply to meshes 0,1,2,3
746
    effect[1].setMeshAssociation( 3,-1);  // apply to meshes 0,1
747
    effect[2].setMeshAssociation( 2,-1);  // apply to mesh 1
748
    effect[3].setMeshAssociation( 2,-1);  // apply to mesh 0
749
    effect[4].setMeshAssociation(12,-1);  // apply to meshes 2,3
750
    effect[5].setMeshAssociation(12,-1);  // apply to meshes 2,3
751
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
752
    effect[7].setMeshAssociation(12,-1);  // apply to meshes 2,3
753
    effect[8].setMeshAssociation( 4,-1);  // apply to mesh 2
754
    effect[9].setMeshAssociation( 8,-1);  // apply to mesh 3
755

    
756
    return effect;
757
    }
758

    
759
///////////////////////////////////////////////////////////////////////////////////////////////////
760

    
761
  VertexEffect[] createVertexEffectsHelicopterCorner()
762
    {
763
    float E = 0.5f;
764

    
765
    Static3D axisX  = new Static3D(1,0,0);
766
    Static3D axisY  = new Static3D(0,1,0);
767
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
768
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
769
    Static1D angle1 = new Static1D(+90);
770
    Static1D angle2 = new Static1D(-90);
771
    Static1D angle3 = new Static1D(-135);
772
    Static1D angle4 = new Static1D(90);
773
    Static1D angle5 = new Static1D(120);
774
    Static1D angle6 = new Static1D(240);
775
    Static3D center1= new Static3D(0,0,0);
776
    Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
777
    Static3D move1  = new Static3D(-E/4,-E/4,0);
778
    Static3D move2  = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
779

    
780
    VertexEffect[] effect = new VertexEffect[10];
781

    
782
    effect[0] = new VertexEffectMove(move1);
783
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
784
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
785
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
786
    effect[4] = new VertexEffectMove(move2);
787
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
788
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
789
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
790
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
791
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
792

    
793
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
794
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
795
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
796
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
797
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
798
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
799
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
800
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
801
    effect[8].setMeshAssociation(16,-1);  // mesh 4
802
    effect[9].setMeshAssociation(32,-1);  // mesh 5
803

    
804
    return effect;
805
    }
806

    
807
///////////////////////////////////////////////////////////////////////////////////////////////////
808

    
809
  VertexEffect[] createVertexEffectsHelicopterFace()
810
    {
811
    float E = 0.5f;
812
    float F = SQ2/4;
813

    
814
    Static3D move0  = new Static3D(-E/4, -E/4, 0);
815
    Static3D move1  = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
816
    Static3D move2  = new Static3D(-E/2, F/3, 0);
817
    Static3D move3  = new Static3D(+E/2, F/3, 0);
818
    Static3D move4  = new Static3D(+E/3,+E/3, 0);
819
    Static1D angle1 = new Static1D(135);
820
    Static1D angle2 = new Static1D(90);
821
    Static1D angle3 = new Static1D(-90);
822
    Static1D angle4 = new Static1D(-135);
823
    Static3D axisX  = new Static3D(1,0,0);
824
    Static3D axisY  = new Static3D(0,1,0);
825
    Static3D axisZ  = new Static3D(0,0,1);
826
    Static3D axis1  = new Static3D(1,-1,0);
827
    Static3D center = new Static3D(0,0,0);
828
    Static3D center1= new Static3D(-E/2,-E/2,0);
829

    
830
    VertexEffect[] effect = new VertexEffect[10];
831

    
832
    effect[0] = new VertexEffectMove(move0);
833
    effect[1] = new VertexEffectRotate(angle1, axisZ, center);
834
    effect[2] = new VertexEffectMove(move1);
835
    effect[3] = new VertexEffectRotate(angle2, axis1, center1);
836
    effect[4] = new VertexEffectMove(move2);
837
    effect[5] = new VertexEffectMove(move3);
838
    effect[6] = new VertexEffectRotate(angle3, axisZ, center);
839
    effect[7] = new VertexEffectRotate(angle4, axisX, center);
840
    effect[8] = new VertexEffectRotate(angle1, axisY, center);
841
    effect[9] = new VertexEffectMove(move4);
842

    
843
    effect[0].setMeshAssociation( 1,-1);  // mesh 0
844
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
845
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
846
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
847
    effect[4].setMeshAssociation( 4,-1);  // mesh 2
848
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
849
    effect[6].setMeshAssociation( 8,-1);  // mesh 3
850
    effect[7].setMeshAssociation( 4,-1);  // mesh 2
851
    effect[8].setMeshAssociation( 8,-1);  // mesh 3
852
    effect[9].setMeshAssociation(15,-1);  // meshes 0,1,2,3
853

    
854
    return effect;
855
    }
856

    
857
///////////////////////////////////////////////////////////////////////////////////////////////////
858

    
859
  VertexEffect[] createVertexEffectsRediEdge()
860
    {
861
    Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
862
    Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
863
    Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
864
    Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
865
    Static3D flipZ = new Static3D(1,1,-1);
866
    Static3D flipX = new Static3D(-1,1,1);
867
    Static3D scale = new Static3D(2,2,2);
868
    Static3D cent0 = new Static3D(0,0, 0);
869
    Static3D cent1 = new Static3D(0,0, -1.5f);
870
    Static3D axisX = new Static3D(1,0, 0);
871
    Static3D axisY = new Static3D(0,1, 0);
872
    Static3D axis  = new Static3D(0,SQ2/2,-SQ2/2);
873
    Static1D angle1= new Static1D(90);
874
    Static1D angle2= new Static1D(45);
875
    Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
876

    
877
    VertexEffect[] effect = new VertexEffect[12];
878

    
879
    effect[0] = new VertexEffectScale(scale);
880
    effect[1] = new VertexEffectMove(move0);
881
    effect[2] = new VertexEffectScale(flipZ);
882
    effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
883
    effect[4] = new VertexEffectMove(move1);
884
    effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
885
    effect[6] = new VertexEffectMove(move2);
886
    effect[7] = new VertexEffectScale(flipX);
887
    effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
888
    effect[9] = new VertexEffectMove(move3);
889
    effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
890
    effect[11]= new VertexEffectScale(flipX);
891

    
892
    effect[0].setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
893
    effect[1].setMeshAssociation( 3,-1);  // meshes 0,1
894
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
895
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
896
    effect[4].setMeshAssociation(12,-1);  // meshes 2,3
897
    effect[5].setMeshAssociation(60,-1);  // meshes 2,3,4,5
898
    effect[6].setMeshAssociation(12,-1);  // meshes 2,3
899
    effect[7].setMeshAssociation( 8,-1);  // mesh 3
900
    effect[8].setMeshAssociation(48,-1);  // meshes 4,5
901
    effect[9].setMeshAssociation(48,-1);  // meshes 4,5
902
    effect[10].setMeshAssociation(48,-1); // meshes 4,5
903
    effect[11].setMeshAssociation(32,-1); // mesh 5
904

    
905
    return effect;
906
    }
907

    
908
///////////////////////////////////////////////////////////////////////////////////////////////////
909

    
910
  VertexEffect[] createVertexEffectsRediCorner()
911
    {
912
    Static3D axisY   = new Static3D(0,1,0);
913
    Static3D axisX   = new Static3D(1,0,0);
914
    Static3D axisZ   = new Static3D(0,0,1);
915
    Static3D center  = new Static3D(0,0,0);
916
    Static1D angle90 = new Static1D(90);
917
    Static1D angle270= new Static1D(270);
918
    Static1D angle45 = new Static1D(-45);
919
    Static3D scale   = new Static3D(1.0f, SQ2, 1.0f);
920

    
921
    VertexEffect[] effect = new VertexEffect[7];
922

    
923
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
924
    effect[1] = new VertexEffectRotate( angle270, axisX, center );
925
    effect[2] = new VertexEffectRotate( angle90 , axisY, center );
926
    effect[3] = new VertexEffectScale(scale);
927
    effect[4] = new VertexEffectRotate( angle45 , axisX, center );
928
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
929
    effect[6] = new VertexEffectRotate( angle270, axisZ, center );
930

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

    
939
    return effect;
940
    }
941

    
942
///////////////////////////////////////////////////////////////////////////////////////////////////
943

    
944
  VertexEffect[] createVertexEffectsIvyCorner()
945
    {
946
    return createVertexEffectsSkewbCorner();
947
    }
948

    
949
///////////////////////////////////////////////////////////////////////////////////////////////////
950
// OBJECTS
951
///////////////////////////////////////////////////////////////////////////////////////////////////
952
// CUBE
953

    
954
  MeshBase createCubeMesh(int index)
955
    {
956
    MeshBase mesh = createFacesCube(index);
957
    VertexEffect[] effects = createVertexEffectsCube();
958
    for( VertexEffect effect : effects ) mesh.apply(effect);
959

    
960
    Static3D roundingCenter  = new Static3D(0,0,0);
961
    Static3D[] vertices = new Static3D[8];
962
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
963
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
964
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
965
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
966
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
967
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
968
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
969
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
970

    
971
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
972

    
973
    mesh.mergeEffComponents();
974

    
975
    return mesh;
976
    }
977

    
978
///////////////////////////////////////////////////////////////////////////////////////////////////
979
// SKEWB
980

    
981
  MeshBase createSkewbCornerMesh()
982
    {
983
    MeshBase mesh = createFacesSkewbCorner();
984
    VertexEffect[] effects = createVertexEffectsSkewbCorner();
985
    for( VertexEffect effect : effects ) mesh.apply(effect);
986

    
987
    float E = 0.5f;
988
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
989

    
990
    Static3D[] verticesType1 = new Static3D[1];
991
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
992
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
993

    
994
    Static3D[] verticesType2 = new Static3D[3];
995
    verticesType2[0] = new Static3D(-E, 0, 0);
996
    verticesType2[1] = new Static3D( 0,-E, 0);
997
    verticesType2[2] = new Static3D( 0, 0,-E);
998
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
999

    
1000
    mesh.mergeEffComponents();
1001

    
1002
    return mesh;
1003
    }
1004

    
1005
///////////////////////////////////////////////////////////////////////////////////////////////////
1006

    
1007
  MeshBase createSkewbFaceMesh()
1008
    {
1009
    MeshBase mesh = createFacesSkewbFace();
1010
    VertexEffect[] effects = createVertexEffectsSkewbFace();
1011
    for( VertexEffect effect : effects ) mesh.apply(effect);
1012

    
1013
    Static3D roundingCenter = new Static3D(0,0,-0.2f);
1014
    float E = SQ2/4;
1015
    Static3D[] vertices = new Static3D[4];
1016
    vertices[0] = new Static3D(-E*SQ2,      0, 0);
1017
    vertices[1] = new Static3D(+E*SQ2,      0, 0);
1018
    vertices[2] = new Static3D(     0, -E*SQ2, 0);
1019
    vertices[3] = new Static3D(     0, +E*SQ2, 0);
1020
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
1021

    
1022
    mesh.mergeEffComponents();
1023
    mesh.addEmptyTexComponent();
1024

    
1025
    return mesh;
1026
    }
1027

    
1028
///////////////////////////////////////////////////////////////////////////////////////////////////
1029
// SKEWB DIAMOND / PYRAMINX
1030

    
1031
  MeshBase createOctaMesh()
1032
    {
1033
    MeshBase mesh = createFacesOcta();
1034
    VertexEffect[] effects = createVertexEffectsOcta();
1035
    for( VertexEffect effect : effects ) mesh.apply(effect);
1036

    
1037
    Static3D roundingCenter = new Static3D(0,0,0);
1038
    Static3D[] vertices = new Static3D[6];
1039
    vertices[0] = new Static3D(    0, SQ2/2,    0 );
1040
    vertices[1] = new Static3D( 0.5f,     0, 0.5f );
1041
    vertices[2] = new Static3D(-0.5f,     0, 0.5f );
1042
    vertices[3] = new Static3D(    0,-SQ2/2,    0 );
1043
    vertices[4] = new Static3D(-0.5f,     0,-0.5f );
1044
    vertices[5] = new Static3D( 0.5f,     0,-0.5f );
1045

    
1046
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
1047

    
1048
    mesh.mergeEffComponents();
1049

    
1050
    return mesh;
1051
    }
1052

    
1053
///////////////////////////////////////////////////////////////////////////////////////////////////
1054

    
1055
  MeshBase createTetraMesh()
1056
    {
1057
    MeshBase mesh = createFacesTetra();
1058
    VertexEffect[] effects = createVertexEffectsTetra();
1059
    for( VertexEffect effect : effects ) mesh.apply(effect);
1060

    
1061
    Static3D roundingCenter = new Static3D(0,0,0);
1062
    Static3D[] verticesRound = new Static3D[4];
1063
    verticesRound[0] = new Static3D(-0.5f,+SQ2/4,   0 );
1064
    verticesRound[1] = new Static3D(+0.5f,+SQ2/4,   0 );
1065
    verticesRound[2] = new Static3D(    0,-SQ2/4,+0.5f);
1066
    verticesRound[3] = new Static3D(    0,-SQ2/4,-0.5f);
1067
    roundCorners(mesh,roundingCenter,verticesRound,0.08f,0.15f);
1068

    
1069
    mesh.mergeEffComponents();
1070
    mesh.addEmptyTexComponent();
1071
    mesh.addEmptyTexComponent();
1072
    mesh.addEmptyTexComponent();
1073
    mesh.addEmptyTexComponent();
1074

    
1075
    return mesh;
1076
    }
1077

    
1078
///////////////////////////////////////////////////////////////////////////////////////////////////
1079
// DINO
1080

    
1081
  MeshBase createDinoMesh()
1082
    {
1083
    MeshBase mesh = createFacesDino();
1084
    VertexEffect[] effects = createVertexEffectsDino();
1085
    for( VertexEffect effect : effects ) mesh.apply(effect);
1086

    
1087
    float F = 0.5f;
1088
    Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
1089
    Static3D[] verticesRound = new Static3D[4];
1090
    verticesRound[0] = new Static3D(     0,-3*F,    0 );
1091
    verticesRound[1] = new Static3D(     0,   0, -3*F );
1092
    verticesRound[2] = new Static3D(  -3*F,   0,    0 );
1093
    verticesRound[3] = new Static3D(  +3*F,   0,    0 );
1094
    roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
1095

    
1096
    mesh.mergeEffComponents();
1097

    
1098
    return mesh;
1099
    }
1100

    
1101
///////////////////////////////////////////////////////////////////////////////////////////////////
1102
// Helicopter
1103

    
1104
  MeshBase createHelicopterCornerMesh()
1105
    {
1106
    MeshBase mesh = createFacesHelicopterCorner();
1107
    VertexEffect[] effects = createVertexEffectsHelicopterCorner();
1108
    for( VertexEffect effect : effects ) mesh.apply(effect);
1109

    
1110
    float E = 0.5f;
1111
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1112

    
1113
    Static3D[] verticesType1 = new Static3D[1];
1114
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1115
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1116

    
1117
    Static3D[] verticesType2 = new Static3D[3];
1118
    verticesType2[0] = new Static3D(-E, 0, 0);
1119
    verticesType2[1] = new Static3D( 0,-E, 0);
1120
    verticesType2[2] = new Static3D( 0, 0,-E);
1121
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1122

    
1123
    mesh.mergeEffComponents();
1124

    
1125
    return mesh;
1126
    }
1127

    
1128
///////////////////////////////////////////////////////////////////////////////////////////////////
1129

    
1130
  MeshBase createHelicopterFaceMesh()
1131
    {
1132
    MeshBase mesh = createFacesHelicopterFace();
1133
    VertexEffect[] effects = createVertexEffectsHelicopterFace();
1134
    for( VertexEffect effect : effects ) mesh.apply(effect);
1135

    
1136
    float E = 0.5f;
1137
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
1138

    
1139
    Static3D[] verticesType1 = new Static3D[1];
1140
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
1141
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
1142

    
1143
    Static3D[] verticesType2 = new Static3D[2];
1144
    verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
1145
    verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
1146
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1147

    
1148
    mesh.mergeEffComponents();
1149
    mesh.addEmptyTexComponent();
1150
    mesh.addEmptyTexComponent();
1151

    
1152
    return mesh;
1153
    }
1154

    
1155
///////////////////////////////////////////////////////////////////////////////////////////////////
1156
// Redi cube
1157

    
1158
  MeshBase createRediEdgeMesh()
1159
    {
1160
    MeshBase mesh = createFacesRediEdge();
1161
    VertexEffect[] effects = createVertexEffectsRediEdge();
1162
    for( VertexEffect effect : effects ) mesh.apply(effect);
1163

    
1164
    Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
1165
    Static3D[] vertices = new Static3D[2];
1166
    vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
1167
    vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
1168
    roundCorners(mesh,center,vertices,0.06f,0.20f);
1169

    
1170
    mesh.mergeEffComponents();
1171

    
1172
    return mesh;
1173
    }
1174

    
1175
///////////////////////////////////////////////////////////////////////////////////////////////////
1176

    
1177
  MeshBase createRediCornerMesh()
1178
    {
1179
    MeshBase mesh = createFacesRediCorner();
1180
    VertexEffect[] effects = createVertexEffectsRediCorner();
1181
    for( VertexEffect effect : effects ) mesh.apply(effect);
1182

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

    
1194
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1195

    
1196
    mesh.mergeEffComponents();
1197

    
1198
    return mesh;
1199
    }
1200

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

    
1203
  MeshBase createIvyCornerMesh()
1204
    {
1205
    MeshBase mesh = createFacesIvyCorner();
1206
    VertexEffect[] effects = createVertexEffectsIvyCorner();
1207
    for( VertexEffect effect : effects ) mesh.apply(effect);
1208

    
1209
    Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
1210
    Static3D[] vertices = new Static3D[4];
1211
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1212
    vertices[1] = new Static3D(-0.5f,+0.5f,+0.5f);
1213
    vertices[2] = new Static3D(+0.5f,+0.5f,-0.5f);
1214
    vertices[3] = new Static3D(+0.5f,-0.5f,+0.5f);
1215

    
1216
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1217

    
1218
    mesh.mergeEffComponents();
1219

    
1220
    return mesh;
1221
    }
1222

    
1223
///////////////////////////////////////////////////////////////////////////////////////////////////
1224

    
1225
  MeshBase createIvyFaceMesh()
1226
    {
1227
    MeshBase mesh = createFacesIvyFace();
1228

    
1229
    Static3D center = new Static3D(0.0f,0.0f,-0.5f);
1230
    Static3D[] vertices = new Static3D[2];
1231
    vertices[0] = new Static3D(+SQ2/2 -IVY_D,-SQ2/2 +IVY_D,+0.0f);
1232
    vertices[1] = new Static3D(-SQ2/2 +IVY_D,+SQ2/2 -IVY_D,+0.0f);
1233

    
1234
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1235

    
1236
    mesh.mergeEffComponents();
1237
    mesh.addEmptyTexComponent();
1238
    mesh.addEmptyTexComponent();
1239
    mesh.addEmptyTexComponent();
1240
    mesh.addEmptyTexComponent();
1241
    mesh.addEmptyTexComponent();
1242

    
1243
    return mesh;
1244
    }
1245
  }
(2-2/24)