Project

General

Profile

Download (68.1 KB) Statistics
| Branch: | Revision:

examples / src / main / java / org / distorted / examples / meshfile / FactoryCubit.java @ ef02f5e0

1 7edab735 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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.examples.meshfile;
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 55f20739 Leszek Koltunski
class FactoryCubit
37 7edab735 Leszek Koltunski
  {
38
  private static final float SQ2 = (float)Math.sqrt(2);
39
  private static final float SQ3 = (float)Math.sqrt(3);
40 fe032f52 Leszek Koltunski
  private static final float SQ5 = (float)Math.sqrt(5);
41 7edab735 Leszek Koltunski
  private static final float SQ6 = (float)Math.sqrt(6);
42
43 1c41c4c9 Leszek Koltunski
  private static final float IVY_D = 0.003f;
44 55f20739 Leszek Koltunski
  private static final int   IVY_N = 8;
45 1c41c4c9 Leszek Koltunski
  private static final float IVY_C = 0.59f;
46
  private static final float IVY_M = 0.35f;
47 f7936f2f Leszek Koltunski
  private static final float REX_D = 0.2f;
48 7cd30f7c Leszek Koltunski
  private static final int   REX_N = 5;
49 55f20739 Leszek Koltunski
50 6d020cb6 Leszek Koltunski
  static final float SIN18    = (SQ5-1)/4;
51
  static final float COS18    = (float)(0.25f*Math.sqrt(10.0f+2.0f*SQ5));
52
  static final float SIN54    = (SQ5+1)/4;
53
  static final float COS54    = (float)(Math.sqrt(10-2*SQ5)/4);
54 b3d28a81 Leszek Koltunski
  static final float COS_HALFD= (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
55
  static final float SIN_HALFD= (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
56 fe032f52 Leszek Koltunski
57 6d020cb6 Leszek Koltunski
  static final float DIHEDRAL1= (float)(Math.acos(-SQ5/5)*180/Math.PI);
58
  static final float DIHEDRAL2= (float)((180/Math.PI)*Math.asin((2*SIN54*SIN54-1)/COS54) - 90);
59
60 7edab735 Leszek Koltunski
  private static final Static1D RADIUS = new Static1D(1);
61
62 55f20739 Leszek Koltunski
  private static FactoryCubit mThis;
63 7edab735 Leszek Koltunski
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65
66 55f20739 Leszek Koltunski
  private FactoryCubit()
67 7edab735 Leszek Koltunski
    {
68
69
    }
70
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72
73 55f20739 Leszek Koltunski
  public static FactoryCubit getInstance()
74 7edab735 Leszek Koltunski
    {
75 55f20739 Leszek Koltunski
    if( mThis==null ) mThis = new FactoryCubit();
76 7edab735 Leszek Koltunski
77
    return mThis;
78
    }
79
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81
// H - height of the band in the middle
82
// alpha - angle of the edge  [0,90]
83
// dist - often in a polygon the distance from edge to center is not 1, but something else.
84
// This is the distance.
85
// K - where to begin the second, much more flat part of the band. [0,1]
86
// N - number of bands. N>=3
87
//
88
// theory: two distinct parts to the band:
89
// 1) (0,B) - steep
90
// 2) (B,1) - flat
91
//
92
// In first part, we have y = g(x) ; in second - y = g(f(x)) where
93
//
94
// g(x) = sqrt( R^2 - (x-D)^2 ) - R*cos(alpha)
95
// f(x) = ((D-B)/(1-B)*x + B*(1-D)/(1-B)
96
// h(x) = R*(sin(alpha) - sin(x))
97
// R = H/(1-cos(alpha))
98
// D = H*sin(alpha)
99
// B = h(K*alpha)
100
//
101
// The N points are taken at:
102
//
103
// 1) in the second part, there are K2 = (N-3)/3 such points
104
// 2) in the first - K1 = (N-3) - K2
105
// 3) also, the 3 points 0,B,1
106
//
107
// so we have the sequence A[i] of N points
108
//
109
// 0
110
// h((i+1)*(1-K)*alpha/(K1+1)) (i=0,1,...,K1-1)
111
// B
112
// (1-B)*(i+1)/(K2+1) + B   (i=0,i,...,K2-1)
113
// 1
114
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116
117
  private float f(float D, float B, float x)
118
    {
119
    return ((D-B)*x + B*(1-D))/(1-B);
120
    }
121
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123
124
  private float g(float R, float D, float x, float cosAlpha)
125
    {
126
    float d = x-D;
127
    return (float)(Math.sqrt(R*R-d*d)-R*cosAlpha);
128
    }
129
130
///////////////////////////////////////////////////////////////////////////////////////////////////
131
132
  private float h(float R, float sinAlpha, float x)
133
    {
134
    return R*(sinAlpha-(float)Math.sin(x));
135
    }
136
137
///////////////////////////////////////////////////////////////////////////////////////////////////
138
139 55f20739 Leszek Koltunski
  float[] computeBands(float H, int alpha, float dist, float K, int N)
140 7edab735 Leszek Koltunski
    {
141
    float[] bands = new float[2*N];
142
143
    bands[0] = 1.0f;
144
    bands[1] = 0.0f;
145
146
    float beta = (float)Math.atan(dist*Math.tan(Math.PI*alpha/180));
147
    float sinBeta = (float)Math.sin(beta);
148
    float cosBeta = (float)Math.cos(beta);
149
    float R = cosBeta<1.0f ? H/(1.0f-cosBeta) : 0.0f;
150
    float D = R*sinBeta;
151
    float B = h(R,sinBeta,K*beta);
152
153
    if( D>1.0f )
154
      {
155
      for(int i=1; i<N; i++)
156
        {
157
        bands[2*i  ] = (float)(N-1-i)/(N-1);
158
        bands[2*i+1] = H*(1-bands[2*i]);
159
        }
160
      }
161
    else
162
      {
163 55f20739 Leszek Koltunski
      int K2 = (int)((N-3)*K);
164 7edab735 Leszek Koltunski
      int K1 = (N-3)-K2;
165
166
      for(int i=0; i<=K1; i++)
167
        {
168
        float angle = K*beta + (1-K)*beta*(K1-i)/(K1+1);
169
        float x = h(R,sinBeta,angle);
170
        bands[2*i+2] = 1.0f - x;
171
        bands[2*i+3] = g(R,D,x,cosBeta);
172
        }
173
174
      for(int i=0; i<=K2; i++)
175
        {
176
        float x = (1-B)*(i+1)/(K2+1) + B;
177
        bands[2*K1+2 + 2*i+2] = 1.0f - x;
178
        bands[2*K1+2 + 2*i+3] = g(R,D,f(D,B,x),cosBeta);
179
        }
180
      }
181
182 55f20739 Leszek Koltunski
    bands[2*N-2] = 0.0f;
183
    bands[2*N-1] =    H;
184
185 7edab735 Leszek Koltunski
    return bands;
186
    }
187
188
///////////////////////////////////////////////////////////////////////////////////////////////////
189
190
  private void roundCorners(MeshBase mesh, Static3D center, Static3D[] vertices, float strength, float regionRadius)
191
    {
192
    Static4D reg= new Static4D(0,0,0,regionRadius);
193
194
    float centX = center.get0();
195
    float centY = center.get1();
196
    float centZ = center.get2();
197
198
    for (Static3D vertex : vertices)
199
      {
200
      float x = strength*(centX - vertex.get0());
201
      float y = strength*(centY - vertex.get1());
202
      float z = strength*(centZ - vertex.get2());
203
204
      VertexEffect effect = new VertexEffectDeform(new Static3D(x,y,z), RADIUS, vertex, reg);
205
      mesh.apply(effect);
206
      }
207
    }
208
209 7cd30f7c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
210 63fb0859 Leszek Koltunski
// Compute (rx,ry) - coords of a point which is the result of rotation by angle 'radians' of the point
211
// (px,py) along axis Z. Center of rotation: (cx,cy). Rotation is counterclockwise!
212 7cd30f7c Leszek Koltunski
// Write (rx,ry) to array[index] and array[index+1].
213
214 63fb0859 Leszek Koltunski
  private void writeVertex( float cx, float cy, float px, float py, float radians, float[] array, int index)
215 7cd30f7c Leszek Koltunski
    {
216
    float vx = px-cx;
217
    float vy = py-cy;
218
219 63fb0859 Leszek Koltunski
    float sinA = (float)Math.sin(radians);
220
    float cosA = (float)Math.cos(radians);
221 7cd30f7c Leszek Koltunski
222 63fb0859 Leszek Koltunski
    float rvx = vx*cosA - vy*sinA;
223
    float rvy = vx*sinA + vy*cosA;
224 7cd30f7c Leszek Koltunski
225
    array[index  ] = rvx + cx;
226
    array[index+1] = rvy + cy;
227
    }
228
229 7edab735 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
230
231 55f20739 Leszek Koltunski
  MeshBase createFacesCube(int sizeIndex)
232 7edab735 Leszek Koltunski
    {
233 55f20739 Leszek Koltunski
    MeshBase[] meshes = new MeshPolygon[6];
234 7edab735 Leszek Koltunski
235 55f20739 Leszek Koltunski
    float E = 0.5f;
236
    int extraI, extraV, num;
237 7edab735 Leszek Koltunski
238 55f20739 Leszek Koltunski
    switch(sizeIndex)
239 7edab735 Leszek Koltunski
      {
240 55f20739 Leszek Koltunski
      case 0 : num = 6; extraI = 2; extraV = 2; break;
241
      case 1 : num = 5; extraI = 2; extraV = 2; break;
242
      case 2 : num = 5; extraI = 1; extraV = 2; break;
243
      default: num = 4; extraI = 1; extraV = 1; break;
244 7edab735 Leszek Koltunski
      }
245
246 55f20739 Leszek Koltunski
    float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E };
247
    float[] bands = computeBands(0.048f,35,E,0.7f,num);
248 7edab735 Leszek Koltunski
249 55f20739 Leszek Koltunski
    meshes[0] = new MeshPolygon(vertices,bands,extraI,extraV);
250
    meshes[0].setEffectAssociation(0,1,0);
251
    meshes[1] = meshes[0].copy(true);
252
    meshes[1].setEffectAssociation(0,2,0);
253
    meshes[2] = meshes[0].copy(true);
254
    meshes[2].setEffectAssociation(0,4,0);
255
    meshes[3] = meshes[0].copy(true);
256
    meshes[3].setEffectAssociation(0,8,0);
257
    meshes[4] = meshes[0].copy(true);
258
    meshes[4].setEffectAssociation(0,16,0);
259
    meshes[5] = meshes[0].copy(true);
260
    meshes[5].setEffectAssociation(0,32,0);
261 7edab735 Leszek Koltunski
262
    return new MeshJoined(meshes);
263
    }
264
265
///////////////////////////////////////////////////////////////////////////////////////////////////
266
267
  MeshBase createFacesSkewbCorner()
268
    {
269
    MeshBase[] meshes = new MeshBase[6];
270
271
    float E = 0.5f;
272
    float F = SQ2/2;
273 55f20739 Leszek Koltunski
    float G = SQ6/16;
274 7edab735 Leszek Koltunski
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
275 55f20739 Leszek Koltunski
    float[] bands0 = computeBands(0.028f,35,E/3,0.7f,7);
276 7edab735 Leszek Koltunski
277
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
278
    meshes[0].setEffectAssociation(0,1,0);
279
    meshes[1] = meshes[0].copy(true);
280
    meshes[1].setEffectAssociation(0,2,0);
281
    meshes[2] = meshes[0].copy(true);
282
    meshes[2].setEffectAssociation(0,4,0);
283
284 55f20739 Leszek Koltunski
    float[] vertices1 = { -F/2,-2*G, F/2,-2*G, 3*F/8,-G, 1*F/8,G, 0,2*G };
285 7edab735 Leszek Koltunski
    float[] bands1 = computeBands(0,0,1,0,3);
286
287
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
288
    meshes[3].setEffectAssociation(0,8,0);
289
    meshes[4] = meshes[3].copy(true);
290
    meshes[4].setEffectAssociation(0,16,0);
291
    meshes[5] = meshes[3].copy(true);
292
    meshes[5].setEffectAssociation(0,32,0);
293
294
    return new MeshJoined(meshes);
295
    }
296
297
///////////////////////////////////////////////////////////////////////////////////////////////////
298
299
  MeshBase createFacesSkewbFace()
300
    {
301
    MeshBase[] meshes = new MeshBase[5];
302
303
    float E = SQ2/4;
304
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
305 55f20739 Leszek Koltunski
    float[] bands0 = computeBands(0.051f,35,E/2,0.9f,7);
306 7edab735 Leszek Koltunski
307
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
308
    meshes[0].setEffectAssociation(0,1,0);
309
310 6af1e973 Leszek Koltunski
    float[] vertices1 = { -E,-SQ3*E, -E*0.7f,-SQ3*E, +E*0.7f,-SQ3*E, +E,-SQ3*E, 0,0 };
311 7edab735 Leszek Koltunski
    float[] bands1 = computeBands(0,0,1,0,3);
312
313
    meshes[1] = new MeshPolygon(vertices1,bands1,0,0);
314
    meshes[1].setEffectAssociation(0,2,0);
315
    meshes[2] = meshes[1].copy(true);
316
    meshes[2].setEffectAssociation(0,4,0);
317
    meshes[3] = meshes[1].copy(true);
318
    meshes[3].setEffectAssociation(0,8,0);
319
    meshes[4] = meshes[1].copy(true);
320
    meshes[4].setEffectAssociation(0,16,0);
321
322
    return new MeshJoined(meshes);
323
    }
324
325
///////////////////////////////////////////////////////////////////////////////////////////////////
326
327
  MeshBase createFacesOcta()
328
    {
329 55f20739 Leszek Koltunski
    MeshBase[] meshes = new MeshPolygon[8];
330 7edab735 Leszek Koltunski
331 55f20739 Leszek Koltunski
    float E = 0.75f;
332 7edab735 Leszek Koltunski
    float F = 0.5f;
333
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
334 55f20739 Leszek Koltunski
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
335 7edab735 Leszek Koltunski
336
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
337 55f20739 Leszek Koltunski
    meshes[0].setEffectAssociation(0,1,0);
338
    meshes[1] = meshes[0].copy(true);
339
    meshes[1].setEffectAssociation(0,2,0);
340
    meshes[2] = meshes[0].copy(true);
341
    meshes[2].setEffectAssociation(0,4,0);
342
    meshes[3] = meshes[0].copy(true);
343
    meshes[3].setEffectAssociation(0,8,0);
344
    meshes[4] = meshes[0].copy(true);
345
    meshes[4].setEffectAssociation(0,16,0);
346
    meshes[5] = meshes[0].copy(true);
347
    meshes[5].setEffectAssociation(0,32,0);
348
    meshes[6] = meshes[0].copy(true);
349
    meshes[6].setEffectAssociation(0,64,0);
350
    meshes[7] = meshes[0].copy(true);
351
    meshes[7].setEffectAssociation(0,128,0);
352 7edab735 Leszek Koltunski
353
    return new MeshJoined(meshes);
354
    }
355
356
///////////////////////////////////////////////////////////////////////////////////////////////////
357
358
  MeshBase createFacesTetra()
359
    {
360
    MeshBase[] meshes = new MeshBase[4];
361
362 55f20739 Leszek Koltunski
    float E = 0.75f;
363 7edab735 Leszek Koltunski
    float F = 0.5f;
364
    float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
365 55f20739 Leszek Koltunski
    float[] bands = computeBands(0.05f,35,F,0.8f,6);
366 7edab735 Leszek Koltunski
367
    meshes[0] = new MeshPolygon(vertices, bands, 2,2);
368 55f20739 Leszek Koltunski
    meshes[0].setEffectAssociation(0,1,0);
369
    meshes[1] = meshes[0].copy(true);
370
    meshes[1].setEffectAssociation(0,2,0);
371
    meshes[2] = meshes[0].copy(true);
372
    meshes[2].setEffectAssociation(0,4,0);
373
    meshes[3] = meshes[0].copy(true);
374
    meshes[3].setEffectAssociation(0,8,0);
375 7edab735 Leszek Koltunski
376
    return new MeshJoined(meshes);
377
    }
378
379
///////////////////////////////////////////////////////////////////////////////////////////////////
380
381
  MeshBase createFacesDino()
382
    {
383 55f20739 Leszek Koltunski
    MeshBase[] meshes = new MeshPolygon[4];
384 7edab735 Leszek Koltunski
385
    float E = 0.5f*SQ2;
386
    float F = 0.5f;
387
    float[] vertices0 = { -F,F/3, 0,-2*F/3, +F,F/3 };
388 55f20739 Leszek Koltunski
    float[] bands0 = computeBands(0.028f,30,F/3,0.8f,7);
389 7edab735 Leszek Koltunski
390
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 5);
391
    meshes[0].setEffectAssociation(0,1,0);
392
    meshes[1] = meshes[0].copy(true);
393
    meshes[1].setEffectAssociation(0,2,0);
394
395
    float[] vertices1 = { -E/2,-E*(SQ3/6), E/2,-E*(SQ3/6), 0,E*(SQ3/3) };
396
    float[] bands1 = computeBands(0.02f,45,F/3,0.2f,3);
397
398
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
399
    meshes[2].setEffectAssociation(0,4,0);
400
    meshes[3] = meshes[2].copy(true);
401
    meshes[3].setEffectAssociation(0,8,0);
402
403
    return new MeshJoined(meshes);
404
    }
405
406
///////////////////////////////////////////////////////////////////////////////////////////////////
407
408
  MeshBase createFacesHelicopterCorner()
409
    {
410
    MeshBase[] meshes = new MeshBase[6];
411
412
    float E = 0.5f;
413
    float F = SQ2/4;
414
    float G = 1.0f/12;
415
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
416 55f20739 Leszek Koltunski
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
417 7edab735 Leszek Koltunski
418
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
419
    meshes[0].setEffectAssociation(0,1,0);
420
    meshes[1] = meshes[0].copy(true);
421
    meshes[1].setEffectAssociation(0,2,0);
422
    meshes[2] = meshes[0].copy(true);
423
    meshes[2].setEffectAssociation(0,4,0);
424
425
    float[] vertices1 = { -F,-G, 0,-G, +F,-G, 0,2*G };
426
    float[] bands1 = computeBands(0.00f,0,0,0.0f,3);
427
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
428
    meshes[3].setEffectAssociation(0,8,0);
429
    meshes[4] = meshes[3].copy(true);
430
    meshes[4].setEffectAssociation(0,16,0);
431
    meshes[5] = meshes[3].copy(true);
432
    meshes[5].setEffectAssociation(0,32,0);
433
434
    return new MeshJoined(meshes);
435
    }
436
437
///////////////////////////////////////////////////////////////////////////////////////////////////
438
439
  MeshBase createFacesHelicopterFace()
440
    {
441
    MeshBase[] meshes = new MeshBase[4];
442
443
    float E = 0.5f;
444
    float F = SQ2/4;
445
    float G = 1.0f/12;
446
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
447 55f20739 Leszek Koltunski
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
448 7edab735 Leszek Koltunski
449
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
450
    meshes[0].setEffectAssociation(0,1,0);
451
452
    float[] vertices1 = { -F,-G, +F,-G, 0,2*G};
453
    float[] bands1 = computeBands(0.01f,45,F,0.0f,3);
454
455
    meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3);
456
    meshes[1].setEffectAssociation(0,2,0);
457
458
    float[] vertices2 = { -E/2,-F/3, +E/2,-F/3, 0,2*F/3};
459
460
    meshes[2] = new MeshPolygon(vertices2, bands1, 1, 3);
461
    meshes[2].setEffectAssociation(0,4,0);
462
    meshes[3] = meshes[2].copy(true);
463
    meshes[3].setEffectAssociation(0,8,0);
464
465
    return new MeshJoined(meshes);
466
    }
467
468
///////////////////////////////////////////////////////////////////////////////////////////////////
469
470
  MeshBase createFacesRediEdge()
471
    {
472 55f20739 Leszek Koltunski
    MeshBase[] meshes = new MeshPolygon[6];
473 7edab735 Leszek Koltunski
474 55f20739 Leszek Koltunski
    float F = 0.25f;
475 7edab735 Leszek Koltunski
    float[] vertices0 = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F };
476 55f20739 Leszek Koltunski
    float[] bands0 = computeBands(0.038f,35,F,0.7f,7);
477 7edab735 Leszek Koltunski
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
483 55f20739 Leszek Koltunski
    float[] bands1 = computeBands(0.02f,35,F/2,0.2f,3);
484 7edab735 Leszek Koltunski
    float[] vertices1 = { -F/2, +F/2, -F/2, -1.5f*F, 1.5f*F, +F/2 };
485
486
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
487
    meshes[2].setEffectAssociation(0,4,0);
488
    meshes[3] = meshes[2].copy(true);
489
    meshes[3].setEffectAssociation(0,8,0);
490
491
    float X = 0.25f*SQ2;
492
    float Y = SQ6/16;
493
    float[] vertices2 = { -X, Y, -1.5f*X, -Y, +1.5f*X, -Y, +X, Y };
494
495
    meshes[4] = new MeshPolygon(vertices2, bands1, 1, 1);
496
    meshes[4].setEffectAssociation(0,16,0);
497
    meshes[5] = meshes[4].copy(true);
498
    meshes[5].setEffectAssociation(0,32,0);
499
500
    return new MeshJoined(meshes);
501
    }
502
503
///////////////////////////////////////////////////////////////////////////////////////////////////
504
505
  MeshBase createFacesRediCorner()
506
    {
507 55f20739 Leszek Koltunski
    MeshBase[] meshes = new MeshBase[6];
508 7edab735 Leszek Koltunski
509
    float E = 0.5f;
510 55f20739 Leszek Koltunski
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
511
    float[] bands0 = computeBands(0.06f,35,E,0.7f,6);
512 7edab735 Leszek Koltunski
513 55f20739 Leszek Koltunski
    meshes[0] = new MeshPolygon(vertices0,bands0,2,2);
514 7edab735 Leszek Koltunski
    meshes[0].setEffectAssociation(0,1,0);
515
    meshes[1] = meshes[0].copy(true);
516
    meshes[1].setEffectAssociation(0,2,0);
517
    meshes[2] = meshes[0].copy(true);
518
    meshes[2].setEffectAssociation(0,4,0);
519
520 55f20739 Leszek Koltunski
    float F = 0.5f;
521 7edab735 Leszek Koltunski
    float X = 0.5f;
522
    float G = 0.72f;
523 55f20739 Leszek Koltunski
    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 };
524
    float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2);
525 7edab735 Leszek Koltunski
526 55f20739 Leszek Koltunski
    meshes[3] = new MeshPolygon(vertices1,bands1,0,0);
527 7edab735 Leszek Koltunski
    meshes[3].setEffectAssociation(0,8,0);
528
    meshes[4] = meshes[3].copy(true);
529
    meshes[4].setEffectAssociation(0,16,0);
530
    meshes[5] = meshes[3].copy(true);
531
    meshes[5].setEffectAssociation(0,32,0);
532
533
    return new MeshJoined(meshes);
534
    }
535
536 55f20739 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
537
538
  MeshBase createFacesIvyCorner()
539
    {
540
    MeshBase[] meshes = new MeshBase[6];
541
542
    final float angle = (float)Math.PI/(2*IVY_N);
543 1c41c4c9 Leszek Koltunski
    final float CORR  = 1.0f - 2*IVY_D;
544
    final float DIST  = -0.5f*CORR + IVY_D;
545
    float[] vertices  = new float[2*(IVY_N+1)+6];
546 55f20739 Leszek Koltunski
547 1c41c4c9 Leszek Koltunski
    vertices[0] = (0.5f-IVY_M) * IVY_C;
548
    vertices[1] = (DIST-IVY_M) * IVY_C;
549
    vertices[2] = (0.5f-IVY_M) * IVY_C;
550
    vertices[3] = (0.5f-IVY_M) * IVY_C;
551
    vertices[4] = (DIST-IVY_M) * IVY_C;
552
    vertices[5] = (0.5f-IVY_M) * IVY_C;
553 55f20739 Leszek Koltunski
554
    for(int i=0; i<=IVY_N; i++)
555
      {
556 1c41c4c9 Leszek Koltunski
      float ang = (IVY_N-i)*angle;
557
      float sin = (float)Math.sin(ang);
558
      float cos = (float)Math.cos(ang);
559 55f20739 Leszek Koltunski
560 1c41c4c9 Leszek Koltunski
      vertices[2*i+6] = (CORR*(cos-0.5f)-IVY_M)*IVY_C;
561
      vertices[2*i+7] = (CORR*(sin-0.5f)-IVY_M)*IVY_C;
562 55f20739 Leszek Koltunski
      }
563
564 1c41c4c9 Leszek Koltunski
    float[] bands0 = computeBands(+0.012f,20,0.2f,0.5f,7);
565
    float[] bands1 = computeBands(-0.100f,20,0.2f,0.0f,2);
566 55f20739 Leszek Koltunski
567 1c41c4c9 Leszek Koltunski
    meshes[0] = new MeshPolygon(vertices,bands0,1,2);
568 55f20739 Leszek Koltunski
    meshes[0].setEffectAssociation(0,1,0);
569
    meshes[1] = meshes[0].copy(true);
570
    meshes[1].setEffectAssociation(0,2,0);
571
    meshes[2] = meshes[0].copy(true);
572
    meshes[2].setEffectAssociation(0,4,0);
573 1c41c4c9 Leszek Koltunski
    meshes[3] = new MeshPolygon(vertices,bands1,1,2);
574 55f20739 Leszek Koltunski
    meshes[3].setEffectAssociation(0,8,0);
575
    meshes[4] = meshes[3].copy(true);
576
    meshes[4].setEffectAssociation(0,16,0);
577
    meshes[5] = meshes[3].copy(true);
578
    meshes[5].setEffectAssociation(0,32,0);
579
580
    return new MeshJoined(meshes);
581
    }
582
583
///////////////////////////////////////////////////////////////////////////////////////////////////
584
585
  MeshBase createFacesIvyFace()
586
    {
587
    MeshBase[] meshes = new MeshBase[2];
588
589
    final float angle = (float)Math.PI/(2*IVY_N);
590
    final float CORR  = 1.0f - IVY_D*SQ2;
591
    float[] vertices = new float[4*IVY_N];
592
593
    for(int i=0; i<IVY_N; i++)
594
      {
595
      float sin = (float)Math.sin(i*angle);
596
      float cos = (float)Math.cos(i*angle);
597
598
      vertices[2*i          ] = CORR*(0.5f-cos);
599
      vertices[2*i+1        ] = CORR*(0.5f-sin);
600
      vertices[2*i  +2*IVY_N] = CORR*(cos-0.5f);
601
      vertices[2*i+1+2*IVY_N] = CORR*(sin-0.5f);
602
      }
603
604
    float[] bands0 = computeBands(+0.05f,35,0.5f,0.5f,5);
605
    float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2);
606
607
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
608
    meshes[0].setEffectAssociation(0,1,0);
609
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
610
    meshes[1].setEffectAssociation(0,2,0);
611
612
    return new MeshJoined(meshes);
613
    }
614
615 7cd30f7c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
616
617
  MeshBase createFacesRexCorner()
618
    {
619
    MeshBase[] meshes = new MeshBase[2];
620
621
    final float angle = (float)Math.PI/(6*REX_N);
622
    float[] vertices = new float[6*REX_N];
623
    final float D = 0.5f - REX_D;
624 63fb0859 Leszek Koltunski
    final float F = D*SQ2*(SQ3-1);
625
    final float B = 2.5f;
626 7cd30f7c Leszek Koltunski
627
    final float V1x = -F*0.5f;
628
    final float V1y = -F*SQ3/6;
629
    final float V2x = -V1x;
630
    final float V2y = V1y;
631
    final float V3x = 0.0f;
632
    final float V3y = -2*V1y;
633
634
    final float C1x = 0.0f;
635 63fb0859 Leszek Koltunski
    final float C1y = -F*(1+2*SQ3/3);
636
    final float C2x = B*V1x;
637
    final float C2y = B*V1y;
638
    final float C3x = B*V2x;
639
    final float C3y = B*V2y;
640 7cd30f7c Leszek Koltunski
641
    for(int i=0; i<REX_N; i++)
642
      {
643 63fb0859 Leszek Koltunski
      writeVertex(C1x,C1y,V1x,V1y,-i*angle, vertices, 2*i          );
644 7cd30f7c Leszek Koltunski
      writeVertex(C2x,C2y,V2x,V2y, i*angle, vertices, 2*i + 2*REX_N);
645
      writeVertex(C3x,C3y,V3x,V3y, i*angle, vertices, 2*i + 4*REX_N);
646
      }
647
648 63fb0859 Leszek Koltunski
    float[] bands0 = computeBands(+0.02f,10,0.5f,0.5f,5);
649 7cd30f7c Leszek Koltunski
    float[] bands1 = computeBands(-0.00f,45,0.5f,0.0f,2);
650
651
    meshes[0] = new MeshPolygon(vertices,bands0,1,1);
652
    meshes[0].setEffectAssociation(0,1,0);
653
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
654
    meshes[1].setEffectAssociation(0,2,0);
655
656
    return new MeshJoined(meshes);
657
    }
658
659
///////////////////////////////////////////////////////////////////////////////////////////////////
660
661
  MeshBase createFacesRexFace()
662
    {
663
    MeshBase[] meshes = new MeshBase[2];
664
665
    final float angle = (float)Math.PI/(6*REX_N);
666
    float[] vertices = new float[8*REX_N];
667
    final float D = 0.5f - REX_D;
668 63fb0859 Leszek Koltunski
    final float F = D*(SQ3-1);
669 7cd30f7c Leszek Koltunski
670
    final float V1x = 0.0f;
671
    final float V1y = +F;
672 63fb0859 Leszek Koltunski
    final float V2x = -F;
673 7cd30f7c Leszek Koltunski
    final float V2y = 0.0f;
674
    final float V3x = 0.0f;
675
    final float V3y = -F;
676 63fb0859 Leszek Koltunski
    final float V4x = +F;
677 7cd30f7c Leszek Koltunski
    final float V4y = 0.0f;
678
679 63fb0859 Leszek Koltunski
    final float C1x = +D;
680 7cd30f7c Leszek Koltunski
    final float C1y = -D;
681 63fb0859 Leszek Koltunski
    final float C2x = +D;
682 7cd30f7c Leszek Koltunski
    final float C2y = +D;
683 63fb0859 Leszek Koltunski
    final float C3x = -D;
684 7cd30f7c Leszek Koltunski
    final float C3y = +D;
685 63fb0859 Leszek Koltunski
    final float C4x = -D;
686 7cd30f7c Leszek Koltunski
    final float C4y = -D;
687
688
    for(int i=0; i<REX_N; i++)
689
      {
690
      writeVertex(C1x,C1y,V1x,V1y, i*angle, vertices, 2*i          );
691
      writeVertex(C2x,C2y,V2x,V2y, i*angle, vertices, 2*i + 2*REX_N);
692
      writeVertex(C3x,C3y,V3x,V3y, i*angle, vertices, 2*i + 4*REX_N);
693
      writeVertex(C4x,C4y,V4x,V4y, i*angle, vertices, 2*i + 6*REX_N);
694
      }
695
696 63fb0859 Leszek Koltunski
    float[] bands0 = computeBands(+0.02f,10,0.5f,0.5f,5);
697 7cd30f7c Leszek Koltunski
    float[] bands1 = computeBands(-0.00f,45,0.5f,0.0f,2);
698
699
    meshes[0] = new MeshPolygon(vertices,bands0,0,0);
700
    meshes[0].setEffectAssociation(0,1,0);
701
    meshes[1] = new MeshPolygon(vertices,bands1,0,0);
702
    meshes[1].setEffectAssociation(0,2,0);
703
704
    return new MeshJoined(meshes);
705
    }
706
707
///////////////////////////////////////////////////////////////////////////////////////////////////
708
709
  MeshBase createFacesRexEdge()
710
    {
711 f7936f2f Leszek Koltunski
    MeshBase[] meshes = new MeshPolygon[6];
712 63fb0859 Leszek Koltunski
713 f7936f2f Leszek Koltunski
    float E = 0.5f - REX_D;
714
    float F = 0.5f;
715
    float[] vertices0 = { -F,E/3, 0,-2*E/3, +F,E/3 };
716
    float[] bands0 = computeBands(0.03f,27,F/3,0.8f,5);
717 7cd30f7c Leszek Koltunski
718 f7936f2f Leszek Koltunski
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 3);
719 7cd30f7c Leszek Koltunski
    meshes[0].setEffectAssociation(0,1,0);
720
    meshes[1] = meshes[0].copy(true);
721
    meshes[1].setEffectAssociation(0,2,0);
722 f7936f2f Leszek Koltunski
723
    float G = (float)Math.sqrt(E*E+F*F);
724
    float[] vertices1 = { -2*G/3, -E/3, G/3, -E/3, G/3, 2*E/3 };
725
    float[] bands1 = computeBands(0.00f,45,G/3,0.2f,3);
726
727
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
728 7cd30f7c Leszek Koltunski
    meshes[2].setEffectAssociation(0,4,0);
729
    meshes[3] = meshes[2].copy(true);
730
    meshes[3].setEffectAssociation(0,8,0);
731 f7936f2f Leszek Koltunski
    meshes[4] = meshes[2].copy(true);
732
    meshes[4].setEffectAssociation(0,16,0);
733
    meshes[5] = meshes[2].copy(true);
734
    meshes[5].setEffectAssociation(0,32,0);
735
736 7cd30f7c Leszek Koltunski
    return new MeshJoined(meshes);
737
    }
738
739 fe032f52 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
740
741 b3d28a81 Leszek Koltunski
  MeshBase createFacesKilominxCorner()
742 fe032f52 Leszek Koltunski
    {
743
    MeshBase[] meshes = new MeshPolygon[6];
744
745
    float X1= (SQ5+1)/8;
746
    float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
747
    float Y2= Y1 - (float)(Math.sqrt(10-2*SQ5)/8);
748 b3d28a81 Leszek Koltunski
    float H = 0.5f* SIN54 / COS54;
749
    float X2= H*SIN_HALFD;
750
    float Y3= H/(2*COS_HALFD);
751
    float Y4= H*(1/(2*COS_HALFD) - COS_HALFD);
752 fe032f52 Leszek Koltunski
753
    float[] vertices0 = { -X1, Y2, 0, -Y1, X1, Y2, 0, Y1 };
754
    float[] bands0 = computeBands(0.03f,39,0.3f,0.2f,5);
755
    float[] vertices1 = { -X2, Y4, 0, -Y3, X2, Y4, 0, Y3 };
756 e0838536 Leszek Koltunski
    float[] bands1 = computeBands(0.00f,27,0.25f,0.5f,5);
757 fe032f52 Leszek Koltunski
758
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
759
    meshes[0].setEffectAssociation(0, 1,0);
760
    meshes[1] = meshes[0].copy(true);
761
    meshes[1].setEffectAssociation(0, 2,0);
762
    meshes[2] = meshes[0].copy(true);
763
    meshes[2].setEffectAssociation(0, 4,0);
764 e0838536 Leszek Koltunski
    meshes[3] = new MeshPolygon(vertices1, bands1, 1, 1);
765 fe032f52 Leszek Koltunski
    meshes[3].setEffectAssociation(0, 8,0);
766
    meshes[4] = meshes[3].copy(true);
767
    meshes[4].setEffectAssociation(0,16,0);
768
    meshes[5] = meshes[3].copy(true);
769
    meshes[5].setEffectAssociation(0,32,0);
770
771
    return new MeshJoined(meshes);
772
    }
773
774 b3d28a81 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
775
776
  MeshBase createFacesMegaminxCorner()
777
    {
778
    MeshBase[] meshes = new MeshPolygon[6];
779
780
    float Y = COS54/(2*SIN54);
781
782
    float[] vertices0 = { -0.5f, 0.0f, 0.0f, -Y, 0.5f, 0.0f, 0.0f, Y };
783
    float[] bands0 = computeBands(0.04f,34,0.3f,0.2f,5);
784
    float[] bands1 = computeBands(0.00f,34,0.3f,0.2f,2);
785
786
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
787
    meshes[0].setEffectAssociation(0, 1,0);
788
    meshes[1] = meshes[0].copy(true);
789
    meshes[1].setEffectAssociation(0, 2,0);
790
    meshes[2] = meshes[0].copy(true);
791
    meshes[2].setEffectAssociation(0, 4,0);
792
    meshes[3] = new MeshPolygon(vertices0, bands1, 1, 4);
793
    meshes[3].setEffectAssociation(0, 8,0);
794
    meshes[4] = meshes[3].copy(true);
795
    meshes[4].setEffectAssociation(0,16,0);
796
    meshes[5] = meshes[3].copy(true);
797
    meshes[5].setEffectAssociation(0,32,0);
798
799
    return new MeshJoined(meshes);
800
    }
801
802 6d020cb6 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
803
804
  MeshBase createFacesMegaminxEdge(float width, float height)
805
    {
806
    MeshBase[] meshes = new MeshPolygon[6];
807
808
    float D = height/COS18;
809
    float W = D*SIN18;
810
811
    float Y1 = 0.5f*width;
812
    float Y2 = 0.5f*width + W;
813
    float Y3 = 0.5f*width + 2*W;
814
    float X2 = D*SIN54;
815
    float X1 = 0.5f*height;
816
    float Y4 = D*COS54;
817
818
    float[] vertices0 = { -X1, Y1, -X1, -Y1, X1, -Y2, X1, Y2 };
819
    float[] vertices1 = { -X1, Y3, -X1, -Y3, X1, -Y2, X1, Y2 };
820
    float[] vertices2 = { -X2, 0.0f, 0.0f, -Y4, X2, 0.0f, 0.0f, Y4 };
821
822
    float[] bands0 = computeBands(0.04f,34,  X1,0.2f,5);
823
    float[] bands1 = computeBands(0.00f,34,0.3f,0.2f,2);
824
825
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
826
    meshes[0].setEffectAssociation(0, 1,0);
827
    meshes[1] = meshes[0].copy(true);
828
    meshes[1].setEffectAssociation(0, 2,0);
829
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 4);
830
    meshes[2].setEffectAssociation(0, 4,0);
831
    meshes[3] = meshes[2].copy(true);
832
    meshes[3].setEffectAssociation(0, 8,0);
833
    meshes[4] = new MeshPolygon(vertices2, bands1, 1, 4);
834
    meshes[4].setEffectAssociation(0,16,0);
835
    meshes[5] = meshes[4].copy(true);
836
    meshes[5].setEffectAssociation(0,32,0);
837
838
    return new MeshJoined(meshes);
839
    }
840
841 55f20739 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
842
// EFFECTS
843 7edab735 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
844
845
  VertexEffect[] createVertexEffectsCube()
846
    {
847
    Static3D axisY   = new Static3D(0,1,0);
848
    Static3D axisX   = new Static3D(1,0,0);
849
    Static3D center  = new Static3D(0,0,0);
850
    Static1D angle90 = new Static1D(90);
851
    Static1D angle180= new Static1D(180);
852
    Static1D angle270= new Static1D(270);
853
854
    VertexEffect[] effect = new VertexEffect[6];
855
856
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
857
    effect[1] = new VertexEffectRotate( angle180, axisX, center );
858
    effect[2] = new VertexEffectRotate( angle90 , axisX, center );
859
    effect[3] = new VertexEffectRotate( angle270, axisX, center );
860
    effect[4] = new VertexEffectRotate( angle270, axisY, center );
861
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
862
863
    effect[0].setMeshAssociation(63,-1);  // all 6 sides
864
    effect[1].setMeshAssociation(32,-1);  // back
865
    effect[2].setMeshAssociation( 8,-1);  // bottom
866
    effect[3].setMeshAssociation( 4,-1);  // top
867
    effect[4].setMeshAssociation( 2,-1);  // left
868
    effect[5].setMeshAssociation( 1,-1);  // right
869
870
    return effect;
871
    }
872
873
///////////////////////////////////////////////////////////////////////////////////////////////////
874
875
  VertexEffect[] createVertexEffectsSkewbCorner()
876
    {
877
    float E = 0.5f;
878
879
    Static3D axisX  = new Static3D(1,0,0);
880
    Static3D axisY  = new Static3D(0,1,0);
881
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
882
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
883
    Static1D angle1 = new Static1D(+90);
884
    Static1D angle2 = new Static1D(-90);
885
    Static1D angle3 = new Static1D(-15);
886
    Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
887
    Static1D angle5 = new Static1D(120);
888
    Static1D angle6 = new Static1D(240);
889
    Static3D center1= new Static3D(0,0,0);
890
    Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
891
    Static3D move1  = new Static3D(-E/4,-E/4,0);
892 55f20739 Leszek Koltunski
    Static3D move2  = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
893 7edab735 Leszek Koltunski
894
    VertexEffect[] effect = new VertexEffect[10];
895
896
    effect[0] = new VertexEffectMove(move1);
897
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
898
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
899
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
900
    effect[4] = new VertexEffectMove(move2);
901
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
902
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
903
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
904
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
905
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
906
907
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
908
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
909
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
910
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
911
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
912
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
913
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
914
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
915
    effect[8].setMeshAssociation(16,-1);  // mesh 4
916
    effect[9].setMeshAssociation(32,-1);  // mesh 5
917
918
    return effect;
919
    }
920
921
///////////////////////////////////////////////////////////////////////////////////////////////////
922
923
  VertexEffect[] createVertexEffectsSkewbFace()
924
    {
925
    Static3D center = new Static3D(0,0,0);
926
    Static3D axisX  = new Static3D(1,0,0);
927
    Static3D axisZ  = new Static3D(0,0,1);
928
    float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
929
930
    VertexEffect[] effect = new VertexEffect[6];
931
932
    effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center);
933
    effect[1] = new VertexEffectRotate( new Static1D(  135), axisZ, center);
934
    effect[2] = new VertexEffectRotate( new Static1D(   45), axisZ, center);
935
    effect[3] = new VertexEffectRotate( new Static1D(  -45), axisZ, center);
936
    effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center);
937
    effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) );
938
939
    effect[0].setMeshAssociation(30,-1);  // meshes 1,2,3,4
940
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
941
    effect[2].setMeshAssociation( 5,-1);  // meshes 0,2
942
    effect[3].setMeshAssociation( 8,-1);  // mesh 3
943
    effect[4].setMeshAssociation(16,-1);  // mesh 4
944
    effect[5].setMeshAssociation(30,-1);  // meshes 1,2,3,4
945
946
    return effect;
947
    }
948
949
///////////////////////////////////////////////////////////////////////////////////////////////////
950
951
  VertexEffect[] createVertexEffectsOcta()
952
    {
953
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
954
    Static1D angle1= new Static1D( 90);
955
    Static1D angle2= new Static1D(180);
956
    Static1D angle3= new Static1D(270);
957
    Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
958
    Static3D axisX = new Static3D(1,0,0);
959
    Static3D axisY = new Static3D(0,1,0);
960
    Static3D cent0 = new Static3D(0,0,0);
961
    Static3D cent1 = new Static3D(0,SQ2/2,0);
962
    Static3D flipY = new Static3D( 1,-1, 1);
963 55f20739 Leszek Koltunski
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
964 7edab735 Leszek Koltunski
965 55f20739 Leszek Koltunski
    VertexEffect[] effect = new VertexEffect[7];
966 7edab735 Leszek Koltunski
967 55f20739 Leszek Koltunski
    effect[0] = new VertexEffectScale(scale);
968
    effect[1] = new VertexEffectMove(move1);
969
    effect[2] = new VertexEffectRotate(alpha , axisX, cent1);
970
    effect[3] = new VertexEffectRotate(angle1, axisY, cent0);
971
    effect[4] = new VertexEffectRotate(angle2, axisY, cent0);
972
    effect[5] = new VertexEffectRotate(angle3, axisY, cent0);
973
    effect[6] = new VertexEffectScale(flipY);
974 7edab735 Leszek Koltunski
975 55f20739 Leszek Koltunski
    effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
976
    effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
977
    effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7
978
    effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
979 7edab735 Leszek Koltunski
980
    return effect;
981
    }
982
983
///////////////////////////////////////////////////////////////////////////////////////////////////
984
985
  VertexEffect[] createVertexEffectsTetra()
986
    {
987
    Static3D flipZ = new Static3D( 1, 1,-1);
988
    Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
989
    Static1D angle1= new Static1D( 90);
990
    Static1D angle2= new Static1D(180);
991
    Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
992
    Static3D axisX = new Static3D(1,0,0);
993
    Static3D axisY = new Static3D(0,1,0);
994
    Static3D axisZ = new Static3D(0,0,1);
995
    Static3D cent0 = new Static3D(0,0,0);
996
    Static3D cent1 = new Static3D(0,SQ2/4,0);
997 55f20739 Leszek Koltunski
    Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
998 7edab735 Leszek Koltunski
999 55f20739 Leszek Koltunski
    VertexEffect[] effect = new VertexEffect[7];
1000 7edab735 Leszek Koltunski
1001 55f20739 Leszek Koltunski
    effect[0] = new VertexEffectScale(scale);
1002
    effect[1] = new VertexEffectRotate(angle2, axisZ, cent0);
1003
    effect[2] = new VertexEffectMove(move1);
1004
    effect[3] = new VertexEffectRotate(alpha , axisX, cent1);
1005
    effect[4] = new VertexEffectScale(flipZ);
1006
    effect[5] = new VertexEffectRotate(angle1, axisY, cent0);
1007
    effect[6] = new VertexEffectRotate(angle2, axisZ, cent0);
1008
1009
    effect[4].setMeshAssociation(10,-1); // meshes 1 & 3
1010 7edab735 Leszek Koltunski
    effect[5].setMeshAssociation(12,-1); // meshes 2 & 3
1011 55f20739 Leszek Koltunski
    effect[6].setMeshAssociation(12,-1); // meshes 2 & 3
1012 7edab735 Leszek Koltunski
1013
    return effect;
1014
    }
1015
1016
///////////////////////////////////////////////////////////////////////////////////////////////////
1017
1018
  VertexEffect[] createVertexEffectsDino()
1019
    {
1020
    float E = 0.5f*SQ2;
1021
    float F = 0.5f;
1022
    final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
1023
1024
    Static1D angle1 = new Static1D(-ANGLE);
1025
    Static1D angle2 = new Static1D(+ANGLE);
1026
    Static3D axisX  = new Static3D(1,0,0);
1027
    Static3D axisY  = new Static3D(0,1,0);
1028
    Static3D axisZ  = new Static3D(0,-1,1);
1029
    Static3D center0= new Static3D(0,0,0);
1030
    Static3D center1= new Static3D(0,-3*F,0);
1031
1032
    VertexEffect[] effect = new VertexEffect[10];
1033
1034
    effect[0] = new VertexEffectScale ( new Static3D(3,3,3) );
1035
    effect[1] = new VertexEffectMove  ( new Static3D(0,-F,0) );
1036
    effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 );
1037
    effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) );
1038
    effect[4] = new VertexEffectMove  ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
1039
    effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
1040
    effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) );
1041
    effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
1042
    effect[8] = new VertexEffectRotate( angle1           , axisZ, center1 );
1043
    effect[9] = new VertexEffectRotate( angle2           , axisZ, center1 );
1044
1045
    effect[0].setMeshAssociation(15,-1);  // apply to meshes 0,1,2,3
1046
    effect[1].setMeshAssociation( 3,-1);  // apply to meshes 0,1
1047
    effect[2].setMeshAssociation( 2,-1);  // apply to mesh 1
1048
    effect[3].setMeshAssociation( 2,-1);  // apply to mesh 0
1049
    effect[4].setMeshAssociation(12,-1);  // apply to meshes 2,3
1050
    effect[5].setMeshAssociation(12,-1);  // apply to meshes 2,3
1051
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
1052
    effect[7].setMeshAssociation(12,-1);  // apply to meshes 2,3
1053
    effect[8].setMeshAssociation( 4,-1);  // apply to mesh 2
1054
    effect[9].setMeshAssociation( 8,-1);  // apply to mesh 3
1055
1056
    return effect;
1057
    }
1058
1059
///////////////////////////////////////////////////////////////////////////////////////////////////
1060
1061
  VertexEffect[] createVertexEffectsHelicopterCorner()
1062
    {
1063
    float E = 0.5f;
1064
1065
    Static3D axisX  = new Static3D(1,0,0);
1066
    Static3D axisY  = new Static3D(0,1,0);
1067
    Static3D axis0  = new Static3D(-SQ2/2,0,SQ2/2);
1068
    Static3D axis1  = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
1069
    Static1D angle1 = new Static1D(+90);
1070
    Static1D angle2 = new Static1D(-90);
1071
    Static1D angle3 = new Static1D(-135);
1072
    Static1D angle4 = new Static1D(90);
1073
    Static1D angle5 = new Static1D(120);
1074
    Static1D angle6 = new Static1D(240);
1075
    Static3D center1= new Static3D(0,0,0);
1076
    Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
1077
    Static3D move1  = new Static3D(-E/4,-E/4,0);
1078
    Static3D move2  = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
1079
1080
    VertexEffect[] effect = new VertexEffect[10];
1081
1082
    effect[0] = new VertexEffectMove(move1);
1083
    effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
1084
    effect[2] = new VertexEffectRotate(angle1,axisX,center1);
1085
    effect[3] = new VertexEffectRotate(angle2,axisY,center1);
1086
    effect[4] = new VertexEffectMove(move2);
1087
    effect[5] = new VertexEffectRotate(angle1,axisX,center2);
1088
    effect[6] = new VertexEffectRotate(angle3,axisY,center2);
1089
    effect[7] = new VertexEffectRotate(angle4,axis0,center2);
1090
    effect[8] = new VertexEffectRotate(angle5,axis1,center2);
1091
    effect[9] = new VertexEffectRotate(angle6,axis1,center2);
1092
1093
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1094
    effect[1].setMeshAssociation( 6,-1);  // meshes 1,2
1095
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1096
    effect[3].setMeshAssociation( 4,-1);  // mesh 2
1097
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1098
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1099
    effect[6].setMeshAssociation(56,-1);  // meshes 3,4,5
1100
    effect[7].setMeshAssociation(56,-1);  // meshes 3,4,5
1101
    effect[8].setMeshAssociation(16,-1);  // mesh 4
1102
    effect[9].setMeshAssociation(32,-1);  // mesh 5
1103
1104
    return effect;
1105
    }
1106
1107
///////////////////////////////////////////////////////////////////////////////////////////////////
1108
1109
  VertexEffect[] createVertexEffectsHelicopterFace()
1110
    {
1111
    float E = 0.5f;
1112
    float F = SQ2/4;
1113
1114
    Static3D move0  = new Static3D(-E/4, -E/4, 0);
1115
    Static3D move1  = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
1116
    Static3D move2  = new Static3D(-E/2, F/3, 0);
1117
    Static3D move3  = new Static3D(+E/2, F/3, 0);
1118
    Static3D move4  = new Static3D(+E/3,+E/3, 0);
1119
    Static1D angle1 = new Static1D(135);
1120
    Static1D angle2 = new Static1D(90);
1121
    Static1D angle3 = new Static1D(-90);
1122
    Static1D angle4 = new Static1D(-135);
1123
    Static3D axisX  = new Static3D(1,0,0);
1124
    Static3D axisY  = new Static3D(0,1,0);
1125
    Static3D axisZ  = new Static3D(0,0,1);
1126
    Static3D axis1  = new Static3D(1,-1,0);
1127
    Static3D center = new Static3D(0,0,0);
1128
    Static3D center1= new Static3D(-E/2,-E/2,0);
1129
1130
    VertexEffect[] effect = new VertexEffect[10];
1131
1132
    effect[0] = new VertexEffectMove(move0);
1133
    effect[1] = new VertexEffectRotate(angle1, axisZ, center);
1134
    effect[2] = new VertexEffectMove(move1);
1135
    effect[3] = new VertexEffectRotate(angle2, axis1, center1);
1136
    effect[4] = new VertexEffectMove(move2);
1137
    effect[5] = new VertexEffectMove(move3);
1138
    effect[6] = new VertexEffectRotate(angle3, axisZ, center);
1139
    effect[7] = new VertexEffectRotate(angle4, axisX, center);
1140
    effect[8] = new VertexEffectRotate(angle1, axisY, center);
1141
    effect[9] = new VertexEffectMove(move4);
1142
1143
    effect[0].setMeshAssociation( 1,-1);  // mesh 0
1144
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
1145
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1146
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1147
    effect[4].setMeshAssociation( 4,-1);  // mesh 2
1148
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
1149
    effect[6].setMeshAssociation( 8,-1);  // mesh 3
1150
    effect[7].setMeshAssociation( 4,-1);  // mesh 2
1151
    effect[8].setMeshAssociation( 8,-1);  // mesh 3
1152
    effect[9].setMeshAssociation(15,-1);  // meshes 0,1,2,3
1153
1154
    return effect;
1155
    }
1156
1157
///////////////////////////////////////////////////////////////////////////////////////////////////
1158
1159
  VertexEffect[] createVertexEffectsRediEdge()
1160
    {
1161
    Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
1162
    Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
1163
    Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
1164
    Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
1165
    Static3D flipZ = new Static3D(1,1,-1);
1166
    Static3D flipX = new Static3D(-1,1,1);
1167
    Static3D scale = new Static3D(2,2,2);
1168
    Static3D cent0 = new Static3D(0,0, 0);
1169
    Static3D cent1 = new Static3D(0,0, -1.5f);
1170
    Static3D axisX = new Static3D(1,0, 0);
1171
    Static3D axisY = new Static3D(0,1, 0);
1172
    Static3D axis  = new Static3D(0,SQ2/2,-SQ2/2);
1173
    Static1D angle1= new Static1D(90);
1174
    Static1D angle2= new Static1D(45);
1175
    Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
1176
1177
    VertexEffect[] effect = new VertexEffect[12];
1178
1179
    effect[0] = new VertexEffectScale(scale);
1180
    effect[1] = new VertexEffectMove(move0);
1181
    effect[2] = new VertexEffectScale(flipZ);
1182
    effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
1183
    effect[4] = new VertexEffectMove(move1);
1184
    effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
1185
    effect[6] = new VertexEffectMove(move2);
1186
    effect[7] = new VertexEffectScale(flipX);
1187
    effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
1188
    effect[9] = new VertexEffectMove(move3);
1189
    effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
1190
    effect[11]= new VertexEffectScale(flipX);
1191
1192
    effect[0].setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
1193
    effect[1].setMeshAssociation( 3,-1);  // meshes 0,1
1194
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
1195
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
1196
    effect[4].setMeshAssociation(12,-1);  // meshes 2,3
1197
    effect[5].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1198
    effect[6].setMeshAssociation(12,-1);  // meshes 2,3
1199
    effect[7].setMeshAssociation( 8,-1);  // mesh 3
1200
    effect[8].setMeshAssociation(48,-1);  // meshes 4,5
1201
    effect[9].setMeshAssociation(48,-1);  // meshes 4,5
1202
    effect[10].setMeshAssociation(48,-1); // meshes 4,5
1203
    effect[11].setMeshAssociation(32,-1); // mesh 5
1204
1205
    return effect;
1206
    }
1207
1208
///////////////////////////////////////////////////////////////////////////////////////////////////
1209
1210
  VertexEffect[] createVertexEffectsRediCorner()
1211
    {
1212
    Static3D axisY   = new Static3D(0,1,0);
1213
    Static3D axisX   = new Static3D(1,0,0);
1214
    Static3D axisZ   = new Static3D(0,0,1);
1215
    Static3D center  = new Static3D(0,0,0);
1216
    Static1D angle90 = new Static1D(90);
1217
    Static1D angle270= new Static1D(270);
1218
    Static1D angle45 = new Static1D(-45);
1219 55f20739 Leszek Koltunski
    Static3D scale   = new Static3D(1.0f, SQ2, 1.0f);
1220 7edab735 Leszek Koltunski
1221 55f20739 Leszek Koltunski
    VertexEffect[] effect = new VertexEffect[7];
1222 7edab735 Leszek Koltunski
1223
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
1224
    effect[1] = new VertexEffectRotate( angle270, axisX, center );
1225
    effect[2] = new VertexEffectRotate( angle90 , axisY, center );
1226 55f20739 Leszek Koltunski
    effect[3] = new VertexEffectScale(scale);
1227
    effect[4] = new VertexEffectRotate( angle45 , axisX, center );
1228
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
1229
    effect[6] = new VertexEffectRotate( angle270, axisZ, center );
1230 7edab735 Leszek Koltunski
1231
    effect[0].setMeshAssociation( 7,-1);  // 0,1,2
1232
    effect[1].setMeshAssociation( 2,-1);  // 1
1233
    effect[2].setMeshAssociation( 4,-1);  // 2
1234 55f20739 Leszek Koltunski
    effect[3].setMeshAssociation(56,-1);  // 3,4,5
1235
    effect[4].setMeshAssociation(56,-1);  // 3,4,5
1236
    effect[5].setMeshAssociation(16,-1);  // 4
1237
    effect[6].setMeshAssociation(32,-1);  // 5
1238
1239
    return effect;
1240
    }
1241
1242
///////////////////////////////////////////////////////////////////////////////////////////////////
1243
1244
  VertexEffect[] createVertexEffectsIvyCorner()
1245
    {
1246
    Static3D axisX  = new Static3D(1,0,0);
1247
    Static3D axisY  = new Static3D(0,1,0);
1248
    Static1D angle1 = new Static1D(+90);
1249
    Static1D angle2 = new Static1D(-90);
1250
    Static3D center = new Static3D(0,0,0);
1251 1c41c4c9 Leszek Koltunski
    Static3D move1  = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
1252 55f20739 Leszek Koltunski
1253
    VertexEffect[] effect = new VertexEffect[5];
1254
1255 1c41c4c9 Leszek Koltunski
    effect[0] = new VertexEffectScale(1/IVY_C);
1256 55f20739 Leszek Koltunski
    effect[1] = new VertexEffectMove(move1);
1257
    effect[2] = new VertexEffectScale(new Static3D(1,1,-1));
1258
    effect[3] = new VertexEffectRotate(angle1,axisX,center);
1259
    effect[4] = new VertexEffectRotate(angle2,axisY,center);
1260
1261
    effect[2].setMeshAssociation(54,-1);  // meshes 1,2,4,5
1262
    effect[3].setMeshAssociation(18,-1);  // meshes 1,4
1263
    effect[4].setMeshAssociation(36,-1);  // meshes 2,5
1264 7edab735 Leszek Koltunski
1265
    return effect;
1266
    }
1267
1268 7cd30f7c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
1269
1270
  VertexEffect[] createVertexEffectsRexEdge()
1271
    {
1272 f7936f2f Leszek Koltunski
    float E = 0.5f - REX_D;
1273
    float F = 0.5f;
1274
    float G = (float)Math.sqrt(E*E+F*F);
1275
    float A = (float)((180/Math.PI)*Math.asin(E/G));
1276 7cd30f7c Leszek Koltunski
1277 f7936f2f Leszek Koltunski
    Static3D move1 = new Static3D(    0.0f, -E/3, 0.0f);
1278
    Static3D move2 = new Static3D(2*G/3 -F, +E/3, 0.0f);
1279
1280
    Static3D center0= new Static3D(0.0f, 0.0f, 0.0f);
1281
    Static3D center1= new Static3D(  -F, 0.0f, 0.0f);
1282
    Static3D center2= new Static3D(  +F, 0.0f, 0.0f);
1283
    Static3D axisX  = new Static3D(1.0f, 0.0f, 0.0f);
1284
    Static3D axisY  = new Static3D(0.0f, 1.0f, 0.0f);
1285
    Static3D axisZ  = new Static3D(0.0f, 0.0f, 1.0f);
1286 7cd30f7c Leszek Koltunski
1287
    Static1D angle180 = new Static1D(180);
1288
    Static1D angle90  = new Static1D( 90);
1289 f7936f2f Leszek Koltunski
    Static1D angle270 = new Static1D(270);
1290
    Static1D angle1   = new Static1D(+A);
1291
    Static1D angle2   = new Static1D(-A);
1292 7cd30f7c Leszek Koltunski
1293 f7936f2f Leszek Koltunski
    VertexEffect[] effect = new VertexEffect[12];
1294 7cd30f7c Leszek Koltunski
1295 f7936f2f Leszek Koltunski
    effect[0] = new VertexEffectMove(move1);
1296
    effect[1] = new VertexEffectMove(move2);
1297
    effect[2] = new VertexEffectRotate(  angle90, axisX, center0 );
1298
    effect[3] = new VertexEffectRotate( angle270, axisX, center0 );
1299
    effect[4] = new VertexEffectRotate( angle180, axisX, center0 );
1300
    effect[5] = new VertexEffectRotate( angle180, axisY, center0 );
1301
    effect[6] = new VertexEffectScale ( new Static3D(-1, 1, 1) );
1302
    effect[7] = new VertexEffectScale ( new Static3D( 1,-1, 1) );
1303
    effect[8] = new VertexEffectRotate(   angle1, axisY, center1);
1304
    effect[9] = new VertexEffectRotate(   angle2, axisY, center2);
1305
    effect[10]= new VertexEffectRotate(   angle2, axisZ, center1);
1306
    effect[11]= new VertexEffectRotate(   angle1, axisZ, center2);
1307
1308
    effect[0].setMeshAssociation( 3,-1);  // meshes 0 & 1
1309
    effect[1].setMeshAssociation(60,-1);  // meshes 2,3,4,5
1310
    effect[2].setMeshAssociation( 2,-1);  // meshes 1
1311
    effect[3].setMeshAssociation(12,-1);  // meshes 2,3
1312
    effect[4].setMeshAssociation(48,-1);  // meshes 4,5
1313
    effect[5].setMeshAssociation(32,-1);  // mesh 5
1314
    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
1315
    effect[7].setMeshAssociation( 2,-1);  // apply to mesh 1
1316
    effect[8].setMeshAssociation(16,-1);  // apply to mesh 4
1317
    effect[9].setMeshAssociation(32,-1);  // apply to mesh 5
1318
    effect[10].setMeshAssociation(4,-1);  // apply to mesh 2
1319
    effect[11].setMeshAssociation(8,-1);  // apply to mesh 3
1320 7cd30f7c Leszek Koltunski
1321
    return effect;
1322
    }
1323
1324
///////////////////////////////////////////////////////////////////////////////////////////////////
1325
1326
  VertexEffect[] createVertexEffectsRexCorner()
1327
    {
1328
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1329
    Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f);
1330
    Static1D angle = new Static1D(45);
1331
1332
    VertexEffect[] effect = new VertexEffect[1];
1333
    effect[0] = new VertexEffectRotate(angle, axisZ, center);
1334
1335
    return effect;
1336
    }
1337
1338 fe032f52 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
1339
1340 b3d28a81 Leszek Koltunski
  VertexEffect[] createVertexEffectsKilominxCorner()
1341 fe032f52 Leszek Koltunski
    {
1342
    VertexEffect[] effect = new VertexEffect[9];
1343
1344 b3d28a81 Leszek Koltunski
    float H = 0.5f*(SIN54 / COS54);
1345 fe032f52 Leszek Koltunski
    float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
1346 b3d28a81 Leszek Koltunski
    float Y2= H/(2*COS_HALFD);
1347 fe032f52 Leszek Koltunski
    float A = (float)(Math.acos(-SQ5/5)*180/Math.PI);  // dihedral angle of a dedecahedron in degrees
1348 6d020cb6 Leszek Koltunski
    float sin18 = SIN18;
1349
    float cos18 = (float)(Math.sqrt(1- SIN18 * SIN18));
1350 b3d28a81 Leszek Koltunski
    float LEN   = (float)Math.sqrt(H*H/(COS_HALFD*COS_HALFD) + 0.25f);
1351 fe032f52 Leszek Koltunski
1352
    Static3D axisZ = new Static3D(0.0f  , 0.0f , 1.0f);
1353
    Static3D axisY = new Static3D(0.0f  , 1.0f , 0.0f);
1354
    Static3D axisA = new Static3D(-sin18, cos18, 0.0f);
1355 b3d28a81 Leszek Koltunski
    Static3D axisC = new Static3D( H/LEN, -0.5f/LEN,-H*SIN_HALFD/(COS_HALFD*LEN));
1356 fe032f52 Leszek Koltunski
1357
    Static3D move1 = new Static3D(0,-Y1,0);
1358
    Static3D move2 = new Static3D(0,-Y2,0);
1359
    Static3D move3 = new Static3D(0.5f*cos18,0.5f*sin18,0);
1360
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1361
1362
    Static1D angle1 = new Static1D(54);
1363
    Static1D angle2 = new Static1D(A/2+18);
1364
    Static1D angle3 = new Static1D(90);
1365
    Static1D angle4 = new Static1D(120);
1366
    Static1D angle5 = new Static1D(240);
1367
    Static1D angle6 = new Static1D(90-A/2);
1368
1369
    effect[0] = new VertexEffectMove(move1);
1370
    effect[1] = new VertexEffectMove(move2);
1371
    effect[2] = new VertexEffectRotate(angle1, axisZ, center);
1372
    effect[3] = new VertexEffectRotate(angle2, axisZ, center);
1373
    effect[4] = new VertexEffectRotate(angle3, axisA, center);
1374
    effect[5] = new VertexEffectMove(move3);
1375
    effect[6] = new VertexEffectRotate(angle4, axisC, center);
1376
    effect[7] = new VertexEffectRotate(angle5, axisC, center);
1377
    effect[8] = new VertexEffectRotate(angle6, axisY, center);
1378
1379
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1380
    effect[1].setMeshAssociation(56,-1);  // meshes 3,4,5
1381
    effect[2].setMeshAssociation( 7,-1);  // meshes 0,1,2
1382
    effect[3].setMeshAssociation(56,-1);  // meshes 3,4,5
1383
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1384
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1385
    effect[6].setMeshAssociation(18,-1);  // meshes 1,4
1386
    effect[7].setMeshAssociation(36,-1);  // meshes 2,5
1387
1388
    return effect;
1389
    }
1390
1391 b3d28a81 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
1392
1393
  VertexEffect[] createVertexEffectsMegaminxCorner()
1394
    {
1395
    VertexEffect[] effect = new VertexEffect[9];
1396
1397
    float Y = COS54/(2*SIN54);
1398
1399
    float sinA = (2*SIN54*SIN54-1)/COS54;
1400
    float cosA = (float)Math.sqrt(1-sinA*sinA);
1401
    float LEN  = 0.5f/SIN54;
1402
1403
    Static3D axisA = new Static3D( SIN54, COS54, 0.0f);
1404
    Static3D axisB = new Static3D(-SIN54, COS54, 0.0f);
1405
    Static3D axisX = new Static3D(  1.0f,  0.0f, 0.0f);
1406
1407
    Static3D centerU = new Static3D( 0.0f, Y, 0.0f);
1408
    Static3D centerD = new Static3D( 0.0f,-Y, 0.0f);
1409
1410
    Static3D move1= new Static3D(0.0f, -sinA*LEN, -cosA*LEN );
1411
    Static3D move2= new Static3D(0.0f, Y , 0.0f );
1412
1413 6d020cb6 Leszek Koltunski
    Static1D angleD = new Static1D(DIHEDRAL1);
1414
    Static1D angleE = new Static1D(360-DIHEDRAL1);
1415
    Static1D angleF = new Static1D(DIHEDRAL2);
1416 b3d28a81 Leszek Koltunski
1417
    effect[0] = new VertexEffectScale ( new Static3D( 1, 1,-1) );
1418
    effect[1] = new VertexEffectRotate(angleE, axisA, centerU);
1419
    effect[2] = new VertexEffectRotate(angleD, axisB, centerU);
1420
    effect[3] = new VertexEffectMove(move1);
1421
    effect[4] = new VertexEffectRotate(angleE, axisA, centerD);
1422
    effect[5] = new VertexEffectRotate(angleD, axisB, centerD);
1423
    effect[6] = new VertexEffectRotate(angleF, axisX, centerD);
1424
    effect[7] = new VertexEffectMove(move2);
1425
    effect[8] = new VertexEffectScale(SIN54);
1426
1427
    effect[0].setMeshAssociation(  3,-1);  // meshes 0,1
1428
    effect[1].setMeshAssociation( 16,-1);  // mesh 4
1429
    effect[2].setMeshAssociation( 32,-1);  // mesh 5
1430
    effect[3].setMeshAssociation( 56,-1);  // meshes 3,4,5
1431
    effect[4].setMeshAssociation(  1,-1);  // mesh 0
1432
    effect[5].setMeshAssociation(  2,-1);  // mesh 1
1433
1434
    return effect;
1435
    }
1436
1437 6d020cb6 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
1438
1439
  VertexEffect[] createVertexEffectsMegaminxEdge(float width, float height)
1440
    {
1441
    VertexEffect[] effect = new VertexEffect[11];
1442
1443
    float X = 0.5f*height;
1444
    float Y = height*(COS54/COS18) + width*0.5f;
1445
    float Z = 2*height*COS_HALFD;
1446
1447
    float alpha = 90-DIHEDRAL1/2;
1448
    float beta  = DIHEDRAL2;
1449
1450
    Static1D angle1 = new Static1D(alpha);
1451
    Static1D angle2 = new Static1D(180-alpha);
1452
    Static1D angle3 = new Static1D(beta);
1453
1454
    Static3D move1 = new Static3D(X,0,0);
1455
    Static3D move2 = new Static3D(X,0,-Z);
1456
    Static3D move3 = new Static3D(0,+Y,0);
1457
    Static3D move4 = new Static3D(0,-Y,0);
1458
    Static3D scale = new Static3D(+1,+1,-1);
1459
1460
    Static3D axisXplus = new Static3D(+1, 0, 0);
1461
    Static3D axisXminus= new Static3D(-1, 0, 0);
1462
    Static3D axisYplus = new Static3D( 0,+1, 0);
1463
    Static3D axisYminus= new Static3D( 0,-1, 0);
1464
1465
    Static3D center1= new Static3D( 0, 0, 0);
1466
    Static3D center2= new Static3D( 0, 0,-Z);
1467
    Static3D center3= new Static3D( 0,+width*0.5f, 0);
1468
    Static3D center4= new Static3D( 0,-width*0.5f, 0);
1469
1470
    effect[ 0] = new VertexEffectMove(move1);
1471
    effect[ 1] = new VertexEffectMove(move2);
1472
    effect[ 2] = new VertexEffectMove(move3);
1473
    effect[ 3] = new VertexEffectMove(move4);
1474
    effect[ 4] = new VertexEffectScale(scale);
1475
    effect[ 5] = new VertexEffectRotate(angle1, axisYplus , center1);
1476
    effect[ 6] = new VertexEffectRotate(angle2, axisYplus , center1);
1477
    effect[ 7] = new VertexEffectRotate(angle1, axisYminus, center2);
1478
    effect[ 8] = new VertexEffectRotate(angle2, axisYminus, center2);
1479
    effect[ 9] = new VertexEffectRotate(angle3, axisXplus , center3);
1480
    effect[10] = new VertexEffectRotate(angle3, axisXminus, center4);
1481
1482
    effect[ 0].setMeshAssociation( 3,-1);  // meshes 0,1
1483
    effect[ 1].setMeshAssociation(12,-1);  // meshes 2,3
1484
    effect[ 2].setMeshAssociation(16,-1);  // mesh 4
1485
    effect[ 3].setMeshAssociation(32,-1);  // mesh 5
1486
    effect[ 4].setMeshAssociation( 2,-1);  // mesh 1
1487
    effect[ 5].setMeshAssociation( 1,-1);  // mesh 0
1488
    effect[ 6].setMeshAssociation( 2,-1);  // mesh 1
1489
    effect[ 7].setMeshAssociation( 4,-1);  // mesh 2
1490
    effect[ 8].setMeshAssociation( 8,-1);  // mesh 3
1491
    effect[ 9].setMeshAssociation(16,-1);  // mesh 4
1492
    effect[10].setMeshAssociation(32,-1);  // mesh 5
1493
1494
    return effect;
1495
    }
1496
1497 7edab735 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
1498
// OBJECTS
1499
///////////////////////////////////////////////////////////////////////////////////////////////////
1500
// CUBE
1501
1502
  MeshBase createCubeMesh(int index)
1503
    {
1504
    MeshBase mesh = createFacesCube(index);
1505
    VertexEffect[] effects = createVertexEffectsCube();
1506
    for( VertexEffect effect : effects ) mesh.apply(effect);
1507
1508
    Static3D roundingCenter  = new Static3D(0,0,0);
1509
    Static3D[] vertices = new Static3D[8];
1510
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1511
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1512
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1513
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1514
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1515
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1516
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1517
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1518 55f20739 Leszek Koltunski
1519 7edab735 Leszek Koltunski
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
1520
1521 55f20739 Leszek Koltunski
    mesh.mergeEffComponents();
1522
1523 7edab735 Leszek Koltunski
    return mesh;
1524
    }
1525
1526
///////////////////////////////////////////////////////////////////////////////////////////////////
1527
// SKEWB
1528
1529
  MeshBase createSkewbCornerMesh()
1530
    {
1531
    MeshBase mesh = createFacesSkewbCorner();
1532
    VertexEffect[] effects = createVertexEffectsSkewbCorner();
1533
    for( VertexEffect effect : effects ) mesh.apply(effect);
1534
1535
    float E = 0.5f;
1536
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1537
1538
    Static3D[] verticesType1 = new Static3D[1];
1539
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1540
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1541
1542
    Static3D[] verticesType2 = new Static3D[3];
1543
    verticesType2[0] = new Static3D(-E, 0, 0);
1544
    verticesType2[1] = new Static3D( 0,-E, 0);
1545
    verticesType2[2] = new Static3D( 0, 0,-E);
1546
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1547
1548 55f20739 Leszek Koltunski
    mesh.mergeEffComponents();
1549
1550 7edab735 Leszek Koltunski
    return mesh;
1551
    }
1552
1553
///////////////////////////////////////////////////////////////////////////////////////////////////
1554
1555
  MeshBase createSkewbFaceMesh()
1556
    {
1557
    MeshBase mesh = createFacesSkewbFace();
1558
    VertexEffect[] effects = createVertexEffectsSkewbFace();
1559
    for( VertexEffect effect : effects ) mesh.apply(effect);
1560
1561
    Static3D roundingCenter = new Static3D(0,0,-0.2f);
1562
    float E = SQ2/4;
1563
    Static3D[] vertices = new Static3D[4];
1564
    vertices[0] = new Static3D(-E*SQ2,      0, 0);
1565
    vertices[1] = new Static3D(+E*SQ2,      0, 0);
1566
    vertices[2] = new Static3D(     0, -E*SQ2, 0);
1567
    vertices[3] = new Static3D(     0, +E*SQ2, 0);
1568 55f20739 Leszek Koltunski
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
1569
1570
    mesh.mergeEffComponents();
1571
    mesh.addEmptyTexComponent();
1572 7edab735 Leszek Koltunski
1573
    return mesh;
1574
    }
1575
1576
///////////////////////////////////////////////////////////////////////////////////////////////////
1577
// SKEWB DIAMOND / PYRAMINX
1578
1579
  MeshBase createOctaMesh()
1580
    {
1581
    MeshBase mesh = createFacesOcta();
1582
    VertexEffect[] effects = createVertexEffectsOcta();
1583
    for( VertexEffect effect : effects ) mesh.apply(effect);
1584
1585
    Static3D roundingCenter = new Static3D(0,0,0);
1586
    Static3D[] vertices = new Static3D[6];
1587
    vertices[0] = new Static3D(    0, SQ2/2,    0 );
1588
    vertices[1] = new Static3D( 0.5f,     0, 0.5f );
1589
    vertices[2] = new Static3D(-0.5f,     0, 0.5f );
1590
    vertices[3] = new Static3D(    0,-SQ2/2,    0 );
1591
    vertices[4] = new Static3D(-0.5f,     0,-0.5f );
1592
    vertices[5] = new Static3D( 0.5f,     0,-0.5f );
1593 55f20739 Leszek Koltunski
1594 7edab735 Leszek Koltunski
    roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
1595
1596 55f20739 Leszek Koltunski
    mesh.mergeEffComponents();
1597
1598 7edab735 Leszek Koltunski
    return mesh;
1599
    }
1600
1601
///////////////////////////////////////////////////////////////////////////////////////////////////
1602
1603
  MeshBase createTetraMesh()
1604
    {
1605
    MeshBase mesh = createFacesTetra();
1606
    VertexEffect[] effects = createVertexEffectsTetra();
1607
    for( VertexEffect effect : effects ) mesh.apply(effect);
1608
1609
    Static3D roundingCenter = new Static3D(0,0,0);
1610
    Static3D[] verticesRound = new Static3D[4];
1611
    verticesRound[0] = new Static3D(-0.5f,+SQ2/4,   0 );
1612
    verticesRound[1] = new Static3D(+0.5f,+SQ2/4,   0 );
1613
    verticesRound[2] = new Static3D(    0,-SQ2/4,+0.5f);
1614
    verticesRound[3] = new Static3D(    0,-SQ2/4,-0.5f);
1615
    roundCorners(mesh,roundingCenter,verticesRound,0.08f,0.15f);
1616
1617 55f20739 Leszek Koltunski
    mesh.mergeEffComponents();
1618
    mesh.addEmptyTexComponent();
1619
    mesh.addEmptyTexComponent();
1620
    mesh.addEmptyTexComponent();
1621
    mesh.addEmptyTexComponent();
1622
1623 7edab735 Leszek Koltunski
    return mesh;
1624
    }
1625
1626
///////////////////////////////////////////////////////////////////////////////////////////////////
1627
// DINO
1628
1629
  MeshBase createDinoMesh()
1630
    {
1631
    MeshBase mesh = createFacesDino();
1632
    VertexEffect[] effects = createVertexEffectsDino();
1633
    for( VertexEffect effect : effects ) mesh.apply(effect);
1634
1635
    float F = 0.5f;
1636
    Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
1637
    Static3D[] verticesRound = new Static3D[4];
1638
    verticesRound[0] = new Static3D(     0,-3*F,    0 );
1639
    verticesRound[1] = new Static3D(     0,   0, -3*F );
1640
    verticesRound[2] = new Static3D(  -3*F,   0,    0 );
1641
    verticesRound[3] = new Static3D(  +3*F,   0,    0 );
1642
    roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
1643
1644 55f20739 Leszek Koltunski
    mesh.mergeEffComponents();
1645
1646 7edab735 Leszek Koltunski
    return mesh;
1647
    }
1648
1649
///////////////////////////////////////////////////////////////////////////////////////////////////
1650
// Helicopter
1651
1652
  MeshBase createHelicopterCornerMesh()
1653
    {
1654
    MeshBase mesh = createFacesHelicopterCorner();
1655
    VertexEffect[] effects = createVertexEffectsHelicopterCorner();
1656
    for( VertexEffect effect : effects ) mesh.apply(effect);
1657
1658
    float E = 0.5f;
1659
    Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
1660
1661
    Static3D[] verticesType1 = new Static3D[1];
1662
    verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
1663
    roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
1664
1665
    Static3D[] verticesType2 = new Static3D[3];
1666
    verticesType2[0] = new Static3D(-E, 0, 0);
1667
    verticesType2[1] = new Static3D( 0,-E, 0);
1668
    verticesType2[2] = new Static3D( 0, 0,-E);
1669 55f20739 Leszek Koltunski
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1670
1671
    mesh.mergeEffComponents();
1672 7edab735 Leszek Koltunski
1673
    return mesh;
1674
    }
1675
1676
///////////////////////////////////////////////////////////////////////////////////////////////////
1677
1678
  MeshBase createHelicopterFaceMesh()
1679
    {
1680
    MeshBase mesh = createFacesHelicopterFace();
1681
    VertexEffect[] effects = createVertexEffectsHelicopterFace();
1682
    for( VertexEffect effect : effects ) mesh.apply(effect);
1683
1684
    float E = 0.5f;
1685
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
1686
1687
    Static3D[] verticesType1 = new Static3D[1];
1688
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
1689
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
1690
1691
    Static3D[] verticesType2 = new Static3D[2];
1692
    verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
1693
    verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
1694 55f20739 Leszek Koltunski
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1695
1696
    mesh.mergeEffComponents();
1697
    mesh.addEmptyTexComponent();
1698
    mesh.addEmptyTexComponent();
1699 7edab735 Leszek Koltunski
1700
    return mesh;
1701
    }
1702
1703
///////////////////////////////////////////////////////////////////////////////////////////////////
1704
// Redi cube
1705
1706
  MeshBase createRediEdgeMesh()
1707
    {
1708
    MeshBase mesh = createFacesRediEdge();
1709
    VertexEffect[] effects = createVertexEffectsRediEdge();
1710
    for( VertexEffect effect : effects ) mesh.apply(effect);
1711
1712
    Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
1713 55f20739 Leszek Koltunski
    Static3D[] vertices = new Static3D[2];
1714 7edab735 Leszek Koltunski
    vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
1715
    vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
1716
    roundCorners(mesh,center,vertices,0.06f,0.20f);
1717
1718 55f20739 Leszek Koltunski
    mesh.mergeEffComponents();
1719
1720 7edab735 Leszek Koltunski
    return mesh;
1721
    }
1722
1723
///////////////////////////////////////////////////////////////////////////////////////////////////
1724
1725
  MeshBase createRediCornerMesh()
1726
    {
1727
    MeshBase mesh = createFacesRediCorner();
1728
    VertexEffect[] effects = createVertexEffectsRediCorner();
1729
    for( VertexEffect effect : effects ) mesh.apply(effect);
1730
1731
    Static3D center = new Static3D(0,0,0);
1732
    Static3D[] vertices = new Static3D[8];
1733
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1734
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1735
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1736
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1737
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1738
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1739
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1740
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1741
1742
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1743
1744 55f20739 Leszek Koltunski
    mesh.mergeEffComponents();
1745
1746
    return mesh;
1747
    }
1748
1749
///////////////////////////////////////////////////////////////////////////////////////////////////
1750
1751
  MeshBase createIvyCornerMesh()
1752
    {
1753
    MeshBase mesh = createFacesIvyCorner();
1754
    VertexEffect[] effects = createVertexEffectsIvyCorner();
1755
    for( VertexEffect effect : effects ) mesh.apply(effect);
1756
1757
    Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
1758
    Static3D[] vertices = new Static3D[4];
1759 1c41c4c9 Leszek Koltunski
    vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f);
1760
    vertices[1] = new Static3D(-1.0f,+0.0f,+0.0f);
1761
    vertices[2] = new Static3D(+0.0f,-1.0f,+0.0f);
1762
    vertices[3] = new Static3D(+0.0f,+0.0f,-1.0f);
1763 55f20739 Leszek Koltunski
1764 1c41c4c9 Leszek Koltunski
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1765 55f20739 Leszek Koltunski
1766
    mesh.mergeEffComponents();
1767
1768
    return mesh;
1769
    }
1770
1771
///////////////////////////////////////////////////////////////////////////////////////////////////
1772
1773
  MeshBase createIvyFaceMesh()
1774
    {
1775
    MeshBase mesh = createFacesIvyFace();
1776
1777 1c41c4c9 Leszek Koltunski
    Static3D center = new Static3D(-0.0f,-0.0f,-0.5f);
1778 55f20739 Leszek Koltunski
    Static3D[] vertices = new Static3D[2];
1779 1c41c4c9 Leszek Koltunski
    vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f);
1780
    vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f);
1781 55f20739 Leszek Koltunski
1782 1c41c4c9 Leszek Koltunski
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1783 55f20739 Leszek Koltunski
1784
    mesh.mergeEffComponents();
1785
    mesh.addEmptyTexComponent();
1786
    mesh.addEmptyTexComponent();
1787
    mesh.addEmptyTexComponent();
1788
    mesh.addEmptyTexComponent();
1789
1790 7cd30f7c Leszek Koltunski
    return mesh;
1791
    }
1792
1793
///////////////////////////////////////////////////////////////////////////////////////////////////
1794
1795
  MeshBase createRexCornerMesh()
1796
    {
1797
    MeshBase mesh = createFacesRexCorner();
1798
    VertexEffect[] effects = createVertexEffectsRexCorner();
1799
    for( VertexEffect effect : effects ) mesh.apply(effect);
1800
1801
    Static3D center = new Static3D(0.0f,0.0f,-0.25f);
1802
    Static3D[] vertices = new Static3D[1];
1803
    vertices[0] = new Static3D(+0.25f,+0.25f,+0.0f);
1804
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1805
1806
    mesh.mergeEffComponents();
1807
    mesh.addEmptyTexComponent();
1808
    mesh.addEmptyTexComponent();
1809
1810
    return mesh;
1811
    }
1812
1813
///////////////////////////////////////////////////////////////////////////////////////////////////
1814
1815
  MeshBase createRexFaceMesh()
1816
    {
1817
    MeshBase mesh = createFacesRexFace();
1818
1819
    mesh.mergeEffComponents();
1820
    mesh.addEmptyTexComponent();
1821
    mesh.addEmptyTexComponent();
1822
1823
    return mesh;
1824
    }
1825
1826
///////////////////////////////////////////////////////////////////////////////////////////////////
1827
1828
  MeshBase createRexEdgeMesh()
1829
    {
1830
    MeshBase mesh = createFacesRexEdge();
1831
    VertexEffect[] effects = createVertexEffectsRexEdge();
1832
    for( VertexEffect effect : effects ) mesh.apply(effect);
1833 fe032f52 Leszek Koltunski
1834 7cd30f7c Leszek Koltunski
    Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
1835
    Static3D[] vertices = new Static3D[2];
1836
    vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
1837
    vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
1838 fe032f52 Leszek Koltunski
    roundCorners(mesh,center,vertices,0.06f,0.10f);
1839 7cd30f7c Leszek Koltunski
1840
    mesh.mergeEffComponents();
1841 fe032f52 Leszek Koltunski
1842
    return mesh;
1843
    }
1844
1845
///////////////////////////////////////////////////////////////////////////////////////////////////
1846
1847 b3d28a81 Leszek Koltunski
  MeshBase createKilominxCornerMesh()
1848 fe032f52 Leszek Koltunski
    {
1849 b3d28a81 Leszek Koltunski
    MeshBase mesh = createFacesKilominxCorner();
1850
    VertexEffect[] effects = createVertexEffectsKilominxCorner();
1851 fe032f52 Leszek Koltunski
    for( VertexEffect effect : effects ) mesh.apply(effect);
1852 e0838536 Leszek Koltunski
1853 b3d28a81 Leszek Koltunski
    float A = (2*SQ3/3)* SIN54;
1854 e0838536 Leszek Koltunski
    float B = 0.4f;
1855 b3d28a81 Leszek Koltunski
    float X = SIN_HALFD* SIN54 * COS54;
1856
    float Y = SIN54 * SIN54 - 0.5f;
1857
    float Z = COS_HALFD* SIN54 * COS54;
1858 e0838536 Leszek Koltunski
1859
    Static3D center = new Static3D(0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B);
1860
1861
    Static3D[] vertices = new Static3D[4];
1862
    vertices[0] = new Static3D( 0.0f, 0.0f, 0.0f);
1863
    vertices[1] = new Static3D( 0.0f,-0.5f, 0.0f);
1864
    vertices[2] = new Static3D(-X   , Y   ,-Z   );
1865
    vertices[3] = new Static3D(+X   , Y   ,-Z   );
1866
1867
    roundCorners(mesh,center,vertices,0.03f,0.10f);
1868
1869 fe032f52 Leszek Koltunski
    //mesh.mergeEffComponents();
1870
1871 b3d28a81 Leszek Koltunski
    return mesh;
1872
    }
1873
1874
///////////////////////////////////////////////////////////////////////////////////////////////////
1875
1876
  MeshBase createMegaminxCornerMesh()
1877
    {
1878
    MeshBase mesh = createFacesMegaminxCorner();
1879
    VertexEffect[] effects = createVertexEffectsMegaminxCorner();
1880
    for( VertexEffect effect : effects ) mesh.apply(effect);
1881
1882
    float A = (2*SQ3/3)* SIN54;
1883
    float B = 0.4f;
1884
    float X = SIN_HALFD* SIN54 * COS54;
1885
    float Y = SIN54 * SIN54 - 0.5f;
1886
    float Z = COS_HALFD* SIN54 * COS54;
1887
1888
    Static3D center = new Static3D(0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B);
1889
1890
    Static3D[] vertices = new Static3D[4];
1891
    vertices[0] = new Static3D( 0.0f, 0.0f, 0.0f);
1892
    vertices[1] = new Static3D( 0.0f,-0.5f, 0.0f);
1893
    vertices[2] = new Static3D(-X   , Y   ,-Z   );
1894
    vertices[3] = new Static3D(+X   , Y   ,-Z   );
1895
1896
    roundCorners(mesh,center,vertices,0.04f,0.10f);
1897
1898
    //mesh.mergeEffComponents();
1899
1900 6d020cb6 Leszek Koltunski
    return mesh;
1901
    }
1902
1903
///////////////////////////////////////////////////////////////////////////////////////////////////
1904
1905
  MeshBase createMegaminxEdgeMesh(float width, float height)
1906
    {
1907
    MeshBase mesh = createFacesMegaminxEdge(width,height);
1908
    VertexEffect[] effects = createVertexEffectsMegaminxEdge(width,height);
1909
    for( VertexEffect effect : effects ) mesh.apply(effect);
1910
1911
    //mesh.mergeEffComponents();
1912
1913 7edab735 Leszek Koltunski
    return mesh;
1914
    }
1915
  }