Project

General

Profile

« Previous | Next » 

Revision e6cf7283

Added by Leszek Koltunski about 3 years ago

Change the Cubit center from a Static3D to a float[].
The point: now we can have more than one center, and bandaged objects need more than one, because in this way they are going to fill up their RotationRow bitmaps.

View differences:

src/main/java/org/distorted/objects/TwistyMegaminx.java
125 125
      {
126 126
      int[] map = mCenterMap[center];
127 127

  
128
      float x = CORNERS[map[0]].get0() +
129
                CORNERS[map[1]].get0() +
130
                CORNERS[map[2]].get0() +
131
                CORNERS[map[3]].get0() +
132
                CORNERS[map[4]].get0() ;
133

  
134
      float y = CORNERS[map[0]].get1() +
135
                CORNERS[map[1]].get1() +
136
                CORNERS[map[2]].get1() +
137
                CORNERS[map[3]].get1() +
138
                CORNERS[map[4]].get1() ;
139

  
140
      float z = CORNERS[map[0]].get2() +
141
                CORNERS[map[1]].get2() +
142
                CORNERS[map[2]].get2() +
143
                CORNERS[map[3]].get2() +
144
                CORNERS[map[4]].get2() ;
128
      float x = CORNERS[map[0]][0] +
129
                CORNERS[map[1]][0] +
130
                CORNERS[map[2]][0] +
131
                CORNERS[map[3]][0] +
132
                CORNERS[map[4]][0] ;
133

  
134
      float y = CORNERS[map[0]][1] +
135
                CORNERS[map[1]][1] +
136
                CORNERS[map[2]][1] +
137
                CORNERS[map[3]][1] +
138
                CORNERS[map[4]][1] ;
139

  
140
      float z = CORNERS[map[0]][2] +
141
                CORNERS[map[1]][2] +
142
                CORNERS[map[2]][2] +
143
                CORNERS[map[3]][2] +
144
                CORNERS[map[4]][2] ;
145 145

  
146 146
      mCenterCoords[center][0] = x/5;
147 147
      mCenterCoords[center][1] = y/5;
......
225 225

  
226 226
///////////////////////////////////////////////////////////////////////////////////////////////////
227 227

  
228
  private void computeCenter(Static3D pos, int center, int numLayers)
228
  private float[] computeCenter(int center, int numLayers)
229 229
    {
230 230
    float[] coords = mCenterCoords[center];
231 231
    float A = numLayers/3.0f;
232 232

  
233
    pos.set( A*coords[0], A*coords[1], A*coords[2] );
233
    return new float[] { A*coords[0], A*coords[1], A*coords[2] };
234 234
    }
235 235

  
236 236
///////////////////////////////////////////////////////////////////////////////////////////////////
......
248 248

  
249 249
///////////////////////////////////////////////////////////////////////////////////////////////////
250 250

  
251
  private void computeCorner(Static3D pos, int numCubitsPerCorner, int numLayers, int corner, int part)
251
  private float[] computeCorner(int numCubitsPerCorner, int numLayers, int corner, int part)
252 252
    {
253 253
    float D = numLayers/3.0f;
254
    Static3D corn = CORNERS[corner];
254
    float[] corn = CORNERS[corner];
255 255

  
256 256
    if( part==0 )
257 257
      {
258
      pos.set( corn.get0()*D, corn.get1()*D, corn.get2()*D );
258
      return new float[] { corn[0]*D, corn[1]*D, corn[2]*D };
259 259
      }
260 260
    else
261 261
      {
......
269 269
      int multP = (block % ((numLayers-3)/2)) + 1;
270 270
      int multS = (block / ((numLayers-3)/2));
271 271

  
272
      pos.set( corn.get0()*D + (pri.get0()*multP + sec.get0()*multS)*E,
273
               corn.get1()*D + (pri.get1()*multP + sec.get1()*multS)*E,
274
               corn.get2()*D + (pri.get2()*multP + sec.get2()*multS)*E );
272
      return new float[] {
273
                          corn[0]*D + (pri.get0()*multP + sec.get0()*multS)*E,
274
                          corn[1]*D + (pri.get1()*multP + sec.get1()*multS)*E,
275
                          corn[2]*D + (pri.get2()*multP + sec.get2()*multS)*E
276
                         };
275 277
      }
276 278
    }
277 279

  
......
285 287

  
286 288
///////////////////////////////////////////////////////////////////////////////////////////////////
287 289

  
288
  private void computeEdge(Static3D pos, int numLayers, int edge, int part)
290
  private float[] computeEdge(int numLayers, int edge, int part)
289 291
    {
290 292
    float corr = numLayers/3.0f;
291 293

  
292
    Static3D c1 = CORNERS[ mEdgeMap[edge][0] ];
293
    Static3D c2 = CORNERS[ mEdgeMap[edge][1] ];
294
    float x = corr*(c1.get0() + c2.get0())/2;
295
    float y = corr*(c1.get1() + c2.get1())/2;
296
    float z = corr*(c1.get2() + c2.get2())/2;
294
    float[] c1 = CORNERS[ mEdgeMap[edge][0] ];
295
    float[] c2 = CORNERS[ mEdgeMap[edge][1] ];
296
    float x = corr * (c1[0]+c2[0]) / 2;
297
    float y = corr * (c1[1]+c2[1]) / 2;
298
    float z = corr * (c1[2]+c2[2]) / 2;
297 299

  
298 300
    if( part==0 )
299 301
      {
300
      pos.set(x,y,z);
302
      return new float[] { x, y, z };
301 303
      }
302 304
    else
303 305
      {
......
312 314
      float len = (float)Math.sqrt(vX*vX+vY*vY+vZ*vZ);
313 315
      float A = mult*corr*(0.5f-MEGA_D)*COS18/((numLayers-1)*0.5f)/len;
314 316

  
315
      pos.set( x+A*vX, y+A*vY, z+A*vZ );
317
      return new float[] { x+A*vX, y+A*vY, z+A*vZ };
316 318
      }
317 319
    }
318 320

  
319 321
///////////////////////////////////////////////////////////////////////////////////////////////////
320 322

  
321
  Static3D[] getCubitPositions(int numLayers)
323
  float[][] getCubitPositions(int numLayers)
322 324
    {
323 325
    int numCubitsPerCorner = numCubitsPerCorner(numLayers);
324 326
    int numCubitsPerEdge   = numCubitsPerEdge(numLayers);
325 327
    int numCubits = NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge + NUM_CENTERS;
326 328
    int index=0;
327 329

  
328
    final Static3D[] CENTERS = new Static3D[numCubits];
330
    final float[][] CENTERS = new float[numCubits][];
329 331

  
330 332
    for(int corner=0; corner<NUM_CORNERS; corner++)
331 333
      {
......
333 335

  
334 336
      for(int part=0; part<numCubitsPerCorner; part++, index++)
335 337
        {
336
        CENTERS[index] = new Static3D(0,0,0);
337
        computeCorner(CENTERS[index],numCubitsPerCorner,numLayers,corner,part);
338
        CENTERS[index] = computeCorner(numCubitsPerCorner,numLayers,corner,part);
338 339
        }
339 340
      }
340 341

  
......
342 343
      {
343 344
      for(int part=0; part<numCubitsPerEdge; part++, index++)
344 345
        {
345
        CENTERS[index] = new Static3D(0,0,0);
346
        computeEdge(CENTERS[index], numLayers, edge, part );
346
        CENTERS[index] = computeEdge(numLayers, edge, part );
347 347
        }
348 348
      }
349 349

  
350 350
    for(int center=0; center<NUM_CENTERS; center++, index++)
351 351
      {
352
      CENTERS[index] = new Static3D(0,0,0);
353
      computeCenter(CENTERS[index], center, numLayers);
352
      CENTERS[index] = computeCenter(center, numLayers);
354 353
      }
355 354

  
356 355
    return CENTERS;

Also available in: Unified diff