1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2016 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Distorted. //
|
5
|
// //
|
6
|
// Distorted 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
|
// Distorted 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 Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
package org.distorted.examples.meshfile;
|
21
|
|
22
|
import android.content.Context;
|
23
|
import android.content.res.Resources;
|
24
|
import android.graphics.Bitmap;
|
25
|
import android.graphics.Canvas;
|
26
|
import android.graphics.Paint;
|
27
|
import android.opengl.GLSurfaceView;
|
28
|
|
29
|
import org.distorted.examples.R;
|
30
|
import org.distorted.library.effect.Effect;
|
31
|
import org.distorted.library.effect.EffectType;
|
32
|
import org.distorted.library.effect.MatrixEffectQuaternion;
|
33
|
import org.distorted.library.effect.MatrixEffectScale;
|
34
|
import org.distorted.library.effect.VertexEffectDisappear;
|
35
|
import org.distorted.library.main.DistortedEffects;
|
36
|
import org.distorted.library.main.DistortedLibrary;
|
37
|
import org.distorted.library.main.DistortedScreen;
|
38
|
import org.distorted.library.main.DistortedTexture;
|
39
|
import org.distorted.library.mesh.MeshBase;
|
40
|
import org.distorted.library.mesh.MeshFile;
|
41
|
import org.distorted.library.mesh.MeshPolygon;
|
42
|
import org.distorted.library.type.DynamicQuat;
|
43
|
import org.distorted.library.type.Static3D;
|
44
|
import org.distorted.library.type.Static4D;
|
45
|
|
46
|
import org.distorted.objectlib.helpers.FactoryCubit;
|
47
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
48
|
import org.distorted.objectlib.helpers.ObjectShape;
|
49
|
|
50
|
import java.io.DataInputStream;
|
51
|
import java.io.IOException;
|
52
|
import java.io.InputStream;
|
53
|
|
54
|
import javax.microedition.khronos.egl.EGLConfig;
|
55
|
import javax.microedition.khronos.opengles.GL10;
|
56
|
|
57
|
import static org.distorted.examples.meshfile.MeshFileActivity.POLYGON;
|
58
|
import static org.distorted.examples.meshfile.MeshFileActivity.PROCEDURAL;
|
59
|
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
|
60
|
|
61
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
62
|
|
63
|
class MeshFileRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
64
|
{
|
65
|
private static final float SQ2 = (float)Math.sqrt(2);
|
66
|
private static final float SQ3 = (float)Math.sqrt(3);
|
67
|
private static final float SQ5 = (float)Math.sqrt(5);
|
68
|
private final float DEFAULT_SCALE = 0.3f;
|
69
|
|
70
|
private final GLSurfaceView mView;
|
71
|
private DistortedTexture mTexture;
|
72
|
private final DistortedScreen mScreen;
|
73
|
private final DistortedEffects mEffects;
|
74
|
private final Static3D mScale;
|
75
|
private long mTime;
|
76
|
private float mCurrentScale;
|
77
|
private MeshBase mMesh;
|
78
|
|
79
|
Static4D mQuat1, mQuat2;
|
80
|
int mScreenMin;
|
81
|
|
82
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
83
|
|
84
|
MeshFileRenderer(GLSurfaceView v)
|
85
|
{
|
86
|
mView = v;
|
87
|
mScreen = new DistortedScreen();
|
88
|
mScale= new Static3D(1,1,1);
|
89
|
Static3D center=new Static3D(0,0,0);
|
90
|
|
91
|
mCurrentScale = DEFAULT_SCALE;
|
92
|
|
93
|
mQuat1 = new Static4D(0,0,0,1);
|
94
|
mQuat2 = new Static4D(0,0,0,1);
|
95
|
|
96
|
DynamicQuat quatInt1 = new DynamicQuat(0,0.5f);
|
97
|
DynamicQuat quatInt2 = new DynamicQuat(0,0.5f);
|
98
|
|
99
|
quatInt1.add(mQuat1);
|
100
|
quatInt2.add(mQuat2);
|
101
|
|
102
|
VertexEffectDisappear disappear = new VertexEffectDisappear();
|
103
|
disappear.setMeshAssociation(1,-1);
|
104
|
|
105
|
mEffects = new DistortedEffects();
|
106
|
mEffects.apply( new MatrixEffectQuaternion(quatInt2, center) );
|
107
|
mEffects.apply( new MatrixEffectQuaternion(quatInt1, center) );
|
108
|
mEffects.apply( new MatrixEffectScale(mScale));
|
109
|
|
110
|
mEffects.apply( disappear );
|
111
|
|
112
|
mScreen.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
113
|
mScreen.showFPS();
|
114
|
}
|
115
|
|
116
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
117
|
|
118
|
public void onDrawFrame(GL10 glUnused)
|
119
|
{
|
120
|
mScreen.render( System.currentTimeMillis() );
|
121
|
}
|
122
|
|
123
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
124
|
|
125
|
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
126
|
{
|
127
|
mScreenMin = Math.min(width, height);
|
128
|
float factor = mCurrentScale*mScreenMin;
|
129
|
mScale.set(factor,factor,factor);
|
130
|
mScreen.resize(width, height);
|
131
|
}
|
132
|
|
133
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
134
|
|
135
|
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
136
|
{
|
137
|
if( mTexture==null ) mTexture = new DistortedTexture();
|
138
|
|
139
|
Effect.enableEffects(EffectType.VERTEX);
|
140
|
DistortedLibrary.setMax(EffectType.VERTEX, 20);
|
141
|
DistortedLibrary.needTransformFeedback();
|
142
|
DistortedLibrary.onSurfaceCreated(mView.getContext(), this);
|
143
|
}
|
144
|
|
145
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
146
|
|
147
|
public void distortedException(Exception ex)
|
148
|
{
|
149
|
android.util.Log.e("MeshFile", ex.getMessage() );
|
150
|
}
|
151
|
|
152
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
153
|
// 0 ---> 0
|
154
|
// 50 ---> DEFAULT_SCALE
|
155
|
// 100 ---> 4*DEFAULT_SCALE
|
156
|
|
157
|
void setScale(int scale)
|
158
|
{
|
159
|
if( scale<= 50 )
|
160
|
{
|
161
|
mCurrentScale = DEFAULT_SCALE * scale / 50.0f;
|
162
|
}
|
163
|
else
|
164
|
{
|
165
|
mCurrentScale = DEFAULT_SCALE * ( 3*(scale/50.0f) - 2.0f);
|
166
|
}
|
167
|
|
168
|
float factor = mCurrentScale*mScreenMin;
|
169
|
mScale.set(factor,factor,factor);
|
170
|
}
|
171
|
|
172
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
173
|
|
174
|
void open(int resourceID)
|
175
|
{
|
176
|
if( mTexture==null ) mTexture = new DistortedTexture();
|
177
|
mTexture.setTexture( createTexture(resourceID) );
|
178
|
|
179
|
long t1 = System.currentTimeMillis();
|
180
|
|
181
|
if( resourceID==PROCEDURAL )
|
182
|
{
|
183
|
createMesh();
|
184
|
}
|
185
|
else if( resourceID==POLYGON )
|
186
|
{
|
187
|
createPolygon();
|
188
|
}
|
189
|
else
|
190
|
{
|
191
|
openMesh(resourceID);
|
192
|
}
|
193
|
|
194
|
long t2 = System.currentTimeMillis();
|
195
|
|
196
|
mTime = t2-t1;
|
197
|
|
198
|
mScreen.detachAll();
|
199
|
mScreen.attach(mTexture,mEffects,mMesh);
|
200
|
}
|
201
|
|
202
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
203
|
|
204
|
private Bitmap createTexture(int resourceID)
|
205
|
{
|
206
|
TextureFactory factory = TextureFactory.getInstance();
|
207
|
|
208
|
float[] vertices;
|
209
|
int[] colors;
|
210
|
float F = 0.5f;
|
211
|
float E = SQ3/2;
|
212
|
|
213
|
switch(resourceID)
|
214
|
{
|
215
|
case R.raw.deferredjob:
|
216
|
case R.raw.meshjoin :
|
217
|
case PROCEDURAL :
|
218
|
case POLYGON :
|
219
|
case R.raw.predeform : return createWhiteTexture();
|
220
|
|
221
|
case R.raw.cube2 :
|
222
|
case R.raw.cube3 :
|
223
|
case R.raw.cube4 :
|
224
|
case R.raw.cube5 : colors = new int[] { 0xffffff00, 0xffffffff, 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffb5651d };
|
225
|
vertices = new float[] { -F,-F, +F,-F, +F,+F, -F,+F};
|
226
|
return factory.createTexture(vertices,colors,0.10f, 0.10f, true);
|
227
|
case R.raw.pyra3 :
|
228
|
case R.raw.pyra4 :
|
229
|
case R.raw.pyra5 : colors = new int[] { 0xffffff00, 0xff00ff00, 0xff0000ff, 0xffff0000 };
|
230
|
vertices = new float[] { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
|
231
|
return factory.createTexture(vertices,colors,0.05f, 0.05f, true);
|
232
|
|
233
|
case R.raw.dino : colors = new int[] { 0xffffff00, 0xffffffff, 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffb5651d };
|
234
|
vertices = new float[] { -F,F/3, 0,-2*F/3, +F,F/3 };
|
235
|
return factory.createTexture(vertices,colors,0.05f, 0.03f, true);
|
236
|
|
237
|
case R.raw.skewb : colors = new int[] { 0xffffff00, 0xffffffff, 0xff0000ff, 0xff00ff00, 0xffff0000, 0xffb5651d };
|
238
|
//vertices = new float[] { -G,-G, +G,-G, +G,+G, -G,+G };
|
239
|
|
240
|
vertices = new float[] { -F+F/4,F/4, F/4,-F+F/4, F/4,F/4};
|
241
|
return factory.createTexture(vertices,colors,0.05f, 0.08f, true);
|
242
|
}
|
243
|
|
244
|
return null;
|
245
|
}
|
246
|
|
247
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
248
|
|
249
|
private Bitmap createWhiteTexture()
|
250
|
{
|
251
|
int SIZE = 1;
|
252
|
Bitmap bitmap = Bitmap.createBitmap(SIZE,SIZE, Bitmap.Config.ARGB_8888);
|
253
|
Canvas canvas = new Canvas(bitmap);
|
254
|
|
255
|
Paint paint = new Paint();
|
256
|
paint.setColor(0xffffff55);
|
257
|
paint.setStyle(Paint.Style.FILL);
|
258
|
canvas.drawRect(0, 0, SIZE, SIZE, paint);
|
259
|
|
260
|
return bitmap;
|
261
|
}
|
262
|
|
263
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
264
|
|
265
|
private void createPolygon()
|
266
|
{
|
267
|
float A = 0.5f;
|
268
|
float B = 0.1f;
|
269
|
|
270
|
int extraIndex = 2;
|
271
|
int extraVertices = 2;
|
272
|
int numBands = 2;
|
273
|
|
274
|
float[] vertices = new float[] { -A,-A, A,-A, A,A, -A,A };
|
275
|
float[] bands = new float[2*numBands];
|
276
|
|
277
|
for(int i=0; i<numBands; i++)
|
278
|
{
|
279
|
bands[2*i ] = 1 + i/(1.0f-numBands);
|
280
|
bands[2*i+1] = B/(numBands-1)*i;
|
281
|
}
|
282
|
|
283
|
mMesh = new MeshPolygon(vertices,bands,extraIndex,extraVertices);
|
284
|
mMesh.setEffectAssociation(0,0,0);
|
285
|
mMesh.setShowNormals(true);
|
286
|
}
|
287
|
|
288
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
289
|
|
290
|
private void createMesh()
|
291
|
{
|
292
|
int mode =24;
|
293
|
int numComponents = 0;
|
294
|
float[][] vertices = null;
|
295
|
int[][] vertIndexes = null;
|
296
|
float[][] bands = null;
|
297
|
int[] bandIndexes = null;
|
298
|
float[][] corners = null;
|
299
|
int[] cornerIndexes = null;
|
300
|
float[][] centers = null;
|
301
|
int[] centerIndexes = null;
|
302
|
float[] convexCenter= null;
|
303
|
|
304
|
///// CUBE ////////////////////////////////////////////////////////////////////////////////
|
305
|
|
306
|
if( mode==0 )
|
307
|
{
|
308
|
vertices = new float[][]
|
309
|
{
|
310
|
{ 0.5f, 0.5f, 0.5f },
|
311
|
{ 0.5f, 0.5f,-0.5f },
|
312
|
{ 0.5f,-0.5f, 0.5f },
|
313
|
{ 0.5f,-0.5f,-0.5f },
|
314
|
{-0.5f, 0.5f, 0.5f },
|
315
|
{-0.5f, 0.5f,-0.5f },
|
316
|
{-0.5f,-0.5f, 0.5f },
|
317
|
{-0.5f,-0.5f,-0.5f },
|
318
|
};
|
319
|
|
320
|
vertIndexes = new int[][]
|
321
|
{
|
322
|
{2,3,1,0}, // counterclockwise!
|
323
|
{7,6,4,5},
|
324
|
{4,0,1,5},
|
325
|
{7,3,2,6},
|
326
|
{6,2,0,4},
|
327
|
{3,7,5,1}
|
328
|
};
|
329
|
|
330
|
bands = new float[][]
|
331
|
{
|
332
|
{0.05f,40,0.5f,0.2f,5, 2,2}
|
333
|
};
|
334
|
|
335
|
bandIndexes = new int[] { 0,0,0,0,0,0 };
|
336
|
|
337
|
corners = new float[][]
|
338
|
{
|
339
|
{ 0.01f, 0.10f }
|
340
|
};
|
341
|
|
342
|
cornerIndexes = new int[] { 0,0,0,0,0,0,0,0 };
|
343
|
|
344
|
centers = new float[][]
|
345
|
{
|
346
|
{ 0.0f, 0.0f, 0.0f }
|
347
|
};
|
348
|
|
349
|
centerIndexes = new int[] { 0,0,0,0,0,0,0,0 };
|
350
|
|
351
|
numComponents = 8;
|
352
|
}
|
353
|
|
354
|
///// TETRAHEDRON //////////////////////////////////////////////////////////////////////////
|
355
|
|
356
|
else if( mode==1 )
|
357
|
{
|
358
|
vertices = new float[][]
|
359
|
{
|
360
|
{-0.5f, SQ2/4, 0.0f},
|
361
|
{ 0.5f, SQ2/4, 0.0f},
|
362
|
{ 0.0f,-SQ2/4, 0.5f},
|
363
|
{ 0.0f,-SQ2/4,-0.5f}
|
364
|
};
|
365
|
|
366
|
vertIndexes = new int[][]
|
367
|
{
|
368
|
{2,1,0}, // counterclockwise!
|
369
|
{2,3,1},
|
370
|
{3,2,0},
|
371
|
{3,0,1}
|
372
|
};
|
373
|
|
374
|
bands = new float[][]
|
375
|
{
|
376
|
{0.05f,30,0.6f,0.5f,5, 2,2}
|
377
|
};
|
378
|
|
379
|
bandIndexes = new int[] { 0,0,0,0 };
|
380
|
|
381
|
corners = new float[][]
|
382
|
{
|
383
|
{ 0.02f, 0.10f }
|
384
|
};
|
385
|
|
386
|
cornerIndexes = new int[] { 0,0,0,0 };
|
387
|
|
388
|
centers = new float[][]
|
389
|
{
|
390
|
{ 0.0f, 0.0f, 0.0f }
|
391
|
};
|
392
|
|
393
|
centerIndexes = new int[] { 0,0,0,0 };
|
394
|
|
395
|
numComponents = 4;
|
396
|
}
|
397
|
|
398
|
///// DINO ////////////////////////////////////////////////////////////////////////////////
|
399
|
|
400
|
else if( mode==2 )
|
401
|
{
|
402
|
vertices = new float[][]
|
403
|
{
|
404
|
{-1.5f, 0.0f, 0.0f},
|
405
|
{ 1.5f, 0.0f, 0.0f},
|
406
|
{ 0.0f,-1.5f, 0.0f},
|
407
|
{ 0.0f, 0.0f,-1.5f}
|
408
|
};
|
409
|
|
410
|
vertIndexes = new int[][]
|
411
|
{
|
412
|
{2,1,0}, // counterclockwise!
|
413
|
{3,0,1},
|
414
|
{2,3,1},
|
415
|
{3,2,0},
|
416
|
};
|
417
|
|
418
|
bands = new float[][]
|
419
|
{
|
420
|
{0.035f,30,0.16f,0.8f,6,2,2},
|
421
|
{0.010f,45,0.16f,0.2f,6,2,2}
|
422
|
};
|
423
|
|
424
|
bandIndexes = new int[] { 0,0,1,1 };
|
425
|
|
426
|
corners = new float[][]
|
427
|
{
|
428
|
{0.07f,0.40f},
|
429
|
{0.05f,0.30f}
|
430
|
};
|
431
|
|
432
|
cornerIndexes = new int[] { 0,0,1,1 };
|
433
|
|
434
|
centers = new float[][]
|
435
|
{
|
436
|
{ 0.0f,-0.75f,-0.75f }
|
437
|
};
|
438
|
|
439
|
centerIndexes = new int[] { 0,0,0,0 };
|
440
|
|
441
|
numComponents = 4;
|
442
|
}
|
443
|
|
444
|
///// OCTAHEDRON ////////////////////////////////////////////////////////////////////////////
|
445
|
|
446
|
else if( mode==3 )
|
447
|
{
|
448
|
vertices = new float[][]
|
449
|
{
|
450
|
{ 0.5f, 0.0f, 0.5f},
|
451
|
{ 0.5f, 0.0f,-0.5f},
|
452
|
{-0.5f, 0.0f,-0.5f},
|
453
|
{-0.5f, 0.0f, 0.5f},
|
454
|
{ 0.0f, SQ2/2, 0.0f},
|
455
|
{ 0.0f, -SQ2/2, 0.0f},
|
456
|
};
|
457
|
|
458
|
vertIndexes = new int[][]
|
459
|
{
|
460
|
{3,0,4}, // counterclockwise!
|
461
|
{0,1,4},
|
462
|
{1,2,4},
|
463
|
{2,3,4},
|
464
|
{5,0,3},
|
465
|
{5,1,0},
|
466
|
{5,2,1},
|
467
|
{5,3,2}
|
468
|
};
|
469
|
|
470
|
bands = new float[][]
|
471
|
{
|
472
|
{0.05f,17,0.5f,0.2f,5, 2,2}
|
473
|
};
|
474
|
|
475
|
bandIndexes = new int[] { 0,0,0,0,0,0,0,0 };
|
476
|
|
477
|
corners = new float[][]
|
478
|
{
|
479
|
{ 0.03f, 0.12f }
|
480
|
};
|
481
|
|
482
|
cornerIndexes = new int[] { 0,0,0,0,0,0 };
|
483
|
|
484
|
centers = new float[][]
|
485
|
{
|
486
|
{ 0.0f, 0.0f, 0.0f }
|
487
|
};
|
488
|
|
489
|
centerIndexes = new int[] { 0,0,0,0,0,0 };
|
490
|
|
491
|
numComponents = 8;
|
492
|
}
|
493
|
|
494
|
///// KILOMINX EDGE ////////////////////////////////////////////////////////////////////////
|
495
|
|
496
|
else if( mode==4 )
|
497
|
{
|
498
|
float SQ5 = (float)Math.sqrt(5);
|
499
|
float SIN18= (SQ5-1)/4;
|
500
|
float COS18= 0.25f*(float)Math.sqrt(10.0+2.0*SQ5);
|
501
|
float H = 1.0f;
|
502
|
float L = 2.0f;
|
503
|
float X = H*(float)Math.sqrt((5+SQ5)/10);
|
504
|
float Y = H*(float)Math.sqrt((5-SQ5)/10);
|
505
|
float D = H*SIN18/COS18;
|
506
|
|
507
|
vertices = new float[][]
|
508
|
{
|
509
|
{ 0.0f, Y, L/2},
|
510
|
{ X, 0.0f, L/2},
|
511
|
{ 0.0f, -Y, L/2},
|
512
|
{ -X, 0.0f, L/2},
|
513
|
{ 0.0f, Y, -L/2 +D},
|
514
|
{ X, 0.0f,-L/2 },
|
515
|
{ 0.0f, -Y, -L/2-D },
|
516
|
{ -X, 0.0f,-L/2 }
|
517
|
};
|
518
|
|
519
|
vertIndexes = new int[][]
|
520
|
{
|
521
|
{3,2,1,0}, // counterclockwise!
|
522
|
{0,1,5,4},
|
523
|
{3,0,4,7},
|
524
|
{2,1,5,6},
|
525
|
{3,2,6,7},
|
526
|
{4,5,6,7}
|
527
|
};
|
528
|
|
529
|
bands = new float[][]
|
530
|
{
|
531
|
{0.04f,13,(float)(L/3),(float)L/8, 5,2,3},
|
532
|
{0.00f, 0,(float)(L/2),(float)L/4, 5,2,3}
|
533
|
};
|
534
|
|
535
|
bandIndexes = new int[] { 1,0,0,1,1,1 };
|
536
|
|
537
|
corners = new float[][]
|
538
|
{
|
539
|
{ 0.04f, 0.12f }
|
540
|
};
|
541
|
|
542
|
cornerIndexes = new int[] { 0,-1,-1,-1,0,-1,-1,-1 };
|
543
|
|
544
|
centers = new float[][]
|
545
|
{
|
546
|
{ 0.0f, 0.0f, 0.0f }
|
547
|
};
|
548
|
|
549
|
centerIndexes = new int[] { 0,-1,-1,-1,0,-1,-1,-1 };
|
550
|
|
551
|
numComponents = 6;
|
552
|
}
|
553
|
|
554
|
///// IVY_CORNER ////////////////////////////////////////////////////////////////////////
|
555
|
|
556
|
else if( mode==5 )
|
557
|
{
|
558
|
int IVY_N = 8;
|
559
|
final float IVY_D = 0.003f;
|
560
|
final float angle = (float)Math.PI/(2*IVY_N);
|
561
|
final float CORR = 1.0f - 2*IVY_D;
|
562
|
|
563
|
vertices = new float[3*IVY_N+7][3];
|
564
|
vertIndexes = new int[6][IVY_N+4];
|
565
|
|
566
|
vertices[0][0] = 0.0f;
|
567
|
vertices[0][1] = 0.0f;
|
568
|
vertices[0][2] = 0.0f;
|
569
|
vertices[1][0] =-1.0f;
|
570
|
vertices[1][1] = 0.0f;
|
571
|
vertices[1][2] = 0.0f;
|
572
|
vertices[2][0] = 0.0f;
|
573
|
vertices[2][1] =-1.0f;
|
574
|
vertices[2][2] = 0.0f;
|
575
|
vertices[3][0] = 0.0f;
|
576
|
vertices[3][1] = 0.0f;
|
577
|
vertices[3][2] =-1.0f;
|
578
|
|
579
|
vertIndexes[0][0] = 2;
|
580
|
vertIndexes[0][1] = 0;
|
581
|
vertIndexes[0][2] = 1;
|
582
|
vertIndexes[3][0] = 2;
|
583
|
vertIndexes[3][1] = 0;
|
584
|
vertIndexes[3][2] = 1;
|
585
|
|
586
|
vertIndexes[1][0] = 3;
|
587
|
vertIndexes[1][1] = 0;
|
588
|
vertIndexes[1][2] = 2;
|
589
|
vertIndexes[4][0] = 3;
|
590
|
vertIndexes[4][1] = 0;
|
591
|
vertIndexes[4][2] = 2;
|
592
|
|
593
|
vertIndexes[2][0] = 1;
|
594
|
vertIndexes[2][1] = 0;
|
595
|
vertIndexes[2][2] = 3;
|
596
|
vertIndexes[5][0] = 1;
|
597
|
vertIndexes[5][1] = 0;
|
598
|
vertIndexes[5][2] = 3;
|
599
|
|
600
|
int N1 = 4;
|
601
|
int N2 = N1 + IVY_N + 1;
|
602
|
int N3 = N2 + IVY_N + 1;
|
603
|
|
604
|
for(int i=0; i<=IVY_N; i++)
|
605
|
{
|
606
|
float cos1 = (float)Math.cos((IVY_N-i)*angle);
|
607
|
float sin1 = (float)Math.sin((IVY_N-i)*angle);
|
608
|
float cos2 = (float)Math.cos(( i)*angle);
|
609
|
float sin2 = (float)Math.sin(( i)*angle);
|
610
|
|
611
|
vertices[N1+i][0] = CORR*(cos1-0.5f) - 0.5f;
|
612
|
vertices[N1+i][1] = CORR*(sin1-0.5f) - 0.5f;
|
613
|
vertices[N1+i][2] = 0.0f;
|
614
|
|
615
|
vertices[N2+i][0] = 0.0f;
|
616
|
vertices[N2+i][1] = CORR*(sin2-0.5f) - 0.5f;
|
617
|
vertices[N2+i][2] = CORR*(cos2-0.5f) - 0.5f;
|
618
|
|
619
|
vertices[N3+i][0] = CORR*(cos2-0.5f) - 0.5f;
|
620
|
vertices[N3+i][1] = 0.0f;
|
621
|
vertices[N3+i][2] = CORR*(sin2-0.5f) - 0.5f;
|
622
|
|
623
|
vertIndexes[0][i+3] = N1 + i;
|
624
|
vertIndexes[1][i+3] = N2 + i;
|
625
|
vertIndexes[2][i+3] = N3 + i;
|
626
|
vertIndexes[3][i+3] = N1 + i;
|
627
|
vertIndexes[4][i+3] = N2 + i;
|
628
|
vertIndexes[5][i+3] = N3 + i;
|
629
|
}
|
630
|
|
631
|
bands = new float[][]
|
632
|
{
|
633
|
{+0.012f,20,0.2f,0.5f,7,1,2},
|
634
|
{-0.100f,20,0.2f,0.0f,2,1,2}
|
635
|
};
|
636
|
|
637
|
bandIndexes = new int[] { 0,0,0,1,1,1 };
|
638
|
|
639
|
corners = new float[][]
|
640
|
{
|
641
|
{ 0.04f, 0.12f }
|
642
|
};
|
643
|
|
644
|
cornerIndexes = new int[3*IVY_N+7];
|
645
|
|
646
|
centers = new float[][]
|
647
|
{
|
648
|
{-0.5f,-0.5f,-0.5f}
|
649
|
};
|
650
|
|
651
|
centerIndexes = new int[3*IVY_N+7];
|
652
|
|
653
|
for(int i=0; i<4; i++)
|
654
|
{
|
655
|
cornerIndexes[i] = 0;
|
656
|
centerIndexes[i] = 0;
|
657
|
}
|
658
|
for(int i=4; i<3*IVY_N+7; i++)
|
659
|
{
|
660
|
cornerIndexes[i] = -1;
|
661
|
centerIndexes[i] = -1;
|
662
|
}
|
663
|
|
664
|
float C = 0.5f - SQ2/4;
|
665
|
convexCenter = new float[] {-C,-C,-C};
|
666
|
|
667
|
numComponents = 6;
|
668
|
}
|
669
|
|
670
|
///// IVY_FACE ////////////////////////////////////////////////////////////////////////
|
671
|
|
672
|
else if( mode==6 )
|
673
|
{
|
674
|
int IVY_N = 6;
|
675
|
final float IVY_D = 0.003f;
|
676
|
final float angle = (float)Math.PI/(2*IVY_N);
|
677
|
final float CORR = 1.0f - 2*IVY_D;
|
678
|
|
679
|
vertices = new float[2*IVY_N][3];
|
680
|
vertIndexes= new int[2][2*IVY_N];
|
681
|
|
682
|
for(int i=0; i<IVY_N; i++)
|
683
|
{
|
684
|
float cos = (float)Math.cos(i*angle);
|
685
|
float sin = (float)Math.sin(i*angle);
|
686
|
|
687
|
vertices[i ][0] = CORR*(0.5f-cos);
|
688
|
vertices[i ][1] = CORR*(0.5f-sin);
|
689
|
vertices[i ][2] = 0.0f;
|
690
|
vertices[i+IVY_N][0] = CORR*(cos-0.5f);
|
691
|
vertices[i+IVY_N][1] = CORR*(sin-0.5f);
|
692
|
vertices[i+IVY_N][2] = 0.0f;
|
693
|
|
694
|
vertIndexes[0][i ] = i;
|
695
|
vertIndexes[0][i+IVY_N] = i+IVY_N;
|
696
|
vertIndexes[1][i ] = i;
|
697
|
vertIndexes[1][i+IVY_N] = i+IVY_N;
|
698
|
}
|
699
|
|
700
|
bands = new float[][]
|
701
|
{
|
702
|
{+0.012f,20,0.2f,0.5f,7,1,2},
|
703
|
{-0.100f,20,0.2f,0.0f,2,1,2},
|
704
|
};
|
705
|
|
706
|
bandIndexes = new int[] { 0,1 };
|
707
|
|
708
|
corners = new float[][]
|
709
|
{
|
710
|
{0.03f,0.10f}
|
711
|
};
|
712
|
|
713
|
centers = new float[][]
|
714
|
{
|
715
|
{-0.0f,-0.0f,-0.5f}
|
716
|
};
|
717
|
|
718
|
cornerIndexes = new int[2*IVY_N];
|
719
|
centerIndexes = new int[2*IVY_N];
|
720
|
|
721
|
for(int i=0; i<2*IVY_N; i++)
|
722
|
{
|
723
|
cornerIndexes[i] = -1;
|
724
|
centerIndexes[i] = -1;
|
725
|
}
|
726
|
|
727
|
cornerIndexes[0 ] = 0;
|
728
|
cornerIndexes[IVY_N] = 0;
|
729
|
centerIndexes[0 ] = 0;
|
730
|
centerIndexes[IVY_N] = 0;
|
731
|
|
732
|
numComponents = 2;
|
733
|
}
|
734
|
|
735
|
///// SKEWB Ultimate SMALL /////////////////////////////////////////////////////////////
|
736
|
|
737
|
else if( mode==7 )
|
738
|
{
|
739
|
float S = (SQ5+1)/4;
|
740
|
|
741
|
vertices = new float[][]
|
742
|
{
|
743
|
{ 0.0f , 0.0f , 0.0f },
|
744
|
{ -0.5f*S , 0.5f*S+0.25f, -0.25f },
|
745
|
{-0.25f , -S/2 , (-2*S-1)/4 },
|
746
|
{ 0.5f*S+0.25f, 0.25f , -S/2 },
|
747
|
{ 0.0f , 0.5f , -S-0.5f },
|
748
|
{ 0.0f , 0.5f , 0.0f },
|
749
|
{ -0.5f*S ,-0.5f*S+0.25f, -0.25f },
|
750
|
{ 0.5f*S ,-0.5f*S+0.25f, -0.25f }
|
751
|
};
|
752
|
|
753
|
vertIndexes = new int[][]
|
754
|
{
|
755
|
{6,0,5,1}, // counterclockwise!
|
756
|
{0,7,3,5},
|
757
|
{0,6,2,7},
|
758
|
{4,3,5,1},
|
759
|
{4,2,7,3},
|
760
|
{4,1,6,2},
|
761
|
};
|
762
|
|
763
|
bands = new float[][]
|
764
|
{
|
765
|
{0.04f,17,0.5f,0.2f,5, 2,2},
|
766
|
{0.01f, 1,0.5f,0.2f,5, 2,2}
|
767
|
};
|
768
|
|
769
|
bandIndexes = new int[] { 0,0,0,1,1,1 };
|
770
|
|
771
|
corners = new float[][]
|
772
|
{
|
773
|
{ 0.013f, 0.08f }
|
774
|
};
|
775
|
|
776
|
cornerIndexes = new int[] { 0, 0, 0, 0,-1,0,0,0 };
|
777
|
|
778
|
centers = new float[][]
|
779
|
{
|
780
|
{ 0.0f,-0.5f, (float)(-S-0.5) }
|
781
|
};
|
782
|
|
783
|
centerIndexes = new int[] { 0,0,0,0,0,0,0,0 };
|
784
|
|
785
|
numComponents = 8;
|
786
|
}
|
787
|
|
788
|
///// SKEWB Ultimate BIG ///////////////////////////////////////////////////////////////
|
789
|
|
790
|
else if( mode==8 )
|
791
|
{
|
792
|
float S = (SQ5+1)/4;
|
793
|
|
794
|
vertices = new float[][]
|
795
|
{
|
796
|
{-S/2 ,-S/2+0.25f, 0.25f},
|
797
|
{ S/2 , S/2-0.25f, -0.25f},
|
798
|
{-S , 0.00f, 0.00f},
|
799
|
{ 0.25f, S/2 ,-S/2-0.25f},
|
800
|
{-S/2 ,-S/2-0.25f, 0.25f},
|
801
|
{ S/2+0.25f, -0.25f,-S/2 },
|
802
|
{-S , -0.50f, 0.00f},
|
803
|
{ 0.50f, 0.00f,-S },
|
804
|
{-S +0.25f, S/2 ,-S/2-0.25f},
|
805
|
{ 0.25f,-S/2-0.50f,-S/2+0.25f},
|
806
|
{-S/2 ,-S/2-0.25f,-S -0.25f}
|
807
|
};
|
808
|
|
809
|
vertIndexes = new int[][]
|
810
|
{
|
811
|
{0,1,3,8,2}, // counterclockwise!
|
812
|
{0,4,9,5,1},
|
813
|
{ 0,2,6,4},
|
814
|
{ 1,5,7,3},
|
815
|
{10,9,4,6},
|
816
|
{10,9,5,7},
|
817
|
{10,8,3,7},
|
818
|
{10,8,2,6}
|
819
|
};
|
820
|
|
821
|
bands = new float[][]
|
822
|
{
|
823
|
{0.04f,17,0.5f,0.2f,5, 2,2},
|
824
|
{0.04f,17,0.5f,0.2f,5, 2,2},
|
825
|
{0.01f, 1,0.5f,0.2f,5, 2,2}
|
826
|
};
|
827
|
|
828
|
bandIndexes = new int[] { 0,0,1,1,2,2,2,2 };
|
829
|
|
830
|
corners = new float[][]
|
831
|
{
|
832
|
{ 0.013f, 0.08f }
|
833
|
};
|
834
|
|
835
|
cornerIndexes = new int[] { 0,0,0,0,0,0,0,0,0,0,-1 };
|
836
|
|
837
|
centers = new float[][]
|
838
|
{
|
839
|
{ (float)(-S/2), 0.25f, (float)(-S/2-0.5) }
|
840
|
};
|
841
|
|
842
|
centerIndexes = new int[] { 0,0,0,0,0,0,0,0,0,0,0 };
|
843
|
|
844
|
numComponents = 8;
|
845
|
}
|
846
|
|
847
|
///// SQUARE-1 MIDDLE ///////////////////////////////////////////////////////////////
|
848
|
|
849
|
else if( mode==9 )
|
850
|
{
|
851
|
final float X = 3*(2-SQ3)/2;
|
852
|
|
853
|
vertices = new float[][]
|
854
|
{
|
855
|
{ -1.5f-X, 0.5f, 1.5f },
|
856
|
{ 0.0f, 0.5f, 1.5f },
|
857
|
{ 0.0f, 0.5f,-1.5f },
|
858
|
{ -1.5f+X, 0.5f,-1.5f },
|
859
|
{ -1.5f-X,-0.5f, 1.5f },
|
860
|
{ 0.0f,-0.5f, 1.5f },
|
861
|
{ 0.0f,-0.5f,-1.5f },
|
862
|
{ -1.5f+X,-0.5f,-1.5f }
|
863
|
};
|
864
|
|
865
|
vertIndexes = new int[][]
|
866
|
{
|
867
|
{0,1,2,3}, // counterclockwise!
|
868
|
{4,5,6,7},
|
869
|
{4,5,1,0},
|
870
|
{5,6,2,1},
|
871
|
{6,7,3,2},
|
872
|
{7,4,0,3}
|
873
|
};
|
874
|
|
875
|
bands = new float[][]
|
876
|
{
|
877
|
{0.040f,35,0.8f,1.0f,5,2,1},
|
878
|
{0.020f,35,0.8f,1.0f,5,2,1},
|
879
|
{0.001f,35,0.8f,1.0f,5,2,1}
|
880
|
};
|
881
|
|
882
|
bandIndexes = new int[] { 2,2,1,1,0,2 };
|
883
|
|
884
|
corners = new float[][]
|
885
|
{
|
886
|
{0.04f,0.05f}
|
887
|
};
|
888
|
|
889
|
cornerIndexes = new int[] { 0,0,0,0,0,0,0,0 };
|
890
|
|
891
|
centers = new float[][]
|
892
|
{
|
893
|
{ -0.75f, 0.0f, 0.0f}
|
894
|
};
|
895
|
|
896
|
centerIndexes = new int[] { 0,0,0,0,0,0,0,0 };
|
897
|
|
898
|
numComponents = 6;
|
899
|
}
|
900
|
|
901
|
///// SQUARE-1 EDGE ///////////////////////////////////////////////////////////////
|
902
|
|
903
|
else if( mode==10 )
|
904
|
{
|
905
|
final float X = 3*(2-SQ3)/2;
|
906
|
|
907
|
vertices = new float[][]
|
908
|
{
|
909
|
{ -X, 0.5f, 0.0f },
|
910
|
{ +X, 0.5f, 0.0f },
|
911
|
{0.0f, 0.5f,-1.5f },
|
912
|
{ -X,-0.5f, 0.0f },
|
913
|
{ +X,-0.5f, 0.0f },
|
914
|
{0.0f,-0.5f,-1.5f },
|
915
|
};
|
916
|
|
917
|
vertIndexes = new int[][]
|
918
|
{
|
919
|
{0,1,2}, // counterclockwise!
|
920
|
{3,4,5},
|
921
|
{3,4,1,0},
|
922
|
{4,5,2,1},
|
923
|
{5,3,0,2}
|
924
|
};
|
925
|
|
926
|
bands = new float[][]
|
927
|
{
|
928
|
{0.038f,35,0.5f,0.9f, 5,2,1},
|
929
|
{0.001f,35,0.5f,0.9f, 5,2,1}
|
930
|
};
|
931
|
|
932
|
bandIndexes = new int[] { 0,1,0,1,1 };
|
933
|
|
934
|
corners = new float[][]
|
935
|
{
|
936
|
{0.06f,0.20f}
|
937
|
};
|
938
|
|
939
|
cornerIndexes = new int[] { 0,0,-1,0,0,-1 };
|
940
|
|
941
|
centers = new float[][]
|
942
|
{
|
943
|
{ 0.0f, 0.0f,-0.5f}
|
944
|
};
|
945
|
|
946
|
centerIndexes = new int[] { 0,0,-1,0,0,-1 };
|
947
|
|
948
|
numComponents = 6;
|
949
|
}
|
950
|
|
951
|
///// SQUARE-1 CORNER ///////////////////////////////////////////////////////////////
|
952
|
|
953
|
else if( mode==11 )
|
954
|
{
|
955
|
final float X = 3*(2-SQ3)/2;
|
956
|
|
957
|
vertices = new float[][]
|
958
|
{
|
959
|
{ X-1.5f, 0.5f, 0.0f },
|
960
|
{ 0.0f, 0.5f, 0.0f },
|
961
|
{ 0.0f, 0.5f,X-1.5f },
|
962
|
{ -1.5f, 0.5f, -1.5f },
|
963
|
{ X-1.5f,-0.5f, 0.0f },
|
964
|
{ 0.0f,-0.5f, 0.0f },
|
965
|
{ 0.0f,-0.5f,X-1.5f },
|
966
|
{ -1.5f,-0.5f, -1.5f }
|
967
|
};
|
968
|
|
969
|
vertIndexes = new int[][]
|
970
|
{
|
971
|
{0,1,2,3}, // counterclockwise!
|
972
|
{4,5,6,7},
|
973
|
{4,5,1,0},
|
974
|
{5,6,2,1},
|
975
|
{7,4,0,3},
|
976
|
{6,7,3,2}
|
977
|
};
|
978
|
|
979
|
bands = new float[][]
|
980
|
{
|
981
|
{0.038f,35,0.9f,1.0f, 5,2,1},
|
982
|
{0.001f,35,0.9f,1.0f, 5,2,1}
|
983
|
};
|
984
|
|
985
|
bandIndexes = new int[] { 0,1,0,0,1,1 };
|
986
|
|
987
|
corners = new float[][]
|
988
|
{
|
989
|
{0.08f,0.20f}
|
990
|
};
|
991
|
|
992
|
cornerIndexes = new int[] { 0,0,0,-1,0,0,0,-1 };
|
993
|
|
994
|
centers = new float[][]
|
995
|
{
|
996
|
{ -0.5f, 0.0f,-0.5f}
|
997
|
};
|
998
|
|
999
|
centerIndexes = new int[] { -1,0,-1,-1,-1,0,-1,-1 };
|
1000
|
|
1001
|
numComponents = 6;
|
1002
|
}
|
1003
|
|
1004
|
///// SQUARE-2 CORNER ///////////////////////////////////////////////////////////////
|
1005
|
|
1006
|
else if( mode==12 )
|
1007
|
{
|
1008
|
final float X = 3*(2-SQ3)/2;
|
1009
|
final float Z = 0.75f - X/2;
|
1010
|
|
1011
|
vertices = new float[][]
|
1012
|
{
|
1013
|
{ X-1.5f+Z, 0.5f, 0.0f },
|
1014
|
{ Z, 0.5f, 0.0f },
|
1015
|
{ -1.5f+Z, 0.5f, -1.5f },
|
1016
|
{ X-1.5f+Z,-0.5f, 0.0f },
|
1017
|
{ Z,-0.5f, 0.0f },
|
1018
|
{ -1.5f+Z,-0.5f, -1.5f }
|
1019
|
};
|
1020
|
|
1021
|
vertIndexes = new int[][]
|
1022
|
{
|
1023
|
{0,1,2}, // counterclockwise!
|
1024
|
{5,4,3},
|
1025
|
{3,4,1,0},
|
1026
|
{4,5,2,1},
|
1027
|
{5,3,0,2}
|
1028
|
};
|
1029
|
|
1030
|
bands = new float[][]
|
1031
|
{
|
1032
|
{0.040f,35,0.9f,1.0f, 5,2,1},
|
1033
|
{0.001f,35,0.9f,1.0f, 5,2,1}
|
1034
|
};
|
1035
|
|
1036
|
bandIndexes = new int[] { 0,0,0,1,1 };
|
1037
|
|
1038
|
corners = new float[][]
|
1039
|
{
|
1040
|
{0.05f,0.13f}
|
1041
|
};
|
1042
|
|
1043
|
cornerIndexes = new int[] { 0,0,-1,0,0,-1 };
|
1044
|
|
1045
|
centers = new float[][]
|
1046
|
{
|
1047
|
{ 0.0f, 0.0f,-0.5f}
|
1048
|
};
|
1049
|
|
1050
|
centerIndexes = new int[] { 0,0,-1,0,0,-1 };
|
1051
|
|
1052
|
numComponents = 5;
|
1053
|
}
|
1054
|
|
1055
|
///// REDI CORNER ///////////////////////////////////////////////////////////////
|
1056
|
|
1057
|
else if( mode==13 )
|
1058
|
{
|
1059
|
vertices = new float[][]
|
1060
|
{
|
1061
|
{ 0.0f, 0.0f, 0.0f },
|
1062
|
{-0.5f, 0.5f, 0.5f },
|
1063
|
{-0.5f,-0.5f, 0.5f },
|
1064
|
{ 0.5f, 0.5f, 0.5f },
|
1065
|
{ 0.5f,-0.5f, 0.5f },
|
1066
|
{ 0.5f, 0.5f,-0.5f },
|
1067
|
{ 0.5f,-0.5f,-0.5f },
|
1068
|
{-0.5f, 0.5f,-0.5f },
|
1069
|
};
|
1070
|
|
1071
|
vertIndexes = new int[][]
|
1072
|
{
|
1073
|
{ 2,4,3,1 },
|
1074
|
{ 1,3,5,7 },
|
1075
|
{ 4,6,5,3 },
|
1076
|
|
1077
|
{ 2,4,0 },
|
1078
|
{ 5,7,0 },
|
1079
|
{ 4,6,0 },
|
1080
|
{ 7,1,0 },
|
1081
|
{ 1,2,0 },
|
1082
|
{ 6,5,0 }
|
1083
|
};
|
1084
|
|
1085
|
bands = new float[][]
|
1086
|
{
|
1087
|
{0.06f,35,0.5f,0.7f,5,2,2},
|
1088
|
{0.01f,35,0.2f,0.4f,5,2,2}
|
1089
|
};
|
1090
|
|
1091
|
bandIndexes = new int[] { 0,0,0,1,1,1,1,1,1 };
|
1092
|
|
1093
|
corners = new float[][]
|
1094
|
{
|
1095
|
{0.06f,0.12f}
|
1096
|
};
|
1097
|
|
1098
|
cornerIndexes = new int[] { -1,0,-1,0,0,0,-1,-1 };
|
1099
|
|
1100
|
centers = new float[][]
|
1101
|
{
|
1102
|
{ 0.0f, 0.0f, 0.0f}
|
1103
|
};
|
1104
|
|
1105
|
centerIndexes = new int[] { -1,0,-1,0,0,0,-1,-1 };
|
1106
|
|
1107
|
numComponents = 9;
|
1108
|
}
|
1109
|
|
1110
|
///// JING CORNER ///////////////////////////////////////////////////////////////
|
1111
|
|
1112
|
else if( mode==14 )
|
1113
|
{
|
1114
|
final float F = 0.24f;
|
1115
|
final float X = F/2;
|
1116
|
final float Y = F*SQ2/2;
|
1117
|
final float Z =-F/2;
|
1118
|
|
1119
|
vertices = new float[][]
|
1120
|
{
|
1121
|
{ 0.0f, 0.0f, 0.0f },
|
1122
|
{ X, Y, Z },
|
1123
|
{ 0.0f, 2*Y, 2*Z },
|
1124
|
{ -X, Y, Z },
|
1125
|
{ 0.0f, 0.0f, -F },
|
1126
|
{ X, Y, Z-F },
|
1127
|
{ 0.0f, 2*Y, 2*Z-F },
|
1128
|
{ -X, Y, Z-F },
|
1129
|
};
|
1130
|
|
1131
|
vertIndexes = new int[][]
|
1132
|
{
|
1133
|
{0,1,2,3},
|
1134
|
{1,0,4,5},
|
1135
|
{7,4,0,3},
|
1136
|
{1,5,6,2},
|
1137
|
{7,3,2,6},
|
1138
|
{4,7,6,5}
|
1139
|
};
|
1140
|
|
1141
|
bands = new float[][]
|
1142
|
{
|
1143
|
{0.015f,35,0.5f*F,F,5,1,1},
|
1144
|
{0.001f,35,0.5f*F,F,5,1,1}
|
1145
|
};
|
1146
|
|
1147
|
bandIndexes = new int[] { 0,0,0,1,1,1 };
|
1148
|
|
1149
|
corners = new float[][]
|
1150
|
{
|
1151
|
{0.08f,0.20f*F},
|
1152
|
{0.07f,0.20f*F}
|
1153
|
};
|
1154
|
|
1155
|
cornerIndexes = new int[] { 0,1,1,-1,1,-1,-1,-1 };
|
1156
|
|
1157
|
centers = new float[][]
|
1158
|
{
|
1159
|
{ 0.0f, Y, Z-F/2}
|
1160
|
};
|
1161
|
|
1162
|
centerIndexes = new int[] { 0,0,0,-1,0,-1,-1,-1 };
|
1163
|
|
1164
|
numComponents = 6;
|
1165
|
}
|
1166
|
|
1167
|
///// JING EDGE ///////////////////////////////////////////////////////////////
|
1168
|
|
1169
|
else if( mode==15 )
|
1170
|
{
|
1171
|
final float F = 0.24f;
|
1172
|
final float X = F/2;
|
1173
|
final float Y = F*SQ2/2;
|
1174
|
final float Z =-F/2;
|
1175
|
|
1176
|
vertices = new float[][]
|
1177
|
{
|
1178
|
{ 0.0f, 0.0f, 0.5f-F },
|
1179
|
{ X, Y, Z+0.5f-F },
|
1180
|
{ 0.0f, 2*Y, 2*Z+0.5f-F },
|
1181
|
{ -X, Y, Z+0.5f-F },
|
1182
|
{ 0.0f, 0.0f, -0.5f+F },
|
1183
|
{ X, Y, -Z-0.5f+F },
|
1184
|
{ 0.0f, 2*Y,-2*Z-0.5f+F },
|
1185
|
{ -X, Y, -Z-0.5f+F },
|
1186
|
};
|
1187
|
|
1188
|
vertIndexes = new int[][]
|
1189
|
{
|
1190
|
{0,4,5,1},
|
1191
|
{3,7,4,0},
|
1192
|
{0,1,2,3},
|
1193
|
{4,7,6,5},
|
1194
|
{1,5,6,2},
|
1195
|
{2,6,7,3}
|
1196
|
};
|
1197
|
|
1198
|
bands = new float[][]
|
1199
|
{
|
1200
|
{0.015f,35,0.5f*F,F,5,1,1},
|
1201
|
{0.001f,35,0.5f*F,F,5,1,1}
|
1202
|
};
|
1203
|
|
1204
|
bandIndexes = new int[] { 0,0,1,1,1,1 };
|
1205
|
|
1206
|
corners = new float[][]
|
1207
|
{
|
1208
|
{0.07f,0.20f*F}
|
1209
|
};
|
1210
|
|
1211
|
cornerIndexes = new int[] { 0,0,-1,0,0,0,-1,0 };
|
1212
|
|
1213
|
centers = new float[][]
|
1214
|
{
|
1215
|
{ 0, F*SQ2/2, 0 }
|
1216
|
};
|
1217
|
|
1218
|
centerIndexes = new int[] { 0,0,-1,0,0,0,-1,0 };
|
1219
|
|
1220
|
numComponents = 6;
|
1221
|
}
|
1222
|
|
1223
|
///// JING FACE ///////////////////////////////////////////////////////////////
|
1224
|
|
1225
|
else if( mode==16 )
|
1226
|
{
|
1227
|
final float F = 0.24f;
|
1228
|
final float L = (1-3*F);
|
1229
|
final float X = L/2;
|
1230
|
final float Y = L*SQ2/2;
|
1231
|
final float Z =-L/2;
|
1232
|
final float D = F/L;
|
1233
|
|
1234
|
vertices = new float[][]
|
1235
|
{
|
1236
|
{ 0.0f, -2*Y/3, -2*Z/3 },
|
1237
|
{ X, Y/3, Z/3 },
|
1238
|
{ -X, Y/3, Z/3 },
|
1239
|
{ 0.0f, -2*Y/3, -2*Z/3+2*D*Z },
|
1240
|
{ X-D*X, Y/3-D*Y, Z/3+D*Z },
|
1241
|
{ -X+D*X, Y/3-D*Y, Z/3+D*Z },
|
1242
|
};
|
1243
|
|
1244
|
vertIndexes = new int[][]
|
1245
|
{
|
1246
|
{0,1,2},
|
1247
|
{3,5,4},
|
1248
|
{0,3,4,1},
|
1249
|
{5,3,0,2},
|
1250
|
{4,5,2,1}
|
1251
|
};
|
1252
|
|
1253
|
bands = new float[][]
|
1254
|
{
|
1255
|
{0.025f,35,0.20f*(1-3*F),0.6f*(1-3*F),5,1,1},
|
1256
|
{0.001f,35,0.05f*(1-3*F),0.1f*(1-3*F),5,1,1}
|
1257
|
};
|
1258
|
|
1259
|
bandIndexes = new int[] { 0,1,1,1,1,1 };
|
1260
|
|
1261
|
corners = new float[][]
|
1262
|
{
|
1263
|
{0.04f,0.15f}
|
1264
|
};
|
1265
|
|
1266
|
cornerIndexes = new int[] { 0,0,0,-1,-1,-1 };
|
1267
|
|
1268
|
centers = new float[][]
|
1269
|
{
|
1270
|
{ 0, -2*Y/3, 4*Z/3 }
|
1271
|
};
|
1272
|
|
1273
|
centerIndexes = new int[] { 0,0,0,-1,-1,-1 };
|
1274
|
|
1275
|
numComponents = 6;
|
1276
|
}
|
1277
|
|
1278
|
///// REX PETAL ///////////////////////////////////////////////////////////////
|
1279
|
|
1280
|
else if( mode==17 )
|
1281
|
{
|
1282
|
final float REX_D = 0.2f;
|
1283
|
float G = (1-REX_D)*SQ2/2;
|
1284
|
vertices = new float[][] {{-0.10f,0.70f,0},{-0.70f,0.10f,0},{+0.65f,-0.71f,0},{+0.71f,-0.65f,0},{0,0.05f,-0.2f} };
|
1285
|
vertIndexes = new int[][] { {0,1,2,3},{0,3,4},{3,2,4},{2,1,4},{1,0,4} };
|
1286
|
centers= new float[][] { {0.0f,0.0f,-G} };
|
1287
|
corners= new float[][] { {0.03f,0.30f} };
|
1288
|
cornerIndexes = new int[] {-1,-1,0,0,-1};
|
1289
|
centerIndexes = new int[] {-1,-1,0,0,-1};
|
1290
|
bandIndexes = new int[] { 0,1,1,1,1 };
|
1291
|
bands = new float[][] { {+0.016f,10,G/3,0.5f,5,1,1},{ +0.0f,45,0.1f,0.1f,2,0,0} };
|
1292
|
|
1293
|
numComponents = 5;
|
1294
|
}
|
1295
|
|
1296
|
///// TRAJBER'S FACE ///////////////////////////////////////////////////////////////
|
1297
|
|
1298
|
else if( mode==18 )
|
1299
|
{
|
1300
|
final float CUT = 1.0f/6;
|
1301
|
final float LEN = 1.5f;
|
1302
|
|
1303
|
final float A = SQ2*CUT*LEN;
|
1304
|
final float B = 2*CUT*LEN;
|
1305
|
|
1306
|
vertices = new float[][]
|
1307
|
{
|
1308
|
{ 0.01f, 0.01f, 0},
|
1309
|
{ A, A, -A},
|
1310
|
{ A, -A, -A},
|
1311
|
{ B, 0, 0},
|
1312
|
{ 0, 0, -B},
|
1313
|
{ A+B, A, -A},
|
1314
|
{ A+B, -A, -A},
|
1315
|
{ A, A, -A-B},
|
1316
|
{ A, -A, -A-B},
|
1317
|
|
1318
|
{ LEN , A, SQ2*A-LEN},
|
1319
|
{ LEN , -A, SQ2*A-LEN},
|
1320
|
{ LEN-SQ2*A, A, -LEN},
|
1321
|
{ LEN-SQ2*A, -A, -LEN}
|
1322
|
};
|
1323
|
|
1324
|
vertIndexes = new int[][]
|
1325
|
{
|
1326
|
{0,3,5,1},
|
1327
|
{0,2,6,3},
|
1328
|
{0,4,8,2},
|
1329
|
{0,1,7,4},
|
1330
|
{3,6,10,9,5},
|
1331
|
{2,8,12,10,6},
|
1332
|
{4,7,11,12,8},
|
1333
|
{1,5,9,11,7},
|
1334
|
{9,10,12,11}
|
1335
|
};
|
1336
|
|
1337
|
bands = new float[][] { {0.05f,35,0.15f,0.3f,4,1,1},{0.00f,35,0.15f,0.3f,3,0,0} };
|
1338
|
bandIndexes = new int[] { 0,0,0,0,1,1,1,1,1 };
|
1339
|
corners = new float[][] { {0.03f,0.10f} };
|
1340
|
cornerIndexes = new int[] { 0,-1,-1,-1,-1,0,0,0,0,-1,-1,-1,-1 };
|
1341
|
centers = new float[][] { { LEN/2, 0.0f, -LEN/2} };
|
1342
|
centerIndexes = new int[] { 0,-1,-1,-1,-1,0,0,0,0,-1,-1,-1,-1 };
|
1343
|
|
1344
|
numComponents = 9;
|
1345
|
}
|
1346
|
|
1347
|
///// TRAJBER'S EDGE ///////////////////////////////////////////////////////////////
|
1348
|
|
1349
|
else if( mode==19 )
|
1350
|
{
|
1351
|
final float CUT = 1.0f/6;
|
1352
|
final float LEN = 1.5f;
|
1353
|
|
1354
|
final float A = SQ2*CUT*LEN;
|
1355
|
final float B = LEN-2*LEN*CUT;
|
1356
|
|
1357
|
vertices = new float[][]
|
1358
|
{
|
1359
|
{ -B, 0, 0},
|
1360
|
{ -B+A, SQ2*A, -A},
|
1361
|
{ -B+A,-SQ2*A, -A},
|
1362
|
{ B, 0, 0},
|
1363
|
{ B-A, SQ2*A, -A},
|
1364
|
{ B-A,-SQ2*A, -A},
|
1365
|
{ 0, SQ2*A, -B},
|
1366
|
{ 0,-SQ2*A, -B},
|
1367
|
};
|
1368
|
|
1369
|
vertIndexes = new int[][]
|
1370
|
{
|
1371
|
{0,3,4,1},
|
1372
|
{0,2,5,3},
|
1373
|
{1,4,6},
|
1374
|
{2,7,5},
|
1375
|
{0,1,6,7,2},
|
1376
|
{3,5,7,6,4}
|
1377
|
};
|
1378
|
|
1379
|
bands = new float[][] { {0.03f,35,0.15f,0.3f,3,1,1},{0.00f,35,0.15f,0.3f,3,0,0} };
|
1380
|
bandIndexes = new int[] { 0,0,1,1,1,1 };
|
1381
|
corners = new float[][] { {0.02f,0.10f} };
|
1382
|
cornerIndexes= new int[] { 0,0,0,0,0,0,-1,-1 };
|
1383
|
centers = new float[][] { { 0, 0, -LEN/2} };
|
1384
|
centerIndexes= new int[] { 0,0,0,0,0,0,-1,-1 };
|
1385
|
|
1386
|
numComponents = 9;
|
1387
|
}
|
1388
|
|
1389
|
///// TRAJBER'S CORNER ///////////////////////////////////////////////////////////////
|
1390
|
|
1391
|
else if( mode==20 )
|
1392
|
{
|
1393
|
final float CUT = 1.0f/6;
|
1394
|
final float LEN = 1.5f;
|
1395
|
|
1396
|
final float A = SQ2*CUT*LEN;
|
1397
|
final float C = LEN-2*LEN*CUT;
|
1398
|
final float L = C-A;
|
1399
|
|
1400
|
vertices = new float[][]
|
1401
|
{
|
1402
|
{ -L, -(SQ2/3)*L, L/3 },
|
1403
|
{ L, -(SQ2/3)*L, L/3 },
|
1404
|
{ 0,(2*SQ2/3)*L,-2*L/3 },
|
1405
|
{ 0, -(SQ2/3)*L,-2*L/3 },
|
1406
|
};
|
1407
|
|
1408
|
vertIndexes = new int[][]
|
1409
|
{
|
1410
|
{0,1,2},
|
1411
|
{0,1,3},
|
1412
|
{0,2,3},
|
1413
|
{1,3,2},
|
1414
|
};
|
1415
|
|
1416
|
bands = new float[][] { {0.05f,35,0.15f,0.3f,4,1,1},{0.00f,35,0.15f,0.3f,4,0,0} };
|
1417
|
bandIndexes = new int[] { 0,1,1,1 };
|
1418
|
corners = new float[][] { {0.02f,0.10f} };
|
1419
|
cornerIndexes= new int[] { 0,0,0,-1 };
|
1420
|
centers = new float[][] { {0, -(SQ2/3)*L,-2*L/3} };
|
1421
|
centerIndexes= new int[] { 0,0,0,-1 };
|
1422
|
|
1423
|
numComponents = 9;
|
1424
|
}
|
1425
|
|
1426
|
///// WINDMILL CORNER ///////////////////////////////////////////////////////////////
|
1427
|
|
1428
|
else if( mode==21 )
|
1429
|
{
|
1430
|
final float X = 1.8f; // the cut goes from a corner and splits the opposing side 1.2 / 1.8
|
1431
|
final float h = 3*X*X/(X*X+9);
|
1432
|
final float d = h*X/3;
|
1433
|
final float l = X/2;
|
1434
|
|
1435
|
vertices = new float[][]
|
1436
|
{
|
1437
|
{ -l, 0.5f, 0.0f },
|
1438
|
{ l, 0.5f, 0.0f },
|
1439
|
{ l,-0.5f, 0.0f },
|
1440
|
{ -l,-0.5f, 0.0f },
|
1441
|
{ d-l, 0.5f, -h },
|
1442
|
{ d-l,-0.5f, -h },
|
1443
|
};
|
1444
|
|
1445
|
vertIndexes = new int[][]
|
1446
|
{
|
1447
|
{ 3,2,1,0 },
|
1448
|
{ 0,1,4 },
|
1449
|
{ 5,2,3 },
|
1450
|
{ 5,3,0,4 },
|
1451
|
{ 2,5,4,1 },
|
1452
|
};
|
1453
|
|
1454
|
bands = new float[][] { {0.03f,20,0.2f,0.4f,5,1,1}, {0.01f,20,0.2f,0.4f,5,1,1} };
|
1455
|
bandIndexes = new int[] { 0,0,0,1,1 };
|
1456
|
corners = new float[][] { {0.05f,0.10f} };
|
1457
|
cornerIndexes= new int[] { 0,0,0,0,-1,-1 };
|
1458
|
centers = new float[][] { { d-l, 0.0f,-h } };
|
1459
|
centerIndexes= new int[] { 0,0,0,0,-1,-1 };
|
1460
|
|
1461
|
numComponents = 5;
|
1462
|
}
|
1463
|
|
1464
|
///// WINDMILL EDGE ///////////////////////////////////////////////////////////////
|
1465
|
|
1466
|
else if( mode==22 )
|
1467
|
{
|
1468
|
final float X = 1.8f; // the cut goes from a corner and splits the opposing side 1.2 / 1.8
|
1469
|
final float h = 3*X*X/(X*X+9);
|
1470
|
final float d = h*X/3;
|
1471
|
final float H = 3*h/X;
|
1472
|
final float l = (3-X)/2;
|
1473
|
|
1474
|
vertices = new float[][]
|
1475
|
{
|
1476
|
{ -l, 0.5f, 0.0f },
|
1477
|
{ l, 0.5f, 0.0f },
|
1478
|
{ l,-0.5f, 0.0f },
|
1479
|
{ -l,-0.5f, 0.0f },
|
1480
|
{h-l, 0.5f, -H },
|
1481
|
{d+l, 0.5f, -h },
|
1482
|
{d+l,-0.5f, -h },
|
1483
|
{h-l,-0.5f, -H }
|
1484
|
};
|
1485
|
|
1486
|
vertIndexes = new int[][]
|
1487
|
{
|
1488
|
{ 3,2,1,0 },
|
1489
|
{ 0,1,5,4 },
|
1490
|
{ 7,6,2,3 },
|
1491
|
{ 2,6,5,1 },
|
1492
|
{ 6,7,4,5 },
|
1493
|
{ 7,3,0,4 }
|
1494
|
};
|
1495
|
|
1496
|
bands = new float[][] { {0.03f,20,0.2f,0.4f,5,1,1}, {0.01f,20,0.2f,0.4f,5,1,1} };
|
1497
|
bandIndexes = new int[] { 0,0,0,1,1,1 };
|
1498
|
corners = new float[][] { {0.05f,0.10f} };
|
1499
|
cornerIndexes= new int[] { 0,0,0,0,-1,-1,-1,-1 };
|
1500
|
centers = new float[][] { {h-l, 0.5f, -H } };
|
1501
|
centerIndexes= new int[] { 0,0,0,0,-1,-1,-1,-1 };
|
1502
|
|
1503
|
numComponents = 6;
|
1504
|
}
|
1505
|
|
1506
|
///// Pyramorphics corner ///////////////////////////////////////////////////////////////
|
1507
|
|
1508
|
else if( mode==23 )
|
1509
|
{
|
1510
|
final float Y = SQ2/2;
|
1511
|
final float Z = 1.0f;
|
1512
|
|
1513
|
vertices = new float[][]
|
1514
|
{
|
1515
|
{0.0f, 2*Y/3, 2*Z/3 },
|
1516
|
{0.0f, 2*Y/3, -Z/3 },
|
1517
|
{ Z/2, -Y/3, Z/6 },
|
1518
|
{-Z/2, -Y/3, Z/6 },
|
1519
|
{0.0f, -Y/3, -Z/3 }
|
1520
|
};
|
1521
|
|
1522
|
vertIndexes = new int[][] { {3,2,0},{2,1,0},{1,3,0},{1,2,4},{3,1,4},{2,3,4} };
|
1523
|
bands = new float[][] { {0.03f,40,0.2f,0.4f,5,1,1}, {0.001f,40,0.2f,0.4f,5,1,1} };
|
1524
|
bandIndexes = new int[] { 0,0,0,1,1,1 };
|
1525
|
corners = new float[][] { {0.08f,0.13f} };
|
1526
|
cornerIndexes= new int[] { 0,0,0,0,-1 };
|
1527
|
centers = new float[][] { { 0.0f,0.0f,0.0f } };
|
1528
|
centerIndexes= new int[] { 0,0,0,0,-1 };
|
1529
|
}
|
1530
|
|
1531
|
///// Pyramorphics face ///////////////////////////////////////////////////////////////
|
1532
|
|
1533
|
else if( mode==24 )
|
1534
|
{
|
1535
|
final float X = 1.0f;
|
1536
|
final float Y = SQ2/2;
|
1537
|
final float Z = 0.5f;
|
1538
|
|
1539
|
vertices = new float[][]
|
1540
|
{
|
1541
|
{-X/2, Y/3, Z/3 },
|
1542
|
{ X/2, Y/3, Z/3 },
|
1543
|
{0.0f,-2*Y/3,-2*Z/3 },
|
1544
|
{0.0f, Y/3,-2*Z/3 }
|
1545
|
};
|
1546
|
|
1547
|
vertIndexes = new int[][] { {0,2,1},{0,1,3},{2,3,1},{2,0,3} };
|
1548
|
bands = new float[][] { {0.03f,30,0.15f,0.5f,5,1,2}, {0.001f,30,0.25f,0.5f,5,1,2} };
|
1549
|
bandIndexes = new int[] { 0,1,1,1 };
|
1550
|
corners = new float[][] { {0.09f,0.13f} };
|
1551
|
cornerIndexes= new int[] { 0,0,0,-1 };
|
1552
|
centers = new float[][] { { 0.0f, Y/3,-2*Z/3 } };
|
1553
|
centerIndexes= new int[] { 0,0,0,-1 };
|
1554
|
}
|
1555
|
|
1556
|
///// END DEFINITIONS /////////////////////////////////////////////////////////////////
|
1557
|
|
1558
|
FactoryCubit factory = FactoryCubit.getInstance();
|
1559
|
factory.clear();
|
1560
|
|
1561
|
ObjectShape shape = new ObjectShape(vertices,vertIndexes);
|
1562
|
ObjectFaceShape face= new ObjectFaceShape(bands,bandIndexes,corners,cornerIndexes,centers,centerIndexes,convexCenter);
|
1563
|
|
1564
|
int[] outer = new int[vertIndexes.length];
|
1565
|
|
1566
|
factory.createNewFaceTransform(shape,outer);
|
1567
|
mMesh = factory.createRoundedSolid(shape,face,MESH_NICE,numComponents);
|
1568
|
|
1569
|
int numEff = mMesh.getNumEffComponents();
|
1570
|
|
1571
|
for(int i=0; i<numEff; i++)
|
1572
|
{
|
1573
|
mMesh.setEffectAssociation(i, 0, i);
|
1574
|
}
|
1575
|
}
|
1576
|
|
1577
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1578
|
|
1579
|
private void openMesh(int resourceID)
|
1580
|
{
|
1581
|
Context con = mView.getContext();
|
1582
|
Resources res = con.getResources();
|
1583
|
InputStream is = res.openRawResource(resourceID);
|
1584
|
DataInputStream dos = new DataInputStream(is);
|
1585
|
mMesh = new MeshFile(dos);
|
1586
|
|
1587
|
int numEff = mMesh.getNumEffComponents();
|
1588
|
|
1589
|
for(int i=0; i<numEff; i++)
|
1590
|
{
|
1591
|
mMesh.setEffectAssociation(i, 0, i);
|
1592
|
}
|
1593
|
|
1594
|
try
|
1595
|
{
|
1596
|
is.close();
|
1597
|
}
|
1598
|
catch(IOException e)
|
1599
|
{
|
1600
|
android.util.Log.e("MeshFile", "Error closing InputStream: "+e.toString());
|
1601
|
}
|
1602
|
}
|
1603
|
|
1604
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1605
|
|
1606
|
MeshBase getMesh()
|
1607
|
{
|
1608
|
return mMesh;
|
1609
|
}
|
1610
|
|
1611
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1612
|
|
1613
|
long getTime()
|
1614
|
{
|
1615
|
return mTime;
|
1616
|
}
|
1617
|
|
1618
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1619
|
|
1620
|
int getBytes()
|
1621
|
{
|
1622
|
if( mMesh instanceof MeshFile )
|
1623
|
{
|
1624
|
return ((MeshFile)mMesh).getNumBytes();
|
1625
|
}
|
1626
|
|
1627
|
return 0;
|
1628
|
}
|
1629
|
|
1630
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1631
|
|
1632
|
int getVertices()
|
1633
|
{
|
1634
|
return mMesh.getNumVertices();
|
1635
|
}
|
1636
|
|
1637
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1638
|
|
1639
|
int getEndEffIndex(int component)
|
1640
|
{
|
1641
|
return mMesh.getLastVertexEff(component);
|
1642
|
}
|
1643
|
|
1644
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1645
|
|
1646
|
int getEndTexIndex(int component)
|
1647
|
{
|
1648
|
return mMesh.getLastVertexTex(component);
|
1649
|
}
|
1650
|
|
1651
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1652
|
|
1653
|
int getEffComponentNum()
|
1654
|
{
|
1655
|
return mMesh.getNumEffComponents();
|
1656
|
}
|
1657
|
|
1658
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1659
|
|
1660
|
int getTexComponentNum()
|
1661
|
{
|
1662
|
return mMesh.getNumTexComponents();
|
1663
|
}
|
1664
|
}
|