1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2020 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Magic Cube. //
|
5
|
// //
|
6
|
// Magic Cube is free software: you can redistribute it and/or modify //
|
7
|
// it under the terms of the GNU General Public License as published by //
|
8
|
// the Free Software Foundation, either version 2 of the License, or //
|
9
|
// (at your option) any later version. //
|
10
|
// //
|
11
|
// Magic Cube is distributed in the hope that it will be useful, //
|
12
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14
|
// GNU General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU General Public License //
|
17
|
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
package org.distorted.objects;
|
21
|
|
22
|
import org.distorted.library.effect.VertexEffect;
|
23
|
import org.distorted.library.effect.VertexEffectDeform;
|
24
|
import org.distorted.library.effect.VertexEffectMove;
|
25
|
import org.distorted.library.effect.VertexEffectRotate;
|
26
|
import org.distorted.library.effect.VertexEffectScale;
|
27
|
import org.distorted.library.mesh.MeshBase;
|
28
|
import org.distorted.library.mesh.MeshJoined;
|
29
|
import org.distorted.library.mesh.MeshPolygon;
|
30
|
import org.distorted.library.type.Static1D;
|
31
|
import org.distorted.library.type.Static3D;
|
32
|
import org.distorted.library.type.Static4D;
|
33
|
|
34
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
35
|
|
36
|
class FactoryCubit
|
37
|
{
|
38
|
static final float IVY_D = 0.003f;
|
39
|
static final float IVY_C = 0.59f;
|
40
|
static final float IVY_M = 0.35f;
|
41
|
|
42
|
private static final float SQ2 = (float)Math.sqrt(2);
|
43
|
private static final float SQ3 = (float)Math.sqrt(3);
|
44
|
private static final float SQ6 = (float)Math.sqrt(6);
|
45
|
|
46
|
private static final int IVY_N = 8;
|
47
|
private static final Static1D RADIUS = new Static1D(1);
|
48
|
private static FactoryCubit mThis;
|
49
|
|
50
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
51
|
|
52
|
private FactoryCubit()
|
53
|
{
|
54
|
|
55
|
}
|
56
|
|
57
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
58
|
|
59
|
public static FactoryCubit getInstance()
|
60
|
{
|
61
|
if( mThis==null ) mThis = new FactoryCubit();
|
62
|
|
63
|
return mThis;
|
64
|
}
|
65
|
|
66
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
67
|
// H - height of the band in the middle
|
68
|
// alpha - angle of the edge [0,90]
|
69
|
// dist - often in a polygon the distance from edge to center is not 1, but something else.
|
70
|
// This is the distance.
|
71
|
// K - where to begin the second, much more flat part of the band. [0,1]
|
72
|
// N - number of bands. N>=3
|
73
|
//
|
74
|
// theory: two distinct parts to the band:
|
75
|
// 1) (0,B) - steep
|
76
|
// 2) (B,1) - flat
|
77
|
//
|
78
|
// In first part, we have y = g(x) ; in second - y = g(f(x)) where
|
79
|
//
|
80
|
// g(x) = sqrt( R^2 - (x-D)^2 ) - R*cos(alpha)
|
81
|
// f(x) = ((D-B)/(1-B)*x + B*(1-D)/(1-B)
|
82
|
// h(x) = R*(sin(alpha) - sin(x))
|
83
|
// R = H/(1-cos(alpha))
|
84
|
// D = H*sin(alpha)
|
85
|
// B = h(K*alpha)
|
86
|
//
|
87
|
// The N points are taken at:
|
88
|
//
|
89
|
// 1) in the second part, there are K2 = (N-3)/3 such points
|
90
|
// 2) in the first - K1 = (N-3) - K2
|
91
|
// 3) also, the 3 points 0,B,1
|
92
|
//
|
93
|
// so we have the sequence A[i] of N points
|
94
|
//
|
95
|
// 0
|
96
|
// h((i+1)*(1-K)*alpha/(K1+1)) (i=0,1,...,K1-1)
|
97
|
// B
|
98
|
// (1-B)*(i+1)/(K2+1) + B (i=0,i,...,K2-1)
|
99
|
// 1
|
100
|
|
101
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
102
|
|
103
|
private float f(float D, float B, float x)
|
104
|
{
|
105
|
return ((D-B)*x + B*(1-D))/(1-B);
|
106
|
}
|
107
|
|
108
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
109
|
|
110
|
private float g(float R, float D, float x, float cosAlpha)
|
111
|
{
|
112
|
float d = x-D;
|
113
|
return (float)(Math.sqrt(R*R-d*d)-R*cosAlpha);
|
114
|
}
|
115
|
|
116
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
117
|
|
118
|
private float h(float R, float sinAlpha, float x)
|
119
|
{
|
120
|
return R*(sinAlpha-(float)Math.sin(x));
|
121
|
}
|
122
|
|
123
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
124
|
|
125
|
private float[] computeBands(float H, int alpha, float dist, float K, int N)
|
126
|
{
|
127
|
float[] bands = new float[2*N];
|
128
|
|
129
|
bands[0] = 1.0f;
|
130
|
bands[1] = 0.0f;
|
131
|
|
132
|
float beta = (float)Math.atan(dist*Math.tan(Math.PI*alpha/180));
|
133
|
float sinBeta = (float)Math.sin(beta);
|
134
|
float cosBeta = (float)Math.cos(beta);
|
135
|
float R = cosBeta<1.0f ? H/(1.0f-cosBeta) : 0.0f;
|
136
|
float D = R*sinBeta;
|
137
|
float B = h(R,sinBeta,K*beta);
|
138
|
|
139
|
if( D>1.0f )
|
140
|
{
|
141
|
for(int i=1; i<N; i++)
|
142
|
{
|
143
|
bands[2*i ] = (float)(N-1-i)/(N-1);
|
144
|
bands[2*i+1] = H*(1-bands[2*i]);
|
145
|
}
|
146
|
}
|
147
|
else
|
148
|
{
|
149
|
int K2 = (int)((N-3)*K);
|
150
|
int K1 = (N-3)-K2;
|
151
|
|
152
|
for(int i=0; i<=K1; i++)
|
153
|
{
|
154
|
float angle = K*beta + (1-K)*beta*(K1-i)/(K1+1);
|
155
|
float x = h(R,sinBeta,angle);
|
156
|
bands[2*i+2] = 1.0f - x;
|
157
|
bands[2*i+3] = g(R,D,x,cosBeta);
|
158
|
}
|
159
|
|
160
|
for(int i=0; i<=K2; i++)
|
161
|
{
|
162
|
float x = (1-B)*(i+1)/(K2+1) + B;
|
163
|
bands[2*K1+2 + 2*i+2] = 1.0f - x;
|
164
|
bands[2*K1+2 + 2*i+3] = g(R,D,f(D,B,x),cosBeta);
|
165
|
}
|
166
|
}
|
167
|
|
168
|
bands[2*N-2] = 0.0f;
|
169
|
bands[2*N-1] = H;
|
170
|
|
171
|
return bands;
|
172
|
}
|
173
|
|
174
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
175
|
|
176
|
private void roundCorners(MeshBase mesh, Static3D center, Static3D[] vertices, float strength, float regionRadius)
|
177
|
{
|
178
|
Static4D reg= new Static4D(0,0,0,regionRadius);
|
179
|
|
180
|
float centX = center.get0();
|
181
|
float centY = center.get1();
|
182
|
float centZ = center.get2();
|
183
|
|
184
|
for (Static3D vertex : vertices)
|
185
|
{
|
186
|
float x = strength*(centX - vertex.get0());
|
187
|
float y = strength*(centY - vertex.get1());
|
188
|
float z = strength*(centZ - vertex.get2());
|
189
|
|
190
|
VertexEffect effect = new VertexEffectDeform(new Static3D(x,y,z), RADIUS, vertex, reg);
|
191
|
mesh.apply(effect);
|
192
|
}
|
193
|
}
|
194
|
|
195
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
196
|
|
197
|
MeshBase createFacesCube(int sizeIndex)
|
198
|
{
|
199
|
MeshBase[] meshes = new MeshPolygon[6];
|
200
|
|
201
|
float E = 0.5f;
|
202
|
int extraI, extraV, num;
|
203
|
|
204
|
switch(sizeIndex)
|
205
|
{
|
206
|
case 0 : num = 6; extraI = 2; extraV = 2; break;
|
207
|
case 1 : num = 5; extraI = 2; extraV = 2; break;
|
208
|
case 2 : num = 5; extraI = 1; extraV = 2; break;
|
209
|
default: num = 4; extraI = 1; extraV = 1; break;
|
210
|
}
|
211
|
|
212
|
float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E };
|
213
|
float[] bands = computeBands(0.048f,35,E,0.7f,num);
|
214
|
|
215
|
meshes[0] = new MeshPolygon(vertices,bands,extraI,extraV);
|
216
|
meshes[0].setEffectAssociation(0,1,0);
|
217
|
meshes[1] = meshes[0].copy(true);
|
218
|
meshes[1].setEffectAssociation(0,2,0);
|
219
|
meshes[2] = meshes[0].copy(true);
|
220
|
meshes[2].setEffectAssociation(0,4,0);
|
221
|
meshes[3] = meshes[0].copy(true);
|
222
|
meshes[3].setEffectAssociation(0,8,0);
|
223
|
meshes[4] = meshes[0].copy(true);
|
224
|
meshes[4].setEffectAssociation(0,16,0);
|
225
|
meshes[5] = meshes[0].copy(true);
|
226
|
meshes[5].setEffectAssociation(0,32,0);
|
227
|
|
228
|
return new MeshJoined(meshes);
|
229
|
}
|
230
|
|
231
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
232
|
|
233
|
MeshBase createFacesSkewbCorner()
|
234
|
{
|
235
|
MeshBase[] meshes = new MeshBase[6];
|
236
|
|
237
|
float E = 0.5f;
|
238
|
float F = SQ2/2;
|
239
|
float G = SQ6/16;
|
240
|
float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
|
241
|
float[] bands0 = computeBands(0.028f,35,E/3,0.7f,7);
|
242
|
|
243
|
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
|
244
|
meshes[0].setEffectAssociation(0,1,0);
|
245
|
meshes[1] = meshes[0].copy(true);
|
246
|
meshes[1].setEffectAssociation(0,2,0);
|
247
|
meshes[2] = meshes[0].copy(true);
|
248
|
meshes[2].setEffectAssociation(0,4,0);
|
249
|
|
250
|
float[] vertices1 = { -F/2,-2*G, F/2,-2*G, 3*F/8,-G, 1*F/8,G, 0,2*G };
|
251
|
float[] bands1 = computeBands(0,0,1,0,3);
|
252
|
|
253
|
meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
|
254
|
meshes[3].setEffectAssociation(0,8,0);
|
255
|
meshes[4] = meshes[3].copy(true);
|
256
|
meshes[4].setEffectAssociation(0,16,0);
|
257
|
meshes[5] = meshes[3].copy(true);
|
258
|
meshes[5].setEffectAssociation(0,32,0);
|
259
|
|
260
|
return new MeshJoined(meshes);
|
261
|
}
|
262
|
|
263
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
264
|
|
265
|
MeshBase createFacesSkewbFace()
|
266
|
{
|
267
|
MeshBase[] meshes = new MeshBase[5];
|
268
|
|
269
|
float E = SQ2/4;
|
270
|
float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
|
271
|
float[] bands0 = computeBands(0.051f,35,E/2,0.9f,7);
|
272
|
|
273
|
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
|
274
|
meshes[0].setEffectAssociation(0,1,0);
|
275
|
|
276
|
float[] vertices1 = { -E,-SQ3*E, -E*0.7f,-SQ3*E, +E*0.7f,-SQ3*E, +E,-SQ3*E, 0,0 };
|
277
|
float[] bands1 = computeBands(0,0,1,0,3);
|
278
|
|
279
|
meshes[1] = new MeshPolygon(vertices1,bands1,0,0);
|
280
|
meshes[1].setEffectAssociation(0,2,0);
|
281
|
meshes[2] = meshes[1].copy(true);
|
282
|
meshes[2].setEffectAssociation(0,4,0);
|
283
|
meshes[3] = meshes[1].copy(true);
|
284
|
meshes[3].setEffectAssociation(0,8,0);
|
285
|
meshes[4] = meshes[1].copy(true);
|
286
|
meshes[4].setEffectAssociation(0,16,0);
|
287
|
|
288
|
return new MeshJoined(meshes);
|
289
|
}
|
290
|
|
291
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
292
|
|
293
|
MeshBase createFacesOcta()
|
294
|
{
|
295
|
MeshBase[] meshes = new MeshPolygon[8];
|
296
|
|
297
|
float E = 0.75f;
|
298
|
float F = 0.5f;
|
299
|
float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
|
300
|
float[] bands = computeBands(0.05f,35,F,0.8f,6);
|
301
|
|
302
|
meshes[0] = new MeshPolygon(vertices, bands, 2,2);
|
303
|
meshes[0].setEffectAssociation(0,1,0);
|
304
|
meshes[1] = meshes[0].copy(true);
|
305
|
meshes[1].setEffectAssociation(0,2,0);
|
306
|
meshes[2] = meshes[0].copy(true);
|
307
|
meshes[2].setEffectAssociation(0,4,0);
|
308
|
meshes[3] = meshes[0].copy(true);
|
309
|
meshes[3].setEffectAssociation(0,8,0);
|
310
|
meshes[4] = meshes[0].copy(true);
|
311
|
meshes[4].setEffectAssociation(0,16,0);
|
312
|
meshes[5] = meshes[0].copy(true);
|
313
|
meshes[5].setEffectAssociation(0,32,0);
|
314
|
meshes[6] = meshes[0].copy(true);
|
315
|
meshes[6].setEffectAssociation(0,64,0);
|
316
|
meshes[7] = meshes[0].copy(true);
|
317
|
meshes[7].setEffectAssociation(0,128,0);
|
318
|
|
319
|
return new MeshJoined(meshes);
|
320
|
}
|
321
|
|
322
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
323
|
|
324
|
MeshBase createFacesTetra()
|
325
|
{
|
326
|
MeshBase[] meshes = new MeshBase[4];
|
327
|
|
328
|
float E = 0.75f;
|
329
|
float F = 0.5f;
|
330
|
float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
|
331
|
float[] bands = computeBands(0.05f,35,F,0.8f,6);
|
332
|
|
333
|
meshes[0] = new MeshPolygon(vertices, bands, 2,2);
|
334
|
meshes[0].setEffectAssociation(0,1,0);
|
335
|
meshes[1] = meshes[0].copy(true);
|
336
|
meshes[1].setEffectAssociation(0,2,0);
|
337
|
meshes[2] = meshes[0].copy(true);
|
338
|
meshes[2].setEffectAssociation(0,4,0);
|
339
|
meshes[3] = meshes[0].copy(true);
|
340
|
meshes[3].setEffectAssociation(0,8,0);
|
341
|
|
342
|
return new MeshJoined(meshes);
|
343
|
}
|
344
|
|
345
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
346
|
|
347
|
MeshBase createFacesDino()
|
348
|
{
|
349
|
MeshBase[] meshes = new MeshPolygon[4];
|
350
|
|
351
|
float E = 0.5f*SQ2;
|
352
|
float F = 0.5f;
|
353
|
float[] vertices0 = { -F,F/3, 0,-2*F/3, +F,F/3 };
|
354
|
float[] bands0 = computeBands(0.028f,30,F/3,0.8f,7);
|
355
|
|
356
|
meshes[0] = new MeshPolygon(vertices0, bands0, 2, 5);
|
357
|
meshes[0].setEffectAssociation(0,1,0);
|
358
|
meshes[1] = meshes[0].copy(true);
|
359
|
meshes[1].setEffectAssociation(0,2,0);
|
360
|
|
361
|
float[] vertices1 = { -E/2,-E*(SQ3/6), E/2,-E*(SQ3/6), 0,E*(SQ3/3) };
|
362
|
float[] bands1 = computeBands(0.02f,45,F/3,0.2f,3);
|
363
|
|
364
|
meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
|
365
|
meshes[2].setEffectAssociation(0,4,0);
|
366
|
meshes[3] = meshes[2].copy(true);
|
367
|
meshes[3].setEffectAssociation(0,8,0);
|
368
|
|
369
|
return new MeshJoined(meshes);
|
370
|
}
|
371
|
|
372
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
373
|
|
374
|
MeshBase createFacesHelicopterCorner()
|
375
|
{
|
376
|
MeshBase[] meshes = new MeshBase[6];
|
377
|
|
378
|
float E = 0.5f;
|
379
|
float F = SQ2/4;
|
380
|
float G = 1.0f/12;
|
381
|
float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
|
382
|
float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
|
383
|
|
384
|
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
|
385
|
meshes[0].setEffectAssociation(0,1,0);
|
386
|
meshes[1] = meshes[0].copy(true);
|
387
|
meshes[1].setEffectAssociation(0,2,0);
|
388
|
meshes[2] = meshes[0].copy(true);
|
389
|
meshes[2].setEffectAssociation(0,4,0);
|
390
|
|
391
|
float[] vertices1 = { -F,-G, 0,-G, +F,-G, 0,2*G };
|
392
|
float[] bands1 = computeBands(0.00f,0,0,0.0f,3);
|
393
|
meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
|
394
|
meshes[3].setEffectAssociation(0,8,0);
|
395
|
meshes[4] = meshes[3].copy(true);
|
396
|
meshes[4].setEffectAssociation(0,16,0);
|
397
|
meshes[5] = meshes[3].copy(true);
|
398
|
meshes[5].setEffectAssociation(0,32,0);
|
399
|
|
400
|
return new MeshJoined(meshes);
|
401
|
}
|
402
|
|
403
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
404
|
|
405
|
MeshBase createFacesHelicopterFace()
|
406
|
{
|
407
|
MeshBase[] meshes = new MeshBase[4];
|
408
|
|
409
|
float E = 0.5f;
|
410
|
float F = SQ2/4;
|
411
|
float G = 1.0f/12;
|
412
|
float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
|
413
|
float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
|
414
|
|
415
|
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
|
416
|
meshes[0].setEffectAssociation(0,1,0);
|
417
|
|
418
|
float[] vertices1 = { -F,-G, +F,-G, 0,2*G};
|
419
|
float[] bands1 = computeBands(0.01f,45,F,0.0f,3);
|
420
|
|
421
|
meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3);
|
422
|
meshes[1].setEffectAssociation(0,2,0);
|
423
|
|
424
|
float[] vertices2 = { -E/2,-F/3, +E/2,-F/3, 0,2*F/3};
|
425
|
|
426
|
meshes[2] = new MeshPolygon(vertices2, bands1, 1, 3);
|
427
|
meshes[2].setEffectAssociation(0,4,0);
|
428
|
meshes[3] = meshes[2].copy(true);
|
429
|
meshes[3].setEffectAssociation(0,8,0);
|
430
|
|
431
|
return new MeshJoined(meshes);
|
432
|
}
|
433
|
|
434
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
435
|
|
436
|
MeshBase createFacesRediEdge()
|
437
|
{
|
438
|
MeshBase[] meshes = new MeshPolygon[6];
|
439
|
|
440
|
float F = 0.25f;
|
441
|
float[] vertices0 = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F };
|
442
|
float[] bands0 = computeBands(0.038f,35,F,0.7f,7);
|
443
|
|
444
|
meshes[0] = new MeshPolygon(vertices0, bands0, 2, 2);
|
445
|
meshes[0].setEffectAssociation(0,1,0);
|
446
|
meshes[1] = meshes[0].copy(true);
|
447
|
meshes[1].setEffectAssociation(0,2,0);
|
448
|
|
449
|
float[] bands1 = computeBands(0.02f,35,F/2,0.2f,3);
|
450
|
float[] vertices1 = { -F/2, +F/2, -F/2, -1.5f*F, 1.5f*F, +F/2 };
|
451
|
|
452
|
meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
|
453
|
meshes[2].setEffectAssociation(0,4,0);
|
454
|
meshes[3] = meshes[2].copy(true);
|
455
|
meshes[3].setEffectAssociation(0,8,0);
|
456
|
|
457
|
float X = 0.25f*SQ2;
|
458
|
float Y = SQ6/16;
|
459
|
float[] vertices2 = { -X, Y, -1.5f*X, -Y, +1.5f*X, -Y, +X, Y };
|
460
|
|
461
|
meshes[4] = new MeshPolygon(vertices2, bands1, 1, 1);
|
462
|
meshes[4].setEffectAssociation(0,16,0);
|
463
|
meshes[5] = meshes[4].copy(true);
|
464
|
meshes[5].setEffectAssociation(0,32,0);
|
465
|
|
466
|
return new MeshJoined(meshes);
|
467
|
}
|
468
|
|
469
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
470
|
|
471
|
MeshBase createFacesRediCorner()
|
472
|
{
|
473
|
MeshBase[] meshes = new MeshBase[6];
|
474
|
|
475
|
float E = 0.5f;
|
476
|
float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
|
477
|
float[] bands0 = computeBands(0.06f,35,E,0.7f,6);
|
478
|
|
479
|
meshes[0] = new MeshPolygon(vertices0,bands0,2,2);
|
480
|
meshes[0].setEffectAssociation(0,1,0);
|
481
|
meshes[1] = meshes[0].copy(true);
|
482
|
meshes[1].setEffectAssociation(0,2,0);
|
483
|
meshes[2] = meshes[0].copy(true);
|
484
|
meshes[2].setEffectAssociation(0,4,0);
|
485
|
|
486
|
float F = 0.5f;
|
487
|
float X = 0.5f;
|
488
|
float G = 0.72f;
|
489
|
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 };
|
490
|
float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2);
|
491
|
|
492
|
meshes[3] = new MeshPolygon(vertices1,bands1,0,0);
|
493
|
meshes[3].setEffectAssociation(0,8,0);
|
494
|
meshes[4] = meshes[3].copy(true);
|
495
|
meshes[4].setEffectAssociation(0,16,0);
|
496
|
meshes[5] = meshes[3].copy(true);
|
497
|
meshes[5].setEffectAssociation(0,32,0);
|
498
|
|
499
|
return new MeshJoined(meshes);
|
500
|
}
|
501
|
|
502
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
503
|
|
504
|
MeshBase createFacesIvyCorner()
|
505
|
{
|
506
|
MeshBase[] meshes = new MeshBase[6];
|
507
|
|
508
|
final float angle = (float)Math.PI/(2*IVY_N);
|
509
|
final float CORR = 1.0f - 2*IVY_D;
|
510
|
final float DIST = -0.5f*CORR + IVY_D;
|
511
|
float[] vertices = new float[2*(IVY_N+1)+6];
|
512
|
|
513
|
vertices[0] = (0.5f-IVY_M) * IVY_C;
|
514
|
vertices[1] = (DIST-IVY_M) * IVY_C;
|
515
|
vertices[2] = (0.5f-IVY_M) * IVY_C;
|
516
|
vertices[3] = (0.5f-IVY_M) * IVY_C;
|
517
|
vertices[4] = (DIST-IVY_M) * IVY_C;
|
518
|
vertices[5] = (0.5f-IVY_M) * IVY_C;
|
519
|
|
520
|
for(int i=0; i<=IVY_N; i++)
|
521
|
{
|
522
|
float ang = (IVY_N-i)*angle;
|
523
|
float sin = (float)Math.sin(ang);
|
524
|
float cos = (float)Math.cos(ang);
|
525
|
|
526
|
vertices[2*i+6] = (CORR*(cos-0.5f)-IVY_M)*IVY_C;
|
527
|
vertices[2*i+7] = (CORR*(sin-0.5f)-IVY_M)*IVY_C;
|
528
|
}
|
529
|
|
530
|
float[] bands0 = computeBands(+0.01f,12,0.2f,0.5f,5);
|
531
|
float[] bands1 = computeBands(-0.10f,20,0.2f,0.0f,2);
|
532
|
|
533
|
meshes[0] = new MeshPolygon(vertices,bands0,1,2);
|
534
|
meshes[0].setEffectAssociation(0,1,0);
|
535
|
meshes[1] = meshes[0].copy(true);
|
536
|
meshes[1].setEffectAssociation(0,2,0);
|
537
|
meshes[2] = meshes[0].copy(true);
|
538
|
meshes[2].setEffectAssociation(0,4,0);
|
539
|
meshes[3] = new MeshPolygon(vertices,bands1,1,2);
|
540
|
meshes[3].setEffectAssociation(0,8,0);
|
541
|
meshes[4] = meshes[3].copy(true);
|
542
|
meshes[4].setEffectAssociation(0,16,0);
|
543
|
meshes[5] = meshes[3].copy(true);
|
544
|
meshes[5].setEffectAssociation(0,32,0);
|
545
|
|
546
|
return new MeshJoined(meshes);
|
547
|
}
|
548
|
|
549
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
550
|
|
551
|
MeshBase createFacesIvyFace()
|
552
|
{
|
553
|
MeshBase[] meshes = new MeshBase[2];
|
554
|
|
555
|
final float angle = (float)Math.PI/(2*IVY_N);
|
556
|
final float CORR = 1.0f - 2*IVY_D;
|
557
|
float[] vertices = new float[4*IVY_N];
|
558
|
|
559
|
for(int i=0; i<IVY_N; i++)
|
560
|
{
|
561
|
float sin = (float)Math.sin(i*angle);
|
562
|
float cos = (float)Math.cos(i*angle);
|
563
|
|
564
|
vertices[2*i ] = CORR*(0.5f-cos);
|
565
|
vertices[2*i+1 ] = CORR*(0.5f-sin);
|
566
|
vertices[2*i +2*IVY_N] = CORR*(cos-0.5f);
|
567
|
vertices[2*i+1+2*IVY_N] = CORR*(sin-0.5f);
|
568
|
}
|
569
|
|
570
|
float[] bands0 = computeBands(+0.03f,35,0.5f,0.5f,5);
|
571
|
float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2);
|
572
|
|
573
|
meshes[0] = new MeshPolygon(vertices,bands0,0,0);
|
574
|
meshes[0].setEffectAssociation(0,1,0);
|
575
|
meshes[1] = new MeshPolygon(vertices,bands1,0,0);
|
576
|
meshes[1].setEffectAssociation(0,2,0);
|
577
|
|
578
|
return new MeshJoined(meshes);
|
579
|
}
|
580
|
|
581
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
582
|
// EFFECTS
|
583
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
584
|
|
585
|
VertexEffect[] createVertexEffectsCube()
|
586
|
{
|
587
|
Static3D axisY = new Static3D(0,1,0);
|
588
|
Static3D axisX = new Static3D(1,0,0);
|
589
|
Static3D center = new Static3D(0,0,0);
|
590
|
Static1D angle90 = new Static1D(90);
|
591
|
Static1D angle180= new Static1D(180);
|
592
|
Static1D angle270= new Static1D(270);
|
593
|
|
594
|
VertexEffect[] effect = new VertexEffect[6];
|
595
|
|
596
|
effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
|
597
|
effect[1] = new VertexEffectRotate( angle180, axisX, center );
|
598
|
effect[2] = new VertexEffectRotate( angle90 , axisX, center );
|
599
|
effect[3] = new VertexEffectRotate( angle270, axisX, center );
|
600
|
effect[4] = new VertexEffectRotate( angle270, axisY, center );
|
601
|
effect[5] = new VertexEffectRotate( angle90 , axisY, center );
|
602
|
|
603
|
effect[0].setMeshAssociation(63,-1); // all 6 sides
|
604
|
effect[1].setMeshAssociation(32,-1); // back
|
605
|
effect[2].setMeshAssociation( 8,-1); // bottom
|
606
|
effect[3].setMeshAssociation( 4,-1); // top
|
607
|
effect[4].setMeshAssociation( 2,-1); // left
|
608
|
effect[5].setMeshAssociation( 1,-1); // right
|
609
|
|
610
|
return effect;
|
611
|
}
|
612
|
|
613
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
614
|
|
615
|
VertexEffect[] createVertexEffectsSkewbCorner()
|
616
|
{
|
617
|
float E = 0.5f;
|
618
|
|
619
|
Static3D axisX = new Static3D(1,0,0);
|
620
|
Static3D axisY = new Static3D(0,1,0);
|
621
|
Static3D axis0 = new Static3D(-SQ2/2,0,SQ2/2);
|
622
|
Static3D axis1 = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
|
623
|
Static1D angle1 = new Static1D(+90);
|
624
|
Static1D angle2 = new Static1D(-90);
|
625
|
Static1D angle3 = new Static1D(-15);
|
626
|
Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
|
627
|
Static1D angle5 = new Static1D(120);
|
628
|
Static1D angle6 = new Static1D(240);
|
629
|
Static3D center1= new Static3D(0,0,0);
|
630
|
Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
|
631
|
Static3D move1 = new Static3D(-E/4,-E/4,0);
|
632
|
Static3D move2 = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f);
|
633
|
|
634
|
VertexEffect[] effect = new VertexEffect[10];
|
635
|
|
636
|
effect[0] = new VertexEffectMove(move1);
|
637
|
effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
|
638
|
effect[2] = new VertexEffectRotate(angle1,axisX,center1);
|
639
|
effect[3] = new VertexEffectRotate(angle2,axisY,center1);
|
640
|
effect[4] = new VertexEffectMove(move2);
|
641
|
effect[5] = new VertexEffectRotate(angle1,axisX,center2);
|
642
|
effect[6] = new VertexEffectRotate(angle3,axisY,center2);
|
643
|
effect[7] = new VertexEffectRotate(angle4,axis0,center2);
|
644
|
effect[8] = new VertexEffectRotate(angle5,axis1,center2);
|
645
|
effect[9] = new VertexEffectRotate(angle6,axis1,center2);
|
646
|
|
647
|
effect[0].setMeshAssociation( 7,-1); // meshes 0,1,2
|
648
|
effect[1].setMeshAssociation( 6,-1); // meshes 1,2
|
649
|
effect[2].setMeshAssociation( 2,-1); // mesh 1
|
650
|
effect[3].setMeshAssociation( 4,-1); // mesh 2
|
651
|
effect[4].setMeshAssociation(56,-1); // meshes 3,4,5
|
652
|
effect[5].setMeshAssociation(56,-1); // meshes 3,4,5
|
653
|
effect[6].setMeshAssociation(56,-1); // meshes 3,4,5
|
654
|
effect[7].setMeshAssociation(56,-1); // meshes 3,4,5
|
655
|
effect[8].setMeshAssociation(16,-1); // mesh 4
|
656
|
effect[9].setMeshAssociation(32,-1); // mesh 5
|
657
|
|
658
|
return effect;
|
659
|
}
|
660
|
|
661
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
662
|
|
663
|
VertexEffect[] createVertexEffectsSkewbFace()
|
664
|
{
|
665
|
Static3D center = new Static3D(0,0,0);
|
666
|
Static3D axisX = new Static3D(1,0,0);
|
667
|
Static3D axisZ = new Static3D(0,0,1);
|
668
|
float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
|
669
|
|
670
|
VertexEffect[] effect = new VertexEffect[6];
|
671
|
|
672
|
effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center);
|
673
|
effect[1] = new VertexEffectRotate( new Static1D( 135), axisZ, center);
|
674
|
effect[2] = new VertexEffectRotate( new Static1D( 45), axisZ, center);
|
675
|
effect[3] = new VertexEffectRotate( new Static1D( -45), axisZ, center);
|
676
|
effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center);
|
677
|
effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) );
|
678
|
|
679
|
effect[0].setMeshAssociation(30,-1); // meshes 1,2,3,4
|
680
|
effect[1].setMeshAssociation( 2,-1); // mesh 1
|
681
|
effect[2].setMeshAssociation( 5,-1); // meshes 0,2
|
682
|
effect[3].setMeshAssociation( 8,-1); // mesh 3
|
683
|
effect[4].setMeshAssociation(16,-1); // mesh 4
|
684
|
effect[5].setMeshAssociation(30,-1); // meshes 1,2,3,4
|
685
|
|
686
|
return effect;
|
687
|
}
|
688
|
|
689
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
690
|
|
691
|
VertexEffect[] createVertexEffectsOcta()
|
692
|
{
|
693
|
Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
|
694
|
Static1D angle1= new Static1D( 90);
|
695
|
Static1D angle2= new Static1D(180);
|
696
|
Static1D angle3= new Static1D(270);
|
697
|
Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
|
698
|
Static3D axisX = new Static3D(1,0,0);
|
699
|
Static3D axisY = new Static3D(0,1,0);
|
700
|
Static3D cent0 = new Static3D(0,0,0);
|
701
|
Static3D cent1 = new Static3D(0,SQ2/2,0);
|
702
|
Static3D flipY = new Static3D( 1,-1, 1);
|
703
|
Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
|
704
|
|
705
|
VertexEffect[] effect = new VertexEffect[7];
|
706
|
|
707
|
effect[0] = new VertexEffectScale(scale);
|
708
|
effect[1] = new VertexEffectMove(move1);
|
709
|
effect[2] = new VertexEffectRotate(alpha , axisX, cent1);
|
710
|
effect[3] = new VertexEffectRotate(angle1, axisY, cent0);
|
711
|
effect[4] = new VertexEffectRotate(angle2, axisY, cent0);
|
712
|
effect[5] = new VertexEffectRotate(angle3, axisY, cent0);
|
713
|
effect[6] = new VertexEffectScale(flipY);
|
714
|
|
715
|
effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
|
716
|
effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
|
717
|
effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7
|
718
|
effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
|
719
|
|
720
|
return effect;
|
721
|
}
|
722
|
|
723
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
724
|
|
725
|
VertexEffect[] createVertexEffectsTetra()
|
726
|
{
|
727
|
Static3D flipZ = new Static3D( 1, 1,-1);
|
728
|
Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
|
729
|
Static1D angle1= new Static1D( 90);
|
730
|
Static1D angle2= new Static1D(180);
|
731
|
Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
|
732
|
Static3D axisX = new Static3D(1,0,0);
|
733
|
Static3D axisY = new Static3D(0,1,0);
|
734
|
Static3D axisZ = new Static3D(0,0,1);
|
735
|
Static3D cent0 = new Static3D(0,0,0);
|
736
|
Static3D cent1 = new Static3D(0,SQ2/4,0);
|
737
|
Static3D scale = new Static3D( 1, 2*SQ3/3, 1);
|
738
|
|
739
|
VertexEffect[] effect = new VertexEffect[7];
|
740
|
|
741
|
effect[0] = new VertexEffectScale(scale);
|
742
|
effect[1] = new VertexEffectRotate(angle2, axisZ, cent0);
|
743
|
effect[2] = new VertexEffectMove(move1);
|
744
|
effect[3] = new VertexEffectRotate(alpha , axisX, cent1);
|
745
|
effect[4] = new VertexEffectScale(flipZ);
|
746
|
effect[5] = new VertexEffectRotate(angle1, axisY, cent0);
|
747
|
effect[6] = new VertexEffectRotate(angle2, axisZ, cent0);
|
748
|
|
749
|
effect[4].setMeshAssociation(10,-1); // meshes 1 & 3
|
750
|
effect[5].setMeshAssociation(12,-1); // meshes 2 & 3
|
751
|
effect[6].setMeshAssociation(12,-1); // meshes 2 & 3
|
752
|
|
753
|
return effect;
|
754
|
}
|
755
|
|
756
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
757
|
|
758
|
VertexEffect[] createVertexEffectsDino()
|
759
|
{
|
760
|
float E = 0.5f*SQ2;
|
761
|
float F = 0.5f;
|
762
|
final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
|
763
|
|
764
|
Static1D angle1 = new Static1D(-ANGLE);
|
765
|
Static1D angle2 = new Static1D(+ANGLE);
|
766
|
Static3D axisX = new Static3D(1,0,0);
|
767
|
Static3D axisY = new Static3D(0,1,0);
|
768
|
Static3D axisZ = new Static3D(0,-1,1);
|
769
|
Static3D center0= new Static3D(0,0,0);
|
770
|
Static3D center1= new Static3D(0,-3*F,0);
|
771
|
|
772
|
VertexEffect[] effect = new VertexEffect[10];
|
773
|
|
774
|
effect[0] = new VertexEffectScale ( new Static3D(3,3,3) );
|
775
|
effect[1] = new VertexEffectMove ( new Static3D(0,-F,0) );
|
776
|
effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 );
|
777
|
effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) );
|
778
|
effect[4] = new VertexEffectMove ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
|
779
|
effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
|
780
|
effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) );
|
781
|
effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
|
782
|
effect[8] = new VertexEffectRotate( angle1 , axisZ, center1 );
|
783
|
effect[9] = new VertexEffectRotate( angle2 , axisZ, center1 );
|
784
|
|
785
|
effect[0].setMeshAssociation(15,-1); // apply to meshes 0,1,2,3
|
786
|
effect[1].setMeshAssociation( 3,-1); // apply to meshes 0,1
|
787
|
effect[2].setMeshAssociation( 2,-1); // apply to mesh 1
|
788
|
effect[3].setMeshAssociation( 2,-1); // apply to mesh 0
|
789
|
effect[4].setMeshAssociation(12,-1); // apply to meshes 2,3
|
790
|
effect[5].setMeshAssociation(12,-1); // apply to meshes 2,3
|
791
|
effect[6].setMeshAssociation( 8,-1); // apply to mesh 3
|
792
|
effect[7].setMeshAssociation(12,-1); // apply to meshes 2,3
|
793
|
effect[8].setMeshAssociation( 4,-1); // apply to mesh 2
|
794
|
effect[9].setMeshAssociation( 8,-1); // apply to mesh 3
|
795
|
|
796
|
return effect;
|
797
|
}
|
798
|
|
799
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
800
|
|
801
|
VertexEffect[] createVertexEffectsHelicopterCorner()
|
802
|
{
|
803
|
float E = 0.5f;
|
804
|
|
805
|
Static3D axisX = new Static3D(1,0,0);
|
806
|
Static3D axisY = new Static3D(0,1,0);
|
807
|
Static3D axis0 = new Static3D(-SQ2/2,0,SQ2/2);
|
808
|
Static3D axis1 = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
|
809
|
Static1D angle1 = new Static1D(+90);
|
810
|
Static1D angle2 = new Static1D(-90);
|
811
|
Static1D angle3 = new Static1D(-135);
|
812
|
Static1D angle4 = new Static1D(90);
|
813
|
Static1D angle5 = new Static1D(120);
|
814
|
Static1D angle6 = new Static1D(240);
|
815
|
Static3D center1= new Static3D(0,0,0);
|
816
|
Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
|
817
|
Static3D move1 = new Static3D(-E/4,-E/4,0);
|
818
|
Static3D move2 = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
|
819
|
|
820
|
VertexEffect[] effect = new VertexEffect[10];
|
821
|
|
822
|
effect[0] = new VertexEffectMove(move1);
|
823
|
effect[1] = new VertexEffectScale(new Static3D(1,1,-1));
|
824
|
effect[2] = new VertexEffectRotate(angle1,axisX,center1);
|
825
|
effect[3] = new VertexEffectRotate(angle2,axisY,center1);
|
826
|
effect[4] = new VertexEffectMove(move2);
|
827
|
effect[5] = new VertexEffectRotate(angle1,axisX,center2);
|
828
|
effect[6] = new VertexEffectRotate(angle3,axisY,center2);
|
829
|
effect[7] = new VertexEffectRotate(angle4,axis0,center2);
|
830
|
effect[8] = new VertexEffectRotate(angle5,axis1,center2);
|
831
|
effect[9] = new VertexEffectRotate(angle6,axis1,center2);
|
832
|
|
833
|
effect[0].setMeshAssociation( 7,-1); // meshes 0,1,2
|
834
|
effect[1].setMeshAssociation( 6,-1); // meshes 1,2
|
835
|
effect[2].setMeshAssociation( 2,-1); // mesh 1
|
836
|
effect[3].setMeshAssociation( 4,-1); // mesh 2
|
837
|
effect[4].setMeshAssociation(56,-1); // meshes 3,4,5
|
838
|
effect[5].setMeshAssociation(56,-1); // meshes 3,4,5
|
839
|
effect[6].setMeshAssociation(56,-1); // meshes 3,4,5
|
840
|
effect[7].setMeshAssociation(56,-1); // meshes 3,4,5
|
841
|
effect[8].setMeshAssociation(16,-1); // mesh 4
|
842
|
effect[9].setMeshAssociation(32,-1); // mesh 5
|
843
|
|
844
|
return effect;
|
845
|
}
|
846
|
|
847
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
848
|
|
849
|
VertexEffect[] createVertexEffectsHelicopterFace()
|
850
|
{
|
851
|
float E = 0.5f;
|
852
|
float F = SQ2/4;
|
853
|
|
854
|
Static3D move0 = new Static3D(-E/4, -E/4, 0);
|
855
|
Static3D move1 = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
|
856
|
Static3D move2 = new Static3D(-E/2, F/3, 0);
|
857
|
Static3D move3 = new Static3D(+E/2, F/3, 0);
|
858
|
Static3D move4 = new Static3D(+E/3,+E/3, 0);
|
859
|
Static1D angle1 = new Static1D(135);
|
860
|
Static1D angle2 = new Static1D(90);
|
861
|
Static1D angle3 = new Static1D(-90);
|
862
|
Static1D angle4 = new Static1D(-135);
|
863
|
Static3D axisX = new Static3D(1,0,0);
|
864
|
Static3D axisY = new Static3D(0,1,0);
|
865
|
Static3D axisZ = new Static3D(0,0,1);
|
866
|
Static3D axis1 = new Static3D(1,-1,0);
|
867
|
Static3D center = new Static3D(0,0,0);
|
868
|
Static3D center1= new Static3D(-E/2,-E/2,0);
|
869
|
|
870
|
VertexEffect[] effect = new VertexEffect[10];
|
871
|
|
872
|
effect[0] = new VertexEffectMove(move0);
|
873
|
effect[1] = new VertexEffectRotate(angle1, axisZ, center);
|
874
|
effect[2] = new VertexEffectMove(move1);
|
875
|
effect[3] = new VertexEffectRotate(angle2, axis1, center1);
|
876
|
effect[4] = new VertexEffectMove(move2);
|
877
|
effect[5] = new VertexEffectMove(move3);
|
878
|
effect[6] = new VertexEffectRotate(angle3, axisZ, center);
|
879
|
effect[7] = new VertexEffectRotate(angle4, axisX, center);
|
880
|
effect[8] = new VertexEffectRotate(angle1, axisY, center);
|
881
|
effect[9] = new VertexEffectMove(move4);
|
882
|
|
883
|
effect[0].setMeshAssociation( 1,-1); // mesh 0
|
884
|
effect[1].setMeshAssociation( 2,-1); // mesh 1
|
885
|
effect[2].setMeshAssociation( 2,-1); // mesh 1
|
886
|
effect[3].setMeshAssociation( 2,-1); // mesh 1
|
887
|
effect[4].setMeshAssociation( 4,-1); // mesh 2
|
888
|
effect[5].setMeshAssociation( 8,-1); // mesh 3
|
889
|
effect[6].setMeshAssociation( 8,-1); // mesh 3
|
890
|
effect[7].setMeshAssociation( 4,-1); // mesh 2
|
891
|
effect[8].setMeshAssociation( 8,-1); // mesh 3
|
892
|
effect[9].setMeshAssociation(15,-1); // meshes 0,1,2,3
|
893
|
|
894
|
return effect;
|
895
|
}
|
896
|
|
897
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
898
|
|
899
|
VertexEffect[] createVertexEffectsRediEdge()
|
900
|
{
|
901
|
Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
|
902
|
Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
|
903
|
Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
|
904
|
Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
|
905
|
Static3D flipZ = new Static3D(1,1,-1);
|
906
|
Static3D flipX = new Static3D(-1,1,1);
|
907
|
Static3D scale = new Static3D(2,2,2);
|
908
|
Static3D cent0 = new Static3D(0,0, 0);
|
909
|
Static3D cent1 = new Static3D(0,0, -1.5f);
|
910
|
Static3D axisX = new Static3D(1,0, 0);
|
911
|
Static3D axisY = new Static3D(0,1, 0);
|
912
|
Static3D axis = new Static3D(0,SQ2/2,-SQ2/2);
|
913
|
Static1D angle1= new Static1D(90);
|
914
|
Static1D angle2= new Static1D(45);
|
915
|
Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
|
916
|
|
917
|
VertexEffect[] effect = new VertexEffect[12];
|
918
|
|
919
|
effect[0] = new VertexEffectScale(scale);
|
920
|
effect[1] = new VertexEffectMove(move0);
|
921
|
effect[2] = new VertexEffectScale(flipZ);
|
922
|
effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
|
923
|
effect[4] = new VertexEffectMove(move1);
|
924
|
effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
|
925
|
effect[6] = new VertexEffectMove(move2);
|
926
|
effect[7] = new VertexEffectScale(flipX);
|
927
|
effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
|
928
|
effect[9] = new VertexEffectMove(move3);
|
929
|
effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
|
930
|
effect[11]= new VertexEffectScale(flipX);
|
931
|
|
932
|
effect[0].setMeshAssociation(63,-1); // meshes 0,1,2,3,4,5
|
933
|
effect[1].setMeshAssociation( 3,-1); // meshes 0,1
|
934
|
effect[2].setMeshAssociation( 2,-1); // mesh 1
|
935
|
effect[3].setMeshAssociation( 2,-1); // mesh 1
|
936
|
effect[4].setMeshAssociation(12,-1); // meshes 2,3
|
937
|
effect[5].setMeshAssociation(60,-1); // meshes 2,3,4,5
|
938
|
effect[6].setMeshAssociation(12,-1); // meshes 2,3
|
939
|
effect[7].setMeshAssociation( 8,-1); // mesh 3
|
940
|
effect[8].setMeshAssociation(48,-1); // meshes 4,5
|
941
|
effect[9].setMeshAssociation(48,-1); // meshes 4,5
|
942
|
effect[10].setMeshAssociation(48,-1); // meshes 4,5
|
943
|
effect[11].setMeshAssociation(32,-1); // mesh 5
|
944
|
|
945
|
return effect;
|
946
|
}
|
947
|
|
948
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
949
|
|
950
|
VertexEffect[] createVertexEffectsRediCorner()
|
951
|
{
|
952
|
Static3D axisY = new Static3D(0,1,0);
|
953
|
Static3D axisX = new Static3D(1,0,0);
|
954
|
Static3D axisZ = new Static3D(0,0,1);
|
955
|
Static3D center = new Static3D(0,0,0);
|
956
|
Static1D angle90 = new Static1D(90);
|
957
|
Static1D angle270= new Static1D(270);
|
958
|
Static1D angle45 = new Static1D(-45);
|
959
|
Static3D scale = new Static3D(1.0f, SQ2, 1.0f);
|
960
|
|
961
|
VertexEffect[] effect = new VertexEffect[7];
|
962
|
|
963
|
effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
|
964
|
effect[1] = new VertexEffectRotate( angle270, axisX, center );
|
965
|
effect[2] = new VertexEffectRotate( angle90 , axisY, center );
|
966
|
effect[3] = new VertexEffectScale(scale);
|
967
|
effect[4] = new VertexEffectRotate( angle45 , axisX, center );
|
968
|
effect[5] = new VertexEffectRotate( angle90 , axisY, center );
|
969
|
effect[6] = new VertexEffectRotate( angle270, axisZ, center );
|
970
|
|
971
|
effect[0].setMeshAssociation( 7,-1); // 0,1,2
|
972
|
effect[1].setMeshAssociation( 2,-1); // 1
|
973
|
effect[2].setMeshAssociation( 4,-1); // 2
|
974
|
effect[3].setMeshAssociation(56,-1); // 3,4,5
|
975
|
effect[4].setMeshAssociation(56,-1); // 3,4,5
|
976
|
effect[5].setMeshAssociation(16,-1); // 4
|
977
|
effect[6].setMeshAssociation(32,-1); // 5
|
978
|
|
979
|
return effect;
|
980
|
}
|
981
|
|
982
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
983
|
|
984
|
VertexEffect[] createVertexEffectsIvyCorner()
|
985
|
{
|
986
|
Static3D axisX = new Static3D(1,0,0);
|
987
|
Static3D axisY = new Static3D(0,1,0);
|
988
|
Static1D angle1 = new Static1D(+90);
|
989
|
Static1D angle2 = new Static1D(-90);
|
990
|
Static3D center = new Static3D(0,0,0);
|
991
|
Static3D move1 = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
|
992
|
|
993
|
VertexEffect[] effect = new VertexEffect[5];
|
994
|
|
995
|
effect[0] = new VertexEffectScale(1/IVY_C);
|
996
|
effect[1] = new VertexEffectMove(move1);
|
997
|
effect[2] = new VertexEffectScale(new Static3D(1,1,-1));
|
998
|
effect[3] = new VertexEffectRotate(angle1,axisX,center);
|
999
|
effect[4] = new VertexEffectRotate(angle2,axisY,center);
|
1000
|
|
1001
|
effect[2].setMeshAssociation(54,-1); // meshes 1,2,4,5
|
1002
|
effect[3].setMeshAssociation(18,-1); // meshes 1,4
|
1003
|
effect[4].setMeshAssociation(36,-1); // meshes 2,5
|
1004
|
|
1005
|
return effect;
|
1006
|
}
|
1007
|
|
1008
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1009
|
// OBJECTS
|
1010
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1011
|
// CUBE
|
1012
|
|
1013
|
MeshBase createCubeMesh(int index)
|
1014
|
{
|
1015
|
MeshBase mesh = createFacesCube(index);
|
1016
|
VertexEffect[] effects = createVertexEffectsCube();
|
1017
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1018
|
|
1019
|
Static3D roundingCenter = new Static3D(0,0,0);
|
1020
|
Static3D[] vertices = new Static3D[8];
|
1021
|
vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
|
1022
|
vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
|
1023
|
vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
|
1024
|
vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
|
1025
|
vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
|
1026
|
vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
|
1027
|
vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
|
1028
|
vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
|
1029
|
|
1030
|
roundCorners(mesh,roundingCenter,vertices,0.06f,0.12f);
|
1031
|
|
1032
|
mesh.mergeEffComponents();
|
1033
|
|
1034
|
return mesh;
|
1035
|
}
|
1036
|
|
1037
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1038
|
// SKEWB
|
1039
|
|
1040
|
MeshBase createSkewbCornerMesh()
|
1041
|
{
|
1042
|
MeshBase mesh = createFacesSkewbCorner();
|
1043
|
VertexEffect[] effects = createVertexEffectsSkewbCorner();
|
1044
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1045
|
|
1046
|
float E = 0.5f;
|
1047
|
Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
|
1048
|
|
1049
|
Static3D[] verticesType1 = new Static3D[1];
|
1050
|
verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
|
1051
|
roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
|
1052
|
|
1053
|
Static3D[] verticesType2 = new Static3D[3];
|
1054
|
verticesType2[0] = new Static3D(-E, 0, 0);
|
1055
|
verticesType2[1] = new Static3D( 0,-E, 0);
|
1056
|
verticesType2[2] = new Static3D( 0, 0,-E);
|
1057
|
roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
|
1058
|
|
1059
|
mesh.mergeEffComponents();
|
1060
|
|
1061
|
return mesh;
|
1062
|
}
|
1063
|
|
1064
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1065
|
|
1066
|
MeshBase createSkewbFaceMesh()
|
1067
|
{
|
1068
|
MeshBase mesh = createFacesSkewbFace();
|
1069
|
VertexEffect[] effects = createVertexEffectsSkewbFace();
|
1070
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1071
|
|
1072
|
Static3D roundingCenter = new Static3D(0,0,-0.2f);
|
1073
|
float E = SQ2/4;
|
1074
|
Static3D[] vertices = new Static3D[4];
|
1075
|
vertices[0] = new Static3D(-E*SQ2, 0, 0);
|
1076
|
vertices[1] = new Static3D(+E*SQ2, 0, 0);
|
1077
|
vertices[2] = new Static3D( 0, -E*SQ2, 0);
|
1078
|
vertices[3] = new Static3D( 0, +E*SQ2, 0);
|
1079
|
roundCorners(mesh,roundingCenter,vertices,0.06f,0.10f);
|
1080
|
|
1081
|
mesh.mergeEffComponents();
|
1082
|
mesh.addEmptyTexComponent();
|
1083
|
|
1084
|
return mesh;
|
1085
|
}
|
1086
|
|
1087
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1088
|
// SKEWB DIAMOND / PYRAMINX
|
1089
|
|
1090
|
MeshBase createOctaMesh()
|
1091
|
{
|
1092
|
MeshBase mesh = createFacesOcta();
|
1093
|
VertexEffect[] effects = createVertexEffectsOcta();
|
1094
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1095
|
|
1096
|
Static3D roundingCenter = new Static3D(0,0,0);
|
1097
|
Static3D[] vertices = new Static3D[6];
|
1098
|
vertices[0] = new Static3D( 0, SQ2/2, 0 );
|
1099
|
vertices[1] = new Static3D( 0.5f, 0, 0.5f );
|
1100
|
vertices[2] = new Static3D(-0.5f, 0, 0.5f );
|
1101
|
vertices[3] = new Static3D( 0,-SQ2/2, 0 );
|
1102
|
vertices[4] = new Static3D(-0.5f, 0,-0.5f );
|
1103
|
vertices[5] = new Static3D( 0.5f, 0,-0.5f );
|
1104
|
|
1105
|
roundCorners(mesh,roundingCenter,vertices,0.06f,0.20f);
|
1106
|
|
1107
|
mesh.mergeEffComponents();
|
1108
|
|
1109
|
return mesh;
|
1110
|
}
|
1111
|
|
1112
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1113
|
|
1114
|
MeshBase createTetraMesh()
|
1115
|
{
|
1116
|
MeshBase mesh = createFacesTetra();
|
1117
|
VertexEffect[] effects = createVertexEffectsTetra();
|
1118
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1119
|
|
1120
|
Static3D roundingCenter = new Static3D(0,0,0);
|
1121
|
Static3D[] verticesRound = new Static3D[4];
|
1122
|
verticesRound[0] = new Static3D(-0.5f,+SQ2/4, 0 );
|
1123
|
verticesRound[1] = new Static3D(+0.5f,+SQ2/4, 0 );
|
1124
|
verticesRound[2] = new Static3D( 0,-SQ2/4,+0.5f);
|
1125
|
verticesRound[3] = new Static3D( 0,-SQ2/4,-0.5f);
|
1126
|
roundCorners(mesh,roundingCenter,verticesRound,0.08f,0.15f);
|
1127
|
|
1128
|
mesh.mergeEffComponents();
|
1129
|
mesh.addEmptyTexComponent();
|
1130
|
mesh.addEmptyTexComponent();
|
1131
|
mesh.addEmptyTexComponent();
|
1132
|
mesh.addEmptyTexComponent();
|
1133
|
|
1134
|
return mesh;
|
1135
|
}
|
1136
|
|
1137
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1138
|
// DINO
|
1139
|
|
1140
|
MeshBase createDinoMesh()
|
1141
|
{
|
1142
|
MeshBase mesh = createFacesDino();
|
1143
|
VertexEffect[] effects = createVertexEffectsDino();
|
1144
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1145
|
|
1146
|
float F = 0.5f;
|
1147
|
Static3D roundingCenter = new Static3D(0.0f, -1.5f*F, -1.5f*F);
|
1148
|
Static3D[] verticesRound = new Static3D[4];
|
1149
|
verticesRound[0] = new Static3D( 0,-3*F, 0 );
|
1150
|
verticesRound[1] = new Static3D( 0, 0, -3*F );
|
1151
|
verticesRound[2] = new Static3D( -3*F, 0, 0 );
|
1152
|
verticesRound[3] = new Static3D( +3*F, 0, 0 );
|
1153
|
roundCorners(mesh,roundingCenter,verticesRound,0.10f,0.40f);
|
1154
|
|
1155
|
mesh.mergeEffComponents();
|
1156
|
|
1157
|
return mesh;
|
1158
|
}
|
1159
|
|
1160
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1161
|
// Helicopter
|
1162
|
|
1163
|
MeshBase createHelicopterCornerMesh()
|
1164
|
{
|
1165
|
MeshBase mesh = createFacesHelicopterCorner();
|
1166
|
VertexEffect[] effects = createVertexEffectsHelicopterCorner();
|
1167
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1168
|
|
1169
|
float E = 0.5f;
|
1170
|
Static3D roundingCenter = new Static3D(-E/2,-E/2,-E/2);
|
1171
|
|
1172
|
Static3D[] verticesType1 = new Static3D[1];
|
1173
|
verticesType1[0] = new Static3D(0.0f,0.0f,0.0f);
|
1174
|
roundCorners(mesh,roundingCenter,verticesType1,0.08f,0.15f);
|
1175
|
|
1176
|
Static3D[] verticesType2 = new Static3D[3];
|
1177
|
verticesType2[0] = new Static3D(-E, 0, 0);
|
1178
|
verticesType2[1] = new Static3D( 0,-E, 0);
|
1179
|
verticesType2[2] = new Static3D( 0, 0,-E);
|
1180
|
roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
|
1181
|
|
1182
|
mesh.mergeEffComponents();
|
1183
|
|
1184
|
return mesh;
|
1185
|
}
|
1186
|
|
1187
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1188
|
|
1189
|
MeshBase createHelicopterFaceMesh()
|
1190
|
{
|
1191
|
MeshBase mesh = createFacesHelicopterFace();
|
1192
|
VertexEffect[] effects = createVertexEffectsHelicopterFace();
|
1193
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1194
|
|
1195
|
float E = 0.5f;
|
1196
|
Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
|
1197
|
|
1198
|
Static3D[] verticesType1 = new Static3D[1];
|
1199
|
verticesType1[0] = new Static3D(E/3,E/3,0.0f);
|
1200
|
roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
|
1201
|
|
1202
|
Static3D[] verticesType2 = new Static3D[2];
|
1203
|
verticesType2[0] = new Static3D(-E+E/3, E/3 , 0);
|
1204
|
verticesType2[1] = new Static3D( E/3 ,-E+E/3, 0);
|
1205
|
roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
|
1206
|
|
1207
|
mesh.mergeEffComponents();
|
1208
|
mesh.addEmptyTexComponent();
|
1209
|
mesh.addEmptyTexComponent();
|
1210
|
|
1211
|
return mesh;
|
1212
|
}
|
1213
|
|
1214
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1215
|
// Redi cube
|
1216
|
|
1217
|
MeshBase createRediEdgeMesh()
|
1218
|
{
|
1219
|
MeshBase mesh = createFacesRediEdge();
|
1220
|
VertexEffect[] effects = createVertexEffectsRediEdge();
|
1221
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1222
|
|
1223
|
Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
|
1224
|
Static3D[] vertices = new Static3D[2];
|
1225
|
vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
|
1226
|
vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
|
1227
|
roundCorners(mesh,center,vertices,0.06f,0.20f);
|
1228
|
|
1229
|
mesh.mergeEffComponents();
|
1230
|
|
1231
|
return mesh;
|
1232
|
}
|
1233
|
|
1234
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1235
|
|
1236
|
MeshBase createRediCornerMesh()
|
1237
|
{
|
1238
|
MeshBase mesh = createFacesRediCorner();
|
1239
|
VertexEffect[] effects = createVertexEffectsRediCorner();
|
1240
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1241
|
|
1242
|
Static3D center = new Static3D(0,0,0);
|
1243
|
Static3D[] vertices = new Static3D[8];
|
1244
|
vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
|
1245
|
vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
|
1246
|
vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
|
1247
|
vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
|
1248
|
vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
|
1249
|
vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
|
1250
|
vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
|
1251
|
vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
|
1252
|
|
1253
|
roundCorners(mesh,center,vertices,0.06f,0.12f);
|
1254
|
|
1255
|
mesh.mergeEffComponents();
|
1256
|
|
1257
|
return mesh;
|
1258
|
}
|
1259
|
|
1260
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1261
|
|
1262
|
MeshBase createIvyCornerMesh()
|
1263
|
{
|
1264
|
MeshBase mesh = createFacesIvyCorner();
|
1265
|
VertexEffect[] effects = createVertexEffectsIvyCorner();
|
1266
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1267
|
|
1268
|
Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
|
1269
|
Static3D[] vertices = new Static3D[1];
|
1270
|
vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f);
|
1271
|
roundCorners(mesh,center,vertices,0.06f,0.15f);
|
1272
|
|
1273
|
mesh.mergeEffComponents();
|
1274
|
|
1275
|
return mesh;
|
1276
|
}
|
1277
|
|
1278
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1279
|
|
1280
|
MeshBase createIvyFaceMesh()
|
1281
|
{
|
1282
|
MeshBase mesh = createFacesIvyFace();
|
1283
|
|
1284
|
mesh.mergeEffComponents();
|
1285
|
mesh.addEmptyTexComponent();
|
1286
|
mesh.addEmptyTexComponent();
|
1287
|
mesh.addEmptyTexComponent();
|
1288
|
mesh.addEmptyTexComponent();
|
1289
|
|
1290
|
return mesh;
|
1291
|
}
|
1292
|
}
|