Project

General

Profile

« Previous | Next » 

Revision 380162cb

Added by Leszek Koltunski over 4 years ago

Progress with RubikDino.

View differences:

src/main/java/org/distorted/objects/RubikDino.java
70 70
  private static final Static4D[] QUATS = new Static4D[]
71 71
         {
72 72
           new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),
73
           new Static4D(  0.5f,  0.5f,  0.5f, -0.5f ),
73 74
           new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
74
           new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
75
           new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
75
           new Static4D(  0.5f, -0.5f, -0.5f, -0.5f ),
76 76
           new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),
77
           new Static4D(  0.5f,  0.5f,  0.5f, -0.5f ),
78
           new Static4D(  0.5f,  0.5f, -0.5f,  0.5f ),
79 77
           new Static4D(  0.5f,  0.5f, -0.5f, -0.5f ),
80
           new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
81 78
           new Static4D(  0.5f, -0.5f,  0.5f, -0.5f ),
82 79
           new Static4D(  0.5f, -0.5f, -0.5f,  0.5f ),
83
           new Static4D(  0.5f, -0.5f, -0.5f, -0.5f )
80
           new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
81
           new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
82
           new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
83
           new Static4D(  0.5f,  0.5f, -0.5f,  0.5f )
84 84
         };
85 85

  
86 86
  // centers of the 12 edges. Must be in the same order like QUATs above.
87 87
  private static final Static3D[] CENTERS = new Static3D[]
88 88
         {
89 89
           new Static3D( 0.0f, 0.5f, 0.5f ),
90
           new Static3D( 0.5f, 0.0f, 0.5f ),
90 91
           new Static3D( 0.0f,-0.5f, 0.5f ),
91
           new Static3D( 0.0f, 0.5f,-0.5f ),
92
           new Static3D( 0.0f,-0.5f,-0.5f ),
92
           new Static3D(-0.5f, 0.0f, 0.5f ),
93 93
           new Static3D( 0.5f, 0.5f, 0.0f ),
94
           new Static3D( 0.5f, 0.0f, 0.5f ),
95
           new Static3D(-0.5f, 0.0f,-0.5f ),
96 94
           new Static3D( 0.5f,-0.5f, 0.0f ),
97
           new Static3D( 0.5f, 0.0f,-0.5f ),
98 95
           new Static3D(-0.5f,-0.5f, 0.0f ),
99 96
           new Static3D(-0.5f, 0.5f, 0.0f ),
100
           new Static3D(-0.5f, 0.0f, 0.5f )
97
           new Static3D( 0.0f, 0.5f,-0.5f ),
98
           new Static3D( 0.5f, 0.0f,-0.5f ),
99
           new Static3D( 0.0f,-0.5f,-0.5f ),
100
           new Static3D(-0.5f, 0.0f,-0.5f )
101 101
         };
102 102

  
103 103
  private static MeshBase mMesh;
......
121 121
    int association = 1;
122 122
    MeshBase[] meshes = new MeshTriangles[MESHES];
123 123

  
124
    meshes[0] = new MeshTriangles(9);
124
    meshes[0] = new MeshTriangles(11);
125 125
    meshes[0].setEffectAssociation(0,association,0);
126 126

  
127 127
    for(int i=1; i<MESHES; i++)
......
141 141
    float tetraHeight = SQ2*SQ3/3;
142 142
    float d1 = 0.75f*tetraHeight;
143 143
    float d2 =-0.10f*tetraHeight;
144
    float d3 = 0.20f*tetraHeight;
144
    float d3 =-0.05f*tetraHeight;
145
    float d4 = 0.15f*tetraHeight;
145 146

  
146 147
    Static3D dCen0 = new Static3D( d1*a0.get0(), d1*a0.get1(), d1*a0.get2() );
147 148
    Static3D dCen1 = new Static3D( d1*a1.get0(), d1*a1.get1(), d1*a1.get2() );
148 149
    Static3D dCen2 = new Static3D( d1*a2.get0(), d1*a2.get1(), d1*a2.get2() );
149 150
    Static3D dCen3 = new Static3D( d1*a3.get0(), d1*a3.get1(), d1*a3.get2() );
150 151

  
151
    Static3D dVec0 = new Static3D( d2*a0.get0(), d2*a0.get1(), d2*a0.get2() );
152
    Static3D dVec1 = new Static3D( d2*a1.get0(), d2*a1.get1(), d2*a1.get2() );
152
    Static3D dVec0 = new Static3D( d3*a0.get0(), d3*a0.get1(), d3*a0.get2() );
153
    Static3D dVec1 = new Static3D( d3*a1.get0(), d3*a1.get1(), d3*a1.get2() );
153 154
    Static3D dVec2 = new Static3D( d2*a2.get0(), d2*a2.get1(), d2*a2.get2() );
154 155
    Static3D dVec3 = new Static3D( d2*a3.get0(), d2*a3.get1(), d2*a3.get2() );
155 156

  
156
    Static4D dReg  = new Static4D(0,0,0,d3);
157
    Static4D dReg  = new Static4D(0,0,0,d4);
157 158
    Static1D dRad  = new Static1D(1);
158 159

  
159 160
    Static1D angle  = new Static1D(ANGLE_FACES);
......
215 216

  
216 217
    MatrixEffectMove   moveEffect = new MatrixEffectMove  ( new Static3D(0.0f,SQ3*SQ2/12,SQ3/6) );
217 218
    MatrixEffectRotate rot1Effect = new MatrixEffectRotate( new Static1D(180+ANGLE_FACES/2), axis, cent);
218
    MatrixEffectScale  scalEffect = new MatrixEffectScale ( new Static3D(1.0f, SQ2/2, SQ2*SQ3/6) );
219
    MatrixEffectScale  scalEffect = new MatrixEffectScale ( new Static3D(1.0f, SQ2/2, 0.5f) );
219 220
    MatrixEffectRotate rot2Effect = new MatrixEffectRotate( new Static1D(-45), axis, cent);
220 221

  
221
    mMesh.apply(moveEffect,0xffffffff,0);
222
    mMesh.apply(rot1Effect,0xffffffff,0);
223
    mMesh.apply(scalEffect,0xffffffff,0);
224
    mMesh.apply(rot2Effect,0xffffffff,0);
222
    mMesh.apply(moveEffect, 0xffffffff, 0);
223
    mMesh.apply(rot1Effect, 0xffffffff, 0);
224
    mMesh.apply(scalEffect, 0xffffffff, 0);
225
    mMesh.apply(rot2Effect, 0xffffffff, 0);
225 226
    }
226 227

  
227 228
///////////////////////////////////////////////////////////////////////////////////////////////////
228 229

  
229 230
  float getScreenRatio()
230 231
    {
231
    return 1.0f;
232
    return 1.5f;
232 233
    }
233 234

  
234 235
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/RubikDinoMovement.java
32 32

  
33 33
  boolean isInsideFace(float[] p)
34 34
    {
35
    return ( p[0]<=0.5f && p[0]>=-0.5f && p[1]<=0.5f && p[1]>=-0.5f );
35
    return false;//( p[0]<=0.5f && p[0]>=-0.5f && p[1]<=0.5f && p[1]>=-0.5f );
36 36
    }
37 37
}
src/main/java/org/distorted/objects/RubikObject.java
494 494
    boolean belongs;
495 495
    final float ratio = 1.0f/(NUM_FACES+1);
496 496

  
497
    if( 3*ROTATION_AXIS.length == 2*NUM_FACES ) // Dino
498
      {
499
      final Static4D[] maps = new Static4D[NUM_CUBITS*NUM_CUBIT_FACES];
500

  
501
      final int[] map = {2,4, 4,0, 3,4, 4,1,
502
                         0,2, 0,3, 1,3, 1,2,
503
                         2,5, 5,0, 3,5, 5,1 };
504

  
505
      for(int i=0; i<NUM_CUBITS; i++)
506
        {
507
        maps[NUM_CUBIT_FACES*i    ] = new Static4D( map[2*i  ]*ratio, 0.0f, ratio, 1.0f);
508
        maps[NUM_CUBIT_FACES*i + 1] = new Static4D( map[2*i+1]*ratio, 0.0f, ratio, 1.0f);
509
        maps[NUM_CUBIT_FACES*i + 2] = new Static4D( NUM_FACES *ratio, 0.0f, ratio, 1.0f);
510
        maps[NUM_CUBIT_FACES*i + 3] = new Static4D( NUM_FACES *ratio, 0.0f, ratio, 1.0f);
511
        }
512

  
513
      mMesh.setTextureMap(maps,0);
514
      return;
515
      }
516

  
517

  
497 518
    for(int cubit=0; cubit<NUM_CUBITS; cubit++)
498 519
      {
499 520
      final Static4D[] maps = new Static4D[NUM_CUBIT_FACES];
......
514 535
          maps[i] = new Static4D( (belongs?i:NUM_FACES)*ratio, 0.0f, ratio, 1.0f);
515 536
          }
516 537
        }
517
      else if( 3*ROTATION_AXIS.length == 2*NUM_FACES ) // Dino  TODO
518
        {
519
        for(int i=0; i<NUM_CUBIT_FACES; i++)
520
          {
521
          belongs = true;//isOnFace(cubit, i, 0 );
522
          maps[i] = new Static4D( (belongs?i:NUM_FACES)*ratio, 0.0f, ratio, 1.0f);
523
          }
524
        }
525 538

  
526 539
      mMesh.setTextureMap(maps,NUM_CUBIT_FACES*cubit);
527 540
      }

Also available in: Unified diff