Revision 47d98cd5
Added by Leszek Koltunski about 4 years ago
| src/main/java/org/distorted/helpers/FactoryCubit.java | ||
|---|---|---|
| 809 | 809 | } | 
| 810 | 810 | } | 
| 811 | 811 |  | 
| 812 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 813 |  | |
| 814 | private void computeConvexityCenter(double[] out, float[] in, FaceTransform ft) | |
| 815 |     {
 | |
| 816 | if( in==null ) | |
| 817 |       {
 | |
| 818 | out[0] = out[1] = 0.0f; | |
| 819 | } | |
| 820 | else | |
| 821 |       {
 | |
| 822 | out[0] = in[0] - ft.vx; | |
| 823 | out[1] = in[1] - ft.vy; | |
| 824 | out[2] = in[2] - ft.vz; | |
| 825 | out[3] = 1.0f; | |
| 826 |  | |
| 827 | mQuat1[0] =-ft.qx; | |
| 828 | mQuat1[1] =-ft.qy; | |
| 829 | mQuat1[2] =-ft.qz; | |
| 830 | mQuat1[3] = ft.qw; | |
| 831 |  | |
| 832 | mQuat2[0] = -mQuat1[0]; | |
| 833 | mQuat2[1] = -mQuat1[1]; | |
| 834 | mQuat2[2] = -mQuat1[2]; | |
| 835 | mQuat2[3] = +mQuat1[3]; | |
| 836 |  | |
| 837 | quatMultiply(mQuat1, out , mQuat3); | |
| 838 | quatMultiply(mQuat3, mQuat2, out ); | |
| 839 |  | |
| 840 | out[0] /= ft.scale; | |
| 841 | out[1] /= ft.scale; | |
| 842 | out[2] /= ft.scale; | |
| 843 | } | |
| 844 | } | |
| 845 |  | |
| 812 | 846 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 813 | 847 |  | 
| 814 | 848 | public MeshBase createRoundedSolid(final double[][] vertices, final int[][] vertIndexes, | 
| 815 | 849 | final float[][] bands , final int[] bandIndexes, | 
| 816 | 850 | final float[][] corners , final int[] cornerIndexes, | 
| 817 | 851 | final float[][] centers , final int[] centerIndexes, | 
| 818 | final int numComponents ) | |
| 852 |                                      final int numComponents  , final float[] convexityCenter )
 | |
| 819 | 853 |     {
 | 
| 820 | 854 | int numFaces = vertIndexes.length; | 
| 821 | 855 | float[] band, bandsComputed; | 
| 822 | 856 | MeshBase[] meshes = new MeshBase[numFaces]; | 
| 823 | 857 | FaceTransform fInfo; | 
| 824 | 858 | StickerCoords sInfo; | 
| 859 | double[] convexXY = new double[4]; | |
| 825 | 860 |  | 
| 826 | 861 | for(int face=0; face<numFaces; face++) | 
| 827 | 862 |       {
 | 
| ... | ... | |
| 833 | 868 | float[] vertsFloat = new float[lenVerts]; | 
| 834 | 869 | for(int i=0; i<lenVerts; i++) vertsFloat[i] = (float)verts[i]; | 
| 835 | 870 |  | 
| 871 | computeConvexityCenter(convexXY,convexityCenter,fInfo); | |
| 872 |  | |
| 836 | 873 | band = bands[bandIndexes[face]]; | 
| 837 | 874 | bandsComputed = computeBands( band[0], (int)band[1], band[2], band[3], (int)band[4]); | 
| 838 | meshes[face] = new MeshPolygon(vertsFloat,bandsComputed,(int)band[5],(int)band[6]); | |
| 875 |       meshes[face] = new MeshPolygon(vertsFloat,bandsComputed,(int)band[5],(int)band[6], (float)convexXY[0], (float)convexXY[1]);
 | |
| 839 | 876 | meshes[face].setEffectAssociation(0,(1<<face),0); | 
| 840 | 877 | } | 
| 841 | 878 |  | 
| src/main/java/org/distorted/objects/ObjectList.java | ||
|---|---|---|
| 168 | 168 |  | 
| 169 | 169 | IVY ( | 
| 170 | 170 |          new int[][] {
 | 
| 171 |                        {2 , 8, 8, R.raw.ivy, R.drawable.ui_small_ivy, R.drawable.ui_medium_ivy, R.drawable.ui_big_ivy, R.drawable.ui_huge_ivy} ,
 | |
| 171 |                        {2 , 8, 8, 0, R.drawable.ui_small_ivy, R.drawable.ui_medium_ivy, R.drawable.ui_big_ivy, R.drawable.ui_huge_ivy} ,
 | |
| 172 | 172 | }, | 
| 173 | 173 | TwistyIvy.class, | 
| 174 | 174 | new MovementIvy(), | 
| src/main/java/org/distorted/objects/TwistyBandagedAbstract.java | ||
|---|---|---|
| 277 | 277 | bands, bandIndexes, | 
| 278 | 278 | corners, cornerIndexes, | 
| 279 | 279 | centers, centerIndexes, | 
| 280 | getNumCubitFaces() ); | |
| 280 |                                                 getNumCubitFaces(), null );
 | |
| 281 | 281 | } | 
| 282 | 282 | } | 
| 283 | 283 |  | 
| src/main/java/org/distorted/objects/TwistyCube.java | ||
|---|---|---|
| 180 | 180 | bands, bandIndexes, | 
| 181 | 181 | corners, cornerIndexes, | 
| 182 | 182 | centers, centerIndexes, | 
| 183 | getNumCubitFaces() ); | |
| 183 |                                                   getNumCubitFaces(), null );
 | |
| 184 | 184 | } | 
| 185 | 185 |  | 
| 186 | 186 | return mMeshes[index].copy(true); | 
| src/main/java/org/distorted/objects/TwistyDiamond.java | ||
|---|---|---|
| 433 | 433 | bands, bandIndexes, | 
| 434 | 434 | corners, cornerIndexes, | 
| 435 | 435 | centers, centerIndexes, | 
| 436 | getNumCubitFaces() ); | |
| 436 |                                                 getNumCubitFaces(), null );
 | |
| 437 | 437 | } | 
| 438 | 438 | mesh = mMeshes[0].copy(true); | 
| 439 | 439 | } | 
| ... | ... | |
| 455 | 455 | bands, bandIndexes, | 
| 456 | 456 | corners, cornerIndexes, | 
| 457 | 457 | centers, centerIndexes, | 
| 458 | getNumCubitFaces() ); | |
| 458 |                                                 getNumCubitFaces(), null );
 | |
| 459 | 459 | } | 
| 460 | 460 | mesh = mMeshes[1].copy(true); | 
| 461 | 461 | } | 
| src/main/java/org/distorted/objects/TwistyDino.java | ||
|---|---|---|
| 210 | 210 | bands, bandIndexes, | 
| 211 | 211 | corners, cornerIndexes, | 
| 212 | 212 | centers, centerIndexes, | 
| 213 | getNumCubitFaces() ); | |
| 213 |                                               getNumCubitFaces(), null );
 | |
| 214 | 214 | } | 
| 215 | 215 |  | 
| 216 | 216 | MeshBase mesh = mMeshes[0].copy(true); | 
| src/main/java/org/distorted/objects/TwistyHelicopter.java | ||
|---|---|---|
| 338 | 338 | bands, bandIndexes, | 
| 339 | 339 | corners, cornerIndexes, | 
| 340 | 340 | centers, centerIndexes, | 
| 341 | getNumCubitFaces() ); | |
| 341 |                                                 getNumCubitFaces(), null );
 | |
| 342 | 342 | } | 
| 343 | 343 | mesh = mMeshes[0].copy(true); | 
| 344 | 344 | } | 
| ... | ... | |
| 363 | 363 | bands, bandIndexes, | 
| 364 | 364 | corners, cornerIndexes, | 
| 365 | 365 | centers, centerIndexes, | 
| 366 | getNumCubitFaces() ); | |
| 366 |                                                 getNumCubitFaces(), null );
 | |
| 367 | 367 | } | 
| 368 | 368 | mesh = mMeshes[1].copy(true); | 
| 369 | 369 | } | 
| src/main/java/org/distorted/objects/TwistyIvy.java | ||
|---|---|---|
| 24 | 24 | import org.distorted.helpers.FactoryCubit; | 
| 25 | 25 | import org.distorted.helpers.ObjectSticker; | 
| 26 | 26 | import org.distorted.library.effect.MatrixEffectQuaternion; | 
| 27 | import org.distorted.library.effect.VertexEffect; | |
| 28 | import org.distorted.library.effect.VertexEffectMove; | |
| 29 | import org.distorted.library.effect.VertexEffectRotate; | |
| 30 | import org.distorted.library.effect.VertexEffectScale; | |
| 31 | 27 | import org.distorted.library.main.DistortedEffects; | 
| 32 | 28 | import org.distorted.library.main.DistortedTexture; | 
| 33 | 29 | import org.distorted.library.mesh.MeshBase; | 
| 34 | import org.distorted.library.mesh.MeshJoined; | |
| 35 | import org.distorted.library.mesh.MeshPolygon; | |
| 36 | 30 | import org.distorted.library.mesh.MeshSquare; | 
| 37 | import org.distorted.library.type.Static1D; | |
| 38 | 31 | import org.distorted.library.type.Static3D; | 
| 39 | 32 | import org.distorted.library.type.Static4D; | 
| 40 | 33 | import org.distorted.main.R; | 
| ... | ... | |
| 46 | 39 | public class TwistyIvy extends TwistyObject | 
| 47 | 40 | {
 | 
| 48 | 41 | public static final float IVY_D = 0.003f; | 
| 49 | public static final float IVY_C = 0.59f; | |
| 50 | public static final float IVY_M = 0.35f; | |
| 51 | private static final int IVY_N = 8; | |
| 42 | private static final int IVY_N = 8; | |
| 52 | 43 |  | 
| 53 | 44 | private static final int FACES_PER_CUBIT =6; | 
| 54 | 45 |  | 
| ... | ... | |
| 90 | 81 |  | 
| 91 | 82 | private static final int[][] mFaceMap = | 
| 92 | 83 |          {
 | 
| 93 |            {  4, 2, 0, 12,12,12 },
 | |
| 94 |            {  5, 2, 1, 12,12,12 },
 | |
| 95 |            {  4, 3, 1, 12,12,12 },
 | |
| 96 |            {  5, 3, 0, 12,12,12 },
 | |
| 84 |            {  4, 0, 2, 12,12,12 },
 | |
| 85 |            {  5, 1, 2, 12,12,12 },
 | |
| 86 |            {  4, 1, 3, 12,12,12 },
 | |
| 87 |            {  5, 0, 3, 12,12,12 },
 | |
| 97 | 88 |  | 
| 98 | 89 |            {  6, 12,12,12,12,12 },
 | 
| 99 | 90 |            {  7, 12,12,12,12,12 },
 | 
| ... | ... | |
| 105 | 96 |  | 
| 106 | 97 | private static MeshBase mCornerMesh, mFaceMesh; | 
| 107 | 98 |  | 
| 108 | private static final int NUM_STICKERS = 2; | |
| 109 | 99 | private static final ObjectSticker[] mStickers; | 
| 110 | 100 |  | 
| 101 | private static final float[][] STICKERS = new float[][] | |
| 102 |           {
 | |
| 103 |              { 0.29258922f, -0.5f, 0.29258922f, 0.29258922f, -0.5f, 0.29258922f },
 | |
| 104 |              { -0.5f, 0.5f, 0.5f, -0.5f }
 | |
| 105 | }; | |
| 106 | private static final int NUM_STICKERS = STICKERS.length; | |
| 107 |  | |
| 111 | 108 | static | 
| 112 | 109 |     {
 | 
| 113 | 110 | mStickers = new ObjectSticker[NUM_STICKERS]; | 
| 114 | 111 |  | 
| 115 | float A = (+0.5f-IVY_M)*IVY_C; | |
| 116 | float B = (-0.5f-IVY_M)*IVY_C; | |
| 117 | float C = 0.50f-IVY_D; | |
| 118 | 112 | float D = (float)(Math.PI/4); | 
| 119 |  | |
| 120 |     final float[][] coords = { {A,B,A,A,B,A},{-C,C,C,-C} };
 | |
| 121 | 113 |     final float[][] angles = { { 0,0,D },{ D,D } };
 | 
| 122 | 114 |     final float[][] radii  = { { 0,0.02f,0 },{ 0.06f,0.06f } };
 | 
| 123 | 115 |     final float[] strokes = { 0.03f, 0.08f };
 | 
| 124 | 116 |  | 
| 125 | 117 | for(int s=0; s<NUM_STICKERS; s++) | 
| 126 | 118 |       {
 | 
| 127 |       mStickers[s] = new ObjectSticker(coords[s],angles[s],radii[s],strokes[s]);
 | |
| 119 |       mStickers[s] = new ObjectSticker(STICKERS[s], angles[s],radii[s],strokes[s]);
 | |
| 128 | 120 | } | 
| 129 | 121 | } | 
| 130 | 122 |  | 
| ... | ... | |
| 231 | 223 | return 0; | 
| 232 | 224 | } | 
| 233 | 225 |  | 
| 234 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 235 |  | |
| 236 | MeshBase createFacesIvyCorner() | |
| 237 |     {
 | |
| 238 | MeshBase[] meshes = new MeshBase[6]; | |
| 239 |  | |
| 240 | final float angle = (float)Math.PI/(2*IVY_N); | |
| 241 | final float CORR = 1.0f - 2*IVY_D; | |
| 242 | final float DIST = -0.5f*CORR + IVY_D; | |
| 243 | float[] vertices = new float[2*(IVY_N+1)+6]; | |
| 244 |  | |
| 245 | vertices[0] = (0.5f-IVY_M) * IVY_C; | |
| 246 | vertices[1] = (DIST-IVY_M) * IVY_C; | |
| 247 | vertices[2] = (0.5f-IVY_M) * IVY_C; | |
| 248 | vertices[3] = (0.5f-IVY_M) * IVY_C; | |
| 249 | vertices[4] = (DIST-IVY_M) * IVY_C; | |
| 250 | vertices[5] = (0.5f-IVY_M) * IVY_C; | |
| 251 |  | |
| 252 | for(int i=0; i<=IVY_N; i++) | |
| 253 |       {
 | |
| 254 | float ang = (IVY_N-i)*angle; | |
| 255 | float sin = (float)Math.sin(ang); | |
| 256 | float cos = (float)Math.cos(ang); | |
| 257 |  | |
| 258 | vertices[2*i+6] = (CORR*(cos-0.5f)-IVY_M)*IVY_C; | |
| 259 | vertices[2*i+7] = (CORR*(sin-0.5f)-IVY_M)*IVY_C; | |
| 260 | } | |
| 261 |  | |
| 262 | FactoryCubit factory = FactoryCubit.getInstance(); | |
| 263 | float[] bands0 = factory.computeBands(+0.012f,20,0.2f,0.5f,7); | |
| 264 | float[] bands1 = factory.computeBands(-0.100f,20,0.2f,0.0f,2); | |
| 265 |  | |
| 266 | meshes[0] = new MeshPolygon(vertices,bands0,1,2); | |
| 267 | meshes[0].setEffectAssociation(0,1,0); | |
| 268 | meshes[1] = meshes[0].copy(true); | |
| 269 | meshes[1].setEffectAssociation(0,2,0); | |
| 270 | meshes[2] = meshes[0].copy(true); | |
| 271 | meshes[2].setEffectAssociation(0,4,0); | |
| 272 | meshes[3] = new MeshPolygon(vertices,bands1,1,2); | |
| 273 | meshes[3].setEffectAssociation(0,8,0); | |
| 274 | meshes[4] = meshes[3].copy(true); | |
| 275 | meshes[4].setEffectAssociation(0,16,0); | |
| 276 | meshes[5] = meshes[3].copy(true); | |
| 277 | meshes[5].setEffectAssociation(0,32,0); | |
| 278 |  | |
| 279 | return new MeshJoined(meshes); | |
| 280 | } | |
| 281 |  | |
| 282 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 283 |  | |
| 284 | private VertexEffect[] createVertexEffectsIvyCorner() | |
| 285 |     {
 | |
| 286 | Static3D axisX = new Static3D(1,0,0); | |
| 287 | Static3D axisY = new Static3D(0,1,0); | |
| 288 | Static1D angle1 = new Static1D(+90); | |
| 289 | Static1D angle2 = new Static1D(-90); | |
| 290 | Static3D center = new Static3D(0,0,0); | |
| 291 | Static3D move1 = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0); | |
| 292 |  | |
| 293 | VertexEffect[] effect = new VertexEffect[5]; | |
| 294 |  | |
| 295 | effect[0] = new VertexEffectScale(1/IVY_C); | |
| 296 | effect[1] = new VertexEffectMove(move1); | |
| 297 | effect[2] = new VertexEffectScale(new Static3D(1,1,-1)); | |
| 298 | effect[3] = new VertexEffectRotate(angle1,axisX,center); | |
| 299 | effect[4] = new VertexEffectRotate(angle2,axisY,center); | |
| 300 |  | |
| 301 | effect[2].setMeshAssociation(54,-1); // meshes 1,2,4,5 | |
| 302 | effect[3].setMeshAssociation(18,-1); // meshes 1,4 | |
| 303 | effect[4].setMeshAssociation(36,-1); // meshes 2,5 | |
| 304 |  | |
| 305 | return effect; | |
| 306 | } | |
| 307 |  | |
| 308 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 309 |  | |
| 310 | private MeshBase createFacesIvyFace() | |
| 311 |     {
 | |
| 312 | MeshBase[] meshes = new MeshBase[2]; | |
| 313 |  | |
| 314 | final float angle = (float)Math.PI/(2*IVY_N); | |
| 315 | final float CORR = 1.0f - 2*IVY_D; | |
| 316 | float[] vertices = new float[4*IVY_N]; | |
| 317 |  | |
| 318 | for(int i=0; i<IVY_N; i++) | |
| 319 |       {
 | |
| 320 | float sin = (float)Math.sin(i*angle); | |
| 321 | float cos = (float)Math.cos(i*angle); | |
| 322 |  | |
| 323 | vertices[2*i ] = CORR*(0.5f-cos); | |
| 324 | vertices[2*i+1 ] = CORR*(0.5f-sin); | |
| 325 | vertices[2*i +2*IVY_N] = CORR*(cos-0.5f); | |
| 326 | vertices[2*i+1+2*IVY_N] = CORR*(sin-0.5f); | |
| 327 | } | |
| 328 |  | |
| 329 | FactoryCubit factory = FactoryCubit.getInstance(); | |
| 330 | float[] bands0 = factory.computeBands(+0.03f,35,0.5f,0.5f,5); | |
| 331 | float[] bands1 = factory.computeBands(-0.10f,45,0.5f,0.0f,2); | |
| 332 |  | |
| 333 | meshes[0] = new MeshPolygon(vertices,bands0,0,0); | |
| 334 | meshes[0].setEffectAssociation(0,1,0); | |
| 335 | meshes[1] = new MeshPolygon(vertices,bands1,0,0); | |
| 336 | meshes[1].setEffectAssociation(0,2,0); | |
| 337 |  | |
| 338 | return new MeshJoined(meshes); | |
| 339 | } | |
| 340 |  | |
| 341 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 342 |  | |
| 343 | private MeshBase createIvyFaceMesh() | |
| 344 |     {
 | |
| 345 | MeshBase mesh = createFacesIvyFace(); | |
| 346 |  | |
| 347 | Static3D center = new Static3D(-0.0f,-0.0f,-0.5f); | |
| 348 | Static3D[] vertices = new Static3D[2]; | |
| 349 | vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f); | |
| 350 | vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f); | |
| 351 |  | |
| 352 | FactoryCubit.getInstance().roundCorners(mesh,center,vertices,0.03f,0.10f); | |
| 353 |  | |
| 354 | mesh.mergeEffComponents(); | |
| 355 | mesh.addEmptyTexComponent(); | |
| 356 | mesh.addEmptyTexComponent(); | |
| 357 | mesh.addEmptyTexComponent(); | |
| 358 | mesh.addEmptyTexComponent(); | |
| 359 |  | |
| 360 | return mesh; | |
| 361 | } | |
| 362 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 363 |  | |
| 364 | private MeshBase createIvyCornerMesh() | |
| 365 |     {
 | |
| 366 | MeshBase mesh = createFacesIvyCorner(); | |
| 367 | VertexEffect[] effects = createVertexEffectsIvyCorner(); | |
| 368 | for( VertexEffect effect : effects ) mesh.apply(effect); | |
| 369 |  | |
| 370 | Static3D center = new Static3D(-0.5f,-0.5f,-0.5f); | |
| 371 | Static3D[] vertices = new Static3D[4]; | |
| 372 | vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f); | |
| 373 | vertices[1] = new Static3D(-1.0f,+0.0f,+0.0f); | |
| 374 | vertices[2] = new Static3D(+0.0f,-1.0f,+0.0f); | |
| 375 | vertices[3] = new Static3D(+0.0f,+0.0f,-1.0f); | |
| 376 |  | |
| 377 | FactoryCubit.getInstance().roundCorners(mesh,center,vertices,0.03f,0.10f); | |
| 378 |  | |
| 379 | mesh.mergeEffComponents(); | |
| 380 |  | |
| 381 | return mesh; | |
| 382 | } | |
| 383 |  | |
| 384 | 226 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 385 | 227 |  | 
| 386 | 228 | MeshBase createCubitMesh(int cubit, int numLayers) | 
| ... | ... | |
| 389 | 231 |  | 
| 390 | 232 | if( cubit<4 ) | 
| 391 | 233 |       {
 | 
| 392 | if( mCornerMesh==null ) mCornerMesh = createIvyCornerMesh(); | |
| 234 | if( mCornerMesh==null ) | |
| 235 |         {
 | |
| 236 | final float angle = (float)Math.PI/(2*IVY_N); | |
| 237 | final float CORR = 1.0f - 2*IVY_D; | |
| 238 |  | |
| 239 |         float[][] centers= new float[][] { {-0.5f,-0.5f,-0.5f} };
 | |
| 240 |         float[][] corners= new float[][] { {0.03f,0.10f}, {0.02f,0.10f} };
 | |
| 241 | int[] cornerIndexes= new int[3*(IVY_N+1)+4]; | |
| 242 | int[] centerIndexes= new int[3*(IVY_N+1)+4]; | |
| 243 | double[][] vertices= new double[3*(IVY_N+1)+4][3]; | |
| 244 | int[][] vertIndexes= new int[6][IVY_N+4]; | |
| 245 |         int[] bandIndexes= new int[] { 0,0,0,1,1,1 };
 | |
| 246 |  | |
| 247 | float[][] bands = | |
| 248 |           {
 | |
| 249 |                {+0.012f,20,0.2f,0.5f,7,1,2},
 | |
| 250 |                {-0.100f,20,0.2f,0.0f,2,1,2}
 | |
| 251 | }; | |
| 252 |  | |
| 253 | for(int i=0; i<3*(IVY_N+1); i++) | |
| 254 |           {
 | |
| 255 | cornerIndexes[i+4] = -1; | |
| 256 | centerIndexes[i+4] = -1; | |
| 257 | } | |
| 258 | cornerIndexes[0] = 1; | |
| 259 | cornerIndexes[1] = 0; | |
| 260 | cornerIndexes[2] = 0; | |
| 261 | cornerIndexes[3] = 0; | |
| 262 |  | |
| 263 | centerIndexes[0] = 0; | |
| 264 | centerIndexes[1] = 0; | |
| 265 | centerIndexes[2] = 0; | |
| 266 | centerIndexes[3] = 0; | |
| 267 |  | |
| 268 | vertices[0][0] = 0.0; | |
| 269 | vertices[0][1] = 0.0; | |
| 270 | vertices[0][2] = 0.0; | |
| 271 | vertices[1][0] =-1.0; | |
| 272 | vertices[1][1] = 0.0; | |
| 273 | vertices[1][2] = 0.0; | |
| 274 | vertices[2][0] = 0.0; | |
| 275 | vertices[2][1] =-1.0; | |
| 276 | vertices[2][2] = 0.0; | |
| 277 | vertices[3][0] = 0.0; | |
| 278 | vertices[3][1] = 0.0; | |
| 279 | vertices[3][2] =-1.0; | |
| 280 |  | |
| 281 | vertIndexes[0][0] = 2; | |
| 282 | vertIndexes[0][1] = 0; | |
| 283 | vertIndexes[0][2] = 1; | |
| 284 | vertIndexes[3][0] = 2; | |
| 285 | vertIndexes[3][1] = 0; | |
| 286 | vertIndexes[3][2] = 1; | |
| 287 |  | |
| 288 | vertIndexes[1][0] = 3; | |
| 289 | vertIndexes[1][1] = 0; | |
| 290 | vertIndexes[1][2] = 2; | |
| 291 | vertIndexes[4][0] = 3; | |
| 292 | vertIndexes[4][1] = 0; | |
| 293 | vertIndexes[4][2] = 2; | |
| 294 |  | |
| 295 | vertIndexes[2][0] = 1; | |
| 296 | vertIndexes[2][1] = 0; | |
| 297 | vertIndexes[2][2] = 3; | |
| 298 | vertIndexes[5][0] = 1; | |
| 299 | vertIndexes[5][1] = 0; | |
| 300 | vertIndexes[5][2] = 3; | |
| 301 |  | |
| 302 | int N1 = 4; | |
| 303 | int N2 = N1 + IVY_N + 1; | |
| 304 | int N3 = N2 + IVY_N + 1; | |
| 305 |  | |
| 306 | for(int i=0; i<=IVY_N; i++) | |
| 307 |           {
 | |
| 308 | double cos1 = Math.cos((IVY_N-i)*angle); | |
| 309 | double sin1 = Math.sin((IVY_N-i)*angle); | |
| 310 | double cos2 = Math.cos(( i)*angle); | |
| 311 | double sin2 = Math.sin(( i)*angle); | |
| 312 |  | |
| 313 | vertices[N1+i][0] = CORR*(cos1-0.5) - 0.5; | |
| 314 | vertices[N1+i][1] = CORR*(sin1-0.5) - 0.5; | |
| 315 | vertices[N1+i][2] = 0.0; | |
| 316 |  | |
| 317 | vertices[N2+i][0] = 0.0; | |
| 318 | vertices[N2+i][1] = CORR*(sin2-0.5) - 0.5; | |
| 319 | vertices[N2+i][2] = CORR*(cos2-0.5) - 0.5; | |
| 320 |  | |
| 321 | vertices[N3+i][0] = CORR*(cos2-0.5) - 0.5; | |
| 322 | vertices[N3+i][1] = 0.0; | |
| 323 | vertices[N3+i][2] = CORR*(sin2-0.5) - 0.5; | |
| 324 |  | |
| 325 | vertIndexes[0][i+3] = N1 + i; | |
| 326 | vertIndexes[1][i+3] = N2 + i; | |
| 327 | vertIndexes[2][i+3] = N3 + i; | |
| 328 | vertIndexes[3][i+3] = N1 + i; | |
| 329 | vertIndexes[4][i+3] = N2 + i; | |
| 330 | vertIndexes[5][i+3] = N3 + i; | |
| 331 | } | |
| 332 |  | |
| 333 | float C = 0.5f - SQ2/4; | |
| 334 |         float[] convexCenter = new float[] {-C,-C,-C};
 | |
| 335 |  | |
| 336 | FactoryCubit factory = FactoryCubit.getInstance(); | |
| 337 | factory.createNewFaceTransform(vertices,vertIndexes); | |
| 338 | mCornerMesh = factory.createRoundedSolid(vertices, vertIndexes, | |
| 339 | bands, bandIndexes, | |
| 340 | corners, cornerIndexes, | |
| 341 | centers, centerIndexes, | |
| 342 | getNumCubitFaces(), convexCenter ); | |
| 343 | } | |
| 393 | 344 | mesh = mCornerMesh.copy(true); | 
| 394 | 345 | } | 
| 395 | 346 | else | 
| 396 | 347 |       {
 | 
| 397 | if( mFaceMesh==null ) mFaceMesh = createIvyFaceMesh(); | |
| 348 | if( mFaceMesh==null ) | |
| 349 |         {
 | |
| 350 | final float angle = (float)Math.PI/(2*IVY_N); | |
| 351 | final float CORR = 1.0f - 2*IVY_D; | |
| 352 | double[][] vertices = new double[2*IVY_N][3]; | |
| 353 | int[][] vert_indices = new int[2][2*IVY_N]; | |
| 354 |  | |
| 355 |         int[] bandIndexes= new int[] { 0,1 };
 | |
| 356 | int[] indexes = new int[2*IVY_N]; | |
| 357 |         float[][] corners= new float[][] { {0.03f,0.10f} };
 | |
| 358 |         float[][] centers= new float[][] { {-0.0f,-0.0f,-0.5f} };
 | |
| 359 |  | |
| 360 | for(int i=0; i<IVY_N; i++) | |
| 361 |           {
 | |
| 362 | double sin = Math.sin(i*angle); | |
| 363 | double cos = Math.cos(i*angle); | |
| 364 |  | |
| 365 | vertices[i ][0] = CORR*(0.5f-cos); | |
| 366 | vertices[i ][1] = CORR*(0.5f-sin); | |
| 367 | vertices[i ][2] = 0; | |
| 368 | vertices[i+IVY_N][0] = CORR*(cos-0.5f); | |
| 369 | vertices[i+IVY_N][1] = CORR*(sin-0.5f); | |
| 370 | vertices[i+IVY_N][2] = 0; | |
| 371 | } | |
| 372 |  | |
| 373 | for(int i=0; i<2*IVY_N; i++) | |
| 374 |           {
 | |
| 375 | vert_indices[0][i] = i; | |
| 376 | vert_indices[1][i] = 2*IVY_N-1-i; | |
| 377 | } | |
| 378 |  | |
| 379 | for(int i=0; i<2*IVY_N; i++) | |
| 380 |           {
 | |
| 381 | indexes[i] = -1; | |
| 382 | } | |
| 383 | indexes[0] = indexes[IVY_N] = 0; | |
| 384 |  | |
| 385 | float[][] bands = | |
| 386 |           {
 | |
| 387 |                {+0.03f,35,0.5f,0.5f,5,0,0},
 | |
| 388 |                {+0.10f,45,0.5f,0.0f,2,0,0}
 | |
| 389 | }; | |
| 390 |  | |
| 391 | FactoryCubit factory = FactoryCubit.getInstance(); | |
| 392 | factory.createNewFaceTransform(vertices,vert_indices); | |
| 393 | mFaceMesh = factory.createRoundedSolid(vertices, vert_indices, | |
| 394 | bands, bandIndexes, | |
| 395 | corners, indexes, | |
| 396 | centers, indexes, | |
| 397 | getNumCubitFaces(), null ); | |
| 398 | } | |
| 398 | 399 | mesh = mFaceMesh.copy(true); | 
| 399 | 400 | } | 
| 400 | 401 |  | 
| src/main/java/org/distorted/objects/TwistyJing.java | ||
|---|---|---|
| 322 | 322 | bands, bandIndexes, | 
| 323 | 323 | corners, cornerIndexes, | 
| 324 | 324 | centers, centerIndexes, | 
| 325 | getNumCubitFaces() ); | |
| 325 |                                                 getNumCubitFaces(), null );
 | |
| 326 | 326 | } | 
| 327 | 327 | mesh = mMeshes[0].copy(true); | 
| 328 | 328 | } | 
| ... | ... | |
| 344 | 344 | bands, bandIndexes, | 
| 345 | 345 | corners, cornerIndexes, | 
| 346 | 346 | centers, centerIndexes, | 
| 347 | getNumCubitFaces() ); | |
| 347 |                                                 getNumCubitFaces(), null );
 | |
| 348 | 348 |  | 
| 349 | 349 | factory.printStickerCoords(); | 
| 350 | 350 | } | 
| ... | ... | |
| 369 | 369 | bands, bandIndexes, | 
| 370 | 370 | corners, cornerIndexes, | 
| 371 | 371 | centers, centerIndexes, | 
| 372 | getNumCubitFaces() ); | |
| 372 |                                                 getNumCubitFaces(), null );
 | |
| 373 | 373 |  | 
| 374 | 374 | factory.printStickerCoords(); | 
| 375 | 375 | } | 
| src/main/java/org/distorted/objects/TwistyKilominx.java | ||
|---|---|---|
| 424 | 424 | bands, bandIndexes, | 
| 425 | 425 | corners, cornerIndexes, | 
| 426 | 426 | centers, centerIndexes, | 
| 427 | getNumCubitFaces() ); | |
| 427 |                                       getNumCubitFaces(), null );
 | |
| 428 | 428 | } | 
| 429 | 429 |  | 
| 430 | 430 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| ... | ... | |
| 496 | 496 | bands, bandIndexes, | 
| 497 | 497 | corners, cornerIndexes, | 
| 498 | 498 | centers, centerIndexes, | 
| 499 | getNumCubitFaces() ); | |
| 499 |                                       getNumCubitFaces(), null );
 | |
| 500 | 500 | } | 
| 501 | 501 |  | 
| 502 | 502 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| src/main/java/org/distorted/objects/TwistyMegaminx.java | ||
|---|---|---|
| 350 | 350 | bands, bandIndexes, | 
| 351 | 351 | corners, cornerIndexes, | 
| 352 | 352 | centers, centerIndexes, | 
| 353 | getNumCubitFaces() ); | |
| 353 |                                       getNumCubitFaces(), null );
 | |
| 354 | 354 | } | 
| 355 | 355 |  | 
| 356 | 356 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| ... | ... | |
| 403 | 403 | bands, bandIndexes, | 
| 404 | 404 | corners, cornerIndexes, | 
| 405 | 405 | centers, centerIndexes, | 
| 406 | getNumCubitFaces() ); | |
| 406 |                                       getNumCubitFaces(), null );
 | |
| 407 | 407 | } | 
| 408 | 408 |  | 
| 409 | 409 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| src/main/java/org/distorted/objects/TwistyMinx.java | ||
|---|---|---|
| 427 | 427 | bands, bandIndexes, | 
| 428 | 428 | corners, cornerIndexes, | 
| 429 | 429 | centers, centerIndexes, | 
| 430 | getNumCubitFaces() ); | |
| 430 |                                       getNumCubitFaces(), null );
 | |
| 431 | 431 | } | 
| 432 | 432 |  | 
| 433 | 433 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| src/main/java/org/distorted/objects/TwistyPyraminx.java | ||
|---|---|---|
| 333 | 333 | bands, bandIndexes, | 
| 334 | 334 | corners, cornerIndexes, | 
| 335 | 335 | centers, centerIndexes, | 
| 336 | getNumCubitFaces() ); | |
| 336 |                                                 getNumCubitFaces(), null );
 | |
| 337 | 337 | } | 
| 338 | 338 | mesh = mMeshes[0].copy(true); | 
| 339 | 339 | } | 
| ... | ... | |
| 355 | 355 | bands, bandIndexes, | 
| 356 | 356 | corners, cornerIndexes, | 
| 357 | 357 | centers, centerIndexes, | 
| 358 | getNumCubitFaces() ); | |
| 358 |                                                 getNumCubitFaces(), null );
 | |
| 359 | 359 |  | 
| 360 | 360 | factory.printStickerCoords(); | 
| 361 | 361 | } | 
| src/main/java/org/distorted/objects/TwistyRedi.java | ||
|---|---|---|
| 340 | 340 | bands, bandIndexes, | 
| 341 | 341 | corners, cornerIndexes, | 
| 342 | 342 | centers, centerIndexes, | 
| 343 | getNumCubitFaces() ); | |
| 343 |                                                 getNumCubitFaces(), null );
 | |
| 344 | 344 | } | 
| 345 | 345 | mesh = mMeshes[0].copy(true); | 
| 346 | 346 | } | 
| ... | ... | |
| 366 | 366 | bands, bandIndexes, | 
| 367 | 367 | corners, cornerIndexes, | 
| 368 | 368 | centers, centerIndexes, | 
| 369 | getNumCubitFaces() ); | |
| 369 |                                                 getNumCubitFaces(), null );
 | |
| 370 | 370 | } | 
| 371 | 371 | mesh = mMeshes[1].copy(true); | 
| 372 | 372 | } | 
| src/main/java/org/distorted/objects/TwistySkewb.java | ||
|---|---|---|
| 502 | 502 | bands, bandIndexes, | 
| 503 | 503 | corners, cornerIndexes, | 
| 504 | 504 | centers, centerIndexes, | 
| 505 | getNumCubitFaces() ); | |
| 505 |                                                 getNumCubitFaces(), null );
 | |
| 506 | 506 | } | 
| 507 | 507 | mesh = mMeshes[0].copy(true); | 
| 508 | 508 | } | 
| ... | ... | |
| 527 | 527 | bands, bandIndexes, | 
| 528 | 528 | corners, cornerIndexes, | 
| 529 | 529 | centers, centerIndexes, | 
| 530 | getNumCubitFaces() ); | |
| 530 |                                                 getNumCubitFaces(), null );
 | |
| 531 | 531 | } | 
| 532 | 532 | mesh = mMeshes[1].copy(true); | 
| 533 | 533 | } | 
| ... | ... | |
| 552 | 552 | bands, bandIndexes, | 
| 553 | 553 | corners, cornerIndexes, | 
| 554 | 554 | centers, centerIndexes, | 
| 555 | getNumCubitFaces() ); | |
| 555 |                                                 getNumCubitFaces(), null );
 | |
| 556 | 556 | } | 
| 557 | 557 | mesh = mMeshes[2].copy(true); | 
| 558 | 558 | } | 
| src/main/java/org/distorted/objects/TwistySquare.java | ||
|---|---|---|
| 191 | 191 | bands, bandIndexes, | 
| 192 | 192 | corners, cornerIndexes, | 
| 193 | 193 | centers, centerIndexes, | 
| 194 | getNumCubitFaces() ); | |
| 194 |                                               getNumCubitFaces(), null );
 | |
| 195 | 195 | } | 
| 196 | 196 |  | 
| 197 | 197 | return mMeshes[0].copy(true); | 
| ... | ... | |
| 220 | 220 | bands, bandIndexes, | 
| 221 | 221 | corners, cornerIndexes, | 
| 222 | 222 | centers, centerIndexes, | 
| 223 | getNumCubitFaces() ); | |
| 223 |                                                getNumCubitFaces(), null );
 | |
| 224 | 224 | } | 
| 225 | 225 | return mMeshes[1].copy(true); | 
| 226 | 226 | } | 
| src/main/java/org/distorted/objects/TwistySquare1.java | ||
|---|---|---|
| 209 | 209 | bands, bandIndexes, | 
| 210 | 210 | corners, cornerIndexes, | 
| 211 | 211 | centers, centerIndexes, | 
| 212 | getNumCubitFaces() ); | |
| 212 |                                               getNumCubitFaces(), null );
 | |
| 213 | 213 | } | 
| 214 | 214 | return mMeshes[2].copy(true); | 
| 215 | 215 | } | 
| src/main/java/org/distorted/objects/TwistySquare2.java | ||
|---|---|---|
| 214 | 214 | bands, bandIndexes, | 
| 215 | 215 | corners, cornerIndexes, | 
| 216 | 216 | centers, centerIndexes, | 
| 217 | getNumCubitFaces() ); | |
| 217 |                                               getNumCubitFaces(), null );
 | |
| 218 | 218 | } | 
| 219 | 219 | return mMeshes[3].copy(true); | 
| 220 | 220 | } | 
| src/main/java/org/distorted/objects/TwistyUltimate.java | ||
|---|---|---|
| 278 | 278 | bands, bandIndexes, | 
| 279 | 279 | corners, cornerIndexes, | 
| 280 | 280 | centers, centerIndexes, | 
| 281 | getNumCubitFaces() ); | |
| 281 |                                                 getNumCubitFaces(), null );
 | |
| 282 | 282 | } | 
| 283 | 283 | mesh = mMeshes[0].copy(true); | 
| 284 | 284 | } | 
| ... | ... | |
| 303 | 303 | bands, bandIndexes, | 
| 304 | 304 | corners, cornerIndexes, | 
| 305 | 305 | centers, centerIndexes, | 
| 306 | getNumCubitFaces() ); | |
| 306 |                                                 getNumCubitFaces(), null );
 | |
| 307 | 307 | } | 
| 308 | 308 | mesh = mMeshes[1].copy(true); | 
| 309 | 309 | } | 
| ... | ... | |
| 329 | 329 | bands, bandIndexes, | 
| 330 | 330 | corners, cornerIndexes, | 
| 331 | 331 | centers, centerIndexes, | 
| 332 | getNumCubitFaces() ); | |
| 332 |                                                 getNumCubitFaces(), null );
 | |
| 333 | 333 | } | 
| 334 | 334 | mesh = mMeshes[2].copy(true); | 
| 335 | 335 | } | 
Also available in: Unified diff
Convert the Ivy corner cubit to the new, 'universal' cubit creation method.
This forces deep changes to 'createRoundSolid' and the underlying 'MeshPolygon' class to make them support arbitrary Polygon 'centers of face convexity'.
Reason: the faces of this cubit are concave and such default 'center of face convexity' (which by default used to be (0,0)) turned to lie outside the face - which produces strange visual artifacts.