Project

General

Profile

« Previous | Next » 

Revision 5da517d3

Added by Leszek Koltunski about 3 years ago

Minor

View differences:

src/main/java/org/distorted/objects/TwistyDiamond.java
52 52
           COLOR_GREEN , COLOR_GREY
53 53
         };
54 54

  
55
  private static final float DIST = 0.50f;
56 55
  private static final int FACES_PER_CUBIT =8;
57 56

  
58 57
  private ScrambleState[] mStates;
......
181 180
    else
182 181
      {
183 182
      float[][] cuts = new float[4][numLayers-1];
184
      float dist = SQ6*0.666f*DIST;
183
      float dist = SQ6/3;
185 184
      float cut  = 0.5f*dist*(2-numLayers);
186 185

  
187 186
      for(int i=0; i<numLayers-1; i++)
......
222 221

  
223 222
  private int createOctaPositions(float[][] centers, int index, int layers, float height)
224 223
    {
225
    float x = DIST*(layers-1);
226
    float z = DIST*(layers+1);
224
    float x = (layers-1)*0.5f;
225
    float z = (layers+1)*0.5f;
227 226

  
228 227
    for(int i=0; i<layers; i++, index++)
229 228
      {
230
      z -= 2*DIST;
229
      z -= 1;
231 230
      centers[index][0] = x;
232 231
      centers[index][1] = height;
233 232
      centers[index][2] = z;
......
235 234

  
236 235
    for(int i=0; i<layers-1; i++, index++)
237 236
      {
238
      x -= 2*DIST;
237
      x -= 1;
239 238
      centers[index][0] = x;
240 239
      centers[index][1] = height;
241 240
      centers[index][2] = z;
......
243 242

  
244 243
    for(int i=0; i<layers-1; i++, index++)
245 244
      {
246
      z += 2*DIST;
245
      z += 1;
247 246
      centers[index][0] = x;
248 247
      centers[index][1] = height;
249 248
      centers[index][2] = z;
......
251 250

  
252 251
    for(int i=0; i<layers-2; i++, index++)
253 252
      {
254
      x += 2*DIST;
253
      x += 1;
255 254
      centers[index][0] = x;
256 255
      centers[index][1] = height;
257 256
      centers[index][2] = z;
......
264 263

  
265 264
  private int createTetraPositions(float[][] centers, int index, int layers, float height)
266 265
    {
267
    float x = DIST*(layers-1);
268
    float z = DIST*layers;
266
    float x = (layers-1)*0.5f;
267
    float z =  layers*0.5f;
269 268

  
270 269
    for(int i=0; i<layers-1; i++, index++)
271 270
      {
272
      z -= 2*DIST;
271
      z -= 1;
273 272
      centers[index][0] = x;
274 273
      centers[index][1] = height;
275 274
      centers[index][2] = z;
276 275
      }
277 276

  
278
    x += DIST;
279
    z -= DIST;
277
    x += 0.5f;
278
    z -= 0.5f;
280 279

  
281 280
    for(int i=0; i<layers-1; i++, index++)
282 281
      {
283
      x -= 2*DIST;
282
      x -= 1;
284 283
      centers[index][0] = x;
285 284
      centers[index][1] = height;
286 285
      centers[index][2] = z;
287 286
      }
288 287

  
289
    x -= DIST;
290
    z -= DIST;
288
    x -= 0.5f;
289
    z -= 0.5f;
291 290

  
292 291
    for(int i=0; i<layers-1; i++, index++)
293 292
      {
294
      z += 2*DIST;
293
      z += 1;
295 294
      centers[index][0] = x;
296 295
      centers[index][1] = height;
297 296
      centers[index][2] = z;
298 297
      }
299 298

  
300
    x -= DIST;
301
    z += DIST;
299
    x -= 0.5f;
300
    z += 0.5f;
302 301

  
303 302
    for(int i=0; i<layers-1; i++, index++)
304 303
      {
305
      x += 2*DIST;
304
      x += 1;
306 305
      centers[index][0] = x;
307 306
      centers[index][1] = height;
308 307
      centers[index][2] = z;
......
326 325

  
327 326
    for(int i=layers-1; i>0; i--)
328 327
      {
329
      height += SQ2*DIST;
328
      height += SQ2/2;
330 329
      index = createOctaPositions(CENTERS,index,i,+height);
331 330
      index = createOctaPositions(CENTERS,index,i,-height);
332 331
      }
333 332

  
334
    height = DIST*SQ2/2;
333
    height = SQ2/4;
335 334

  
336 335
    for(int i=layers; i>1; i--)
337 336
      {
338 337
      index = createTetraPositions(CENTERS,index,i,+height);
339 338
      index = createTetraPositions(CENTERS,index,i,-height);
340
      height += SQ2*DIST;
339
      height += SQ2/2;
341 340
      }
342 341

  
343 342
    return CENTERS;
src/main/java/org/distorted/objects/TwistyPyraminx.java
224 224

  
225 225
///////////////////////////////////////////////////////////////////////////////////////////////////
226 226

  
227
  float[][] getCuts(int size)
227
  float[][] getCuts(int numLayers)
228 228
    {
229
    float[][] cuts = new float[4][size-1];
229
    float[][] cuts = new float[4][numLayers-1];
230 230

  
231
    for(int i=0; i<size-1; i++)
231
    for(int i=0; i<numLayers-1; i++)
232 232
      {
233
      float cut = (1.0f-0.25f*size+i)*(SQ6/3);
233
      float cut = (1.0f+i-numLayers/3.0f)*(SQ6/3);
234 234
      cuts[0][i] = cut;
235 235
      cuts[1][i] = cut;
236 236
      cuts[2][i] = cut;

Also available in: Unified diff