Project

General

Profile

« Previous | Next » 

Revision 4e627d8b

Added by Leszek Koltunski almost 4 years ago

Progress with the Kilominx.

View differences:

src/main/java/org/distorted/objects/FactoryCubit.java
42 42

  
43 43
  private static final float SQ2 = (float)Math.sqrt(2);
44 44
  private static final float SQ3 = (float)Math.sqrt(3);
45
  private static final float SQ5 = (float)Math.sqrt(5);
45 46
  private static final float SQ6 = (float)Math.sqrt(6);
46 47

  
48
  static final float MINX_C0 = (SQ5-1)/4;
49
  static final float MINX_C1 = (SQ5+1)/4;                         // sin(54 deg)
50
  static final float MINX_C3 = (float)(Math.sqrt(10-2*SQ5)/4);    // cos(54 deg)
51
  static final float MINX_C4 = (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
52
  static final float MINX_C5 = (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
53

  
47 54
  private static final int IVY_N = 8;
55

  
48 56
  private static final Static1D RADIUS = new Static1D(1);
49 57
  private static FactoryCubit mThis;
50 58

  
......
674 682
    return new MeshJoined(meshes);
675 683
    }
676 684

  
677

  
678 685
///////////////////////////////////////////////////////////////////////////////////////////////////
679 686

  
680 687
  MeshBase createFacesMinxCorner()
681 688
    {
682 689
    MeshBase[] meshes = new MeshPolygon[6];
683 690

  
684
    float[] vertices0 = {  };   // TODO
685
    float[] bands0 = computeBands(0.03f,27,0.25f,0.5f,5);
686
    float[] vertices1 = {  };   // TODO
691
    float X1= (SQ5+1)/8;
692
    float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
693
    float Y2= Y1 - (float)(Math.sqrt(10-2*SQ5)/8);
694
    float H = 0.5f*MINX_C1/MINX_C3;
695
    float X2= H*MINX_C5;
696
    float Y3= H/(2*MINX_C4);
697
    float Y4= H*(1/(2*MINX_C4) - MINX_C4);
698

  
699
    float[] vertices0 = { -X1, Y2, 0, -Y1, X1, Y2, 0, Y1 };
700
    float[] bands0 = computeBands(0.03f,39,0.3f,0.2f,5);
701
    float[] vertices1 = { -X2, Y4, 0, -Y3, X2, Y4, 0, Y3 };
687 702
    float[] bands1 = computeBands(0.00f,27,0.25f,0.5f,2);
688 703

  
689 704
    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
......
1203 1218

  
1204 1219
  VertexEffect[] createVertexEffectsMinxCorner()
1205 1220
    {
1206
    // TODO
1221
    VertexEffect[] effect = new VertexEffect[9];
1222

  
1223
    float H = 0.5f*(MINX_C1/MINX_C3);
1224
    float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
1225
    float Y2= H/(2*MINX_C4);
1226
    float A = (float)(Math.acos(-SQ5/5)*180/Math.PI);  // dihedral angle of a dedecahedron in degrees
1227
    float sin18 = MINX_C0;
1228
    float cos18 = (float)(Math.sqrt(1-MINX_C0*MINX_C0));
1229
    float LEN   = (float)Math.sqrt(H*H/(MINX_C4*MINX_C4) + 0.25f);
1230

  
1231
    Static3D axisZ = new Static3D(0.0f  , 0.0f , 1.0f);
1232
    Static3D axisY = new Static3D(0.0f  , 1.0f , 0.0f);
1233
    Static3D axisA = new Static3D(-sin18, cos18, 0.0f);
1234
    Static3D axisC = new Static3D( H/LEN, -0.5f/LEN,-H*MINX_C5/(MINX_C4*LEN));
1235

  
1236
    Static3D move1 = new Static3D(0,-Y1,0);
1237
    Static3D move2 = new Static3D(0,-Y2,0);
1238
    Static3D move3 = new Static3D(0.5f*cos18,0.5f*sin18,0);
1239
    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
1240

  
1241
    Static1D angle1 = new Static1D(54);
1242
    Static1D angle2 = new Static1D(A/2+18);
1243
    Static1D angle3 = new Static1D(90);
1244
    Static1D angle4 = new Static1D(120);
1245
    Static1D angle5 = new Static1D(240);
1246
    Static1D angle6 = new Static1D(90-A/2);
1247

  
1248
    effect[0] = new VertexEffectMove(move1);
1249
    effect[1] = new VertexEffectMove(move2);
1250
    effect[2] = new VertexEffectRotate(angle1, axisZ, center);
1251
    effect[3] = new VertexEffectRotate(angle2, axisZ, center);
1252
    effect[4] = new VertexEffectRotate(angle3, axisA, center);
1253
    effect[5] = new VertexEffectMove(move3);
1254
    effect[6] = new VertexEffectRotate(angle4, axisC, center);
1255
    effect[7] = new VertexEffectRotate(angle5, axisC, center);
1256
    effect[8] = new VertexEffectRotate(angle6, axisY, center);
1207 1257

  
1208
    return null;
1258
    effect[0].setMeshAssociation( 7,-1);  // meshes 0,1,2
1259
    effect[1].setMeshAssociation(56,-1);  // meshes 3,4,5
1260
    effect[2].setMeshAssociation( 7,-1);  // meshes 0,1,2
1261
    effect[3].setMeshAssociation(56,-1);  // meshes 3,4,5
1262
    effect[4].setMeshAssociation(56,-1);  // meshes 3,4,5
1263
    effect[5].setMeshAssociation(56,-1);  // meshes 3,4,5
1264
    effect[6].setMeshAssociation(18,-1);  // meshes 1,4
1265
    effect[7].setMeshAssociation(36,-1);  // meshes 2,5
1266

  
1267
    return effect;
1209 1268
    }
1210 1269

  
1211 1270
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyMinx.java
41 41
public class TwistyMinx extends TwistyObject
42 42
{
43 43
  private static final int FACES_PER_CUBIT =6;
44
  private static final float AXIS_LEN = 1.0f/(float)Math.sqrt(2.5f+0.5f*SQ5);
45
  private static final float C0 = (SQ5-1)/4;
46
  private static final float C1 = (SQ5+1)/4;
44

  
45
  static final float C0 = (SQ5-1)/4;
46
  static final float C1 = (SQ5+1)/4;
47
  static final float C2 = (SQ5+3)/4;
48
  static final float C3 = (float)(Math.sqrt(10-2*SQ5)/4);  // cos(54 deg)
47 49

  
48 50
  // the six rotation axis of a RubikMegaminx. Must be normalized.
49 51
  static final Static3D[] ROT_AXIS = new Static3D[]
50 52
         {
51
           new Static3D( AXIS_LEN*C1, AXIS_LEN   , 0          ),
52
           new Static3D(-AXIS_LEN*C1, AXIS_LEN   , 0          ),
53
           new Static3D( 0          , AXIS_LEN*C1, AXIS_LEN   ),
54
           new Static3D( 0          ,-AXIS_LEN*C1, AXIS_LEN   ),
55
           new Static3D( AXIS_LEN   , 0          , AXIS_LEN*C1),
56
           new Static3D( AXIS_LEN   , 0          ,-AXIS_LEN*C1)
53
           new Static3D( C1/(2*C3), 1/(2*C3) , 0        ),
54
           new Static3D(-C1/(2*C3), 1/(2*C3) , 0        ),
55
           new Static3D( 0        , C1/(2*C3), 1/(2*C3) ),
56
           new Static3D( 0        ,-C1/(2*C3), 1/(2*C3) ),
57
           new Static3D( 1/(2*C3) , 0        , C1/(2*C3)),
58
           new Static3D( 1/(2*C3) , 0        ,-C1/(2*C3))
57 59
         };
58 60

  
59 61
  private static final int MINX_LGREEN = 0xff53aa00;
......
233 235

  
234 236
  Static3D[] getCubitPositions(int numLayers)
235 237
    {
236
    final float C0 = (SQ5+1)/4;
237
    final float C1 = (SQ5+3)/4;
238

  
239 238
    final Static3D[] CENTERS = new Static3D[20];
240 239

  
241
    CENTERS[ 0] = new Static3D( 0.0f, 0.5f,   C1);
242
    CENTERS[ 1] = new Static3D( 0.0f, 0.5f,  -C1);
243
    CENTERS[ 2] = new Static3D( 0.0f,-0.5f,   C1);
244
    CENTERS[ 3] = new Static3D( 0.0f,-0.5f,  -C1);
245
    CENTERS[ 4] = new Static3D(   C1, 0.0f, 0.5f);
246
    CENTERS[ 5] = new Static3D(   C1, 0.0f,-0.5f);
247
    CENTERS[ 6] = new Static3D(  -C1, 0.0f, 0.5f);
248
    CENTERS[ 7] = new Static3D(  -C1, 0.0f,-0.5f);
249
    CENTERS[ 8] = new Static3D( 0.5f,   C1, 0.0f);
250
    CENTERS[ 9] = new Static3D( 0.5f,  -C1, 0.0f);
251
    CENTERS[10] = new Static3D(-0.5f,   C1, 0.0f);
252
    CENTERS[11] = new Static3D(-0.5f,  -C1, 0.0f);
253
    CENTERS[12] = new Static3D(   C0,   C0,   C0);
254
    CENTERS[13] = new Static3D(   C0,   C0,  -C0);
255
    CENTERS[14] = new Static3D(   C0,  -C0,   C0);
256
    CENTERS[15] = new Static3D(   C0,  -C0,  -C0);
257
    CENTERS[16] = new Static3D(  -C0,   C0,   C0);
258
    CENTERS[17] = new Static3D(  -C0,   C0,  -C0);
259
    CENTERS[18] = new Static3D(  -C0,  -C0,   C0);
260
    CENTERS[19] = new Static3D(  -C0,  -C0,  -C0);
240
    CENTERS[ 0] = new Static3D( 0.0f, 0.5f,   C2);
241
    CENTERS[ 1] = new Static3D( 0.0f, 0.5f,  -C2);
242
    CENTERS[ 2] = new Static3D( 0.0f,-0.5f,   C2);
243
    CENTERS[ 3] = new Static3D( 0.0f,-0.5f,  -C2);
244
    CENTERS[ 4] = new Static3D(   C2, 0.0f, 0.5f);
245
    CENTERS[ 5] = new Static3D(   C2, 0.0f,-0.5f);
246
    CENTERS[ 6] = new Static3D(  -C2, 0.0f, 0.5f);
247
    CENTERS[ 7] = new Static3D(  -C2, 0.0f,-0.5f);
248
    CENTERS[ 8] = new Static3D( 0.5f,   C2, 0.0f);
249
    CENTERS[ 9] = new Static3D( 0.5f,  -C2, 0.0f);
250
    CENTERS[10] = new Static3D(-0.5f,   C2, 0.0f);
251
    CENTERS[11] = new Static3D(-0.5f,  -C2, 0.0f);
252
    CENTERS[12] = new Static3D(   C1,   C1,   C1);
253
    CENTERS[13] = new Static3D(   C1,   C1,  -C1);
254
    CENTERS[14] = new Static3D(   C1,  -C1,   C1);
255
    CENTERS[15] = new Static3D(   C1,  -C1,  -C1);
256
    CENTERS[16] = new Static3D(  -C1,   C1,   C1);
257
    CENTERS[17] = new Static3D(  -C1,   C1,  -C1);
258
    CENTERS[18] = new Static3D(  -C1,  -C1,   C1);
259
    CENTERS[19] = new Static3D(  -C1,  -C1,  -C1);
261 260

  
262 261
    return CENTERS;
263 262
    }
......
320 319
    float S = 0.08f;
321 320
    float R = 0.12f;
322 321

  
323
    float[] vertices = {  };   // TODO
322
    float X1= (SQ5+1)/8;
323
    float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
324
    float Y2= Y1 - (float)(Math.sqrt(10-2*SQ5)/8);
325

  
326
    float[] vertices = { -X1, Y2, 0, -Y1, X1, Y2, 0, Y1 };
324 327

  
325 328
    FactorySticker factory = FactorySticker.getInstance();
326 329
    factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face], R);
src/main/java/org/distorted/objects/TwistyObject.java
79 79
  private static final float MAX_SIZE_CHANGE = 1.35f;
80 80
  private static final float MIN_SIZE_CHANGE = 0.75f;
81 81

  
82
  private static final boolean mCreateFromDMesh = true;
82
  private static final boolean mCreateFromDMesh = false;
83 83

  
84 84
  private static final Static3D CENTER = new Static3D(0,0,0);
85 85
  private static final int POST_ROTATION_MILLISEC = 500;

Also available in: Unified diff