Project

General

Profile

« Previous | Next » 

Revision 89a11f7b

Added by Leszek Koltunski about 4 years ago

Progress with Pyraminx.

View differences:

src/main/java/org/distorted/object/RubikCube.java
139 139

  
140 140
///////////////////////////////////////////////////////////////////////////////////////////////////
141 141

  
142
  MeshBase createCubitMesh(int vertices)
142
  MeshBase createCubitMesh(int cubit, int vertices)
143 143
    {
144 144
    final int MESHES=6;
145 145

  
src/main/java/org/distorted/object/RubikObject.java
114 114

  
115 115
    for(int i=0; i<NUM_CUBITS; i++)
116 116
      {
117
      MeshBase cubitMesh = createCubitMesh(vertices);
117
      MeshBase cubitMesh = createCubitMesh(i,vertices);
118 118
      mCubits[i] = new Cubit(this,cubitMesh,mOrigPos[i]);
119 119
      textureCubitMesh(cubitMesh,i);
120 120

  
......
469 469
  abstract float[] getLegalQuats();
470 470
  abstract int getNumFaces();
471 471
  abstract void createFaceTexture(Canvas canvas, Paint paint, int face);
472
  abstract MeshBase createCubitMesh(int vertices);
472
  abstract MeshBase createCubitMesh(int cubit, int vertices);
473 473
  abstract Static3D[] getRotationAxis();
474 474
  public abstract int getBasicAngle();
475 475
  }
src/main/java/org/distorted/object/RubikPyraminx.java
64 64
           SQ3/3, -SQ3/3, SQ3/6, -SQ3/6, SQ2*SQ3/3, -SQ2*SQ3/3, SQ2*SQ3/6, -SQ2*SQ3/6
65 65
         };
66 66

  
67
  private Static4D[] mRotArray;
67
  private int[] mRotArray;
68
  private static MatrixEffectRotate[][] ROTATION;
69

  
70
  static
71
    {
72
    Static3D center = new Static3D(0,0,0);
73
    Static1D angle  = new Static1D(180.0f);
74

  
75
    ROTATION = new MatrixEffectRotate[AXIS.length][1];
76

  
77
    for(int i=0; i<AXIS.length; i++)
78
      {
79
      ROTATION[i][0] = new MatrixEffectRotate( angle, AXIS[i], center);
80
      }
81
    }
68 82

  
69 83
///////////////////////////////////////////////////////////////////////////////////////////////////
70 84

  
......
75 89

  
76 90
///////////////////////////////////////////////////////////////////////////////////////////////////
77 91

  
78
  private void emitRow(float x, float y, float z, float dx, float dy, float dz, int n, Static4D rot, Static3D[] array, int index)
92
  private void emitRow(float x, float y, float z, float dx, float dy, float dz, int n, int rot, Static3D[] array, int index)
79 93
    {
80 94
    for(int i=0; i<n; i++)
81 95
      {
......
95 109

  
96 110
    for(int i=n; i>=1; i--)
97 111
      {
98
      emitRow(x,y,z, 1,0,0, i, null, array, added);
112
      emitRow(x,y,z, 1,0,0, i, -1, array, added);
99 113
      added += i;
100 114
      x += 0.5f;
101 115
      y += 0.0f;
......
111 125
    {
112 126
    if( n>1 )
113 127
      {
114
      emitRow(x,y,z, 1,0,0, n-1, null, array, index);
128
      emitRow( x     , y, z      ,  1.0f, 0,     0, n-1, -1, array, index);
115 129
      index += (n-1);
116
      emitRow(x+0.5f,y,z+SQ3/2, 0.5f,0,SQ3/2, n-1, null, array, index);
130
      emitRow( x+0.5f, y, z+SQ3/2,  0.5f, 0, SQ3/2, n-1, -1, array, index);
117 131
      index += (n-1);
118
      emitRow( x+n-1,y,z, -0.5f, 0, SQ3/2, n-1, null, array, index);
132
      emitRow( x+n-1 , y, z      , -0.5f, 0, SQ3/2, n-1, -1, array, index);
119 133
      index += (n-1);
120 134
      }
121 135
    else
122 136
      {
123
      mRotArray[index] = null;
137
      mRotArray[index] = -1;
124 138
      array[index] = new Static3D(x+0.5f,y+SQ2*SQ3/12,z+SQ3/6);
125 139
      index++;
126 140
      }
......
136 150
    {
137 151
    int numCubits = size>1 ? 2*size*size-4*size+4:1;//4*size*size - 6*size +4 : 1;
138 152
    Static3D[] tmp = new Static3D[numCubits];
139
    mRotArray = new Static4D[numCubits];
153
    mRotArray = new int[numCubits];
140 154

  
141 155
    int currentIndex = emitLowermost( -0.5f*size, -(SQ2*SQ3/12)*size, -(SQ3/6)*size, size, tmp);
142 156

  
......
206 220

  
207 221
///////////////////////////////////////////////////////////////////////////////////////////////////
208 222

  
209
  MeshBase createCubitMesh(int vertices)
223
  MeshBase createCubitMesh(int cubit, int vertices)
210 224
    {
211 225
    final float angleFaces = (float)((180/Math.PI)*(2*Math.asin(SQ3/3))); // angle between two faces of a tetrahedron
212 226
    final int MESHES=4;
......
240 254
    axis.set2(SQ3/2);
241 255
    meshes[3].apply(effects1);
242 256

  
243
    return new MeshJoined(meshes);
257
    MeshJoined result = new MeshJoined(meshes);
258

  
259
    if( mRotArray[cubit]>=0 )
260
      {
261
      result.apply( ROTATION[mRotArray[cubit]] );
262
      }
263

  
264
    return result;
244 265
    }
245 266

  
246 267
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff